|
...
|
...
|
@@ -372,10 +372,10 @@ class UpdateSeoTdk extends Command |
|
|
|
} else if ($table == 'gl_product_keyword' && $field == 'seo_title') {
|
|
|
|
# TODO 聚合页seo title 特殊处理 前缀_1 . 关键词 . 后缀_2
|
|
|
|
$seo_title = $v[$this->topic_fields[$table]];;
|
|
|
|
//只有推广项目 且未标记特殊前后缀 才加 前后缀
|
|
|
|
if($project->type == Project::TYPE_TWO && !in_array(8, explode(',', $project->deploy_optimize->special))) {
|
|
|
|
//只有推广项目 才加 前后缀
|
|
|
|
if($project->type == Project::TYPE_TWO) {
|
|
|
|
$prefix = $this->getPrefixKeyword($project_id, 'prefix', 1, $seo_title);
|
|
|
|
$suffix = $this->getPrefixKeyword($project_id, 'suffix', 2, $prefix . ' ' . $seo_title);
|
|
|
|
$suffix = $this->getPrefixKeyword($project_id, 'suffix', 2, trim($prefix . ' ' . $seo_title));
|
|
|
|
if(Str::startsWith($suffix, ', ')){
|
|
|
|
$seo_title = $prefix . ' ' . $seo_title . $suffix;
|
|
|
|
}else{
|
|
...
|
...
|
@@ -567,18 +567,31 @@ class UpdateSeoTdk extends Command |
|
|
|
}
|
|
|
|
|
|
|
|
//前后缀(包括自定义前后缀)如果已经存在,就不在拼接当前类型 后缀只包含了一个,要再拼一个(需去重)
|
|
|
|
$all_prefixes = $this->getAllPrefix($type == 'prefix' ? 1 : 2, $project_id);
|
|
|
|
$all_prefixes = $this->getAllPrefix(1, $project_id);
|
|
|
|
$all_prefixes = array_map('strtolower', $all_prefixes);
|
|
|
|
|
|
|
|
$all_suffixes = $this->getAllPrefix(2, $project_id);
|
|
|
|
$all_suffixes = array_map('strtolower', $all_suffixes);
|
|
|
|
|
|
|
|
//in,for,with,to,near,from 这些介词 只拼前缀,不拼后缀
|
|
|
|
$preposition = ['in', 'for', 'with', 'to', 'near','from'];
|
|
|
|
|
|
|
|
//标题拆成词
|
|
|
|
$topic_words = explode(' ', strtolower($topic));
|
|
|
|
|
|
|
|
//关键词最后一个词是前缀的词,前后缀都不拼
|
|
|
|
if(in_array(Arr::last($topic_words), $all_prefixes)){
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
|
|
|
|
$i= 0;
|
|
|
|
foreach ($topic_words as $topic_word){
|
|
|
|
//包含了前后缀
|
|
|
|
if(in_array($topic_word, $all_prefixes)){
|
|
|
|
//关键词本身包含了前缀就不拼前缀,只拼后缀
|
|
|
|
if(in_array($topic_word, $all_prefixes) && $type == 'prefix'){
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
//关键词本身包含了后缀,可拼前缀,也可以再拼一个不重复的后缀,包含两个后缀就不拼后缀了
|
|
|
|
if(in_array($topic_word, $all_suffixes) && $type == 'suffix'){
|
|
|
|
//前缀包含一个就不拼了 后缀包含两个才不再拼
|
|
|
|
if($i == $num - 1){
|
|
|
|
return $str;
|
|
...
|
...
|
@@ -591,7 +604,6 @@ class UpdateSeoTdk extends Command |
|
|
|
if(in_array($topic_word, $preposition) && $type == 'suffix'){
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//services/service 结尾的词,后缀不拼manufacturer,factory
|
|
...
|
...
|
@@ -603,13 +615,13 @@ class UpdateSeoTdk extends Command |
|
|
|
$ban = array_merge($ban, ['services', 'service']);
|
|
|
|
}
|
|
|
|
|
|
|
|
//前缀有wholesale或cheap的词,后缀不拼 manufacturer,factory,exporter,company
|
|
|
|
if (Str::startsWith(strtolower($topic), ['wholesale', 'cheap']) && $type == 'suffix') {
|
|
|
|
//有wholesale或cheap的词,后缀不拼 manufacturer,factory,exporter,company
|
|
|
|
if (Str::contains(strtolower($topic), ['wholesale', 'cheap', 'buy']) && $type == 'suffix') {
|
|
|
|
$ban = array_merge($ban, ['manufacturer', 'manufacturers', 'factory', 'factories', 'exporter', 'exporters', 'company', 'companies', 'supplier', 'suppliers']);
|
|
|
|
}
|
|
|
|
//关键词以manufacturer,factory,exporter,company结尾, 前缀不拼wholesale或cheap的词
|
|
|
|
if (Str::endsWith(strtolower($topic), ['manufacturer', 'manufacturers', 'factory', 'factories', 'exporter', 'exporters', 'company', 'companies', 'supplier', 'suppliers']) && $type == 'prefix') {
|
|
|
|
$ban = array_merge($ban, ['wholesale', 'cheap']);
|
|
|
|
$ban = array_merge($ban, ['wholesale', 'cheap', 'buy']);
|
|
|
|
}
|
|
|
|
|
|
|
|
//关键词是否包含 品牌词
|
|
...
|
...
|
@@ -660,7 +672,7 @@ class UpdateSeoTdk extends Command |
|
|
|
$keywords[] = $v;
|
|
|
|
$num--;
|
|
|
|
}
|
|
|
|
if ($type == 'suffix' && count($keywords) == 1 && in_array(Arr::last($topic_words), $all_prefixes)) {
|
|
|
|
if ($type == 'suffix' && count($keywords) == 1 && in_array(Arr::last($topic_words), $all_suffixes)) {
|
|
|
|
return ', ' . $keywords[0];
|
|
|
|
}
|
|
|
|
return implode(', ', $keywords);
|
|
...
|
...
|
@@ -774,9 +786,12 @@ class UpdateSeoTdk extends Command |
|
|
|
Cache::forget($cache_key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$a = $text;
|
|
|
|
$text = Common::deal_keywords($text);
|
|
|
|
$text = Common::deal_str($text);
|
|
|
|
if(!$text){
|
|
|
|
echo getmypid() . ' ' . 'AI生成结果['.$a.']被关键词过滤' . PHP_EOL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//包含这写字 重新生成
|
|
|
|
if(Str::contains(Str::lower($text), ['[your brand]', '[brand name]'])){
|
...
|
...
|
|