|
@@ -4,6 +4,8 @@ namespace App\Console\Commands\Tdk; |
|
@@ -4,6 +4,8 @@ namespace App\Console\Commands\Tdk; |
|
4
|
|
4
|
|
|
5
|
|
5
|
|
|
6
|
use App\Helper\Arr;
|
6
|
use App\Helper\Arr;
|
|
|
|
7
|
+use App\Models\News\News;
|
|
|
|
8
|
+use App\Models\News\NewsCategory;
|
|
7
|
use App\Models\Product\Keyword;
|
9
|
use App\Models\Product\Keyword;
|
|
8
|
use App\Models\Project\KeywordPrefix;
|
10
|
use App\Models\Project\KeywordPrefix;
|
|
9
|
use App\Models\Project\Project;
|
11
|
use App\Models\Project\Project;
|
|
@@ -71,41 +73,41 @@ class RerunSeoTdk extends Command |
|
@@ -71,41 +73,41 @@ class RerunSeoTdk extends Command |
|
71
|
* @author zbj
|
73
|
* @author zbj
|
|
72
|
* @date 2025/4/12
|
74
|
* @date 2025/4/12
|
|
73
|
*/
|
75
|
*/
|
|
74
|
- public function judgeAnomalies($project_id){
|
|
|
|
75
|
- dump($project_id);
|
|
|
|
76
|
- $all_prefixes = $this->getAllPrefix(1, $project_id);
|
|
|
|
77
|
- $all_prefixes = array_map('strtolower', $all_prefixes);
|
|
|
|
78
|
-
|
|
|
|
79
|
- //获取当前项目的所有分类
|
|
|
|
80
|
- $list = Keyword::select('title', 'seo_title', 'id')->get()->toArray();
|
|
|
|
81
|
- //新闻 seo_keyword 和 分类名一样的
|
|
|
|
82
|
- $ids = [];
|
|
|
|
83
|
- foreach ($list as $k=>$item){
|
|
|
|
84
|
- $seo_title = $item['seo_title'];
|
|
|
|
85
|
- $id = $item['id'];
|
|
|
|
86
|
- $title = $item['title'];
|
|
|
|
87
|
- if(Str::startsWith(strtolower($seo_title), ['wholesale', 'cheap', 'buy']) && Str::contains(strtolower($seo_title), ['manufacturer', 'manufacturers', 'factory', 'factories', 'exporter', 'exporters', 'company', 'companies', 'supplier', 'suppliers'])){
|
|
|
|
88
|
- $ids[] = $id;
|
|
|
|
89
|
- dump($seo_title);
|
|
|
|
90
|
- continue;
|
|
|
|
91
|
- }
|
|
|
|
92
|
- $topic_words = explode(' ', strtolower($title));
|
|
|
|
93
|
- //关键词最后一个是前缀 且 有前后缀
|
|
|
|
94
|
- if(in_array(Arr::last($topic_words), $all_prefixes) && $title != $seo_title){
|
|
|
|
95
|
- $ids[] = $id;
|
|
|
|
96
|
- dump($seo_title);
|
|
|
|
97
|
- continue;
|
|
|
|
98
|
- }
|
|
|
|
99
|
- }
|
|
|
|
100
|
-
|
|
|
|
101
|
- $count = count($ids);
|
|
|
|
102
|
- if($count){
|
|
|
|
103
|
- echo "项目{$project_id},共{$count}条需要重跑";
|
|
|
|
104
|
- LogUtils::info("RerunSeoTdk: 项目{$project_id},共{$count}条需要重跑");
|
|
|
|
105
|
- Keyword::whereIn('id', $ids)->update(['seo_title' => '']);
|
|
|
|
106
|
- ProjectUpdateTdk::add_task($project_id);
|
|
|
|
107
|
- }
|
|
|
|
108
|
- }
|
76
|
+// public function judgeAnomalies($project_id){
|
|
|
|
77
|
+// dump($project_id);
|
|
|
|
78
|
+// $all_prefixes = $this->getAllPrefix(1, $project_id);
|
|
|
|
79
|
+// $all_prefixes = array_map('strtolower', $all_prefixes);
|
|
|
|
80
|
+//
|
|
|
|
81
|
+// //获取当前项目的所有分类
|
|
|
|
82
|
+// $list = Keyword::select('title', 'seo_title', 'id')->get()->toArray();
|
|
|
|
83
|
+// //新闻 seo_keyword 和 分类名一样的
|
|
|
|
84
|
+// $ids = [];
|
|
|
|
85
|
+// foreach ($list as $k=>$item){
|
|
|
|
86
|
+// $seo_title = $item['seo_title'];
|
|
|
|
87
|
+// $id = $item['id'];
|
|
|
|
88
|
+// $title = $item['title'];
|
|
|
|
89
|
+// if(Str::startsWith(strtolower($seo_title), ['wholesale', 'cheap', 'buy']) && Str::contains(strtolower($seo_title), ['manufacturer', 'manufacturers', 'factory', 'factories', 'exporter', 'exporters', 'company', 'companies', 'supplier', 'suppliers'])){
|
|
|
|
90
|
+// $ids[] = $id;
|
|
|
|
91
|
+// dump($seo_title);
|
|
|
|
92
|
+// continue;
|
|
|
|
93
|
+// }
|
|
|
|
94
|
+// $topic_words = explode(' ', strtolower($title));
|
|
|
|
95
|
+// //关键词最后一个是前缀 且 有前后缀
|
|
|
|
96
|
+// if(in_array(Arr::last($topic_words), $all_prefixes) && $title != $seo_title){
|
|
|
|
97
|
+// $ids[] = $id;
|
|
|
|
98
|
+// dump($seo_title);
|
|
|
|
99
|
+// continue;
|
|
|
|
100
|
+// }
|
|
|
|
101
|
+// }
|
|
|
|
102
|
+//
|
|
|
|
103
|
+// $count = count($ids);
|
|
|
|
104
|
+// if($count){
|
|
|
|
105
|
+// echo "项目{$project_id},共{$count}条需要重跑";
|
|
|
|
106
|
+// LogUtils::info("RerunSeoTdk: 项目{$project_id},共{$count}条需要重跑");
|
|
|
|
107
|
+// Keyword::whereIn('id', $ids)->update(['seo_title' => '']);
|
|
|
|
108
|
+// ProjectUpdateTdk::add_task($project_id);
|
|
|
|
109
|
+// }
|
|
|
|
110
|
+// }
|
|
109
|
|
111
|
|
|
110
|
// /**
|
112
|
// /**
|
|
111
|
// * 判断seo_title后缀重复
|
113
|
// * 判断seo_title后缀重复
|
|
@@ -139,28 +141,28 @@ class RerunSeoTdk extends Command |
|
@@ -139,28 +141,28 @@ class RerunSeoTdk extends Command |
|
139
|
// }
|
141
|
// }
|
|
140
|
// }
|
142
|
// }
|
|
141
|
|
143
|
|
|
142
|
-// /**
|
|
|
|
143
|
-// * 判断异常
|
|
|
|
144
|
-// * @author zbj
|
|
|
|
145
|
-// * @date 2025/4/12
|
|
|
|
146
|
-// */
|
|
|
|
147
|
-// public function judgeAnomalies($project_id){
|
|
|
|
148
|
-// //获取当前项目的所有分类
|
|
|
|
149
|
-// $categories = NewsCategory::pluck('name', 'id')->toArray();
|
|
|
|
150
|
-// //新闻 seo_keyword 和 分类名一样的
|
|
|
|
151
|
-// $news_ids = [];
|
|
|
|
152
|
-// foreach ($categories as $category){
|
|
|
|
153
|
-// $ids = News::WhereRaw("FIND_IN_SET('{$category}', `seo_keywords`)")->pluck('id')->toArray();
|
|
|
|
154
|
-// $news_ids = array_unique(array_merge($news_ids, $ids));
|
|
|
|
155
|
-// }
|
|
|
|
156
|
-//
|
|
|
|
157
|
-// $count = count($news_ids);
|
|
|
|
158
|
-// if($count){
|
|
|
|
159
|
-// echo "项目{$project_id},共{$count}条需要重跑";
|
|
|
|
160
|
-// News::whereIn('id', $news_ids)->update(['seo_keywords' => '']);
|
|
|
|
161
|
-// ProjectUpdateTdk::add_task($project_id);
|
|
|
|
162
|
-// }
|
|
|
|
163
|
-// }
|
144
|
+ /**
|
|
|
|
145
|
+ * 判断异常
|
|
|
|
146
|
+ * @author zbj
|
|
|
|
147
|
+ * @date 2025/4/12
|
|
|
|
148
|
+ */
|
|
|
|
149
|
+ public function judgeAnomalies($project_id){
|
|
|
|
150
|
+ //获取当前项目的所有分类
|
|
|
|
151
|
+ $categories = NewsCategory::pluck('alias', 'id')->toArray();
|
|
|
|
152
|
+ //新闻 seo_keyword 和 分类名一样的
|
|
|
|
153
|
+ $news_ids = [];
|
|
|
|
154
|
+ foreach ($categories as $category){
|
|
|
|
155
|
+ $ids = News::WhereRaw("FIND_IN_SET('{$category}', `seo_keywords`)")->pluck('id')->toArray();
|
|
|
|
156
|
+ $news_ids = array_unique(array_merge($news_ids, $ids));
|
|
|
|
157
|
+ }
|
|
|
|
158
|
+
|
|
|
|
159
|
+ $count = count($news_ids);
|
|
|
|
160
|
+ if($count){
|
|
|
|
161
|
+ echo "项目{$project_id},共{$count}条需要重跑";
|
|
|
|
162
|
+ News::whereIn('id', $news_ids)->update(['seo_keywords' => '']);
|
|
|
|
163
|
+ ProjectUpdateTdk::add_task($project_id);
|
|
|
|
164
|
+ }
|
|
|
|
165
|
+ }
|
|
164
|
|
166
|
|
|
165
|
public function getAllPrefix($type, int $project_id = 0){
|
167
|
public function getAllPrefix($type, int $project_id = 0){
|
|
166
|
$cache_key = 'AllPrefix_' . $type . '_' . $project_id;
|
168
|
$cache_key = 'AllPrefix_' . $type . '_' . $project_id;
|