正在显示
1 个修改的文件
包含
19 行增加
和
2 行删除
| @@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
| 3 | namespace App\Console\Commands\Update; | 3 | namespace App\Console\Commands\Update; |
| 4 | 4 | ||
| 5 | use App\Helper\Arr; | 5 | use App\Helper\Arr; |
| 6 | +use App\Http\Logic\Bside\News\NewsLogic; | ||
| 6 | use App\Http\Logic\Bside\Product\CategoryLogic; | 7 | use App\Http\Logic\Bside\Product\CategoryLogic; |
| 7 | use App\Models\Blog\Blog; | 8 | use App\Models\Blog\Blog; |
| 8 | use App\Models\Collect\CollectSource; | 9 | use App\Models\Collect\CollectSource; |
| @@ -345,6 +346,8 @@ class ProjectUpdate extends Command | @@ -345,6 +346,8 @@ class ProjectUpdate extends Command | ||
| 345 | 346 | ||
| 346 | if ($api_type == 'news') { | 347 | if ($api_type == 'news') { |
| 347 | $model = new News(); | 348 | $model = new News(); |
| 349 | + $category_model = new NewsCategory(); | ||
| 350 | + $logic = new NewsLogic(); | ||
| 348 | } else { | 351 | } else { |
| 349 | $model = new Blog(); | 352 | $model = new Blog(); |
| 350 | } | 353 | } |
| @@ -354,6 +357,12 @@ class ProjectUpdate extends Command | @@ -354,6 +357,12 @@ class ProjectUpdate extends Command | ||
| 354 | if ($route) { | 357 | if ($route) { |
| 355 | $news = $model->read(['url' => $route], 'id'); | 358 | $news = $model->read(['url' => $route], 'id'); |
| 356 | if (!$news) { | 359 | if (!$news) { |
| 360 | + //分类 | ||
| 361 | + $category_id = ''; | ||
| 362 | + if ($api_type == 'news' && ($item['category'] ?? [])) { | ||
| 363 | + $category_arr = $category_model->list(['original_id' => ['in', array_column($item['category'], 'id')]]); | ||
| 364 | + $category_id = $logic->getLastCategory(array_column($category_arr, 'id')); | ||
| 365 | + } | ||
| 357 | try { | 366 | try { |
| 358 | $item['ttile'] = $this->special2str($item['ttile'] ?? ''); | 367 | $item['ttile'] = $this->special2str($item['ttile'] ?? ''); |
| 359 | 368 | ||
| @@ -366,6 +375,7 @@ class ProjectUpdate extends Command | @@ -366,6 +375,7 @@ class ProjectUpdate extends Command | ||
| 366 | $id = $model->insertGetId([ | 375 | $id = $model->insertGetId([ |
| 367 | 'project_id' => $project_id, | 376 | 'project_id' => $project_id, |
| 368 | 'name' => $item['ttile'], | 377 | 'name' => $item['ttile'], |
| 378 | + 'category_id' => $category_id, | ||
| 369 | 'seo_title' => $item['ttile'], | 379 | 'seo_title' => $item['ttile'], |
| 370 | 'seo_keywords' => $item['keywords'] ?? '', | 380 | 'seo_keywords' => $item['keywords'] ?? '', |
| 371 | 'seo_description' => $item['description'] ?? '', | 381 | 'seo_description' => $item['description'] ?? '', |
| @@ -386,6 +396,13 @@ class ProjectUpdate extends Command | @@ -386,6 +396,13 @@ class ProjectUpdate extends Command | ||
| 386 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; | 396 | echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; |
| 387 | continue; | 397 | continue; |
| 388 | } | 398 | } |
| 399 | + } else { | ||
| 400 | + $category_id = ''; | ||
| 401 | + if ($api_type == 'news' && ($item['category'] ?? [])) { | ||
| 402 | + $category_arr = $category_model->list(['original_id' => ['in', array_column($item['category'], 'id')]]); | ||
| 403 | + $category_id = $logic->getLastCategory(array_column($category_arr, 'id')); | ||
| 404 | + } | ||
| 405 | + $model->edit(['category_id' => $category_id], ['id' => $news['id']]); | ||
| 389 | } | 406 | } |
| 390 | } | 407 | } |
| 391 | } | 408 | } |
| @@ -468,7 +485,7 @@ class ProjectUpdate extends Command | @@ -468,7 +485,7 @@ class ProjectUpdate extends Command | ||
| 468 | return $task_id; | 485 | return $task_id; |
| 469 | } | 486 | } |
| 470 | 487 | ||
| 471 | - $task_list = UpdateLog::where('project_id', 528)->where('status', UpdateLog::STATUS_UN)->orderBy('project_id', 'asc')->orderBy('sort', 'asc')->limit(7)->get(); | 488 | + $task_list = UpdateLog::where('project_id', 528)->where('status', UpdateLog::STATUS_UN)->orderBy('project_id', 'asc')->orderBy('sort', 'asc')->limit(8)->get(); |
| 472 | if ($task_list->count() == 0) { | 489 | if ($task_list->count() == 0) { |
| 473 | return false; | 490 | return false; |
| 474 | } | 491 | } |
| @@ -541,7 +558,7 @@ class ProjectUpdate extends Command | @@ -541,7 +558,7 @@ class ProjectUpdate extends Command | ||
| 541 | $model = new NewsCategory(); | 558 | $model = new NewsCategory(); |
| 542 | foreach ($items as $item) { | 559 | foreach ($items as $item) { |
| 543 | $item['name'] = $this->special2str($item['name'] ?? ''); | 560 | $item['name'] = $this->special2str($item['name'] ?? ''); |
| 544 | - if($item['name']){ | 561 | + if ($item['name']) { |
| 545 | $parent = $model->read(['pid' => $pid, 'name' => $item['name']], 'id'); | 562 | $parent = $model->read(['pid' => $pid, 'name' => $item['name']], 'id'); |
| 546 | if (!$parent) { | 563 | if (!$parent) { |
| 547 | try { | 564 | try { |
-
请 注册 或 登录 后发表评论