作者 赵彬吉

update

@@ -199,17 +199,17 @@ class UpdateSeoTdk extends Command @@ -199,17 +199,17 @@ class UpdateSeoTdk extends Command
199 } 199 }
200 $project_id = $task->project_id; 200 $project_id = $task->project_id;
201 201
202 - echo getmypid() . date('Y-m-d H:i:s') . ' start project_id: ' . $project_id . PHP_EOL; 202 + echo getmypid() . ' ' . date('Y-m-d H:i:s') . ' start project_id: ' . $project_id . PHP_EOL;
203 try { 203 try {
204 $this->project = ProjectServer::useProject($project_id); 204 $this->project = ProjectServer::useProject($project_id);
205 $this->seo_tdk($project_id, $task->id); 205 $this->seo_tdk($project_id, $task->id);
206 DB::disconnect('custom_mysql'); 206 DB::disconnect('custom_mysql');
207 }catch (\Exception $e){ 207 }catch (\Exception $e){
208 - echo getmypid() . date('Y-m-d H:i:s') . 'line: '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL; 208 + echo getmypid() . ' ' . date('Y-m-d H:i:s') . 'line: '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
209 ProjectUpdateTdk::retry($task->id, $e->getMessage()); 209 ProjectUpdateTdk::retry($task->id, $e->getMessage());
210 } 210 }
211 Cache::forget('project_deploy_optimize_info_' . $project_id); 211 Cache::forget('project_deploy_optimize_info_' . $project_id);
212 - echo getmypid() . date('Y-m-d H:i:s') . ' end project_id: ' . $project_id . PHP_EOL; 212 + echo getmypid() . ' ' . date('Y-m-d H:i:s') . ' end project_id: ' . $project_id . PHP_EOL;
213 } 213 }
214 } 214 }
215 public function sendNotify($project_id, $route) 215 public function sendNotify($project_id, $route)
@@ -234,7 +234,7 @@ class UpdateSeoTdk extends Command @@ -234,7 +234,7 @@ class UpdateSeoTdk extends Command
234 'language'=> [], 234 'language'=> [],
235 ]; 235 ];
236 http_post($url, json_encode($param)); 236 http_post($url, json_encode($param));
237 - echo getmypid() . '更新中请稍后, 更新完成将会发送站内信通知更新结果!'. PHP_EOL; 237 + echo getmypid() . ' ' . '更新中请稍后, 更新完成将会发送站内信通知更新结果!'. PHP_EOL;
238 } 238 }
239 public function seo_tdk($project_id, $task_id) 239 public function seo_tdk($project_id, $task_id)
240 { 240 {
@@ -246,7 +246,7 @@ class UpdateSeoTdk extends Command @@ -246,7 +246,7 @@ class UpdateSeoTdk extends Command
246 foreach ($this->maps as $table => $map) { 246 foreach ($this->maps as $table => $map) {
247 $total_page = DB::connection('custom_mysql')->table($table)->count(); 247 $total_page = DB::connection('custom_mysql')->table($table)->count();
248 $update[$table] = ['total_page'=>$total_page, 'title'=>0, 'keyword'=>0, 'des'=>0,'keyword_title'=>0,'keyword_content'=>0]; 248 $update[$table] = ['total_page'=>$total_page, 'title'=>0, 'keyword'=>0, 'des'=>0,'keyword_title'=>0,'keyword_content'=>0];
249 - echo getmypid() . date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL; 249 + echo getmypid() . ' ' . date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL;
250 $list = DB::connection('custom_mysql')->table($table) 250 $list = DB::connection('custom_mysql')->table($table)
251 ->where(function ($query) use ($table, $map){ 251 ->where(function ($query) use ($table, $map){
252 if($table == 'gl_product'){ 252 if($table == 'gl_product'){
@@ -280,7 +280,7 @@ class UpdateSeoTdk extends Command @@ -280,7 +280,7 @@ class UpdateSeoTdk extends Command
280 } 280 }
281 281
282 282
283 - echo getmypid() . date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL; 283 + echo getmypid() . ' ' . date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL;
284 $v = DB::connection('custom_mysql')->table($table)->where('id', $v['id'])->first(); 284 $v = DB::connection('custom_mysql')->table($table)->where('id', $v['id'])->first();
285 $v = (array)$v; 285 $v = (array)$v;
286 $data = []; 286 $data = [];
@@ -295,7 +295,7 @@ class UpdateSeoTdk extends Command @@ -295,7 +295,7 @@ class UpdateSeoTdk extends Command
295 } 295 }
296 //已有值的 跳过 296 //已有值的 跳过
297 if ($value) { 297 if ($value) {
298 - echo getmypid() . $field.'已有值 跳过' . PHP_EOL; 298 + echo getmypid() . ' ' . $field.'已有值 跳过' . PHP_EOL;
299 continue; 299 continue;
300 } 300 }
301 301
@@ -423,7 +423,7 @@ class UpdateSeoTdk extends Command @@ -423,7 +423,7 @@ class UpdateSeoTdk extends Command
423 if(strpos($prompt, '{topic}') !== false){ 423 if(strpos($prompt, '{topic}') !== false){
424 $topic = $data[$this->topic_fields[$table]] ?? ''; 424 $topic = $data[$this->topic_fields[$table]] ?? '';
425 if(!$topic){ 425 if(!$topic){
426 - echo getmypid() . 'topic为空 跳过' . PHP_EOL; 426 + echo getmypid() . ' ' . 'topic为空 跳过' . PHP_EOL;
427 return false; 427 return false;
428 } 428 }
429 $prompt = str_replace('{topic}', $topic, $prompt); 429 $prompt = str_replace('{topic}', $topic, $prompt);
@@ -432,7 +432,7 @@ class UpdateSeoTdk extends Command @@ -432,7 +432,7 @@ class UpdateSeoTdk extends Command
432 if(strpos($prompt, '{keyword}') !== false) { 432 if(strpos($prompt, '{keyword}') !== false) {
433 $keyword = $this->mainKeywords($project_id, 1); 433 $keyword = $this->mainKeywords($project_id, 1);
434 if(!$keyword){ 434 if(!$keyword){
435 - echo getmypid() . '核心关键词为空 跳过' . PHP_EOL; 435 + echo getmypid() . ' ' . '核心关键词为空 跳过' . PHP_EOL;
436 return false; 436 return false;
437 } 437 }
438 $prompt = str_replace('{keyword}', $keyword, $prompt); 438 $prompt = str_replace('{keyword}', $keyword, $prompt);
@@ -441,7 +441,7 @@ class UpdateSeoTdk extends Command @@ -441,7 +441,7 @@ class UpdateSeoTdk extends Command
441 if(strpos($prompt, '{company name}') !== false) { 441 if(strpos($prompt, '{company name}') !== false) {
442 $company_name = $this->companyName($project_id); 442 $company_name = $this->companyName($project_id);
443 if(!$company_name){ 443 if(!$company_name){
444 - echo getmypid() . '公司英文全称为空 跳过' . PHP_EOL; 444 + echo getmypid() . ' ' . '公司英文全称为空 跳过' . PHP_EOL;
445 return false; 445 return false;
446 } 446 }
447 $prompt = str_replace('{company name}', $company_name, $prompt); 447 $prompt = str_replace('{company name}', $company_name, $prompt);
@@ -450,7 +450,7 @@ class UpdateSeoTdk extends Command @@ -450,7 +450,7 @@ class UpdateSeoTdk extends Command
450 if(strpos($prompt, '{company detail}') !== false) { 450 if(strpos($prompt, '{company detail}') !== false) {
451 $company_detail = $this->companyName($project_id, 'company_detail'); 451 $company_detail = $this->companyName($project_id, 'company_detail');
452 if(!$company_detail){ 452 if(!$company_detail){
453 - echo getmypid() . '公司英文描述为空 跳过' . PHP_EOL; 453 + echo getmypid() . ' ' . '公司英文描述为空 跳过' . PHP_EOL;
454 return false; 454 return false;
455 } 455 }
456 $prompt = str_replace('{company detail}', $company_detail, $prompt); 456 $prompt = str_replace('{company detail}', $company_detail, $prompt);
@@ -460,7 +460,7 @@ class UpdateSeoTdk extends Command @@ -460,7 +460,7 @@ class UpdateSeoTdk extends Command
460 foreach ($matches[0] as $key=>$val) { 460 foreach ($matches[0] as $key=>$val) {
461 $keyword = $this->getPrefixKeyword($project_id, 'prefix', $matches[1][$key]); 461 $keyword = $this->getPrefixKeyword($project_id, 'prefix', $matches[1][$key]);
462 if(!$keyword){ 462 if(!$keyword){
463 - echo getmypid() . '前缀关键词为空 跳过' . PHP_EOL; 463 + echo getmypid() . ' ' . '前缀关键词为空 跳过' . PHP_EOL;
464 return false; 464 return false;
465 } 465 }
466 $prompt = str_replace($val, $keyword, $prompt); 466 $prompt = str_replace($val, $keyword, $prompt);
@@ -471,7 +471,7 @@ class UpdateSeoTdk extends Command @@ -471,7 +471,7 @@ class UpdateSeoTdk extends Command
471 foreach ($matches[0] as $key=>$val) { 471 foreach ($matches[0] as $key=>$val) {
472 $keyword = $this->getPrefixKeyword($project_id, 'suffix', $matches[1][$key]); 472 $keyword = $this->getPrefixKeyword($project_id, 'suffix', $matches[1][$key]);
473 if(!$keyword){ 473 if(!$keyword){
474 - echo getmypid() . '前缀关键词为空 跳过' . PHP_EOL; 474 + echo getmypid() . ' ' . '前缀关键词为空 跳过' . PHP_EOL;
475 return false; 475 return false;
476 } 476 }
477 $prompt = str_replace($val, $keyword, $prompt); 477 $prompt = str_replace($val, $keyword, $prompt);
@@ -482,7 +482,7 @@ class UpdateSeoTdk extends Command @@ -482,7 +482,7 @@ class UpdateSeoTdk extends Command
482 if(strpos($prompt, '{core keywords 8}') !== false) { 482 if(strpos($prompt, '{core keywords 8}') !== false) {
483 $main_keyword = $this->mainKeywords($project_id, 8); 483 $main_keyword = $this->mainKeywords($project_id, 8);
484 if(!$main_keyword){ 484 if(!$main_keyword){
485 - echo getmypid() . '核心关键词为空 跳过' . PHP_EOL; 485 + echo getmypid() . ' ' . '核心关键词为空 跳过' . PHP_EOL;
486 return false; 486 return false;
487 } 487 }
488 $prompt = str_replace('{core keywords 8}', $main_keyword, $prompt); 488 $prompt = str_replace('{core keywords 8}', $main_keyword, $prompt);
@@ -592,7 +592,7 @@ class UpdateSeoTdk extends Command @@ -592,7 +592,7 @@ class UpdateSeoTdk extends Command
592 $text = Gpt::instance()->openai_chat_qqs($prompt); 592 $text = Gpt::instance()->openai_chat_qqs($prompt);
593 593
594 if (!$text) { 594 if (!$text) {
595 - echo getmypid() . '生成失败' . PHP_EOL; 595 + echo getmypid() . ' ' . '生成失败' . PHP_EOL;
596 596
597 $cache_key = "ai_error_times_{$project_id}_{$table}_{$id}"; 597 $cache_key = "ai_error_times_{$project_id}_{$table}_{$id}";
598 if (!Cache::get($cache_key)) { 598 if (!Cache::get($cache_key)) {