|
...
|
...
|
@@ -3,6 +3,10 @@ |
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
|
|
use App\Helper\Common;
|
|
|
|
use App\Helper\Translate;
|
|
|
|
use App\Models\Ai\AiCommand as AiCommandModel;
|
|
|
|
use App\Models\Project\DeployOptimize;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Services\ProjectServer;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
...
|
...
|
@@ -83,20 +87,26 @@ class UpdateSeoTdk extends Command |
|
|
|
$seo_arr = json_decode($v['seo_mate'], true) ?: [];
|
|
|
|
//更新seo_title
|
|
|
|
if(!isset($seo_arr['title'])){
|
|
|
|
$setting = DB::connection('custom_mysql')->table('gl_web_setting_seo')->where(['project_id'=>$project_id])->first()->toArray();
|
|
|
|
//生成seo_title
|
|
|
|
$seo_arr['title'] = $this->ai_send('product_seo_title',$v['title']);
|
|
|
|
if(!empty($setting['product_prefix']) && !empty($setting['product_suffix'])){
|
|
|
|
$seo_arr['title'] = $setting['product_prefix'] . '-' . $seo_arr['title'] . '-' . $setting['product_suffix'];
|
|
|
|
}else{
|
|
|
|
$seo_arr['title'] = $this->ai_send('seo_title',$seo_arr['title']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//更新seo_keyword
|
|
|
|
if(!isset($seo_arr['keyword'])){
|
|
|
|
$seo_arr['keyword'] = $this->ai_send('product_seo_keyword',$v['title']);
|
|
|
|
$seo_arr['keyword'] = $this->ai_send('seo_keywords',$v['title']);
|
|
|
|
}
|
|
|
|
//更新seo_keyword
|
|
|
|
if(!isset($seo_arr['description'])){
|
|
|
|
$seo_arr['description'] = $this->ai_send('product_seo_description',$v['title']);
|
|
|
|
$seo_arr['description'] = $this->ai_send('seo_meta_description',$v['title']);
|
|
|
|
}
|
|
|
|
$ser_str = json_encode($seo_arr,true);
|
|
|
|
DB::connection('custom_mysql')->table('gl_product')->where(['id'=>$v['id']])->update(['seo_mate'=>$ser_str]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
...
|
...
|
@@ -115,13 +125,19 @@ class UpdateSeoTdk extends Command |
|
|
|
$v = (array)$v;
|
|
|
|
$data = [];
|
|
|
|
if(empty($v['seo_title'])){
|
|
|
|
$data['seo_title'] = $this->ai_send('news_seo_title',$v['name']);
|
|
|
|
$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('news_seo_keyword',$v['name']);
|
|
|
|
$data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']);
|
|
|
|
}
|
|
|
|
if(empty($v['seo_description'])){
|
|
|
|
$data['seo_description'] = $this->ai_send('news_seo_description',$v['name']);
|
|
|
|
$data['seo_description'] = $this->ai_send('seo_meta_description',$v['name']);
|
|
|
|
}
|
|
|
|
if(!$data){
|
|
|
|
continue;
|
|
...
|
...
|
@@ -146,13 +162,19 @@ class UpdateSeoTdk extends Command |
|
|
|
$v = (array)$v;
|
|
|
|
$data = [];
|
|
|
|
if(empty($v['seo_title'])){
|
|
|
|
$data['seo_title'] = $this->ai_send('blog_seo_title',$v['name']);
|
|
|
|
$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('blog_seo_keyword',$v['name']);
|
|
|
|
$data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']);
|
|
|
|
}
|
|
|
|
if(empty($v['seo_description'])){
|
|
|
|
$data['seo_description'] = $this->ai_send('blog_seo_description',$v['name']);
|
|
|
|
$data['seo_description'] = $this->ai_send('seo_meta_description',$v['name']);
|
|
|
|
}
|
|
|
|
if(!$data){
|
|
|
|
continue;
|
|
...
|
...
|
@@ -164,6 +186,70 @@ class UpdateSeoTdk extends Command |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :单页面更新tdk
|
|
|
|
* @name :updatePage
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/30 11:04
|
|
|
|
*/
|
|
|
|
public function updatePage($project_id){
|
|
|
|
$list = DB::connection('custom_mysql')->select(['title','keywords','description','project_id'])->table('gl_web_custom_template')->where(['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['single_page_suffix'])){
|
|
|
|
$data['title'] = $v['title'] . '-' . $setting['single_page_suffix'];
|
|
|
|
}else{
|
|
|
|
$data['title'] = $this->ai_send('seo_title',$v['title']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(empty($v['keywords'])){
|
|
|
|
//
|
|
|
|
$data['keywords'] = $this->ai_send('seo_keywords',$v['title']);
|
|
|
|
}
|
|
|
|
if(empty($v['description'])){
|
|
|
|
$data['description'] = $this->ai_send('page_meta_description',$v['title']);
|
|
|
|
}
|
|
|
|
if(!$data){
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
DB::connection('custom_mysql')->table('gl_blog')->where(['id'=>$v['id']])->update($data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取公司名称
|
|
|
|
* @name :companyName
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/30 11:22
|
|
|
|
*/
|
|
|
|
public function companyName($project_id){
|
|
|
|
$projectModel = new Project();
|
|
|
|
$info = $projectModel->read(['project_id'=>$project_id],['id','company']);
|
|
|
|
return $info['company'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取公司核心关键词
|
|
|
|
* @name :companyName
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/30 11:22
|
|
|
|
*/
|
|
|
|
public function mainKeywords($project_id){
|
|
|
|
$projectOptimizeModel = new DeployOptimize();
|
|
|
|
$info = $projectOptimizeModel->read(['project_id'=>$project_id],['id','main_keywords']);
|
|
|
|
explode(',',$info[])
|
|
|
|
return $info['company'];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :AI发送
|
|
|
|
* @name :ai_send
|
|
|
|
* @author :lyh
|
|
...
|
...
|
@@ -171,7 +257,7 @@ class UpdateSeoTdk extends Command |
|
|
|
* @time :2023/8/19 10:40
|
|
|
|
*/
|
|
|
|
public function ai_send($key,$keywords){
|
|
|
|
$chat_url = 'v2/openai_chat';
|
|
|
|
$chat_url = 'v2/openai_chat_qqs';
|
|
|
|
$param = [
|
|
|
|
'key'=>$key,
|
|
|
|
'keywords'=>$keywords,
|
|
...
|
...
|
@@ -179,4 +265,5 @@ class UpdateSeoTdk extends Command |
|
|
|
$data = Common::send_openai_msg($chat_url,$param);
|
|
|
|
return $data['text'];
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
...
|
...
|
|