作者 赵彬吉

update

@@ -8,6 +8,7 @@ use App\Models\Product\Keyword; @@ -8,6 +8,7 @@ use App\Models\Product\Keyword;
8 use App\Models\Project\Project; 8 use App\Models\Project\Project;
9 use App\Models\Project\ProjectUpdateTdk; 9 use App\Models\Project\ProjectUpdateTdk;
10 use App\Services\ProjectServer; 10 use App\Services\ProjectServer;
  11 +use App\Utils\LogUtils;
11 use Illuminate\Console\Command; 12 use Illuminate\Console\Command;
12 use Illuminate\Support\Facades\DB; 13 use Illuminate\Support\Facades\DB;
13 use Illuminate\Support\Str; 14 use Illuminate\Support\Str;
@@ -63,7 +64,7 @@ class RerunSeoTdk extends Command @@ -63,7 +64,7 @@ class RerunSeoTdk extends Command
63 } 64 }
64 65
65 /** 66 /**
66 - * 判断seo_title后缀重复 67 + * 判断seo_title 前缀有wholesale或cheap的词,后缀也有 manufacturer,factory,exporter,company
67 * @author zbj 68 * @author zbj
68 * @date 2025/4/12 69 * @date 2025/4/12
69 */ 70 */
@@ -72,29 +73,59 @@ class RerunSeoTdk extends Command @@ -72,29 +73,59 @@ class RerunSeoTdk extends Command
72 $seo_titles = Keyword::pluck('seo_title', 'id')->toArray(); 73 $seo_titles = Keyword::pluck('seo_title', 'id')->toArray();
73 //新闻 seo_keyword 和 分类名一样的 74 //新闻 seo_keyword 和 分类名一样的
74 $ids = []; 75 $ids = [];
75 - //Suppliers, Manufacturer  
76 foreach ($seo_titles as $id=>$seo_title){ 76 foreach ($seo_titles as $id=>$seo_title){
77 - if(!Str::contains($seo_title, ', ')){ 77 + if(!Str::startsWith(strtolower($seo_title), ['wholesale', 'cheap'])){
78 continue; 78 continue;
79 } 79 }
80 - $arr = explode(', ', $seo_title);  
81 - $suffix1 = $arr[1];  
82 - $arr = explode(' ', $arr[0]);  
83 - $suffix2 = Arr::last($arr);  
84 - if(Str::singular($suffix1) == Str::singular($suffix2)){  
85 - $ids[] = $id; 80 + if(!Str::contains(strtolower($seo_title), ['manufacturer', 'manufacturers', 'factory', 'factories', 'exporter', 'exporters', 'company', 'companies', 'supplier', 'suppliers'])){
  81 + continue;
86 } 82 }
  83 + dump($seo_title);exit;
  84 + $ids[] = $id;
87 } 85 }
88 86
89 $count = count($ids); 87 $count = count($ids);
90 if($count){ 88 if($count){
91 echo "项目{$project_id},共{$count}条需要重跑"; 89 echo "项目{$project_id},共{$count}条需要重跑";
  90 + LogUtils::info("RerunSeoTdk: 项目{$project_id},共{$count}条需要重跑");
92 Keyword::whereIn('id', $ids)->update(['seo_title' => '']); 91 Keyword::whereIn('id', $ids)->update(['seo_title' => '']);
93 ProjectUpdateTdk::add_task($project_id); 92 ProjectUpdateTdk::add_task($project_id);
94 } 93 }
95 } 94 }
96 95
97 // /** 96 // /**
  97 +// * 判断seo_title后缀重复
  98 +// * @author zbj
  99 +// * @date 2025/4/12
  100 +// */
  101 +// public function judgeAnomalies($project_id){
  102 +// //获取当前项目的所有分类
  103 +// $seo_titles = Keyword::pluck('seo_title', 'id')->toArray();
  104 +// //新闻 seo_keyword 和 分类名一样的
  105 +// $ids = [];
  106 +// //Suppliers, Manufacturer
  107 +// foreach ($seo_titles as $id=>$seo_title){
  108 +// if(!Str::contains($seo_title, ', ')){
  109 +// continue;
  110 +// }
  111 +// $arr = explode(', ', $seo_title);
  112 +// $suffix1 = $arr[1];
  113 +// $arr = explode(' ', $arr[0]);
  114 +// $suffix2 = Arr::last($arr);
  115 +// if(Str::singular($suffix1) == Str::singular($suffix2)){
  116 +// $ids[] = $id;
  117 +// }
  118 +// }
  119 +//
  120 +// $count = count($ids);
  121 +// if($count){
  122 +// echo "项目{$project_id},共{$count}条需要重跑";
  123 +// Keyword::whereIn('id', $ids)->update(['seo_title' => '']);
  124 +// ProjectUpdateTdk::add_task($project_id);
  125 +// }
  126 +// }
  127 +
  128 +// /**
98 // * 判断异常 129 // * 判断异常
99 // * @author zbj 130 // * @author zbj
100 // * @date 2025/4/12 131 // * @date 2025/4/12