作者 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
}
else if ($table == 'gl_product_keyword' && $field == 'seo_title') {
# TODO 聚合页seo title 特殊处理 前缀_1 . 关键词 . 后缀_2
$prefix = $this->getPrefixKeyword($project_id, 'prefix', 1);
$suffix = $this->getPrefixKeyword($project_id, 'suffix', 2);
$prefix = $this->getPrefixKeyword($project_id, 'prefix', 1, $v[$this->topic_fields[$table]]);
$suffix = $this->getPrefixKeyword($project_id, 'suffix', 2, $v[$this->topic_fields[$table]]);
if (empty($prefix) || empty($suffix))
continue;
$seo_title = $prefix . ' ' . $v[$this->topic_fields[$table]] . ' ' . $suffix;
... ... @@ -499,12 +499,31 @@ class UpdateSeoTdk extends Command
* @param $num
* @return string
*/
public function getPrefixKeyword($project_id, $type, $num)
public function getPrefixKeyword($project_id, $type, $num, $topic='')
{
$str = '';
$info = $this->getDeployOptimize($project_id);
if (!empty($info['keyword_' . $type])) {
$fix_keyword = explode(",", $info['keyword_' . $type]);
//去掉标题存在的词
if ($topic) {
foreach ($fix_keyword as $k=>$keyword) {
//处理单词复数 s es ies ves
$keyword = rtrim($keyword, 'ves');
$keyword = rtrim($keyword, 'ies');
$keyword = rtrim($keyword, 'es');
$keyword = rtrim($keyword, 's');
$topic_words = explode(" ", $topic);
if($type == 'prefix' && Str::startsWith($topic_words[0], $keyword)){
unset($fix_keyword[$k]);
}
if($type == 'suffix' && Str::startsWith($topic_words[count($topic_words)-1], $keyword)){
unset($fix_keyword[$k]);
}
}
}
//随机取
shuffle($fix_keyword);
if (count($fix_keyword) < $num)
... ...
... ... @@ -65,19 +65,19 @@ class Gpt
$time = time();
try {
// $result = Http::withHeaders($this->header)->withOptions(['verify' => false])->acceptJson()
// ->withBody(json_encode($data, JSON_UNESCAPED_UNICODE), 'application/json')
// ->post($url);
// $json = $result->json();
$result = Http::withHeaders($this->header)->withOptions(['verify' => false])->acceptJson()
->withBody(json_encode($data, JSON_UNESCAPED_UNICODE), 'application/json')
->post($url);
$json = $result->json();
$client = new \GuzzleHttp\Client();
$result = $client->request('POST', $url, [
'proxy' => 'http://104.255.171.237:51395', // 代理服务器地址和端口号
'headers' => $this->header,
'json' => $data,
'verify' => false,
])->getBody()->getContents();
$json = json_decode($result, true);
// $client = new \GuzzleHttp\Client();
// $result = $client->request('POST', $url, [
// 'proxy' => 'http://104.255.171.237:51395', // 代理服务器地址和端口号
// 'headers' => $this->header,
// 'json' => $data,
// 'verify' => false,
// ])->getBody()->getContents();
// $json = json_decode($result, true);
if (!isset($json['text']) || $json['code'] !==200) {
Log::error('openai_chat_qqs data:', $data);
... ...