正在显示
1 个修改的文件
包含
37 行增加
和
20 行删除
| @@ -13,7 +13,9 @@ use App\Http\Controllers\Bside\BaseController; | @@ -13,7 +13,9 @@ use App\Http\Controllers\Bside\BaseController; | ||
| 13 | use App\Models\Com\UpdateLog; | 13 | use App\Models\Com\UpdateLog; |
| 14 | use App\Models\Com\UpdateOldInfo; | 14 | use App\Models\Com\UpdateOldInfo; |
| 15 | use App\Models\Domain\DomainInfo; | 15 | use App\Models\Domain\DomainInfo; |
| 16 | +use App\Models\Product\Category; | ||
| 16 | use App\Models\Project\ProjectUpdateTdk; | 17 | use App\Models\Project\ProjectUpdateTdk; |
| 18 | +use App\Models\Template\BTemplate; | ||
| 17 | use App\Services\ProjectServer; | 19 | use App\Services\ProjectServer; |
| 18 | use Illuminate\Support\Facades\DB; | 20 | use Illuminate\Support\Facades\DB; |
| 19 | 21 | ||
| @@ -42,7 +44,7 @@ class UpdateController extends BaseController | @@ -42,7 +44,7 @@ class UpdateController extends BaseController | ||
| 42 | ]); | 44 | ]); |
| 43 | try { | 45 | try { |
| 44 | ProjectUpdateTdk::add_task($this->param['project_id']); | 46 | ProjectUpdateTdk::add_task($this->param['project_id']); |
| 45 | - }catch (\Exception $e){ | 47 | + } catch (\Exception $e) { |
| 46 | $this->fail($e->getMessage()); | 48 | $this->fail($e->getMessage()); |
| 47 | } | 49 | } |
| 48 | $this->response('任务添加成功'); | 50 | $this->response('任务添加成功'); |
| @@ -80,6 +82,19 @@ class UpdateController extends BaseController | @@ -80,6 +82,19 @@ class UpdateController extends BaseController | ||
| 80 | $this->fail('非升级无法进行采集操作'); | 82 | $this->fail('非升级无法进行采集操作'); |
| 81 | } | 83 | } |
| 82 | 84 | ||
| 85 | + //产品分类开启了可视化之后,不能重新采集 | ||
| 86 | + $category_list = Category::where('project_id', $this->param['project_id'])->get(); | ||
| 87 | + if ($category_list->count() > 0) { | ||
| 88 | + $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT, BTemplate::IS_LIST);//获取模版id | ||
| 89 | + foreach ($category_list as $category) { | ||
| 90 | + if ($this->getIsRenovation(BTemplate::SOURCE_PRODUCT, BTemplate::IS_LIST, $template_id, $category['id']) == 1) { | ||
| 91 | + //有分类开启了可视化 | ||
| 92 | + $this->param['type'] = 0; | ||
| 93 | + break; | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + | ||
| 83 | $test_domain = $this->param['test_domain'] ?? ''; | 98 | $test_domain = $this->param['test_domain'] ?? ''; |
| 84 | if ($test_domain) { | 99 | if ($test_domain) { |
| 85 | $test_domain_arr = parse_url($test_domain); | 100 | $test_domain_arr = parse_url($test_domain); |
| @@ -94,42 +109,41 @@ class UpdateController extends BaseController | @@ -94,42 +109,41 @@ class UpdateController extends BaseController | ||
| 94 | } | 109 | } |
| 95 | 110 | ||
| 96 | try { | 111 | try { |
| 97 | - if($this->param['old_collect'] == 1){ | 112 | + if ($this->param['old_collect'] == 1) { |
| 98 | //现有数据需要重新采集页面 | 113 | //现有数据需要重新采集页面 |
| 99 | $collect_routes = ''; | 114 | $collect_routes = ''; |
| 100 | - if(isset($this->param['collect_routes'])){ | 115 | + if (isset($this->param['collect_routes'])) { |
| 101 | //填写了采集路由 | 116 | //填写了采集路由 |
| 102 | - $routes_arr = explode(',',$this->param['collect_routes']); | ||
| 103 | - foreach ($routes_arr as &$route){ | ||
| 104 | - $route = "'".$route."'"; | 117 | + $routes_arr = explode(',', $this->param['collect_routes']); |
| 118 | + foreach ($routes_arr as &$route) { | ||
| 119 | + $route = "'" . $route . "'"; | ||
| 105 | } | 120 | } |
| 106 | - $collect_routes = implode(',',$routes_arr); | 121 | + $collect_routes = implode(',', $routes_arr); |
| 107 | } | 122 | } |
| 108 | 123 | ||
| 109 | DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'"); | 124 | DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'"); |
| 110 | if ($domain_info) { | 125 | if ($domain_info) { |
| 111 | //已上线项目 | 126 | //已上线项目 |
| 112 | - if($collect_routes){ | ||
| 113 | - DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0,`domain` = '" . $test_domain . "' WHERE `language` = '' AND `route` IN (".$collect_routes.")"); | ||
| 114 | - }else{ | 127 | + if ($collect_routes) { |
| 128 | + DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0,`domain` = '" . $test_domain . "' WHERE `language` = '' AND `route` IN (" . $collect_routes . ")"); | ||
| 129 | + } else { | ||
| 115 | DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0,`domain` = '" . $test_domain . "' WHERE `language` = ''"); | 130 | DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0,`domain` = '" . $test_domain . "' WHERE `language` = ''"); |
| 116 | } | 131 | } |
| 117 | } else { | 132 | } else { |
| 118 | - if($collect_routes){ | ||
| 119 | - DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = '' AND `route` IN (".$collect_routes.")"); | ||
| 120 | - }else{ | 133 | + if ($collect_routes) { |
| 134 | + DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = '' AND `route` IN (" . $collect_routes . ")"); | ||
| 135 | + } else { | ||
| 121 | DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''"); | 136 | DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''"); |
| 122 | } | 137 | } |
| 123 | } | 138 | } |
| 124 | } | 139 | } |
| 125 | 140 | ||
| 126 | if ($this->param['type'] == 1) { | 141 | if ($this->param['type'] == 1) { |
| 127 | - //需要重新采集分类 | 142 | + //需要重新采集产品分类 |
| 128 | DB::connection('custom_mysql')->statement("TRUNCATE `gl_product_category`"); | 143 | DB::connection('custom_mysql')->statement("TRUNCATE `gl_product_category`"); |
| 129 | DB::connection('custom_mysql')->statement("TRUNCATE `gl_product_category_related`"); | 144 | DB::connection('custom_mysql')->statement("TRUNCATE `gl_product_category_related`"); |
| 130 | - DB::connection('custom_mysql')->statement("TRUNCATE `gl_news_category`"); | ||
| 131 | 145 | ||
| 132 | - DB::connection('custom_mysql')->statement("DELETE FROM `gl_route_map` WHERE `source` = 'product_category' OR `source` = 'news_category'"); | 146 | + DB::connection('custom_mysql')->statement("DELETE FROM `gl_route_map` WHERE `source` = 'product_category'"); |
| 133 | } | 147 | } |
| 134 | } catch (\Exception $e) { | 148 | } catch (\Exception $e) { |
| 135 | errorLog('重新采集升级项目数据', $this->param, $e); | 149 | errorLog('重新采集升级项目数据', $this->param, $e); |
| @@ -153,16 +167,19 @@ class UpdateController extends BaseController | @@ -153,16 +167,19 @@ class UpdateController extends BaseController | ||
| 153 | } | 167 | } |
| 154 | 168 | ||
| 155 | if ($this->param['type'] == 1) { | 169 | if ($this->param['type'] == 1) { |
| 156 | - //需要重新采集分类 | ||
| 157 | - $logs = UpdateLog::where('project_id', $this->param['project_id'])->orderBy('sort', 'asc')->get(); | 170 | + //需要重新采集产品分类,只排除新闻分类 |
| 171 | + $not_api_type = ['category_news']; | ||
| 158 | } else { | 172 | } else { |
| 159 | - $logs = UpdateLog::where('project_id', $this->param['project_id'])->whereNotIn('api_type', ['category', 'category_news'])->orderBy('sort', 'asc')->get(); | 173 | + //无需重新采集产品分类,排除产品分类和新闻分类 |
| 174 | + $not_api_type = ['category', 'category_news']; | ||
| 160 | } | 175 | } |
| 176 | + $logs = UpdateLog::where('project_id', $this->param['project_id'])->whereNotIn('api_type', $not_api_type)->orderBy('sort', 'asc')->get(); | ||
| 161 | 177 | ||
| 162 | foreach ($logs as $log) { | 178 | foreach ($logs as $log) { |
| 163 | $log->status = 0; | 179 | $log->status = 0; |
| 164 | 180 | ||
| 165 | - if (!in_array($log->api_type, ['website_info', 'tag', 'category', 'category_news'])) { | 181 | + if (!in_array($log->api_type, ['website_info', 'tag', 'category'])) { |
| 182 | + //website_info,tag,category三种类型无需采集页面 | ||
| 166 | $log->collect_status = 0; | 183 | $log->collect_status = 0; |
| 167 | } | 184 | } |
| 168 | 185 |
-
请 注册 或 登录 后发表评论