作者 刘锟

update

@@ -139,18 +139,16 @@ class ProjectUpdate extends Command @@ -139,18 +139,16 @@ class ProjectUpdate extends Command
139 'seo_title' => $item['seo_title'] ?? '', 139 'seo_title' => $item['seo_title'] ?? '',
140 'seo_keywords' => $item['seo_keywords'] ?? '', 140 'seo_keywords' => $item['seo_keywords'] ?? '',
141 'seo_description' => $item['seo_description'] ?? '', 141 'seo_description' => $item['seo_description'] ?? '',
  142 + 'route' => $this->get_url_route($item['url'])
142 ]); 143 ]);
143 - $route = $this->set_map($this->get_url_route($item['url']), RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $project_id);  
144 - $model->edit(['route' => $route], ['id' => $id]); 144 + $this->set_map($this->get_url_route($item['url']), RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $project_id);
  145 +
  146 + CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $link_type, $language_list, $page_list);
145 } catch (\Exception $e) { 147 } catch (\Exception $e) {
146 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 148 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
147 continue; 149 continue;
148 } 150 }
149 - } else {  
150 - $id = $keyword['id'];  
151 } 151 }
152 -  
153 - CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $link_type, $language_list, $page_list);  
154 } 152 }
155 } 153 }
156 } 154 }
@@ -271,19 +269,17 @@ class ProjectUpdate extends Command @@ -271,19 +269,17 @@ class ProjectUpdate extends Command
271 'keyword' => $item['keywords'] ?? '', 269 'keyword' => $item['keywords'] ?? '',
272 'description' => $item['description'] ?? '' 270 'description' => $item['description'] ?? ''
273 ]), 271 ]),
274 - 'status' => Product::STATUS_ON 272 + 'status' => Product::STATUS_ON,
  273 + 'route' => $this->get_url_route($item['url'])
275 ]); 274 ]);
276 - $route = $this->set_map($this->get_url_route($item['url']), RouteMap::SOURCE_PRODUCT, $id, $project_id);  
277 - $model->edit(['route' => $route], ['id' => $id]); 275 + $this->set_map($this->get_url_route($item['url']), RouteMap::SOURCE_PRODUCT, $id, $project_id);
  276 +
  277 + CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $link_type, $language_list, $page_list);
278 } catch (\Exception $e) { 278 } catch (\Exception $e) {
279 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 279 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
280 continue; 280 continue;
281 } 281 }
282 - } else {  
283 - $id = $product['id'];  
284 } 282 }
285 -  
286 - CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $link_type, $language_list, $page_list);  
287 } 283 }
288 } 284 }
289 } 285 }
@@ -326,19 +322,17 @@ class ProjectUpdate extends Command @@ -326,19 +322,17 @@ class ProjectUpdate extends Command
326 'seo_description' => $item['description'] ?? '', 322 'seo_description' => $item['description'] ?? '',
327 'text' => $item['content'] ?? '', 323 'text' => $item['content'] ?? '',
328 'image' => $item['images'][0] ?? '', 324 'image' => $item['images'][0] ?? '',
329 - 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE 325 + 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE,
  326 + 'url' => $this->get_url_route($item['url'])
330 ]); 327 ]);
331 - $route = $this->set_map($this->get_url_route($item['url']), $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $project_id);  
332 - $model->edit(['url' => $route], ['id' => $id]); 328 + $this->set_map($this->get_url_route($item['url']), $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $project_id);
  329 +
  330 + CollectTask::_insert($item['url'], $project_id, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $link_type, $language_list, $page_list);
333 } catch (\Exception $e) { 331 } catch (\Exception $e) {
334 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 332 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
335 continue; 333 continue;
336 } 334 }
337 - } else {  
338 - $id = $news['id'];  
339 } 335 }
340 -  
341 - CollectTask::_insert($item['url'], $project_id, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $link_type, $language_list, $page_list);  
342 } 336 }
343 } 337 }
344 } 338 }
@@ -375,19 +369,17 @@ class ProjectUpdate extends Command @@ -375,19 +369,17 @@ class ProjectUpdate extends Command
375 'keywords' => $item['keywords'] ?? '', 369 'keywords' => $item['keywords'] ?? '',
376 'description' => $item['description'] ?? '', 370 'description' => $item['description'] ?? '',
377 'html' => $item['content'] ?? '', 371 'html' => $item['content'] ?? '',
378 - 'status' => 1 372 + 'status' => 1,
  373 + 'url' => $this->get_url_route($item['url'])
379 ]); 374 ]);
380 - $route = $this->set_map($this->get_url_route($item['url']), RouteMap::SOURCE_PAGE, $id, $project_id);  
381 - $model->edit(['url' => $route], ['id' => $id]); 375 + $this->set_map($this->get_url_route($item['url']), RouteMap::SOURCE_PAGE, $id, $project_id);
  376 +
  377 + CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PAGE, $id, $link_type, $language_list, $page_list);
382 } catch (\Exception $e) { 378 } catch (\Exception $e) {
383 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 379 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
384 continue; 380 continue;
385 } 381 }
386 - } else {  
387 - $id = $custom['id'];  
388 } 382 }
389 -  
390 - CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PAGE, $id, $link_type, $language_list, $page_list);  
391 } 383 }
392 } 384 }
393 } 385 }
@@ -463,10 +455,10 @@ class ProjectUpdate extends Command @@ -463,10 +455,10 @@ class ProjectUpdate extends Command
463 'title' => $item['name'], 455 'title' => $item['name'],
464 'pid' => $pid, 456 'pid' => $pid,
465 'keywords' => $item['keywords'] ?? '', 457 'keywords' => $item['keywords'] ?? '',
466 - 'describe' => $item['description'] ?? '' 458 + 'describe' => $item['description'] ?? '',
  459 + 'route' => $this->get_url_route($item['url'])
467 ]); 460 ]);
468 - $route = $this->set_map($this->get_url_route($item['url']), RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);  
469 - $model->edit(['route' => $route], ['id' => $parent_id]); 461 + $this->set_map($this->get_url_route($item['url']), RouteMap::SOURCE_PRODUCT_CATE, $parent_id, $project_id);
470 } catch (\Exception $e) { 462 } catch (\Exception $e) {
471 echo 'date:' . date('Y-m-d H:i:s') . ', category_insert error: ' . $e->getMessage() . PHP_EOL; 463 echo 'date:' . date('Y-m-d H:i:s') . ', category_insert error: ' . $e->getMessage() . PHP_EOL;
472 continue; 464 continue;
@@ -520,10 +512,9 @@ class ProjectUpdate extends Command @@ -520,10 +512,9 @@ class ProjectUpdate extends Command
520 //路由入库 512 //路由入库
521 protected function set_map($route, $source, $source_id, $project_id) 513 protected function set_map($route, $source, $source_id, $project_id)
522 { 514 {
523 - if (empty($route)) {  
524 - return '';  
525 - }  
526 - 515 + if ($route) {
  516 + $route_map = RouteMap::where('project_id', $project_id)->where('source', $source)->where('source_id', $source_id)->first();
  517 + if (!$route_map) {
527 $route_map = new RouteMap(); 518 $route_map = new RouteMap();
528 $route_map->project_id = $project_id; 519 $route_map->project_id = $project_id;
529 $route_map->source = $source; 520 $route_map->source = $source;
@@ -537,7 +528,7 @@ class ProjectUpdate extends Command @@ -537,7 +528,7 @@ class ProjectUpdate extends Command
537 } 528 }
538 529
539 $route_map->save(); 530 $route_map->save();
540 -  
541 - return $route; 531 + }
  532 + }
542 } 533 }
543 } 534 }
@@ -29,8 +29,6 @@ class CollectTask extends Base @@ -29,8 +29,6 @@ class CollectTask extends Base
29 'project_id' => $project_id, 29 'project_id' => $project_id,
30 'source' => $source, 30 'source' => $source,
31 'source_id' => $source_id, 31 'source_id' => $source_id,
32 - 'domain' => $url_arr['host'],  
33 - 'route' => $url_arr['path'],  
34 'language' => '' 32 'language' => ''
35 ]; 33 ];
36 34
@@ -48,7 +46,6 @@ class CollectTask extends Base @@ -48,7 +46,6 @@ class CollectTask extends Base
48 'created_at' => $now, 46 'created_at' => $now,
49 'updated_at' => $now, 47 'updated_at' => $now,
50 ]; 48 ];
51 - }  
52 49
53 if ($link_type > 0 && $language_list && in_array($url_arr['path'], $page_list)) { 50 if ($link_type > 0 && $language_list && in_array($url_arr['path'], $page_list)) {
54 $domain_arr = explode('.', $url_arr['host']); 51 $domain_arr = explode('.', $url_arr['host']);
@@ -77,4 +74,5 @@ class CollectTask extends Base @@ -77,4 +74,5 @@ class CollectTask extends Base
77 74
78 self::insert($data); 75 self::insert($data);
79 } 76 }
  77 + }
80 } 78 }