|
@@ -141,17 +141,6 @@ class UpdateSeoTdk extends Command |
|
@@ -141,17 +141,6 @@ class UpdateSeoTdk extends Command |
|
141
|
try {
|
141
|
try {
|
|
142
|
ProjectServer::useProject($project_id);
|
142
|
ProjectServer::useProject($project_id);
|
|
143
|
$this->seo_tdk($project_id);
|
143
|
$this->seo_tdk($project_id);
|
|
144
|
- } catch (\Exception $e) {
|
|
|
|
145
|
- echo date('Y-m-d H:i:s') . ' line '. $e->getLine() .' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
|
|
|
|
146
|
- $this->updateProduct($project_id);
|
|
|
|
147
|
- $this->updateProductCate($project_id);
|
|
|
|
148
|
- $this->updateBlogs($project_id);
|
|
|
|
149
|
- $this->updateBlogCate($project_id);
|
|
|
|
150
|
- $this->updateNews($project_id);
|
|
|
|
151
|
- $this->updateNewsCate($project_id);
|
|
|
|
152
|
- $this->updatePage($project_id);
|
|
|
|
153
|
- //发送站内信
|
|
|
|
154
|
- $this->send_message($project_id);
|
|
|
|
155
|
DB::disconnect('custom_mysql');
|
144
|
DB::disconnect('custom_mysql');
|
|
156
|
}catch (\Exception $e){
|
145
|
}catch (\Exception $e){
|
|
157
|
echo date('Y-m-d H:i:s') . ' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
|
146
|
echo date('Y-m-d H:i:s') . ' error: ' . $project_id . '->' . $e->getMessage() . PHP_EOL;
|
|
@@ -162,19 +151,21 @@ class UpdateSeoTdk extends Command |
|
@@ -162,19 +151,21 @@ class UpdateSeoTdk extends Command |
|
162
|
|
151
|
|
|
163
|
public function seo_tdk($project_id)
|
152
|
public function seo_tdk($project_id)
|
|
164
|
{
|
153
|
{
|
|
|
|
154
|
+ $data = [];
|
|
|
|
155
|
+ $update = [];//更新统计
|
|
165
|
$ai_commands = AiCommand::where('is_batch', 1)->select('key', 'scene', 'ai')->get()->toArray();
|
156
|
$ai_commands = AiCommand::where('is_batch', 1)->select('key', 'scene', 'ai')->get()->toArray();
|
|
166
|
$ai_commands = Arr::setValueToKey($ai_commands, 'key');
|
157
|
$ai_commands = Arr::setValueToKey($ai_commands, 'key');
|
|
167
|
-
|
|
|
|
168
|
foreach ($this->maps as $table => $map) {
|
158
|
foreach ($this->maps as $table => $map) {
|
|
|
|
159
|
+ $update[$table] = ['total_page'=>0, 'title'=>0, 'keyword'=>0, 'des'=>0];
|
|
169
|
echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL;
|
160
|
echo date('Y-m-d H:i:s') . '更新--' . $table . ': 项目id' . $project_id . PHP_EOL;
|
|
170
|
$list = DB::connection('custom_mysql')->table($table)->get()->toArray();
|
161
|
$list = DB::connection('custom_mysql')->table($table)->get()->toArray();
|
|
171
|
if (!empty($list)) {
|
162
|
if (!empty($list)) {
|
|
172
|
foreach ($list as $v) {
|
163
|
foreach ($list as $v) {
|
|
|
|
164
|
+ $update[$table]['total_page']++;
|
|
173
|
$v = (array)$v;
|
165
|
$v = (array)$v;
|
|
174
|
echo date('Y-m-d H:i:s') . '更新--' . $table . ':id' . $v['id'] . PHP_EOL;
|
166
|
echo date('Y-m-d H:i:s') . '更新--' . $table . ':id' . $v['id'] . PHP_EOL;
|
|
175
|
$data = [];
|
167
|
$data = [];
|
|
176
|
$json_field = '';
|
168
|
$json_field = '';
|
|
177
|
-
|
|
|
|
178
|
foreach ($map as $ai_key => $field) {
|
169
|
foreach ($map as $ai_key => $field) {
|
|
179
|
$field_arr = explode('.', $field);
|
170
|
$field_arr = explode('.', $field);
|
|
180
|
if (count($field_arr) > 1) {
|
171
|
if (count($field_arr) > 1) {
|
|
@@ -196,8 +187,24 @@ class UpdateSeoTdk extends Command |
|
@@ -196,8 +187,24 @@ class UpdateSeoTdk extends Command |
|
196
|
}
|
187
|
}
|
|
197
|
|
188
|
|
|
198
|
if (count($field_arr) > 1) {
|
189
|
if (count($field_arr) > 1) {
|
|
|
|
190
|
+ if($field_arr[1] == 'title'){
|
|
|
|
191
|
+ $update[$table]['title']++;
|
|
|
|
192
|
+ }elseif ($field_arr[1] == 'keyword'){
|
|
|
|
193
|
+ $update[$table]['keyword']++;
|
|
|
|
194
|
+ }elseif ($field_arr[1] == 'description'){
|
|
|
|
195
|
+ $update[$table]['des']++;
|
|
|
|
196
|
+ }
|
|
199
|
$data[$field_arr[0]][$field_arr[1]] = $this->ai_send($prompt);
|
197
|
$data[$field_arr[0]][$field_arr[1]] = $this->ai_send($prompt);
|
|
200
|
}else{
|
198
|
}else{
|
|
|
|
199
|
+ if($field == 'title' || $field == 'seo_title'){
|
|
|
|
200
|
+ $update[$table]['title']++;
|
|
|
|
201
|
+ }
|
|
|
|
202
|
+ if($field == 'keywords' || $field == 'seo_keywords'){
|
|
|
|
203
|
+ $update[$table]['keyword']++;
|
|
|
|
204
|
+ }
|
|
|
|
205
|
+ if($field == 'seo_description' || $field == 'description'){
|
|
|
|
206
|
+ $update[$table]['des']++;
|
|
|
|
207
|
+ }
|
|
201
|
$data[$field] = $this->ai_send($prompt);
|
208
|
$data[$field] = $this->ai_send($prompt);
|
|
202
|
}
|
209
|
}
|
|
203
|
} else {
|
210
|
} else {
|
|
@@ -207,12 +214,32 @@ class UpdateSeoTdk extends Command |
|
@@ -207,12 +214,32 @@ class UpdateSeoTdk extends Command |
|
207
|
//使用核心关键词
|
214
|
//使用核心关键词
|
|
208
|
if(in_array($ai_key, array_keys($this->core_keyword_keys))){
|
215
|
if(in_array($ai_key, array_keys($this->core_keyword_keys))){
|
|
209
|
$data[$field_arr[0]][$field_arr[1]] = $this->mainKeywords($project_id, $this->core_keyword_keys[$ai_key]);
|
216
|
$data[$field_arr[0]][$field_arr[1]] = $this->mainKeywords($project_id, $this->core_keyword_keys[$ai_key]);
|
|
|
|
217
|
+ if(!empty($data[$field_arr[0]][$field_arr[1]])){
|
|
|
|
218
|
+ if($field_arr[1] == 'title'){
|
|
|
|
219
|
+ $data[$table]['title']++;
|
|
|
|
220
|
+ }elseif ($field_arr[1] == 'keyword'){
|
|
|
|
221
|
+ $data[$table]['keyword']++;
|
|
|
|
222
|
+ }elseif ($field_arr[1] == 'description'){
|
|
|
|
223
|
+ $data[$table]['des']++;
|
|
|
|
224
|
+ }
|
|
|
|
225
|
+ }
|
|
210
|
}
|
226
|
}
|
|
211
|
}else{
|
227
|
}else{
|
|
212
|
$data[$field] = $v[$this->topic_fields[$table]] ?? '';
|
228
|
$data[$field] = $v[$this->topic_fields[$table]] ?? '';
|
|
213
|
//使用核心关键词
|
229
|
//使用核心关键词
|
|
214
|
if(in_array($ai_key, array_keys($this->core_keyword_keys))){
|
230
|
if(in_array($ai_key, array_keys($this->core_keyword_keys))){
|
|
215
|
$data[$field] = $this->mainKeywords($project_id, $this->core_keyword_keys[$ai_key]);
|
231
|
$data[$field] = $this->mainKeywords($project_id, $this->core_keyword_keys[$ai_key]);
|
|
|
|
232
|
+ if(!empty($data[$field_arr[0]][$field_arr[1]])){
|
|
|
|
233
|
+ if($field == 'title' || $field == 'seo_title'){
|
|
|
|
234
|
+ $update[$table]['title']++;
|
|
|
|
235
|
+ }
|
|
|
|
236
|
+ if($field == 'keywords' || $field == 'seo_keywords'){
|
|
|
|
237
|
+ $update[$table]['keyword']++;
|
|
|
|
238
|
+ }
|
|
|
|
239
|
+ if($field == 'seo_description' || $field == 'description'){
|
|
|
|
240
|
+ $update[$table]['des']++;
|
|
|
|
241
|
+ }
|
|
|
|
242
|
+ }
|
|
216
|
}
|
243
|
}
|
|
217
|
}
|
244
|
}
|
|
218
|
}
|
245
|
}
|
|
@@ -227,6 +254,7 @@ class UpdateSeoTdk extends Command |
|
@@ -227,6 +254,7 @@ class UpdateSeoTdk extends Command |
|
227
|
}
|
254
|
}
|
|
228
|
$data[$json_field] = json_encode($data[$json_field]);
|
255
|
$data[$json_field] = json_encode($data[$json_field]);
|
|
229
|
}
|
256
|
}
|
|
|
|
257
|
+ $update[$table] = json_encode($update[$table]);
|
|
230
|
DB::connection('custom_mysql')->table($table)->where(['id' => $v['id']])->update($data);
|
258
|
DB::connection('custom_mysql')->table($table)->where(['id' => $v['id']])->update($data);
|
|
231
|
}
|
259
|
}
|
|
232
|
}
|
260
|
}
|