正在显示
1 个修改的文件
包含
59 行增加
和
17 行删除
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Console\Commands; | 3 | namespace App\Console\Commands; |
| 4 | 4 | ||
| 5 | use App\Helper\Common; | 5 | use App\Helper\Common; |
| 6 | +use App\Models\Ai\AiCommand; | ||
| 6 | use App\Models\Project\DeployOptimize; | 7 | use App\Models\Project\DeployOptimize; |
| 7 | use App\Services\ProjectServer; | 8 | use App\Services\ProjectServer; |
| 8 | use Illuminate\Console\Command; | 9 | use Illuminate\Console\Command; |
| @@ -86,7 +87,14 @@ class UpdateSeoTdk extends Command | @@ -86,7 +87,14 @@ class UpdateSeoTdk extends Command | ||
| 86 | $seo_arr = json_decode($v['seo_mate'], true) ?: []; | 87 | $seo_arr = json_decode($v['seo_mate'], true) ?: []; |
| 87 | //更新seo_title | 88 | //更新seo_title |
| 88 | if(!isset($seo_arr['title']) || empty($seo_arr['title'])){ | 89 | if(!isset($seo_arr['title']) || empty($seo_arr['title'])){ |
| 89 | - $seo_arr['title'] = $seo_arr['title']; | 90 | + //查看是否有指令 |
| 91 | + $aiCommandModel = new AiCommand(); | ||
| 92 | + $AiInfo = $aiCommandModel->read(['key'=>'product_seo_title'],['ai']); | ||
| 93 | + if(!empty($AiInfo['ai'])){ | ||
| 94 | + $seo_arr['title'] = $this->ai_send('product_seo_title',$v['title']); | ||
| 95 | + }else { | ||
| 96 | + $seo_arr['title'] = $v['title']; | ||
| 97 | + } | ||
| 90 | } | 98 | } |
| 91 | //更新seo_keyword | 99 | //更新seo_keyword |
| 92 | if(!isset($seo_arr['keyword']) || empty($seo_arr['keyword'])){ | 100 | if(!isset($seo_arr['keyword']) || empty($seo_arr['keyword'])){ |
| @@ -118,14 +126,22 @@ class UpdateSeoTdk extends Command | @@ -118,14 +126,22 @@ class UpdateSeoTdk extends Command | ||
| 118 | $v = (array)$v; | 126 | $v = (array)$v; |
| 119 | $data = []; | 127 | $data = []; |
| 120 | if(empty($v['seo_title'])){ | 128 | if(empty($v['seo_title'])){ |
| 129 | + $aiCommandModel = new AiCommand(); | ||
| 130 | + $AiInfo = $aiCommandModel->read(['key'=>'product_cate_seo_title'],['ai']); | ||
| 131 | + if(!empty($AiInfo['ai'])){ | ||
| 132 | + $data['seo_title'] = $this->ai_send('product_cate_seo_title',$v['title']); | ||
| 133 | + }else{ | ||
| 121 | $data['seo_title'] = $v['title']; | 134 | $data['seo_title'] = $v['title']; |
| 135 | + } | ||
| 122 | } | 136 | } |
| 123 | if(empty($v['seo_keywords'])){ | 137 | if(empty($v['seo_keywords'])){ |
| 124 | $data['seo_keywords'] = $this->ai_send('seo_keywords',$v['title']); | 138 | $data['seo_keywords'] = $this->ai_send('seo_keywords',$v['title']); |
| 125 | } | 139 | } |
| 126 | if(empty($v['seo_des'])){ | 140 | if(empty($v['seo_des'])){ |
| 127 | $name = $this->companyName($project_id); | 141 | $name = $this->companyName($project_id); |
| 128 | - $data['seo_des'] = $this->ai_send('page_meta_description',$v['title'],$name); | 142 | + if(!empty($name)){ |
| 143 | + $data['seo_des'] = $this->ai_send('page_meta_description',$v['title'],$name); | ||
| 144 | + } | ||
| 129 | } | 145 | } |
| 130 | if(!$data){ | 146 | if(!$data){ |
| 131 | continue; | 147 | continue; |
| @@ -150,8 +166,13 @@ class UpdateSeoTdk extends Command | @@ -150,8 +166,13 @@ class UpdateSeoTdk extends Command | ||
| 150 | $v = (array)$v; | 166 | $v = (array)$v; |
| 151 | $data = []; | 167 | $data = []; |
| 152 | if(empty($v['seo_title'])){ | 168 | if(empty($v['seo_title'])){ |
| 153 | - //生成seo_title | ||
| 154 | - $data['seo_title'] = $v['name']; | 169 | + $aiCommandModel = new AiCommand(); |
| 170 | + $AiInfo = $aiCommandModel->read(['key'=>'news_seo_title'],['ai']); | ||
| 171 | + if(!empty($AiInfo['ai'])){ | ||
| 172 | + $data['seo_title'] = $this->ai_send('news_seo_title',$v['name']); | ||
| 173 | + }else{ | ||
| 174 | + $data['seo_title'] = $v['name']; | ||
| 175 | + } | ||
| 155 | } | 176 | } |
| 156 | if(empty($v['seo_keywords'])){ | 177 | if(empty($v['seo_keywords'])){ |
| 157 | $data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']); | 178 | $data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']); |
| @@ -182,14 +203,26 @@ class UpdateSeoTdk extends Command | @@ -182,14 +203,26 @@ class UpdateSeoTdk extends Command | ||
| 182 | $v = (array)$v; | 203 | $v = (array)$v; |
| 183 | $data = []; | 204 | $data = []; |
| 184 | if(empty($v['seo_title'])){ | 205 | if(empty($v['seo_title'])){ |
| 185 | - $data['seo_title'] = $v['name']; | 206 | + $aiCommandModel = new AiCommand(); |
| 207 | + $AiInfo = $aiCommandModel->read(['key'=>'news_cate_seo_title'],['ai']); | ||
| 208 | + if(!empty($AiInfo['ai'])){ | ||
| 209 | + $data['seo_title'] = $this->ai_send('news_cate_seo_title',$v['name']); | ||
| 210 | + }else{ | ||
| 211 | + $data['seo_title'] = $v['name']; | ||
| 212 | + } | ||
| 186 | } | 213 | } |
| 187 | if(empty($v['seo_keywords'])){ | 214 | if(empty($v['seo_keywords'])){ |
| 188 | - $data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']); | 215 | + //获取核心关键词 |
| 216 | + $main_keyword = $this->mainKeywords($project_id); | ||
| 217 | + if(!empty($main_keyword)){ | ||
| 218 | + $data['seo_keywords'] = $this->ai_send('seo_keywords',$main_keyword); | ||
| 219 | + } | ||
| 189 | } | 220 | } |
| 190 | if(empty($v['seo_des'])){ | 221 | if(empty($v['seo_des'])){ |
| 191 | $name = $this->companyName($project_id); | 222 | $name = $this->companyName($project_id); |
| 192 | - $data['seo_des'] = $this->ai_send('page_meta_description',$v['title'],$name); | 223 | + if(!empty($name)){ |
| 224 | + $data['seo_des'] = $this->ai_send('page_meta_description',$v['title'],$name); | ||
| 225 | + } | ||
| 193 | } | 226 | } |
| 194 | if(!$data){ | 227 | if(!$data){ |
| 195 | continue; | 228 | continue; |
| @@ -214,8 +247,13 @@ class UpdateSeoTdk extends Command | @@ -214,8 +247,13 @@ class UpdateSeoTdk extends Command | ||
| 214 | $v = (array)$v; | 247 | $v = (array)$v; |
| 215 | $data = []; | 248 | $data = []; |
| 216 | if(empty($v['seo_title'])){ | 249 | if(empty($v['seo_title'])){ |
| 217 | - //生成seo_title | ||
| 218 | - $data['seo_title'] = $v['name']; | 250 | + $aiCommandModel = new AiCommand(); |
| 251 | + $AiInfo = $aiCommandModel->read(['key'=>'blog_seo_title'],['ai']); | ||
| 252 | + if(!empty($AiInfo['ai'])){ | ||
| 253 | + $data['seo_title'] = $this->ai_send('blog_seo_title',$v['name']); | ||
| 254 | + }else{ | ||
| 255 | + $data['seo_title'] = $v['name']; | ||
| 256 | + } | ||
| 219 | } | 257 | } |
| 220 | if(empty($v['seo_keywords'])){ | 258 | if(empty($v['seo_keywords'])){ |
| 221 | $data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']); | 259 | $data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']); |
| @@ -249,7 +287,11 @@ class UpdateSeoTdk extends Command | @@ -249,7 +287,11 @@ class UpdateSeoTdk extends Command | ||
| 249 | $data['seo_title'] = $v['name']; | 287 | $data['seo_title'] = $v['name']; |
| 250 | } | 288 | } |
| 251 | if(empty($v['seo_keywords'])){ | 289 | if(empty($v['seo_keywords'])){ |
| 252 | - $data['seo_keywords'] = $this->ai_send('seo_keywords',$v['name']); | 290 | + //获取核心关键词 |
| 291 | + $main_keyword = $this->mainKeywords($project_id); | ||
| 292 | + if(!empty($main_keyword)){ | ||
| 293 | + $data['seo_keywords'] = $this->ai_send('seo_keywords',$main_keyword); | ||
| 294 | + } | ||
| 253 | } | 295 | } |
| 254 | if(empty($v['seo_des'])){ | 296 | if(empty($v['seo_des'])){ |
| 255 | $name = $this->companyName($project_id); | 297 | $name = $this->companyName($project_id); |
| @@ -309,9 +351,7 @@ class UpdateSeoTdk extends Command | @@ -309,9 +351,7 @@ class UpdateSeoTdk extends Command | ||
| 309 | */ | 351 | */ |
| 310 | public function companyName($key,$project_id){ | 352 | public function companyName($key,$project_id){ |
| 311 | $data = [ | 353 | $data = [ |
| 312 | - 'news_remark', | ||
| 313 | - 'blog_remark', | ||
| 314 | - 'product_long_description' | 354 | + 'product_long_description', |
| 315 | ]; | 355 | ]; |
| 316 | $projectOptimizeModel = new DeployOptimize(); | 356 | $projectOptimizeModel = new DeployOptimize(); |
| 317 | $info = $projectOptimizeModel->read(['project_id'=>$project_id],['id','company_en_name','company_en_description']); | 357 | $info = $projectOptimizeModel->read(['project_id'=>$project_id],['id','company_en_name','company_en_description']); |
| @@ -333,10 +373,12 @@ class UpdateSeoTdk extends Command | @@ -333,10 +373,12 @@ class UpdateSeoTdk extends Command | ||
| 333 | $str = ''; | 373 | $str = ''; |
| 334 | $projectOptimizeModel = new DeployOptimize(); | 374 | $projectOptimizeModel = new DeployOptimize(); |
| 335 | $info = $projectOptimizeModel->read(['project_id'=>$project_id],['id','main_keywords']); | 375 | $info = $projectOptimizeModel->read(['project_id'=>$project_id],['id','main_keywords']); |
| 336 | - if($info === false){ | ||
| 337 | - $arr = explode(',',$info['main_keywords']); | ||
| 338 | - if(isset($arr[0])){ | ||
| 339 | - $str = $arr[0]; | 376 | + if($info !== false){ |
| 377 | + if(!empty($info['main_keywords'])){ | ||
| 378 | + $arr = explode(',',$info['main_keywords']); | ||
| 379 | + if(isset($arr[0])){ | ||
| 380 | + $str = $arr[0]; | ||
| 381 | + } | ||
| 340 | } | 382 | } |
| 341 | } | 383 | } |
| 342 | return $str; | 384 | return $str; |
-
请 注册 或 登录 后发表评论