Merge remote-tracking branch 'origin/master' into akun
正在显示
12 个修改的文件
包含
46 行增加
和
227 行删除
| @@ -60,8 +60,7 @@ class AiBlogAutoPublish extends Command | @@ -60,8 +60,7 @@ class AiBlogAutoPublish extends Command | ||
| 60 | public function auto_publish() | 60 | public function auto_publish() |
| 61 | { | 61 | { |
| 62 | $this->output('开始自动发布博客文章'); | 62 | $this->output('开始自动发布博客文章'); |
| 63 | - $projects = Project::where('is_ai_blog', 1)->get(); | ||
| 64 | - | 63 | + $projects = Project::where('is_ai_blog', 1)->where('delete_status',0)->where('site_status',0)->where('extend_type',0)->get(); |
| 65 | foreach ($projects as $project) { | 64 | foreach ($projects as $project) { |
| 66 | try { | 65 | try { |
| 67 | $this->output("项目{$project->id}开始自动发布"); | 66 | $this->output("项目{$project->id}开始自动发布"); |
| @@ -122,6 +121,7 @@ class AiBlogAutoPublish extends Command | @@ -122,6 +121,7 @@ class AiBlogAutoPublish extends Command | ||
| 122 | ]); | 121 | ]); |
| 123 | $this->output("自动发布失败:" . $e->getMessage() . $e->getFile() . $e->getLine()); | 122 | $this->output("自动发布失败:" . $e->getMessage() . $e->getFile() . $e->getLine()); |
| 124 | } | 123 | } |
| 124 | + sleep(5); | ||
| 125 | } | 125 | } |
| 126 | } | 126 | } |
| 127 | 127 |
app/Console/Commands/Ai/AiVideoTask.php
已删除
100644 → 0
| 1 | -<?php | ||
| 2 | -/** | ||
| 3 | - * @remark : | ||
| 4 | - * @name :AiBlogTask.php | ||
| 5 | - * @author :lyh | ||
| 6 | - * @method :post | ||
| 7 | - * @time :2025/2/14 11:14 | ||
| 8 | - */ | ||
| 9 | - | ||
| 10 | -namespace App\Console\Commands\Ai; | ||
| 11 | - | ||
| 12 | -use App\Models\Ai\AiBlog; | ||
| 13 | -use App\Models\Ai\AiBlogAuthor; | ||
| 14 | -use App\Models\Ai\AiBlogList; | ||
| 15 | -use App\Models\Ai\AiVideo; | ||
| 16 | -use App\Models\Project\ProjectAiSetting; | ||
| 17 | -use App\Models\RouteMap\RouteMap; | ||
| 18 | -use App\Services\AiBlogService; | ||
| 19 | -use App\Services\ProjectServer; | ||
| 20 | -use Illuminate\Console\Command; | ||
| 21 | -use App\Models\Project\AiBlogTask as AiBlogTaskModel; | ||
| 22 | -use Illuminate\Support\Facades\Cache; | ||
| 23 | -use Illuminate\Support\Facades\DB; | ||
| 24 | -use function Symfony\Component\String\s; | ||
| 25 | - | ||
| 26 | -class AiVideoTask extends Command | ||
| 27 | -{ | ||
| 28 | - /** | ||
| 29 | - * The name and signature of the console command. | ||
| 30 | - * | ||
| 31 | - * @var string | ||
| 32 | - */ | ||
| 33 | - protected $signature = 'save_ai_video'; | ||
| 34 | - | ||
| 35 | - /** | ||
| 36 | - * The console command description. | ||
| 37 | - * | ||
| 38 | - * @var string | ||
| 39 | - */ | ||
| 40 | - protected $description = '查询ai_video是否已经生成'; | ||
| 41 | - | ||
| 42 | - public function handle(){ | ||
| 43 | - $aiBlogTaskModel = new AiBlogTaskModel(); | ||
| 44 | - while (true){ | ||
| 45 | - $list = $aiBlogTaskModel->list(['status'=>1,'type'=>3],'id',['*'],'asc',1000); | ||
| 46 | - if(empty($list)){ | ||
| 47 | - sleep(300); | ||
| 48 | - continue; | ||
| 49 | - } | ||
| 50 | - $updateProject = []; | ||
| 51 | - foreach ($list as $item){ | ||
| 52 | - echo '开始->任务id:' . $item['task_id'] . PHP_EOL . date('Y-m-d H:i:s'); | ||
| 53 | - //获取配置 | ||
| 54 | - $aiSettingInfo = $this->getSetting($item['project_id']); | ||
| 55 | - $aiBlogService = new AiBlogService(); | ||
| 56 | - $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | ||
| 57 | - $aiBlogService->key = $aiSettingInfo['key']; | ||
| 58 | - $aiBlogService->task_id = $item['task_id']; | ||
| 59 | - $result = $aiBlogService->getDetail(); | ||
| 60 | - if($result['status'] != 200){ | ||
| 61 | - sleep(5); | ||
| 62 | - continue; | ||
| 63 | - } | ||
| 64 | - //保存当前项目ai_blog数据 | ||
| 65 | - ProjectServer::useProject($item['project_id']); | ||
| 66 | - $aiVideoModel = new AiVideo(); | ||
| 67 | - $aiBlogInfo = $aiVideoModel->read(['task_id'=>$item['task_id']],['id']); | ||
| 68 | - if($aiBlogInfo === false){ | ||
| 69 | - $aiBlogTaskModel->edit(['status'=>2],['id'=>$item['id']]); | ||
| 70 | - continue; | ||
| 71 | - } | ||
| 72 | - if (!in_array($result['data']['author_id'], $updateProject[$item['project_id']] ?? [])) { | ||
| 73 | - $updateProject[$item['project_id']][] = $result['data']['author_id']; | ||
| 74 | - } | ||
| 75 | - //拿到返回的路由查看是否重复 | ||
| 76 | - $route = RouteMap::setRoute($result['data']['url'], RouteMap::SOURCE_AI_VIDEO, $aiBlogInfo['id'], $item['project_id']); | ||
| 77 | - if($route != $result['data']['url']){ | ||
| 78 | - $aiBlogService->updateDetail(['route'=>$route,'task_id'=>$item['task_id']]); | ||
| 79 | - } | ||
| 80 | - $aiVideoModel->edit(['new_title'=>$result['data']['title'], 'image'=>$result['data']['thumb'], 'text'=>$result['data']['section'], 'author_id'=>$result['data']['author_id'], 'route'=>$route ,'status'=>2], ['task_id'=>$item['task_id']]); | ||
| 81 | - DB::disconnect('custom_mysql'); | ||
| 82 | - $aiBlogTaskModel->edit(['status'=>2],['id'=>$item['id']]); | ||
| 83 | - } | ||
| 84 | - //TODO::更新列表页及作者 | ||
| 85 | - $this->updateProject($updateProject); | ||
| 86 | - echo '结束->任务id:' . $item['task_id'] . PHP_EOL . date('Y-m-d H:i:s'); | ||
| 87 | - } | ||
| 88 | - return true; | ||
| 89 | - } | ||
| 90 | - | ||
| 91 | - /** | ||
| 92 | - * @remark :更新项目作者页面及列表页 | ||
| 93 | - * @name :updateProject | ||
| 94 | - * @author :lyh | ||
| 95 | - * @method :post | ||
| 96 | - * @time :2025/3/4 10:25 | ||
| 97 | - */ | ||
| 98 | - public function updateProject($updateProject){ | ||
| 99 | - if(empty($updateProject)){ | ||
| 100 | - return true; | ||
| 101 | - } | ||
| 102 | - foreach ($updateProject as $project_id => $author){ | ||
| 103 | - ProjectServer::useProject($project_id); | ||
| 104 | - $aiSettingInfo = $this->getSetting($project_id); | ||
| 105 | -// $this->updateBlogList($aiSettingInfo); | ||
| 106 | - //更新作者 | ||
| 107 | - foreach ($author as $val){ | ||
| 108 | - $this->updateAiBlogAuthor($aiSettingInfo,$val); | ||
| 109 | - } | ||
| 110 | - DB::disconnect('custom_mysql'); | ||
| 111 | - } | ||
| 112 | - return true; | ||
| 113 | - } | ||
| 114 | - | ||
| 115 | - /** | ||
| 116 | - * @remark :获取项目配置 | ||
| 117 | - * @name :getSetting | ||
| 118 | - * @author :lyh | ||
| 119 | - * @method :post | ||
| 120 | - * @time :2025/2/14 11:27 | ||
| 121 | - */ | ||
| 122 | - public function getSetting($project_id){ | ||
| 123 | - $ai_cache = Cache::get('ai_blog_'.$project_id); | ||
| 124 | - if($ai_cache){ | ||
| 125 | - return $ai_cache; | ||
| 126 | - } | ||
| 127 | - $projectAiSettingModel = new ProjectAiSetting(); | ||
| 128 | - $aiSettingInfo = $projectAiSettingModel->read(['project_id'=>$project_id]); | ||
| 129 | - Cache::put('ai_blog_'.$project_id,$aiSettingInfo,3600); | ||
| 130 | - return $aiSettingInfo; | ||
| 131 | - } | ||
| 132 | - | ||
| 133 | - /** | ||
| 134 | - * @remark :更新作者的页面 | ||
| 135 | - * @name :updateAiBlogAuthor | ||
| 136 | - * @author :lyh | ||
| 137 | - * @method :post | ||
| 138 | - * @time :2025/2/21 11:53 | ||
| 139 | - */ | ||
| 140 | - public function updateAiBlogAuthor($aiSettingInfo,$author_id){ | ||
| 141 | - if(empty($author_id)){ | ||
| 142 | - return true; | ||
| 143 | - } | ||
| 144 | - $aiBlogService = new AiBlogService(); | ||
| 145 | - $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | ||
| 146 | - $aiBlogService->key = $aiSettingInfo['key']; | ||
| 147 | - $aiBlogService->author_id = $author_id; | ||
| 148 | - $result = $aiBlogService->getAuthorDetail(); | ||
| 149 | - if(isset($result['status']) && $result['status'] == 200){ | ||
| 150 | - //当前作者的页面 | ||
| 151 | - $aiBlogAuthorModel = new AiBlogAuthor(); | ||
| 152 | - if(!empty($result['data']['section'])){ | ||
| 153 | - $aiBlogAuthorModel->edit(['text'=>$result['data']['section']],['author_id'=>$author_id]); | ||
| 154 | - } | ||
| 155 | - } | ||
| 156 | - return true; | ||
| 157 | - } | ||
| 158 | - | ||
| 159 | - /** | ||
| 160 | - * @remark :更新列表页 | ||
| 161 | - * @name :updateBlogList | ||
| 162 | - * @author :lyh | ||
| 163 | - * @method :post | ||
| 164 | - * @time :2025/2/26 15:42 | ||
| 165 | - */ | ||
| 166 | - public function updateBlogList($aiSettingInfo){ | ||
| 167 | - $aiBlogService = new AiBlogService(); | ||
| 168 | - $aiBlogService->mch_id = $aiSettingInfo['mch_id']; | ||
| 169 | - $aiBlogService->key = $aiSettingInfo['key']; | ||
| 170 | - $page = 1; | ||
| 171 | - $saveData = []; | ||
| 172 | - $result = $aiBlogService->getAiBlogList($page,15); | ||
| 173 | - if(!isset($result['status']) && $result['status'] != 200){ | ||
| 174 | - return true; | ||
| 175 | - } | ||
| 176 | - $total_page = $result['data']['total_page']; | ||
| 177 | - //组装数据保存 | ||
| 178 | - $saveData[] = [ | ||
| 179 | - 'route'=>$page, | ||
| 180 | - 'text'=>$result['data']['section'], | ||
| 181 | - ]; | ||
| 182 | - while ($total_page > $page){ | ||
| 183 | - $page++; | ||
| 184 | - $result = $aiBlogService->getAiBlogList($page,15); | ||
| 185 | - if(isset($result['status']) && $result['status'] == 200){ | ||
| 186 | - $saveData[] = [ | ||
| 187 | - 'route'=>$page, | ||
| 188 | - 'text'=>$result['data']['section'], | ||
| 189 | - ]; | ||
| 190 | - } | ||
| 191 | - } | ||
| 192 | - $aiBlogListModel = new AiBlogList(); | ||
| 193 | - if(!empty($saveData)){ | ||
| 194 | - //写一条路由信息 | ||
| 195 | - $aiBlogListModel->truncate(); | ||
| 196 | - $aiBlogListModel->insertAll($saveData); | ||
| 197 | - } | ||
| 198 | - return true; | ||
| 199 | - } | ||
| 200 | -} |
| @@ -44,23 +44,26 @@ class ShareUser extends Command | @@ -44,23 +44,26 @@ class ShareUser extends Command | ||
| 44 | //获取所有ayr_share用户 | 44 | //获取所有ayr_share用户 |
| 45 | $ayr_share_model = new AyrShareModel(); | 45 | $ayr_share_model = new AyrShareModel(); |
| 46 | $ayr_release = new AyrReleaseModel(); | 46 | $ayr_release = new AyrReleaseModel(); |
| 47 | - $ayr_share_list = $ayr_share_model->list(['profile_key'=>['!=',''],'project_id'=>410]); | 47 | + $ayr_share_list = $ayr_share_model->list(['profile_key'=>['!=','']]); |
| 48 | foreach ($ayr_share_list as $v){ | 48 | foreach ($ayr_share_list as $v){ |
| 49 | $time = Carbon::now()->modify('-1 days')->toDateString(); | 49 | $time = Carbon::now()->modify('-1 days')->toDateString(); |
| 50 | //创建时间小于7天前的当前时间 | 50 | //创建时间小于7天前的当前时间 |
| 51 | if($v['created_at'] > $time){ | 51 | if($v['created_at'] > $time){ |
| 52 | + echo '创建时间小于7天跳过。'.date('Y-m-d H:i:s').PHP_EOL; | ||
| 52 | continue; | 53 | continue; |
| 53 | } | 54 | } |
| 54 | //查询当前用户是否有未推送的博文 | 55 | //查询当前用户是否有未推送的博文 |
| 55 | $release_info = $this->release_info($ayr_release,$v); | 56 | $release_info = $this->release_info($ayr_release,$v); |
| 56 | //有推文时,直接跳出循环 | 57 | //有推文时,直接跳出循环 |
| 57 | if($release_info !== false){ | 58 | if($release_info !== false){ |
| 59 | + echo '有推文直接跳过。'.date('Y-m-d H:i:s').PHP_EOL; | ||
| 58 | continue; | 60 | continue; |
| 59 | } | 61 | } |
| 60 | //查询7天是否发送博文 | 62 | //查询7天是否发送博文 |
| 61 | $release_info = $this->release_seven_info($ayr_release); | 63 | $release_info = $this->release_seven_info($ayr_release); |
| 62 | //有发送博文,则跳出循环 | 64 | //有发送博文,则跳出循环 |
| 63 | if($release_info !== false){ | 65 | if($release_info !== false){ |
| 66 | + echo '7天内有推文跳过。'.date('Y-m-d H:i:s').PHP_EOL; | ||
| 64 | continue; | 67 | continue; |
| 65 | } | 68 | } |
| 66 | //删除用户第三方配置 | 69 | //删除用户第三方配置 |
| @@ -238,17 +238,20 @@ class CopyProject extends Command | @@ -238,17 +238,20 @@ class CopyProject extends Command | ||
| 238 | $tables = array_column($tables, 'Tables_in_' . $database_name); | 238 | $tables = array_column($tables, 'Tables_in_' . $database_name); |
| 239 | foreach ($tables as $table) { | 239 | foreach ($tables as $table) { |
| 240 | // 1. 删除目标数据库中的表 | 240 | // 1. 删除目标数据库中的表 |
| 241 | - DB::connection('custom_mysql')->statement("DROP TABLE IF EXISTS {$table}"); | 241 | + $result = DB::connection('custom_mysql')->statement("DROP TABLE IF EXISTS {$table}"); |
| 242 | + @file_put_contents(storage_path('logs/copy_mysql_error.log'), var_export('先删除对应数据库的对应表返回结果:'.$result, true) . PHP_EOL, FILE_APPEND); | ||
| 242 | // 2. 复制建表 SQL | 243 | // 2. 复制建表 SQL |
| 243 | $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE `{$table}`"); | 244 | $sql = DB::connection('custom_tmp_mysql_copy')->select("SHOW CREATE TABLE `{$table}`"); |
| 244 | - DB::connection('custom_mysql')->statement(get_object_vars($sql[0])['Create Table']); | 245 | + $result1 = DB::connection('custom_mysql')->statement(get_object_vars($sql[0])['Create Table']); |
| 246 | + @file_put_contents(storage_path('logs/copy_mysql_error.log'), var_export('创建对应表数据:'.$result1, true) . PHP_EOL, FILE_APPEND); | ||
| 245 | // 3. 跳过指定的表 | 247 | // 3. 跳过指定的表 |
| 246 | if (in_array($table, ['gl_customer_visit', 'gl_customer_visit_item', 'gl_inquiry_other', 'gl_inquiry_form_data', 'gl_inquiry_form'])) { | 248 | if (in_array($table, ['gl_customer_visit', 'gl_customer_visit_item', 'gl_inquiry_other', 'gl_inquiry_form_data', 'gl_inquiry_form'])) { |
| 247 | continue; | 249 | continue; |
| 248 | } | 250 | } |
| 249 | // 4. 原生 SQL 插入数据(完全复制) | 251 | // 4. 原生 SQL 插入数据(完全复制) |
| 250 | $insert_sql = "INSERT INTO `{$table}` SELECT * FROM `gl_data_{$project_id}`.`{$table}`"; | 252 | $insert_sql = "INSERT INTO `{$table}` SELECT * FROM `gl_data_{$project_id}`.`{$table}`"; |
| 251 | - DB::connection('custom_mysql')->statement($insert_sql); | 253 | + $result2 = DB::connection('custom_mysql')->statement($insert_sql); |
| 254 | + @file_put_contents(storage_path('logs/copy_mysql_error.log'), var_export('对应表插入数据:'.$result2, true) . PHP_EOL, FILE_APPEND); | ||
| 252 | // 5. 更新 project_id(如果存在) | 255 | // 5. 更新 project_id(如果存在) |
| 253 | if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) { | 256 | if (Schema::connection('custom_mysql')->hasColumn($table, 'project_id')) { |
| 254 | DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]); | 257 | DB::connection('custom_mysql')->table($table)->update(['project_id' => $news_project_id]); |
| @@ -3,10 +3,12 @@ | @@ -3,10 +3,12 @@ | ||
| 3 | namespace App\Console\Commands\RankData; | 3 | namespace App\Console\Commands\RankData; |
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | +use App\Helper\QuanqiusouApi; | ||
| 6 | use App\Http\Logic\Bside\RankData\RankDataLogic; | 7 | use App\Http\Logic\Bside\RankData\RankDataLogic; |
| 7 | use App\Models\RankData\RankDataLog as RankDataLogModel; | 8 | use App\Models\RankData\RankDataLog as RankDataLogModel; |
| 8 | use App\Models\Domain\DomainInfo; | 9 | use App\Models\Domain\DomainInfo; |
| 9 | use App\Models\Project\Project; | 10 | use App\Models\Project\Project; |
| 11 | +use Illuminate\Support\Facades\Cache; | ||
| 10 | use Illuminate\Support\Facades\Log; | 12 | use Illuminate\Support\Facades\Log; |
| 11 | 13 | ||
| 12 | /** | 14 | /** |
| @@ -338,7 +338,7 @@ class UpdateSeoTdk extends Command | @@ -338,7 +338,7 @@ class UpdateSeoTdk extends Command | ||
| 338 | 338 | ||
| 339 | //AI生成 | 339 | //AI生成 |
| 340 | if (!empty($ai_commands[$ai_key]['ai'])) { | 340 | if (!empty($ai_commands[$ai_key]['ai'])) { |
| 341 | - $prompt = $this->getPrompt($project_id, $ai_commands[$ai_key]['ai'], $table, $v); | 341 | + $prompt = $this->getPrompt($project_id, $ai_commands[$ai_key]['ai'], $table, $v, $field); |
| 342 | if(!$prompt){ | 342 | if(!$prompt){ |
| 343 | continue; | 343 | continue; |
| 344 | } | 344 | } |
| @@ -465,7 +465,7 @@ class UpdateSeoTdk extends Command | @@ -465,7 +465,7 @@ class UpdateSeoTdk extends Command | ||
| 465 | $notify_master && $this->sendNotify($project_id, 2); //通知主站按需更新 | 465 | $notify_master && $this->sendNotify($project_id, 2); //通知主站按需更新 |
| 466 | } | 466 | } |
| 467 | 467 | ||
| 468 | - public function getPrompt($project_id, $prompt, $table, $data){ | 468 | + public function getPrompt($project_id, $prompt, $table, $data, $field){ |
| 469 | // topic | 469 | // topic |
| 470 | if(strpos($prompt, '{topic}') !== false){ | 470 | if(strpos($prompt, '{topic}') !== false){ |
| 471 | $topic = $data[$this->topic_fields[$table]] ?? ''; | 471 | $topic = $data[$this->topic_fields[$table]] ?? ''; |
| @@ -507,7 +507,7 @@ class UpdateSeoTdk extends Command | @@ -507,7 +507,7 @@ class UpdateSeoTdk extends Command | ||
| 507 | } | 507 | } |
| 508 | 508 | ||
| 509 | $project = Project::find($project_id); | 509 | $project = Project::find($project_id); |
| 510 | - if (!in_array(8, explode(',', $project->deploy_optimize->special))) { | 510 | + if (!in_array(8, explode(',', $project->deploy_optimize->special)) && $field == 'seo_title') { |
| 511 | // 前缀关键词 | 511 | // 前缀关键词 |
| 512 | if (preg_match_all("/\{qz_(\d+)\}/", $prompt, $matches)) { | 512 | if (preg_match_all("/\{qz_(\d+)\}/", $prompt, $matches)) { |
| 513 | foreach ($matches[0] as $key => $val) { | 513 | foreach ($matches[0] as $key => $val) { |
| @@ -249,7 +249,7 @@ class OptimizeController extends BaseController | @@ -249,7 +249,7 @@ class OptimizeController extends BaseController | ||
| 249 | $query = $query->where('gl_project.title','like','%'.$this->map['title'].'%'); | 249 | $query = $query->where('gl_project.title','like','%'.$this->map['title'].'%'); |
| 250 | } | 250 | } |
| 251 | if(isset($this->map['site_status'])){ | 251 | if(isset($this->map['site_status'])){ |
| 252 | - $query = $query->where('gl_project_deploy_build.site_status',$this->map['site_status']); | 252 | + $query = $query->where('gl_project.site_status',$this->map['site_status']); |
| 253 | } | 253 | } |
| 254 | if(isset($this->map['seo_plan'])){ | 254 | if(isset($this->map['seo_plan'])){ |
| 255 | $query = $query->where('gl_project_deploy_build.seo_plan',$this->map['seo_plan']); | 255 | $query = $query->where('gl_project_deploy_build.seo_plan',$this->map['seo_plan']); |
| @@ -1148,6 +1148,9 @@ class ProductLogic extends BaseLogic | @@ -1148,6 +1148,9 @@ class ProductLogic extends BaseLogic | ||
| 1148 | */ | 1148 | */ |
| 1149 | public function batchSetKeyword(){ | 1149 | public function batchSetKeyword(){ |
| 1150 | if(isset($this->param['is_cover']) && $this->param['is_cover'] == 1){//覆盖 | 1150 | if(isset($this->param['is_cover']) && $this->param['is_cover'] == 1){//覆盖 |
| 1151 | + foreach ($this->param['id'] as $id){ | ||
| 1152 | + KeywordRelated::saveRelated($id,$this->param['keyword_id'] ?? []);//关键字关联 | ||
| 1153 | + } | ||
| 1151 | $this->param['keyword_id'] = ','.implode(',',$this->param['keyword_id']).','; | 1154 | $this->param['keyword_id'] = ','.implode(',',$this->param['keyword_id']).','; |
| 1152 | $this->edit(['keyword_id'=>$this->param['keyword_id']],['id'=>['in',$this->param['id']]]); | 1155 | $this->edit(['keyword_id'=>$this->param['keyword_id']],['id'=>['in',$this->param['id']]]); |
| 1153 | }else{ | 1156 | }else{ |
| @@ -1155,6 +1158,7 @@ class ProductLogic extends BaseLogic | @@ -1155,6 +1158,7 @@ class ProductLogic extends BaseLogic | ||
| 1155 | //获取当前产品的分类 | 1158 | //获取当前产品的分类 |
| 1156 | $productInfo = $this->model->read(['id'=>$id],['id','keyword_id']); | 1159 | $productInfo = $this->model->read(['id'=>$id],['id','keyword_id']); |
| 1157 | $keyword_ids_arr = array_values(array_unique(array_merge($productInfo['keyword_id'],$this->param['keyword_id']))); | 1160 | $keyword_ids_arr = array_values(array_unique(array_merge($productInfo['keyword_id'],$this->param['keyword_id']))); |
| 1161 | + KeywordRelated::saveRelated($id,$keyword_ids_arr ?? []);//关键字关联 | ||
| 1158 | $keyword_ids = ','.implode(',',$keyword_ids_arr).','; | 1162 | $keyword_ids = ','.implode(',',$keyword_ids_arr).','; |
| 1159 | $this->model->edit(['keyword_id'=>$keyword_ids],['id'=>$id]); | 1163 | $this->model->edit(['keyword_id'=>$keyword_ids],['id'=>$id]); |
| 1160 | } | 1164 | } |
| @@ -196,9 +196,9 @@ class RankDataLogic extends BaseLogic | @@ -196,9 +196,9 @@ class RankDataLogic extends BaseLogic | ||
| 196 | $data['current_api_source'] = $api_no == 10690 ? 'Yandex' : 'Google'; | 196 | $data['current_api_source'] = $api_no == 10690 ? 'Yandex' : 'Google'; |
| 197 | } | 197 | } |
| 198 | $data['api_no'] = $api_no; | 198 | $data['api_no'] = $api_no; |
| 199 | - $bmseo_id = RankDataBmseo::where('project_id', $project_id)->value('id'); | ||
| 200 | - if($bmseo_id){ | ||
| 201 | - $data['bmseo_api_no'] = $bmseo_id . '_bmseo'; | 199 | + $api_no = RankDataBmseo::where('project_id', $project_id)->value('api_no'); |
| 200 | + if($api_no){ | ||
| 201 | + $data['bmseo_api_no'] = $api_no; | ||
| 202 | } | 202 | } |
| 203 | 203 | ||
| 204 | return $data; | 204 | return $data; |
| @@ -221,6 +221,10 @@ class RankDataLogic extends BaseLogic | @@ -221,6 +221,10 @@ class RankDataLogic extends BaseLogic | ||
| 221 | $api_no = $project['deploy_optimize']['api_no'] ?? 0; | 221 | $api_no = $project['deploy_optimize']['api_no'] ?? 0; |
| 222 | } | 222 | } |
| 223 | 223 | ||
| 224 | + if(!$api_no){ | ||
| 225 | + $api_no = RankDataBmseo::where('project_id', $project_id)->value('api_no'); | ||
| 226 | + } | ||
| 227 | + | ||
| 224 | $domain = (!empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : ''); | 228 | $domain = (!empty($project['deploy_optimize']['domain']) ? ((new DomainInfo())->getDomain($project['deploy_optimize']['domain'])) : ''); |
| 225 | $domain_arr = parse_url($domain); | 229 | $domain_arr = parse_url($domain); |
| 226 | $domain = $domain_arr['host'] ?? $domain_arr['path']; | 230 | $domain = $domain_arr['host'] ?? $domain_arr['path']; |
| @@ -234,7 +238,7 @@ class RankDataLogic extends BaseLogic | @@ -234,7 +238,7 @@ class RankDataLogic extends BaseLogic | ||
| 234 | $flg_ai = $this->getAiFlag($ai_projects, $domain); | 238 | $flg_ai = $this->getAiFlag($ai_projects, $domain); |
| 235 | $ai_domain = str_replace('www.', '', $this->getAiProjects($domain)['domain'] ?? ''); | 239 | $ai_domain = str_replace('www.', '', $this->getAiProjects($domain)['domain'] ?? ''); |
| 236 | if (Str::endsWith($api_no, '_bmseo')) { | 240 | if (Str::endsWith($api_no, '_bmseo')) { |
| 237 | - $list = RankDataBmseo::where('project_id', $project_id)->where('api_no', $api_no)->where('lang', $lang)->value('data') ?: []; | 241 | + $list = RankDataBmseo::where('project_id', $project_id)->where('api_no', $api_no)->value('data') ?: []; |
| 238 | } else { | 242 | } else { |
| 239 | $list = RankData::where('project_id', $project_id)->where('api_no', $api_no)->where('lang', $lang)->value('data') ?: []; | 243 | $list = RankData::where('project_id', $project_id)->where('api_no', $api_no)->where('lang', $lang)->value('data') ?: []; |
| 240 | } | 244 | } |
| @@ -27,6 +27,9 @@ class GoogleKeywordInsightDetail extends Base | @@ -27,6 +27,9 @@ class GoogleKeywordInsightDetail extends Base | ||
| 27 | $saveData = []; | 27 | $saveData = []; |
| 28 | $textArr = array_column($data, 'text'); | 28 | $textArr = array_column($data, 'text'); |
| 29 | $transData = Translate::tran($textArr, 'zh'); | 29 | $transData = Translate::tran($textArr, 'zh'); |
| 30 | + if(!is_array($transData)){ | ||
| 31 | + $transData = [$transData]; | ||
| 32 | + } | ||
| 30 | foreach ($data as $key => $val){ | 33 | foreach ($data as $key => $val){ |
| 31 | $saveData[] = [ | 34 | $saveData[] = [ |
| 32 | 'search'=>$keyword, | 35 | 'search'=>$keyword, |
| @@ -36,7 +36,7 @@ class InquiryRelateDomain extends Base | @@ -36,7 +36,7 @@ class InquiryRelateDomain extends Base | ||
| 36 | $page = 1; | 36 | $page = 1; |
| 37 | while (true) { | 37 | while (true) { |
| 38 | try { | 38 | try { |
| 39 | - $res = HttpUtils::get('https://www.cmer.site/api/globalso_site', ['pagesite' => 100, 'page' => $page]); | 39 | + $res = HttpUtils::get('https://www.cmer.site/api/globalso_site', ['pagesize' => 100, 'page' => $page]); |
| 40 | if($res) { | 40 | if($res) { |
| 41 | $res = Arr::s2a($res); | 41 | $res = Arr::s2a($res); |
| 42 | $arr = []; | 42 | $arr = []; |
| @@ -47,18 +47,18 @@ class SyncSubmitTaskService | @@ -47,18 +47,18 @@ class SyncSubmitTaskService | ||
| 47 | $data = $task['data']; | 47 | $data = $task['data']; |
| 48 | 48 | ||
| 49 | //有关联域名 替换原数据url | 49 | //有关联域名 替换原数据url |
| 50 | - if($relate_domain){ | ||
| 51 | - $domain = $data['domain']; | ||
| 52 | - foreach ($data as $k=>&$item){ | ||
| 53 | - if($k == 'data'){ | ||
| 54 | - foreach ($item as &$v){ | ||
| 55 | - $v = str_replace($domain, $relate_domain, $v); | ||
| 56 | - } | ||
| 57 | - }else{ | ||
| 58 | - $item = str_replace($domain, $relate_domain, $item); | ||
| 59 | - } | ||
| 60 | - } | ||
| 61 | - } | 50 | +// if($relate_domain){ |
| 51 | +// $domain = $data['domain']; | ||
| 52 | +// foreach ($data as $k=>&$item){ | ||
| 53 | +// if($k == 'data'){ | ||
| 54 | +// foreach ($item as &$v){ | ||
| 55 | +// $v = str_replace($domain, $relate_domain, $v); | ||
| 56 | +// } | ||
| 57 | +// }else{ | ||
| 58 | +// $item = str_replace($domain, $relate_domain, $item); | ||
| 59 | +// } | ||
| 60 | +// } | ||
| 61 | +// } | ||
| 62 | 62 | ||
| 63 | $checkIpCountry = self::checkIpCountry($data['domain'], $data['ip'], $task['type']); | 63 | $checkIpCountry = self::checkIpCountry($data['domain'], $data['ip'], $task['type']); |
| 64 | 64 |
-
请 注册 或 登录 后发表评论