|
...
|
...
|
@@ -3,6 +3,7 @@ |
|
|
|
namespace App\Console\Commands\Update;
|
|
|
|
|
|
|
|
use App\Helper\Arr;
|
|
|
|
use App\Http\Logic\Bside\News\NewsLogic;
|
|
|
|
use App\Http\Logic\Bside\Product\CategoryLogic;
|
|
|
|
use App\Models\Blog\Blog;
|
|
|
|
use App\Models\Collect\CollectSource;
|
|
...
|
...
|
@@ -345,6 +346,8 @@ class ProjectUpdate extends Command |
|
|
|
|
|
|
|
if ($api_type == 'news') {
|
|
|
|
$model = new News();
|
|
|
|
$category_model = new NewsCategory();
|
|
|
|
$logic = new NewsLogic();
|
|
|
|
} else {
|
|
|
|
$model = new Blog();
|
|
|
|
}
|
|
...
|
...
|
@@ -354,6 +357,12 @@ class ProjectUpdate extends Command |
|
|
|
if ($route) {
|
|
|
|
$news = $model->read(['url' => $route], 'id');
|
|
|
|
if (!$news) {
|
|
|
|
//分类
|
|
|
|
$category_id = '';
|
|
|
|
if ($api_type == 'news' && ($item['category'] ?? [])) {
|
|
|
|
$category_arr = $category_model->list(['original_id' => ['in', array_column($item['category'], 'id')]]);
|
|
|
|
$category_id = $logic->getLastCategory(array_column($category_arr, 'id'));
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
$item['ttile'] = $this->special2str($item['ttile'] ?? '');
|
|
|
|
|
|
...
|
...
|
@@ -366,6 +375,7 @@ class ProjectUpdate extends Command |
|
|
|
$id = $model->insertGetId([
|
|
|
|
'project_id' => $project_id,
|
|
|
|
'name' => $item['ttile'],
|
|
|
|
'category_id' => $category_id,
|
|
|
|
'seo_title' => $item['ttile'],
|
|
|
|
'seo_keywords' => $item['keywords'] ?? '',
|
|
|
|
'seo_description' => $item['description'] ?? '',
|
|
...
|
...
|
@@ -386,6 +396,13 @@ class ProjectUpdate extends Command |
|
|
|
echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$category_id = '';
|
|
|
|
if ($api_type == 'news' && ($item['category'] ?? [])) {
|
|
|
|
$category_arr = $category_model->list(['original_id' => ['in', array_column($item['category'], 'id')]]);
|
|
|
|
$category_id = $logic->getLastCategory(array_column($category_arr, 'id'));
|
|
|
|
}
|
|
|
|
$model->edit(['category_id' => $category_id], ['id' => $news['id']]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -468,7 +485,7 @@ class ProjectUpdate extends Command |
|
|
|
return $task_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
$task_list = UpdateLog::where('project_id', 528)->where('status', UpdateLog::STATUS_UN)->orderBy('project_id', 'asc')->orderBy('sort', 'asc')->limit(7)->get();
|
|
|
|
$task_list = UpdateLog::where('project_id', 528)->where('status', UpdateLog::STATUS_UN)->orderBy('project_id', 'asc')->orderBy('sort', 'asc')->limit(8)->get();
|
|
|
|
if ($task_list->count() == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
...
|
...
|
@@ -541,7 +558,7 @@ class ProjectUpdate extends Command |
|
|
|
$model = new NewsCategory();
|
|
|
|
foreach ($items as $item) {
|
|
|
|
$item['name'] = $this->special2str($item['name'] ?? '');
|
|
|
|
if($item['name']){
|
|
|
|
if ($item['name']) {
|
|
|
|
$parent = $model->read(['pid' => $pid, 'name' => $item['name']], 'id');
|
|
|
|
if (!$parent) {
|
|
|
|
try {
|
...
|
...
|
|