作者 lyh

Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into master-server

@@ -335,8 +335,8 @@ class UpdateSeoTdk extends Command @@ -335,8 +335,8 @@ class UpdateSeoTdk extends Command
335 } 335 }
336 else if ($table == 'gl_product_keyword' && $field == 'seo_title') { 336 else if ($table == 'gl_product_keyword' && $field == 'seo_title') {
337 # TODO 聚合页seo title 特殊处理 前缀_1 . 关键词 . 后缀_2 337 # TODO 聚合页seo title 特殊处理 前缀_1 . 关键词 . 后缀_2
338 - $prefix = $this->getPrefixKeyword($project_id, 'prefix', 1);  
339 - $suffix = $this->getPrefixKeyword($project_id, 'suffix', 2); 338 + $prefix = $this->getPrefixKeyword($project_id, 'prefix', 1, $v[$this->topic_fields[$table]]);
  339 + $suffix = $this->getPrefixKeyword($project_id, 'suffix', 2, $v[$this->topic_fields[$table]]);
340 if (empty($prefix) || empty($suffix)) 340 if (empty($prefix) || empty($suffix))
341 continue; 341 continue;
342 $seo_title = $prefix . ' ' . $v[$this->topic_fields[$table]] . ' ' . $suffix; 342 $seo_title = $prefix . ' ' . $v[$this->topic_fields[$table]] . ' ' . $suffix;
@@ -499,12 +499,31 @@ class UpdateSeoTdk extends Command @@ -499,12 +499,31 @@ class UpdateSeoTdk extends Command
499 * @param $num 499 * @param $num
500 * @return string 500 * @return string
501 */ 501 */
502 - public function getPrefixKeyword($project_id, $type, $num) 502 + public function getPrefixKeyword($project_id, $type, $num, $topic='')
503 { 503 {
504 $str = ''; 504 $str = '';
505 $info = $this->getDeployOptimize($project_id); 505 $info = $this->getDeployOptimize($project_id);
506 if (!empty($info['keyword_' . $type])) { 506 if (!empty($info['keyword_' . $type])) {
507 $fix_keyword = explode(",", $info['keyword_' . $type]); 507 $fix_keyword = explode(",", $info['keyword_' . $type]);
  508 +
  509 + //去掉标题存在的词
  510 + if ($topic) {
  511 + foreach ($fix_keyword as $k=>$keyword) {
  512 + //处理单词复数 s es ies ves
  513 + $keyword = rtrim($keyword, 'ves');
  514 + $keyword = rtrim($keyword, 'ies');
  515 + $keyword = rtrim($keyword, 'es');
  516 + $keyword = rtrim($keyword, 's');
  517 +
  518 + $topic_words = explode(" ", $topic);
  519 + if($type == 'prefix' && Str::startsWith($topic_words[0], $keyword)){
  520 + unset($fix_keyword[$k]);
  521 + }
  522 + if($type == 'suffix' && Str::startsWith($topic_words[count($topic_words)-1], $keyword)){
  523 + unset($fix_keyword[$k]);
  524 + }
  525 + }
  526 + }
508 //随机取 527 //随机取
509 shuffle($fix_keyword); 528 shuffle($fix_keyword);
510 if (count($fix_keyword) < $num) 529 if (count($fix_keyword) < $num)
@@ -65,19 +65,19 @@ class Gpt @@ -65,19 +65,19 @@ class Gpt
65 65
66 $time = time(); 66 $time = time();
67 try { 67 try {
68 -// $result = Http::withHeaders($this->header)->withOptions(['verify' => false])->acceptJson()  
69 -// ->withBody(json_encode($data, JSON_UNESCAPED_UNICODE), 'application/json')  
70 -// ->post($url);  
71 -// $json = $result->json(); 68 + $result = Http::withHeaders($this->header)->withOptions(['verify' => false])->acceptJson()
  69 + ->withBody(json_encode($data, JSON_UNESCAPED_UNICODE), 'application/json')
  70 + ->post($url);
  71 + $json = $result->json();
72 72
73 - $client = new \GuzzleHttp\Client();  
74 - $result = $client->request('POST', $url, [  
75 - 'proxy' => 'http://104.255.171.237:51395', // 代理服务器地址和端口号  
76 - 'headers' => $this->header,  
77 - 'json' => $data,  
78 - 'verify' => false,  
79 - ])->getBody()->getContents();  
80 - $json = json_decode($result, true); 73 +// $client = new \GuzzleHttp\Client();
  74 +// $result = $client->request('POST', $url, [
  75 +// 'proxy' => 'http://104.255.171.237:51395', // 代理服务器地址和端口号
  76 +// 'headers' => $this->header,
  77 +// 'json' => $data,
  78 +// 'verify' => false,
  79 +// ])->getBody()->getContents();
  80 +// $json = json_decode($result, true);
81 81
82 if (!isset($json['text']) || $json['code'] !==200) { 82 if (!isset($json['text']) || $json['code'] !==200) {
83 Log::error('openai_chat_qqs data:', $data); 83 Log::error('openai_chat_qqs data:', $data);