作者 刘锟

按需更新tdk

... ... @@ -6,6 +6,7 @@ use App\Helper\Arr;
use App\Helper\Common;
use App\Helper\Gpt;
use App\Models\Ai\AiCommand;
use App\Models\Com\UpdateNotify;
use App\Models\Domain\DomainInfo;
use App\Models\Mail\Mail;
use App\Models\Project\DeployBuild;
... ... @@ -135,6 +136,40 @@ class UpdateSeoTdk extends Command
];
/**
* '表' => 'C端页面更新的数据类型'
* @return array
* @author akun
* @date 2024/11/14
*/
protected $maps_type = [
'gl_web_custom_template' => 'page',
'gl_product' => 'product',
'gl_product_category' => 'product_category',
'gl_blog' => 'blog',
'gl_blog_category' => 'blog_category',
'gl_news' => 'news',
'gl_news_category' => 'news_category',
'gl_product_keyword' => 'product_keyword'
];
/**
* '表' => '对应数据路由字段'
* @return array
* @author akun
* @date 2024/11/14
*/
protected $maps_route = [
'gl_web_custom_template' => 'url',
'gl_product' => 'route',
'gl_product_category' => 'route',
'gl_blog' => 'url',
'gl_blog_category' => 'alias',
'gl_news' => 'url',
'gl_news_category' => 'alias',
'gl_product_keyword' => 'route'
];
/**
* @return bool
*/
public function handle()
... ... @@ -326,9 +361,15 @@ class UpdateSeoTdk extends Command
$data[$json_field] = json_encode($data[$json_field]);
}
DB::connection('custom_mysql')->table($table)->where(['id' => $v['id']])->update($data);
if($table == 'gl_product_keyword'){
$notify_keyword = true;
}else{
// if($table == 'gl_product_keyword'){
// $notify_keyword = true;
// }else{
// $notify_master = true;
// }
//tdk已更新的数据,存入按需更新表
$route = DB::connection('custom_mysql')->table($table)->where(['id' => $v['id']])->value($this->maps_route[$table]);
if($route){
UpdateNotify::addUpdateItem($project_id,$this->maps_type[$table],$route);
$notify_master = true;
}
}
... ... @@ -337,8 +378,9 @@ class UpdateSeoTdk extends Command
ProjectUpdateTdk::finish($task_id, $update);
//通知C端更新界面
$notify_master && $this->sendNotify($project_id, 1); //通知主站更新
$notify_keyword && $this->sendNotify($project_id, 4); //通知聚合页更新
// $notify_master && $this->sendNotify($project_id, 1); //通知主站更新
// $notify_keyword && $this->sendNotify($project_id, 4); //通知聚合页更新
$notify_master && $this->sendNotify($project_id, 2); //通知主站按需更新
}
public function getPrompt($project_id, $prompt, $table, $data){
... ...
... ... @@ -22,4 +22,19 @@ class UpdateNotify extends Base
const PAGE_ALL= 1;//所有
const PAGE_SINGLE = 2;//按需
public static function addUpdateItem($project_id,$type,$route){
$data = self::where(['project_id'=>$project_id,'type'=>$type,'route'=>$route])->first();
if(!$data){
$data = new self();
$data->project_id = $project_id;
$data->type = $type;
$data->route = $route;
}
$data->status = 0;
$data->minor_languages_status = 0;
$data->save();
}
}
... ...