|
...
|
...
|
@@ -61,17 +61,19 @@ class UpdateSeoTdk extends Command |
|
|
|
try {
|
|
|
|
ProjectServer::useProject($project_id);
|
|
|
|
$this->updateProduct($project_id);
|
|
|
|
$this->updateProductCate($project_id);
|
|
|
|
$this->updateBlogs($project_id);
|
|
|
|
$this->updateBlogCate($project_id);
|
|
|
|
$this->updateNews($project_id);
|
|
|
|
$this->updateNewsCate($project_id);
|
|
|
|
$this->updatePage($project_id);
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}catch (\Exception $e){
|
|
|
|
echo date('Y-m-d H:i:s') . ' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo date('Y-m-d H:i:s') . ' end: ' . $project_id . PHP_EOL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :更新产品tdk
|
|
|
|
* @name :updateProduct
|
|
...
|
...
|
@@ -112,6 +114,44 @@ class UpdateSeoTdk extends Command |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :更新产品tdk
|
|
|
|
* @name :updateProduct
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/19 9:25
|
|
|
|
*/
|
|
|
|
public function updateProductCate($project_id){
|
|
|
|
$list = DB::connection('custom_mysql')->table('gl_product_category')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
|
|
|
|
if(!empty($list)){
|
|
|
|
foreach ($list as $v){
|
|
|
|
$v = (array)$v;
|
|
|
|
$data = [];
|
|
|
|
if(empty($v['seo_title'])){
|
|
|
|
$setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first()->toArray();
|
|
|
|
//生成seo_title
|
|
|
|
if(!empty($setting['product_cate_prefix']) && !empty($setting['product_cate_suffix'])){
|
|
|
|
$data['seo_title'] = $setting['product_cate_prefix'] . '-' . $v['title'] . '-' . $setting['product_cate_suffix'];
|
|
|
|
}else{
|
|
|
|
$data['seo_title'] = $this->ai_send('seo_title',$v['title']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(empty($v['seo_keywords'])){
|
|
|
|
$data['seo_keywords'] = $this->ai_send('seo_keywords',$v['title']);
|
|
|
|
}
|
|
|
|
if(empty($v['seo_des'])){
|
|
|
|
$name = $this->companyName($project_id);
|
|
|
|
$data['seo_des'] = $this->ai_send('page_meta_description',$v['title'],$name);
|
|
|
|
}
|
|
|
|
if(!$data){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
DB::connection('custom_mysql')->table('gl_news')->where(['id'=>$v['id']])->update($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :更新新闻Tdk
|
|
|
|
* @name :updateNews
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -149,6 +189,44 @@ class UpdateSeoTdk extends Command |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :更新新闻Tdk
|
|
|
|
* @name :updateNews
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/19 10:06
|
|
|
|
*/
|
|
|
|
public function updateNewsCate($project_id){
|
|
|
|
$list = DB::connection('custom_mysql')->table('gl_news_category')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
|
|
|
|
if(!empty($list)){
|
|
|
|
foreach ($list as $k => $v){
|
|
|
|
$v = (array)$v;
|
|
|
|
$data = [];
|
|
|
|
if(empty($v['seo_title'])){
|
|
|
|
$setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first()->toArray();
|
|
|
|
//生成seo_title
|
|
|
|
if(!empty($setting['single_page_suffix'])){
|
|
|
|
$data['seo_title'] = $v['name'] . '-' . $setting['single_page_suffix'];
|
|
|
|
}else{
|
|
|
|
$data['seo_title'] = $this->ai_send('seo_title',$v['name']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(empty($v['seo_keywords'])){
|
|
|
|
$data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']);
|
|
|
|
}
|
|
|
|
if(empty($v['seo_des'])){
|
|
|
|
$name = $this->companyName($project_id);
|
|
|
|
$data['seo_des'] = $this->ai_send('page_meta_description',$v['title'],$name);
|
|
|
|
}
|
|
|
|
if(!$data){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
DB::connection('custom_mysql')->table('gl_news')->where(['id'=>$v['id']])->update($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :更新blogTdk
|
|
|
|
* @name :updateBlogs
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -186,6 +264,44 @@ class UpdateSeoTdk extends Command |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :更新新闻Tdk
|
|
|
|
* @name :updateNews
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/19 10:06
|
|
|
|
*/
|
|
|
|
public function updateBlogCate($project_id){
|
|
|
|
$list = DB::connection('custom_mysql')->table('gl_blog_category')->where(['status'=>1,'project_id'=>$project_id])->get()->toArray();
|
|
|
|
if(!empty($list)){
|
|
|
|
foreach ($list as $k => $v){
|
|
|
|
$v = (array)$v;
|
|
|
|
$data = [];
|
|
|
|
if(empty($v['seo_title'])){
|
|
|
|
$setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first()->toArray();
|
|
|
|
//生成seo_title
|
|
|
|
if(!empty($setting['single_page_suffix'])){
|
|
|
|
$data['seo_title'] = $v['name'] . '-' . $setting['single_page_suffix'];
|
|
|
|
}else{
|
|
|
|
$data['seo_title'] = $this->ai_send('seo_title',$v['name']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(empty($v['seo_keywords'])){
|
|
|
|
$data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']);
|
|
|
|
}
|
|
|
|
if(empty($v['seo_des'])){
|
|
|
|
$name = $this->companyName($project_id);
|
|
|
|
$data['seo_des'] = $this->ai_send('page_meta_description',$v['title'],$name);
|
|
|
|
}
|
|
|
|
if(!$data){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
DB::connection('custom_mysql')->table('gl_news')->where(['id'=>$v['id']])->update($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :单页面更新tdk
|
|
|
|
* @name :updatePage
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -208,11 +324,17 @@ class UpdateSeoTdk extends Command |
|
|
|
}
|
|
|
|
}
|
|
|
|
if(empty($v['keywords'])){
|
|
|
|
//
|
|
|
|
$data['keywords'] = $this->ai_send('seo_keywords',$v['title']);
|
|
|
|
//获取核心关键词
|
|
|
|
$main_keyword = $this->mainKeywords($project_id);
|
|
|
|
if(!empty($main_keyword)){
|
|
|
|
$data['keywords'] = $this->ai_send('seo_keywords',$main_keyword);
|
|
|
|
}else{
|
|
|
|
$data['keywords'] = $this->ai_send('seo_keywords',$v['title']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(empty($v['description'])){
|
|
|
|
$data['description'] = $this->ai_send('page_meta_description',$v['title']);
|
|
|
|
$name = $this->companyName($project_id);
|
|
|
|
$data['description'] = $this->ai_send('page_meta_description',$v['title'],$name);
|
|
|
|
}
|
|
|
|
if(!$data){
|
|
|
|
continue;
|
|
...
|
...
|
@@ -237,16 +359,20 @@ class UpdateSeoTdk extends Command |
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取公司核心关键词
|
|
|
|
* @name :companyName
|
|
|
|
* @name :mainKeywords
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/30 11:22
|
|
|
|
*/
|
|
|
|
public function mainKeywords($project_id){
|
|
|
|
$str = '';
|
|
|
|
$projectOptimizeModel = new DeployOptimize();
|
|
|
|
$info = $projectOptimizeModel->read(['project_id'=>$project_id],['id','main_keywords']);
|
|
|
|
explode(',',$info[])
|
|
|
|
return $info['company'];
|
|
|
|
if($info === false){
|
|
|
|
$arr = explode(',',$info['main_keywords']);
|
|
|
|
$str = $arr[0];
|
|
|
|
}
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -256,13 +382,13 @@ class UpdateSeoTdk extends Command |
|
|
|
* @method :post
|
|
|
|
* @time :2023/8/19 10:40
|
|
|
|
*/
|
|
|
|
public function ai_send($key,$keywords){
|
|
|
|
public function ai_send($key,$keywords,$name = ''){
|
|
|
|
$chat_url = 'v2/openai_chat_qqs';
|
|
|
|
$param = [
|
|
|
|
'key'=>$key,
|
|
|
|
'keywords'=>$keywords,
|
|
|
|
];
|
|
|
|
$data = Common::send_openai_msg($chat_url,$param);
|
|
|
|
$data = Common::send_openai_msg($chat_url,$param,$name);
|
|
|
|
return $data['text'];
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|