作者 赵彬吉

update

... ... @@ -199,17 +199,17 @@ class UpdateSeoTdk extends Command
}
$project_id = $task->project_id;
echo getmypid() . date('Y-m-d H:i:s') . ' start project_id: ' . $project_id . PHP_EOL;
echo getmypid() . ' ' . date('Y-m-d H:i:s') . ' start project_id: ' . $project_id . PHP_EOL;
try {
$this->project = ProjectServer::useProject($project_id);
$this->seo_tdk($project_id, $task->id);
DB::disconnect('custom_mysql');
}catch (\Exception $e){
echo getmypid() . date('Y-m-d H:i:s') . 'line: '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
echo getmypid() . ' ' . date('Y-m-d H:i:s') . 'line: '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
ProjectUpdateTdk::retry($task->id, $e->getMessage());
}
Cache::forget('project_deploy_optimize_info_' . $project_id);
echo getmypid() . date('Y-m-d H:i:s') . ' end project_id: ' . $project_id . PHP_EOL;
echo getmypid() . ' ' . date('Y-m-d H:i:s') . ' end project_id: ' . $project_id . PHP_EOL;
}
}
public function sendNotify($project_id, $route)
... ... @@ -234,7 +234,7 @@ class UpdateSeoTdk extends Command
'language'=> [],
];
http_post($url, json_encode($param));
echo getmypid() . '更新中请稍后, 更新完成将会发送站内信通知更新结果!'. PHP_EOL;
echo getmypid() . ' ' . '更新中请稍后, 更新完成将会发送站内信通知更新结果!'. PHP_EOL;
}
public function seo_tdk($project_id, $task_id)
{
... ... @@ -246,7 +246,7 @@ class UpdateSeoTdk extends Command
foreach ($this->maps as $table => $map) {
$total_page = DB::connection('custom_mysql')->table($table)->count();
$update[$table] = ['total_page'=>$total_page, 'title'=>0, 'keyword'=>0, 'des'=>0,'keyword_title'=>0,'keyword_content'=>0];
echo getmypid() . date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL;
echo getmypid() . ' ' . date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL;
$list = DB::connection('custom_mysql')->table($table)
->where(function ($query) use ($table, $map){
if($table == 'gl_product'){
... ... @@ -280,7 +280,7 @@ class UpdateSeoTdk extends Command
}
echo getmypid() . date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL;
echo getmypid() . ' ' . date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . ':id' . $v['id'] . PHP_EOL;
$v = DB::connection('custom_mysql')->table($table)->where('id', $v['id'])->first();
$v = (array)$v;
$data = [];
... ... @@ -295,7 +295,7 @@ class UpdateSeoTdk extends Command
}
//已有值的 跳过
if ($value) {
echo getmypid() . $field.'已有值 跳过' . PHP_EOL;
echo getmypid() . ' ' . $field.'已有值 跳过' . PHP_EOL;
continue;
}
... ... @@ -423,7 +423,7 @@ class UpdateSeoTdk extends Command
if(strpos($prompt, '{topic}') !== false){
$topic = $data[$this->topic_fields[$table]] ?? '';
if(!$topic){
echo getmypid() . 'topic为空 跳过' . PHP_EOL;
echo getmypid() . ' ' . 'topic为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace('{topic}', $topic, $prompt);
... ... @@ -432,7 +432,7 @@ class UpdateSeoTdk extends Command
if(strpos($prompt, '{keyword}') !== false) {
$keyword = $this->mainKeywords($project_id, 1);
if(!$keyword){
echo getmypid() . '核心关键词为空 跳过' . PHP_EOL;
echo getmypid() . ' ' . '核心关键词为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace('{keyword}', $keyword, $prompt);
... ... @@ -441,7 +441,7 @@ class UpdateSeoTdk extends Command
if(strpos($prompt, '{company name}') !== false) {
$company_name = $this->companyName($project_id);
if(!$company_name){
echo getmypid() . '公司英文全称为空 跳过' . PHP_EOL;
echo getmypid() . ' ' . '公司英文全称为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace('{company name}', $company_name, $prompt);
... ... @@ -450,7 +450,7 @@ class UpdateSeoTdk extends Command
if(strpos($prompt, '{company detail}') !== false) {
$company_detail = $this->companyName($project_id, 'company_detail');
if(!$company_detail){
echo getmypid() . '公司英文描述为空 跳过' . PHP_EOL;
echo getmypid() . ' ' . '公司英文描述为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace('{company detail}', $company_detail, $prompt);
... ... @@ -460,7 +460,7 @@ class UpdateSeoTdk extends Command
foreach ($matches[0] as $key=>$val) {
$keyword = $this->getPrefixKeyword($project_id, 'prefix', $matches[1][$key]);
if(!$keyword){
echo getmypid() . '前缀关键词为空 跳过' . PHP_EOL;
echo getmypid() . ' ' . '前缀关键词为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace($val, $keyword, $prompt);
... ... @@ -471,7 +471,7 @@ class UpdateSeoTdk extends Command
foreach ($matches[0] as $key=>$val) {
$keyword = $this->getPrefixKeyword($project_id, 'suffix', $matches[1][$key]);
if(!$keyword){
echo getmypid() . '前缀关键词为空 跳过' . PHP_EOL;
echo getmypid() . ' ' . '前缀关键词为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace($val, $keyword, $prompt);
... ... @@ -482,7 +482,7 @@ class UpdateSeoTdk extends Command
if(strpos($prompt, '{core keywords 8}') !== false) {
$main_keyword = $this->mainKeywords($project_id, 8);
if(!$main_keyword){
echo getmypid() . '核心关键词为空 跳过' . PHP_EOL;
echo getmypid() . ' ' . '核心关键词为空 跳过' . PHP_EOL;
return false;
}
$prompt = str_replace('{core keywords 8}', $main_keyword, $prompt);
... ... @@ -592,7 +592,7 @@ class UpdateSeoTdk extends Command
$text = Gpt::instance()->openai_chat_qqs($prompt);
if (!$text) {
echo getmypid() . '生成失败' . PHP_EOL;
echo getmypid() . ' ' . '生成失败' . PHP_EOL;
$cache_key = "ai_error_times_{$project_id}_{$table}_{$id}";
if (!Cache::get($cache_key)) {
... ...