作者 赵彬吉

update

... ... @@ -8,6 +8,7 @@ use App\Models\Product\Keyword;
use App\Models\Project\Project;
use App\Models\Project\ProjectUpdateTdk;
use App\Services\ProjectServer;
use App\Utils\LogUtils;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
... ... @@ -63,7 +64,7 @@ class RerunSeoTdk extends Command
}
/**
* 判断seo_title后缀重复
* 判断seo_title 前缀有wholesale或cheap的词,后缀也有 manufacturer,factory,exporter,company
* @author zbj
* @date 2025/4/12
*/
... ... @@ -72,29 +73,59 @@ class RerunSeoTdk extends Command
$seo_titles = Keyword::pluck('seo_title', 'id')->toArray();
//新闻 seo_keyword 和 分类名一样的
$ids = [];
//Suppliers, Manufacturer
foreach ($seo_titles as $id=>$seo_title){
if(!Str::contains($seo_title, ', ')){
if(!Str::startsWith(strtolower($seo_title), ['wholesale', 'cheap'])){
continue;
}
$arr = explode(', ', $seo_title);
$suffix1 = $arr[1];
$arr = explode(' ', $arr[0]);
$suffix2 = Arr::last($arr);
if(Str::singular($suffix1) == Str::singular($suffix2)){
$ids[] = $id;
if(!Str::contains(strtolower($seo_title), ['manufacturer', 'manufacturers', 'factory', 'factories', 'exporter', 'exporters', 'company', 'companies', 'supplier', 'suppliers'])){
continue;
}
dump($seo_title);exit;
$ids[] = $id;
}
$count = count($ids);
if($count){
echo "项目{$project_id},共{$count}条需要重跑";
LogUtils::info("RerunSeoTdk: 项目{$project_id},共{$count}条需要重跑");
Keyword::whereIn('id', $ids)->update(['seo_title' => '']);
ProjectUpdateTdk::add_task($project_id);
}
}
// /**
// * 判断seo_title后缀重复
// * @author zbj
// * @date 2025/4/12
// */
// public function judgeAnomalies($project_id){
// //获取当前项目的所有分类
// $seo_titles = Keyword::pluck('seo_title', 'id')->toArray();
// //新闻 seo_keyword 和 分类名一样的
// $ids = [];
// //Suppliers, Manufacturer
// foreach ($seo_titles as $id=>$seo_title){
// if(!Str::contains($seo_title, ', ')){
// continue;
// }
// $arr = explode(', ', $seo_title);
// $suffix1 = $arr[1];
// $arr = explode(' ', $arr[0]);
// $suffix2 = Arr::last($arr);
// if(Str::singular($suffix1) == Str::singular($suffix2)){
// $ids[] = $id;
// }
// }
//
// $count = count($ids);
// if($count){
// echo "项目{$project_id},共{$count}条需要重跑";
// Keyword::whereIn('id', $ids)->update(['seo_title' => '']);
// ProjectUpdateTdk::add_task($project_id);
// }
// }
// /**
// * 判断异常
// * @author zbj
// * @date 2025/4/12
... ...