|
...
|
...
|
@@ -13,6 +13,7 @@ use App\Http\Controllers\Bside\BaseController; |
|
|
|
use App\Models\Com\UpdateLog;
|
|
|
|
use App\Models\Com\UpdateOldInfo;
|
|
|
|
use App\Models\Domain\DomainInfo;
|
|
|
|
use App\Models\News\NewsCategory;
|
|
|
|
use App\Models\Product\Category;
|
|
|
|
use App\Models\Project\ProjectUpdateTdk;
|
|
|
|
use App\Models\Template\BTemplate;
|
|
...
|
...
|
@@ -96,17 +97,36 @@ class UpdateController extends BaseController |
|
|
|
$this->fail('已上线项目需填写采集的测试站域名');
|
|
|
|
}
|
|
|
|
|
|
|
|
$product_cate_type = 0;//产品分类是否重采
|
|
|
|
$news_cate_type = 0;//新闻分类是否重采
|
|
|
|
|
|
|
|
if ($this->param['type'] == 1) {
|
|
|
|
$product_cate_type = 1;
|
|
|
|
$news_cate_type = 1;
|
|
|
|
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$template_info = $bSettingModel->read(['project_id' => $this->param['project_id']]);
|
|
|
|
$template_id = $template_info ? $template_info['template_id'] : 0;//获取模版id
|
|
|
|
|
|
|
|
//产品分类重采之前,判断产品分类是否开启了可视化
|
|
|
|
$category_list = Category::where('project_id', $this->param['project_id'])->get();
|
|
|
|
if ($category_list->count() > 0) {
|
|
|
|
$bSettingModel = new Setting();
|
|
|
|
$template_info = $bSettingModel->read(['project_id' => $this->param['project_id']]);
|
|
|
|
$template_id = $template_info ? $template_info['template_id'] : 0;//获取模版id
|
|
|
|
foreach ($category_list as $category) {
|
|
|
|
if ($this->getRenovation($this->param['project_id'], BTemplate::SOURCE_PRODUCT, BTemplate::IS_LIST, $template_id, $category['id']) == 1) {
|
|
|
|
//有分类开启了可视化
|
|
|
|
$this->param['type'] = 0;
|
|
|
|
$product_cate_type = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//新闻分类重采之前,判断新闻分类是否开启了可视化
|
|
|
|
$category_news_list = NewsCategory::where('project_id', $this->param['project_id'])->get();
|
|
|
|
if ($category_news_list->count() > 0) {
|
|
|
|
foreach ($category_news_list as $category_news) {
|
|
|
|
if ($this->getRenovation($this->param['project_id'], BTemplate::SOURCE_NEWS, BTemplate::IS_LIST, $template_id, $category_news['id']) == 1) {
|
|
|
|
//有分类开启了可视化
|
|
|
|
$news_cate_type = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -143,13 +163,20 @@ class UpdateController extends BaseController |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->param['type'] == 1) {
|
|
|
|
if ($product_cate_type == 1) {
|
|
|
|
//需要重新采集产品分类
|
|
|
|
DB::connection('custom_mysql')->statement("TRUNCATE `gl_product_category`");
|
|
|
|
DB::connection('custom_mysql')->statement("TRUNCATE `gl_product_category_related`");
|
|
|
|
|
|
|
|
DB::connection('custom_mysql')->statement("DELETE FROM `gl_route_map` WHERE `source` = 'product_category'");
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($news_cate_type == 1) {
|
|
|
|
//需要重新采集新闻分类
|
|
|
|
DB::connection('custom_mysql')->statement("TRUNCATE `gl_news_category`");
|
|
|
|
|
|
|
|
DB::connection('custom_mysql')->statement("DELETE FROM `gl_route_map` WHERE `source` = 'news_category'");
|
|
|
|
}
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
errorLog('重新采集升级项目数据', $this->param, $e);
|
|
|
|
|
|
...
|
...
|
@@ -171,14 +198,19 @@ class UpdateController extends BaseController |
|
|
|
$old_info->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($this->param['type'] == 1) {
|
|
|
|
//需要重新采集产品分类,只排除新闻分类
|
|
|
|
$not_api_type = ['category_news'];
|
|
|
|
if ($product_cate_type == 1 && $news_cate_type == 1) {
|
|
|
|
//需要重新采集产品分类和新闻分类
|
|
|
|
$logs = UpdateLog::where('project_id', $this->param['project_id'])->orderBy('sort', 'asc')->get();
|
|
|
|
} elseif ($product_cate_type == 1 && $news_cate_type == 0) {
|
|
|
|
//只重采产品分类
|
|
|
|
$logs = UpdateLog::where('project_id', $this->param['project_id'])->where('api_type', '!=', 'category_news')->orderBy('sort', 'asc')->get();
|
|
|
|
} elseif ($product_cate_type == 0 && $news_cate_type == 1) {
|
|
|
|
//只重采新闻分类
|
|
|
|
$logs = UpdateLog::where('project_id', $this->param['project_id'])->where('api_type', '!=', 'category')->orderBy('sort', 'asc')->get();
|
|
|
|
} else {
|
|
|
|
//无需重新采集产品分类,排除产品分类和新闻分类
|
|
|
|
$not_api_type = ['category', 'category_news'];
|
|
|
|
//分类都不重采
|
|
|
|
$logs = UpdateLog::where('project_id', $this->param['project_id'])->whereNotIn('api_type', ['category', 'category_news'])->orderBy('sort', 'asc')->get();
|
|
|
|
}
|
|
|
|
$logs = UpdateLog::where('project_id', $this->param['project_id'])->whereNotIn('api_type', $not_api_type)->orderBy('sort', 'asc')->get();
|
|
|
|
|
|
|
|
foreach ($logs as $log) {
|
|
|
|
$log->status = 0;
|
...
|
...
|
|