Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
21 个修改的文件
包含
286 行增加
和
36 行删除
| @@ -56,11 +56,15 @@ class AiBlogAuthorTask extends Command | @@ -56,11 +56,15 @@ class AiBlogAuthorTask extends Command | ||
| 56 | echo '开始->project_id:' . $info['project_id'] . PHP_EOL . date('Y-m-d H:i:s'); | 56 | echo '开始->project_id:' . $info['project_id'] . PHP_EOL . date('Y-m-d H:i:s'); |
| 57 | //获取配置 | 57 | //获取配置 |
| 58 | $aiSettingInfo = $this->getSetting($info['project_id']); | 58 | $aiSettingInfo = $this->getSetting($info['project_id']); |
| 59 | + if(empty($aiSettingInfo)){ | ||
| 60 | + continue; | ||
| 61 | + } | ||
| 59 | $aiBlogService = new AiBlogService(); | 62 | $aiBlogService = new AiBlogService(); |
| 60 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | 63 | $aiBlogService->mch_id = $aiSettingInfo['mch_id']; |
| 61 | $aiBlogService->key = $aiSettingInfo['key']; | 64 | $aiBlogService->key = $aiSettingInfo['key']; |
| 62 | $result = $aiBlogService->getAuthor(); | 65 | $result = $aiBlogService->getAuthor(); |
| 63 | if(!isset($result['status'])){ | 66 | if(!isset($result['status'])){ |
| 67 | + echo '错误:'.json_encode($result,true); | ||
| 64 | continue; | 68 | continue; |
| 65 | } | 69 | } |
| 66 | if($result['status'] != 200){ | 70 | if($result['status'] != 200){ |
| @@ -68,15 +72,15 @@ class AiBlogAuthorTask extends Command | @@ -68,15 +72,15 @@ class AiBlogAuthorTask extends Command | ||
| 68 | continue; | 72 | continue; |
| 69 | } | 73 | } |
| 70 | if(empty($result['data'])){ | 74 | if(empty($result['data'])){ |
| 71 | - sleep(20); | 75 | + echo '没有作者任务-'.PHP_EOL; |
| 72 | continue; | 76 | continue; |
| 73 | } | 77 | } |
| 74 | //保存当前项目ai_blog数据 | 78 | //保存当前项目ai_blog数据 |
| 75 | ProjectServer::useProject($info['project_id']); | 79 | ProjectServer::useProject($info['project_id']); |
| 76 | $this->saveAiBlogAuthor($result['data'] ?? [],$info['project_id']); | 80 | $this->saveAiBlogAuthor($result['data'] ?? [],$info['project_id']); |
| 81 | + RouteMap::setRoute('top-blog',RouteMap::SOURCE_AI_BLOG_LIST,0,$info['project_id']);//写一条列表页路由 | ||
| 77 | DB::disconnect('custom_mysql'); | 82 | DB::disconnect('custom_mysql'); |
| 78 | //修改任务状态 | 83 | //修改任务状态 |
| 79 | - RouteMap::setRoute('top-blog',RouteMap::SOURCE_AI_BLOG_LIST,0,$info['project_id']);//写一条列表页路由 | ||
| 80 | $aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]); | 84 | $aiBlogTaskModel->edit(['status'=>2],['id'=>$info['id']]); |
| 81 | echo '结束->任务id:' . $info['task_id'] . PHP_EOL . date('Y-m-d H:i:s'); | 85 | echo '结束->任务id:' . $info['task_id'] . PHP_EOL . date('Y-m-d H:i:s'); |
| 82 | } | 86 | } |
| @@ -114,18 +118,23 @@ class AiBlogAuthorTask extends Command | @@ -114,18 +118,23 @@ class AiBlogAuthorTask extends Command | ||
| 114 | return true; | 118 | return true; |
| 115 | } | 119 | } |
| 116 | $aiBlogAuthorModel = new AiBlogAuthor(); | 120 | $aiBlogAuthorModel = new AiBlogAuthor(); |
| 117 | - $info = $aiBlogAuthorModel->counts(['project_id'=>$project_id]); | ||
| 118 | - if($info === false){ | ||
| 119 | - foreach ($data as $v){ | 121 | + foreach ($data as $v){ |
| 122 | + //查询当前数据是否存在 | ||
| 123 | + $info = $aiBlogAuthorModel->read(['author_id'=>$v['id']]); | ||
| 124 | + if($info === false){ | ||
| 120 | $param = [ | 125 | $param = [ |
| 121 | 'author_id'=>$v['id'], | 126 | 'author_id'=>$v['id'], |
| 122 | 'title'=>$v['title'], | 127 | 'title'=>$v['title'], |
| 123 | 'image'=>str_replace_url($v['picture']), | 128 | 'image'=>str_replace_url($v['picture']), |
| 124 | 'description'=>$v['description'], | 129 | 'description'=>$v['description'], |
| 125 | ]; | 130 | ]; |
| 126 | - $id = $aiBlogAuthorModel->addReturnId($param); | ||
| 127 | - $route = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id); | ||
| 128 | - $aiBlogAuthorModel->edit(['route'=>$route],['id'=>$id]); | 131 | + try { |
| 132 | + $id = $aiBlogAuthorModel->addReturnId($param); | ||
| 133 | + $route = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id); | ||
| 134 | + $aiBlogAuthorModel->edit(['route'=>$route],['id'=>$id]); | ||
| 135 | + }catch (\Exception $e){ | ||
| 136 | + echo 'error:'.$e->getMessage(); | ||
| 137 | + } | ||
| 129 | } | 138 | } |
| 130 | } | 139 | } |
| 131 | return true; | 140 | return true; |
| @@ -42,11 +42,12 @@ class AiBlogTask extends Command | @@ -42,11 +42,12 @@ class AiBlogTask extends Command | ||
| 42 | public function handle(){ | 42 | public function handle(){ |
| 43 | $aiBlogTaskModel = new AiBlogTaskModel(); | 43 | $aiBlogTaskModel = new AiBlogTaskModel(); |
| 44 | while (true){ | 44 | while (true){ |
| 45 | - $list = $aiBlogTaskModel->list(['status'=>1,'type'=>2, 'created_at' => ['<', date('Y-m-d H:i:s')]],'id',['*'],'asc',1000); | 45 | + $list = $aiBlogTaskModel->formatQuery(['status'=>1,'type'=>2])->inRandomOrder()->limit(1000)->get(); |
| 46 | if(empty($list)){ | 46 | if(empty($list)){ |
| 47 | sleep(300); | 47 | sleep(300); |
| 48 | continue; | 48 | continue; |
| 49 | } | 49 | } |
| 50 | + $list = $list->toArray(); | ||
| 50 | $updateProject = []; | 51 | $updateProject = []; |
| 51 | foreach ($list as $item){ | 52 | foreach ($list as $item){ |
| 52 | echo '开始->任务id:' . $item['task_id'] . PHP_EOL . date('Y-m-d H:i:s'); | 53 | echo '开始->任务id:' . $item['task_id'] . PHP_EOL . date('Y-m-d H:i:s'); |
| @@ -57,8 +58,12 @@ class AiBlogTask extends Command | @@ -57,8 +58,12 @@ class AiBlogTask extends Command | ||
| 57 | $aiBlogService->key = $aiSettingInfo['key']; | 58 | $aiBlogService->key = $aiSettingInfo['key']; |
| 58 | $aiBlogService->task_id = $item['task_id']; | 59 | $aiBlogService->task_id = $item['task_id']; |
| 59 | $result = $aiBlogService->getDetail(); | 60 | $result = $aiBlogService->getDetail(); |
| 60 | - if(!isset($result['status']) || $result['status'] != 200){ | ||
| 61 | - sleep(5); | 61 | + if(!isset($result['status'])){ |
| 62 | + echo json_encode($result,true).PHP_EOL; | ||
| 63 | + continue; | ||
| 64 | + } | ||
| 65 | + if($result['status'] != 200){ | ||
| 66 | + echo '错误状态码:'.$result['status'].PHP_EOL; | ||
| 62 | continue; | 67 | continue; |
| 63 | } | 68 | } |
| 64 | //保存当前项目ai_blog数据 | 69 | //保存当前项目ai_blog数据 |
| @@ -66,6 +71,7 @@ class AiBlogTask extends Command | @@ -66,6 +71,7 @@ class AiBlogTask extends Command | ||
| 66 | $aiBlogModel = new AiBlog(); | 71 | $aiBlogModel = new AiBlog(); |
| 67 | $aiBlogInfo = $aiBlogModel->read(['task_id'=>$item['task_id']],['id']); | 72 | $aiBlogInfo = $aiBlogModel->read(['task_id'=>$item['task_id']],['id']); |
| 68 | if($aiBlogInfo === false){ | 73 | if($aiBlogInfo === false){ |
| 74 | + echo '任务id不存在:'.$item['task_id'].PHP_EOL; | ||
| 69 | $aiBlogTaskModel->edit(['status'=>2],['id'=>$item['id']]); | 75 | $aiBlogTaskModel->edit(['status'=>2],['id'=>$item['id']]); |
| 70 | continue; | 76 | continue; |
| 71 | } | 77 | } |
| @@ -80,10 +86,10 @@ class AiBlogTask extends Command | @@ -80,10 +86,10 @@ class AiBlogTask extends Command | ||
| 80 | $aiBlogModel->edit(['new_title'=>$result['data']['title'], 'image'=>$result['data']['thumb'], 'text'=>$result['data']['section'], 'author_id'=>$result['data']['author_id'],'seo_title'=>$result['data']['title'],'seo_keyword'=>$result['data']['keyword'],'seo_description'=>$result['data']['description'], 'route'=>$route ,'status'=>2], ['task_id'=>$item['task_id']]); | 86 | $aiBlogModel->edit(['new_title'=>$result['data']['title'], 'image'=>$result['data']['thumb'], 'text'=>$result['data']['section'], 'author_id'=>$result['data']['author_id'],'seo_title'=>$result['data']['title'],'seo_keyword'=>$result['data']['keyword'],'seo_description'=>$result['data']['description'], 'route'=>$route ,'status'=>2], ['task_id'=>$item['task_id']]); |
| 81 | DB::disconnect('custom_mysql'); | 87 | DB::disconnect('custom_mysql'); |
| 82 | $aiBlogTaskModel->edit(['status'=>2],['id'=>$item['id']]); | 88 | $aiBlogTaskModel->edit(['status'=>2],['id'=>$item['id']]); |
| 89 | + echo '结束->任务id:' . $item['task_id'] . PHP_EOL . date('Y-m-d H:i:s'); | ||
| 83 | } | 90 | } |
| 84 | //TODO::更新列表页及作者 | 91 | //TODO::更新列表页及作者 |
| 85 | $this->updateProject($updateProject); | 92 | $this->updateProject($updateProject); |
| 86 | - echo '结束->任务id:' . $item['task_id'] . PHP_EOL . date('Y-m-d H:i:s'); | ||
| 87 | } | 93 | } |
| 88 | return true; | 94 | return true; |
| 89 | } | 95 | } |
| @@ -121,13 +127,8 @@ class AiBlogTask extends Command | @@ -121,13 +127,8 @@ class AiBlogTask extends Command | ||
| 121 | * @time :2025/2/14 11:27 | 127 | * @time :2025/2/14 11:27 |
| 122 | */ | 128 | */ |
| 123 | public function getSetting($project_id){ | 129 | public function getSetting($project_id){ |
| 124 | - $ai_cache = Cache::get('ai_blog_'.$project_id); | ||
| 125 | - if($ai_cache){ | ||
| 126 | - return $ai_cache; | ||
| 127 | - } | ||
| 128 | $projectAiSettingModel = new ProjectAiSetting(); | 130 | $projectAiSettingModel = new ProjectAiSetting(); |
| 129 | $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$project_id]); | 131 | $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$project_id]); |
| 130 | - Cache::put('ai_blog_'.$project_id,$aiSettingInfo,3600); | ||
| 131 | return $aiSettingInfo; | 132 | return $aiSettingInfo; |
| 132 | } | 133 | } |
| 133 | 134 |
| @@ -329,7 +329,7 @@ class PostInquiryForward extends Command | @@ -329,7 +329,7 @@ class PostInquiryForward extends Command | ||
| 329 | 'submit_time' => date('Y-m-d H:i:s'), | 329 | 'submit_time' => date('Y-m-d H:i:s'), |
| 330 | 'source' => 5, | 330 | 'source' => 5, |
| 331 | ]; | 331 | ]; |
| 332 | - $url = 'https://www.globalso.site/api/external-interface/add/fa043f9cbec6b38f'; | 332 | + $url = 'https://form.globalso.com/api/external-interface/add/fa043f9cbec6b38f'; |
| 333 | $res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data)->json(); | 333 | $res = Http::withoutVerifying()->timeout(30)->withHeaders(['User-Agent' => $detail['user_agent']])->post($url, $data)->json(); |
| 334 | if (empty($res['status']) || $res['status'] != 200) { | 334 | if (empty($res['status']) || $res['status'] != 200) { |
| 335 | $log->status = InquiryRelayDetailLog::STATUS_FAIL; | 335 | $log->status = InquiryRelayDetailLog::STATUS_FAIL; |
| @@ -54,7 +54,7 @@ class LyhImportTest extends Command | @@ -54,7 +54,7 @@ class LyhImportTest extends Command | ||
| 54 | public function handle(){ | 54 | public function handle(){ |
| 55 | ProjectServer::useProject(2837); | 55 | ProjectServer::useProject(2837); |
| 56 | echo date('Y-m-d H:i:s') . 'start' . PHP_EOL; | 56 | echo date('Y-m-d H:i:s') . 'start' . PHP_EOL; |
| 57 | - $this->importCustomModule('https://ecdn6.globalso.com/upload/p/2837/file/2025-03/xindaxing-s-product-screening.csv',2837); | 57 | + $this->importCustomModule('https://ecdn6.globalso.com/upload/p/2837/file/2025-03/2.csv',2837); |
| 58 | DB::disconnect('custom_mysql'); | 58 | DB::disconnect('custom_mysql'); |
| 59 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; | 59 | echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; |
| 60 | } | 60 | } |
| @@ -55,18 +55,11 @@ class CopyProject extends Command | @@ -55,18 +55,11 @@ class CopyProject extends Command | ||
| 55 | $this->output('CopyProjectJob start, project_id: ' . $old_project_id); | 55 | $this->output('CopyProjectJob start, project_id: ' . $old_project_id); |
| 56 | $data = $this->copyProject($old_project_id); | 56 | $data = $this->copyProject($old_project_id); |
| 57 | $project_id = $data['project_id']; | 57 | $project_id = $data['project_id']; |
| 58 | - $type = $data['type']; | ||
| 59 | $this->copyDeployBuild($old_project_id,$project_id); | 58 | $this->copyDeployBuild($old_project_id,$project_id); |
| 60 | $this->copyDeployOptimize($old_project_id,$project_id); | 59 | $this->copyDeployOptimize($old_project_id,$project_id); |
| 61 | $this->copyPayment($old_project_id,$project_id); | 60 | $this->copyPayment($old_project_id,$project_id); |
| 62 | $this->copyAfter($old_project_id,$project_id); | 61 | $this->copyAfter($old_project_id,$project_id); |
| 63 | $this->copyUser($old_project_id,$project_id); | 62 | $this->copyUser($old_project_id,$project_id); |
| 64 | - if($type != 0){ | ||
| 65 | - $this->copyMysql($old_project_id,$project_id); | ||
| 66 | - } | ||
| 67 | - //修改项目状态 | ||
| 68 | - $projectModel->edit(['delete_status'=>0],['id'=>$project_id]); | ||
| 69 | - $this->output('CopyProjectJob end, old project_id: ' . $old_project_id . ', new project_id: ' . $project_id); | ||
| 70 | $item->status = NoticeLog::STATUS_SUCCESS; | 63 | $item->status = NoticeLog::STATUS_SUCCESS; |
| 71 | $item->save(); | 64 | $item->save(); |
| 72 | }catch (\Exception $e){ | 65 | }catch (\Exception $e){ |
| @@ -75,6 +68,14 @@ class CopyProject extends Command | @@ -75,6 +68,14 @@ class CopyProject extends Command | ||
| 75 | $item->status = NoticeLog::STATUS_FAIL; | 68 | $item->status = NoticeLog::STATUS_FAIL; |
| 76 | $item->save(); | 69 | $item->save(); |
| 77 | } | 70 | } |
| 71 | + try { | ||
| 72 | + $this->copyMysql($old_project_id,$project_id); | ||
| 73 | + }catch (\Exception $e){ | ||
| 74 | + echo '复制数据库失败:'.$old_project_id . '<->'.$project_id; | ||
| 75 | + } | ||
| 76 | + //修改项目状态 | ||
| 77 | + $projectModel->edit(['delete_status'=>0],['id'=>$project_id]); | ||
| 78 | + $this->output('CopyProjectJob end, old project_id: ' . $old_project_id . ', new project_id: ' . $project_id); | ||
| 78 | } | 79 | } |
| 79 | } | 80 | } |
| 80 | return true; | 81 | return true; |
| @@ -624,7 +624,7 @@ class UpdateSeoTdk extends Command | @@ -624,7 +624,7 @@ class UpdateSeoTdk extends Command | ||
| 624 | $info = Cache::get($cache_key); | 624 | $info = Cache::get($cache_key); |
| 625 | if(!$info){ | 625 | if(!$info){ |
| 626 | $projectOptimizeModel = new DeployOptimize(); | 626 | $projectOptimizeModel = new DeployOptimize(); |
| 627 | - $info = $projectOptimizeModel->read(['project_id' => $project_id], ['id', 'company_en_name', 'company_en_description', 'keyword_prefix', 'keyword_suffix']); | 627 | + $info = $projectOptimizeModel->read(['project_id' => $project_id], ['id', 'company_en_name', 'company_en_description', 'keyword_prefix', 'keyword_suffix', 'brand_keyword']); |
| 628 | $projectKeywordModel = new ProjectKeyword(); | 628 | $projectKeywordModel = new ProjectKeyword(); |
| 629 | $keywordInfo = $projectKeywordModel->read(['project_id'=>$project_id]); | 629 | $keywordInfo = $projectKeywordModel->read(['project_id'=>$project_id]); |
| 630 | $info['main_keyword'] = ''; | 630 | $info['main_keyword'] = ''; |
| @@ -90,7 +90,7 @@ class HtmlCollect extends Command | @@ -90,7 +90,7 @@ class HtmlCollect extends Command | ||
| 90 | 90 | ||
| 91 | //采集html页面,下载资源到本地并替换 | 91 | //采集html页面,下载资源到本地并替换 |
| 92 | try { | 92 | try { |
| 93 | - $html = curl_c('https://' . $collect_info->domain . $collect_info->route, false); | 93 | + $html = curl_code('https://' . $collect_info->domain . $collect_info->route, false); |
| 94 | if (strlen($html) < 4) { | 94 | if (strlen($html) < 4) { |
| 95 | 95 | ||
| 96 | if ($html == 404) { | 96 | if ($html == 404) { |
| @@ -202,6 +202,43 @@ if (!function_exists('curl_c')) { | @@ -202,6 +202,43 @@ if (!function_exists('curl_c')) { | ||
| 202 | } | 202 | } |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | +if (!function_exists('curl_code')) { | ||
| 206 | + /** | ||
| 207 | + * @param $url | ||
| 208 | + * @param $is_array | ||
| 209 | + * @return [] | ||
| 210 | + * @author Akun | ||
| 211 | + * @date 2023/11/22 11:33 | ||
| 212 | + */ | ||
| 213 | + function curl_code($url,$is_array=true){ | ||
| 214 | + $header = array( | ||
| 215 | + 'Expect:', | ||
| 216 | + 'Content-Type: application/json; charset=utf-8' | ||
| 217 | + ); | ||
| 218 | + $ch = curl_init($url); | ||
| 219 | + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
| 220 | + curl_setopt($ch, CURLOPT_HEADER, false); | ||
| 221 | + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | ||
| 222 | + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'); | ||
| 223 | + curl_setopt($ch, CURLOPT_AUTOREFERER, true); | ||
| 224 | + curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); | ||
| 225 | + curl_setopt($ch, CURLOPT_TIMEOUT, 120); | ||
| 226 | + curl_setopt($ch, CURLOPT_MAXREDIRS, 10); | ||
| 227 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | ||
| 228 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); | ||
| 229 | + curl_setopt($ch, CURLOPT_SSLVERSION, 'all'); | ||
| 230 | + curl_setopt($ch, CURLOPT_HTTPHEADER, $header); | ||
| 231 | + $content = curl_exec($ch); | ||
| 232 | + $http_code = curl_getinfo($ch,CURLINFO_HTTP_CODE); | ||
| 233 | + curl_close($ch); | ||
| 234 | + if($http_code == 200){ | ||
| 235 | + return $is_array ? json_decode($content, true) : $content; | ||
| 236 | + }else{ | ||
| 237 | + return $http_code; | ||
| 238 | + } | ||
| 239 | + } | ||
| 240 | +} | ||
| 241 | + | ||
| 205 | 242 | ||
| 206 | if (!function_exists('_get_child')) { | 243 | if (!function_exists('_get_child')) { |
| 207 | /** | 244 | /** |
| @@ -9,6 +9,7 @@ namespace App\Http\Controllers\Api; | @@ -9,6 +9,7 @@ namespace App\Http\Controllers\Api; | ||
| 9 | 9 | ||
| 10 | use App\Enums\Common\Code; | 10 | use App\Enums\Common\Code; |
| 11 | use App\Http\Logic\Bside\User\UserLoginLogic; | 11 | use App\Http\Logic\Bside\User\UserLoginLogic; |
| 12 | +use App\Models\Ai\AiBlog; | ||
| 12 | use App\Models\Blog\Blog; | 13 | use App\Models\Blog\Blog; |
| 13 | use App\Models\Domain\DomainInfo; | 14 | use App\Models\Domain\DomainInfo; |
| 14 | use App\Models\News\News; | 15 | use App\Models\News\News; |
| @@ -317,6 +318,7 @@ class PrivateController extends BaseController | @@ -317,6 +318,7 @@ class PrivateController extends BaseController | ||
| 317 | $news = News::where(['status' => News::STATUS_ONE])->where('release_at', '>', $date)->pluck('url'); | 318 | $news = News::where(['status' => News::STATUS_ONE])->where('release_at', '>', $date)->pluck('url'); |
| 318 | $blog = Blog::where(['status' => Blog::STATUS_ONE])->where('release_at', '>', $date)->pluck('url'); | 319 | $blog = Blog::where(['status' => Blog::STATUS_ONE])->where('release_at', '>', $date)->pluck('url'); |
| 319 | // $keyword = Keyword::where('created_at', '>', $date)->pluck('route'); | 320 | // $keyword = Keyword::where('created_at', '>', $date)->pluck('route'); |
| 321 | + $ai_blog = AiBlog::where(['status' => AiBlog::STATUS_FINISH])->where('updated_at', '>=', $date)->pluck('route'); | ||
| 320 | 322 | ||
| 321 | // 组装链接 | 323 | // 组装链接 |
| 322 | foreach ($product as $item) { | 324 | foreach ($product as $item) { |
| @@ -335,6 +337,10 @@ class PrivateController extends BaseController | @@ -335,6 +337,10 @@ class PrivateController extends BaseController | ||
| 335 | $url = 'https://' . $domain . '/blogs/' . $item; | 337 | $url = 'https://' . $domain . '/blogs/' . $item; |
| 336 | array_push($result, $url); | 338 | array_push($result, $url); |
| 337 | } | 339 | } |
| 340 | + foreach ($ai_blog as $item) { | ||
| 341 | + $url = 'https://' . $domain . '/blog/' . $item; | ||
| 342 | + array_push($result, $url); | ||
| 343 | + } | ||
| 338 | return $this->success($result); | 344 | return $this->success($result); |
| 339 | } | 345 | } |
| 340 | 346 | ||
| @@ -453,7 +459,7 @@ class PrivateController extends BaseController | @@ -453,7 +459,7 @@ class PrivateController extends BaseController | ||
| 453 | return $this->error('未找到当前域名对应的项目!'); | 459 | return $this->error('未找到当前域名对应的项目!'); |
| 454 | } | 460 | } |
| 455 | 461 | ||
| 456 | - $json = file_get_contents(storage_path('data/send_product_tag_keyword/' . $project->id . '.json')); | 462 | + $json = @file_get_contents(storage_path('data/send_product_tag_keyword/' . $project->id . '.json')); |
| 457 | $result = json_decode($json, true) ?: []; | 463 | $result = json_decode($json, true) ?: []; |
| 458 | return $this->success($result); | 464 | return $this->success($result); |
| 459 | } | 465 | } |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AggregateKeywordController.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/3/17 16:03 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Controllers\Aside\Project; | ||
| 11 | + | ||
| 12 | +use App\Enums\Common\Code; | ||
| 13 | +use App\Http\Controllers\Aside\BaseController; | ||
| 14 | +use App\Http\Logic\Aside\Project\AggregateKeywordLogic; | ||
| 15 | +use App\Models\Project\AggregateKeyword; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * @remark :聚合页关键词设置 | ||
| 19 | + * @name :AggregateKeywordController | ||
| 20 | + * @author :lyh | ||
| 21 | + * @method :post | ||
| 22 | + * @time :2025/3/17 16:04 | ||
| 23 | + */ | ||
| 24 | +class AggregateKeywordController extends BaseController | ||
| 25 | +{ | ||
| 26 | + /** | ||
| 27 | + * @remark :根据项目获取项目对应的聚合页关键词 | ||
| 28 | + * @name :lists | ||
| 29 | + * @author :lyh | ||
| 30 | + * @method :post | ||
| 31 | + * @time :2025/3/17 16:04 | ||
| 32 | + */ | ||
| 33 | + public function lists(AggregateKeyword $aggregateKeyword){ | ||
| 34 | + $this->request->validate([ | ||
| 35 | + 'project_id'=>'required', | ||
| 36 | + ],[ | ||
| 37 | + 'project_id.required' => 'project_id不能为空', | ||
| 38 | + ]); | ||
| 39 | + $lists = $aggregateKeyword->list($this->map); | ||
| 40 | + $this->response('success',Code::SUCCESS,$lists); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * @remark :获取数据详情 | ||
| 45 | + * @name :info | ||
| 46 | + * @author :lyh | ||
| 47 | + * @method :post | ||
| 48 | + * @time :2025/3/17 16:18 | ||
| 49 | + */ | ||
| 50 | + public function info(AggregateKeyword $aggregateKeyword){ | ||
| 51 | + $this->request->validate([ | ||
| 52 | + 'id'=>'required', | ||
| 53 | + ],[ | ||
| 54 | + 'id.required' => '主键不能为空', | ||
| 55 | + ]); | ||
| 56 | + $data = $aggregateKeyword->read($this->map); | ||
| 57 | + $this->response('success',Code::SUCCESS,$data); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * @remark :保存数据 | ||
| 62 | + * @name :save | ||
| 63 | + * @author :lyh | ||
| 64 | + * @method :post | ||
| 65 | + * @time :2025/3/17 16:05 | ||
| 66 | + * @param :created_at->创建使劲; operator->创建人; keywords->关键字一行一个; project_id->项目id | ||
| 67 | + */ | ||
| 68 | + public function save(AggregateKeywordLogic $logic){ | ||
| 69 | + $this->request->validate([ | ||
| 70 | + 'project_id'=>'required', | ||
| 71 | + 'created_at'=>'required', | ||
| 72 | + 'operator'=>'required', | ||
| 73 | + 'keywords'=>'required', | ||
| 74 | + ],[ | ||
| 75 | + 'project_id.required' => 'project_id不能为空', | ||
| 76 | + 'created_at.required' => 'created_at不能为空', | ||
| 77 | + 'operator.required' => 'operator不能为空', | ||
| 78 | + 'keywords.required' => 'keywords不能为空', | ||
| 79 | + ]); | ||
| 80 | + $data = $logic->saveKeyword(); | ||
| 81 | + $this->response('success',Code::SUCCESS,$data); | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + /** | ||
| 85 | + * @remark :删除数据 | ||
| 86 | + * @name :del | ||
| 87 | + * @author :lyh | ||
| 88 | + * @method :post | ||
| 89 | + * @time :2025/3/17 16:05 | ||
| 90 | + */ | ||
| 91 | + public function del(AggregateKeyword $aggregateKeyword){ | ||
| 92 | + $this->request->validate([ | ||
| 93 | + 'id'=>'required', | ||
| 94 | + ],[ | ||
| 95 | + 'id.required' => '主键不能为空', | ||
| 96 | + ]); | ||
| 97 | + $data = $aggregateKeyword->del($this->map); | ||
| 98 | + $this->response('success',Code::SUCCESS,$data); | ||
| 99 | + } | ||
| 100 | +} |
| @@ -83,6 +83,7 @@ class ProjectController extends BaseController | @@ -83,6 +83,7 @@ class ProjectController extends BaseController | ||
| 83 | 'gl_project.channel AS channel', | 83 | 'gl_project.channel AS channel', |
| 84 | 'gl_project.company AS company', | 84 | 'gl_project.company AS company', |
| 85 | 'gl_project.type AS type', | 85 | 'gl_project.type AS type', |
| 86 | + 'gl_project.project_type AS project_type', | ||
| 86 | 'gl_project.extend_type AS extend_type', | 87 | 'gl_project.extend_type AS extend_type', |
| 87 | 'gl_project.uptime AS uptime', | 88 | 'gl_project.uptime AS uptime', |
| 88 | 'gl_project.is_upgrade AS is_upgrade', | 89 | 'gl_project.is_upgrade AS is_upgrade', |
| @@ -7,8 +7,6 @@ use App\Exceptions\BsideGlobalException; | @@ -7,8 +7,6 @@ use App\Exceptions\BsideGlobalException; | ||
| 7 | use App\Helper\Common; | 7 | use App\Helper\Common; |
| 8 | use App\Http\Controllers\Controller; | 8 | use App\Http\Controllers\Controller; |
| 9 | use App\Http\Requests\Scene; | 9 | use App\Http\Requests\Scene; |
| 10 | -use App\Models\Project\DeployOptimize; | ||
| 11 | -use App\Models\Project\ProjectKeyword; | ||
| 12 | use App\Models\Template\BTemplate; | 10 | use App\Models\Template\BTemplate; |
| 13 | use App\Models\Template\Setting; | 11 | use App\Models\Template\Setting; |
| 14 | use Illuminate\Http\JsonResponse; | 12 | use Illuminate\Http\JsonResponse; |
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AggregateKeywordLogic.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/3/17 16:10 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Http\Logic\Aside\Project; | ||
| 11 | + | ||
| 12 | +use App\Http\Logic\Aside\BaseLogic; | ||
| 13 | +use App\Models\Project\AggregateKeyword; | ||
| 14 | + | ||
| 15 | +class AggregateKeywordLogic extends BaseLogic | ||
| 16 | +{ | ||
| 17 | + public function __construct() | ||
| 18 | + { | ||
| 19 | + parent::__construct(); | ||
| 20 | + $this->param = $this->requestAll; | ||
| 21 | + $this->model = new AggregateKeyword(); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * @remark : | ||
| 26 | + * @name :saveKeyword | ||
| 27 | + * @author :lyh | ||
| 28 | + * @method :post | ||
| 29 | + * @time :2025/3/17 16:11 | ||
| 30 | + */ | ||
| 31 | + public function saveKeyword(){ | ||
| 32 | + if(isset($this->param['id']) && !empty($this->param['id'])){ | ||
| 33 | + $id = $this->param['id']; | ||
| 34 | + $this->model->edit($this->param,['id'=>$this->param['id']]); | ||
| 35 | + }else{ | ||
| 36 | + $id = $this->model->addReturnId($this->param); | ||
| 37 | + } | ||
| 38 | + return $this->success(['id'=>$id]); | ||
| 39 | + } | ||
| 40 | +} |
| @@ -11,7 +11,6 @@ class DeployBuildLogic extends BaseLogic | @@ -11,7 +11,6 @@ class DeployBuildLogic extends BaseLogic | ||
| 11 | public function __construct() | 11 | public function __construct() |
| 12 | { | 12 | { |
| 13 | parent::__construct(); | 13 | parent::__construct(); |
| 14 | - | ||
| 15 | $this->model = new DeployBuild(); | 14 | $this->model = new DeployBuild(); |
| 16 | } | 15 | } |
| 17 | } | 16 | } |
| @@ -250,7 +250,7 @@ class ProjectLogic extends BaseLogic | @@ -250,7 +250,7 @@ class ProjectLogic extends BaseLogic | ||
| 250 | public function createAuthor($project_id,$mch_id,$key){ | 250 | public function createAuthor($project_id,$mch_id,$key){ |
| 251 | //查看当前项目是否已经创建了作者 | 251 | //查看当前项目是否已经创建了作者 |
| 252 | $aiBlogTaskModel = new AiBlogTask(); | 252 | $aiBlogTaskModel = new AiBlogTask(); |
| 253 | - $count = $aiBlogTaskModel->counts(['project_id'=>$project_id]); | 253 | + $count = $aiBlogTaskModel->counts(['project_id'=>$project_id,'type' => 1]); |
| 254 | if($count > 0){ | 254 | if($count > 0){ |
| 255 | return true; | 255 | return true; |
| 256 | } | 256 | } |
| @@ -259,6 +259,7 @@ class ProjectLogic extends BaseLogic | @@ -259,6 +259,7 @@ class ProjectLogic extends BaseLogic | ||
| 259 | $aiBlogService->key = $key; | 259 | $aiBlogService->key = $key; |
| 260 | $result = $aiBlogService->createAuthor(); | 260 | $result = $aiBlogService->createAuthor(); |
| 261 | if($result['status'] == 200){ | 261 | if($result['status'] == 200){ |
| 262 | + //查看当前是否已有未执行的 | ||
| 262 | $aiBlogTaskModel->add(['project_id'=>$project_id,'status'=>1,'type'=>1]); | 263 | $aiBlogTaskModel->add(['project_id'=>$project_id,'status'=>1,'type'=>1]); |
| 263 | } | 264 | } |
| 264 | return true; | 265 | return true; |
| @@ -103,8 +103,7 @@ class AiBlogLogic extends BaseLogic | @@ -103,8 +103,7 @@ class AiBlogLogic extends BaseLogic | ||
| 103 | if($result['status'] == 200){ | 103 | if($result['status'] == 200){ |
| 104 | $aiBlogTaskModel = new AiBlogTask(); | 104 | $aiBlogTaskModel = new AiBlogTask(); |
| 105 | $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>2,'task_id'=>$result['data']['task_id'],'status'=>1]); | 105 | $aiBlogTaskModel->addReturnId(['project_id'=>$this->user['project_id'],'type'=>2,'task_id'=>$result['data']['task_id'],'status'=>1]); |
| 106 | - $aiBlogModel = new AiBlog(); | ||
| 107 | - $aiBlogModel->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>1, 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],'anchor'=>json_encode($this->param['anchor'] ?? [],true) | 106 | + $this->model->addReturnId(['keyword'=>$this->param['keyword'], 'status'=>1, 'task_id'=>$result['data']['task_id'],'project_id'=>$this->user['project_id'],'anchor'=>json_encode($this->param['anchor'] ?? [],true) |
| 108 | ]); | 107 | ]); |
| 109 | } | 108 | } |
| 110 | return $this->success(); | 109 | return $this->success(); |
| @@ -274,6 +274,7 @@ class UserLoginLogic | @@ -274,6 +274,7 @@ class UserLoginLogic | ||
| 274 | $info['is_watermark'] = $project['is_watermark']; | 274 | $info['is_watermark'] = $project['is_watermark']; |
| 275 | $info['configuration'] = $project['deploy_build']['configuration']; | 275 | $info['configuration'] = $project['deploy_build']['configuration']; |
| 276 | $info['project_type'] = $project['type']; | 276 | $info['project_type'] = $project['type']; |
| 277 | + $info['project_seo_type'] = $project['project_type']; | ||
| 277 | $info['storage_type'] = $project['storage_type']; | 278 | $info['storage_type'] = $project['storage_type']; |
| 278 | $info['open_export_product'] = $project['open_export_product']; | 279 | $info['open_export_product'] = $project['open_export_product']; |
| 279 | $info['project_location'] = $project['project_location']; | 280 | $info['project_location'] = $project['project_location']; |
| @@ -10,4 +10,7 @@ class AiBlog extends Base | @@ -10,4 +10,7 @@ class AiBlog extends Base | ||
| 10 | //连接数据库 | 10 | //连接数据库 |
| 11 | protected $connection = 'custom_mysql'; | 11 | protected $connection = 'custom_mysql'; |
| 12 | 12 | ||
| 13 | + const STATUS_INIT = 0; | ||
| 14 | + const STATUS_RUNNING = 1; | ||
| 15 | + const STATUS_FINISH = 2; | ||
| 13 | } | 16 | } |
| @@ -70,6 +70,28 @@ class Base extends Model | @@ -70,6 +70,28 @@ class Base extends Model | ||
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | /** | 72 | /** |
| 73 | + * @remark :随机获取数据 | ||
| 74 | + * @name :limit_list | ||
| 75 | + * @author :lyh | ||
| 76 | + * @method :post | ||
| 77 | + * @time :2025/3/17 17:26 | ||
| 78 | + */ | ||
| 79 | + public function limit_list($map = [],$order = 'id',$fields = ['*'],$sort = 'desc',$row = 0): array | ||
| 80 | + { | ||
| 81 | + $query = $this->formatQuery($map); | ||
| 82 | + if($row != 0){ | ||
| 83 | + $query = $query->limit($row); | ||
| 84 | + } | ||
| 85 | + $query = $this->sortOrder($query,$order,$sort); | ||
| 86 | + $lists = $query->select($fields)->get(); | ||
| 87 | + if (empty($lists)) { | ||
| 88 | + return []; | ||
| 89 | + } | ||
| 90 | + $lists = $lists->toArray(); | ||
| 91 | + return $lists; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 73 | * @remark :获取数据详情 | 95 | * @remark :获取数据详情 |
| 74 | * @name :read | 96 | * @name :read |
| 75 | * @author :lyh | 97 | * @author :lyh |
| @@ -96,7 +118,7 @@ class Base extends Model | @@ -96,7 +118,7 @@ class Base extends Model | ||
| 96 | */ | 118 | */ |
| 97 | public function add($data){ | 119 | public function add($data){ |
| 98 | $data = $this->filterRequestData($data); | 120 | $data = $this->filterRequestData($data); |
| 99 | - $data['created_at'] = date('Y-m-d H:i:s'); | 121 | + $data['created_at'] = $data['created_at'] ?? date('Y-m-d H:i:s'); |
| 100 | $data['updated_at'] = $data['created_at']; | 122 | $data['updated_at'] = $data['created_at']; |
| 101 | return $this->insert($data); | 123 | return $this->insert($data); |
| 102 | } | 124 | } |
app/Models/Project/AggregateKeyword.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark : | ||
| 4 | + * @name :AggregateKeyword.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2025/3/17 16:02 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Models\Project; | ||
| 11 | + | ||
| 12 | +use App\Models\Base; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * @remark :聚合页关键词设置 | ||
| 16 | + * @name :AggregateKeyword | ||
| 17 | + * @author :lyh | ||
| 18 | + * @method :post | ||
| 19 | + * @time :2025/3/17 16:02 | ||
| 20 | + */ | ||
| 21 | +class AggregateKeyword extends Base | ||
| 22 | +{ | ||
| 23 | + protected $table = 'gl_aggregate_keyword'; | ||
| 24 | +} |
| @@ -533,6 +533,14 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -533,6 +533,14 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 533 | Route::prefix('industry')->group(function () { | 533 | Route::prefix('industry')->group(function () { |
| 534 | Route::any('/', [Aside\Project\ProjectController::class, 'industryList'])->name('admin.industryList'); | 534 | Route::any('/', [Aside\Project\ProjectController::class, 'industryList'])->name('admin.industryList'); |
| 535 | }); | 535 | }); |
| 536 | + | ||
| 537 | + //聚合页关键词设置 | ||
| 538 | + Route::prefix('aggregateKeyword')->group(function () { | ||
| 539 | + Route::any('/', [Aside\Project\AggregateKeywordController::class, 'lists'])->name('admin.aggregateKeyword'); | ||
| 540 | + Route::any('/info', [Aside\Project\AggregateKeywordController::class, 'info'])->name('admin.aggregateKeyword_info'); | ||
| 541 | + Route::any('/save', [Aside\Project\AggregateKeywordController::class, 'save'])->name('admin.aggregateKeyword_save'); | ||
| 542 | + Route::any('/del', [Aside\Project\AggregateKeywordController::class, 'del'])->name('admin.aggregateKeyword_del'); | ||
| 543 | + }); | ||
| 536 | }); | 544 | }); |
| 537 | 545 | ||
| 538 | //无需登录验证的路由组 | 546 | //无需登录验证的路由组 |
-
请 注册 或 登录 后发表评论