作者 刘锟

update

@@ -237,7 +237,7 @@ class SyncProject extends Command @@ -237,7 +237,7 @@ class SyncProject extends Command
237 array_push($param['api_type'],'category_news'); 237 array_push($param['api_type'],'category_news');
238 } 238 }
239 foreach ($param['api_type'] as $v_type){ 239 foreach ($param['api_type'] as $v_type){
240 - if($v_type == 'category' || $v_type == 'category_news'){ 240 + if($v_type == 'category' || $v_type == 'category_news' || $v_type == 'tag'){
241 UpdateLog::createLog($id,$v_type,$param['get_data_url']); 241 UpdateLog::createLog($id,$v_type,$param['get_data_url']);
242 }else{ 242 }else{
243 $task_list[] = $v_type; 243 $task_list[] = $v_type;
@@ -276,6 +276,7 @@ class ProjectUpdate extends Command @@ -276,6 +276,7 @@ class ProjectUpdate extends Command
276 276
277 $model = new Product(); 277 $model = new Product();
278 $category_model = new Category(); 278 $category_model = new Category();
  279 + $keyword_model = new Keyword();
279 $extend_model = new Extend(); 280 $extend_model = new Extend();
280 $extend_info_model = new ExtendInfo(); 281 $extend_info_model = new ExtendInfo();
281 $logic = new CategoryLogic(); 282 $logic = new CategoryLogic();
@@ -297,6 +298,12 @@ class ProjectUpdate extends Command @@ -297,6 +298,12 @@ class ProjectUpdate extends Command
297 $category_arr = $category_model->list(['original_id' => ['in', array_column($item['category'], 'id')]]); 298 $category_arr = $category_model->list(['original_id' => ['in', array_column($item['category'], 'id')]]);
298 $category_id = $logic->getLastCategory(array_column($category_arr, 'id')); 299 $category_id = $logic->getLastCategory(array_column($category_arr, 'id'));
299 } 300 }
  301 + //关键词
  302 + $keyword_id = '';
  303 + if ($item['tags'] ?? []) {
  304 + $keyword_arr = $keyword_model->list(['title' => ['in', array_column($item['tags'], 'name')]]);
  305 + $keyword_id = array_column($keyword_arr,'id');
  306 + }
300 //名称去掉特殊符号 307 //名称去掉特殊符号
301 $item['ttile'] = $this->special2str($item['ttile'] ?? ''); 308 $item['ttile'] = $this->special2str($item['ttile'] ?? '');
302 309
@@ -309,6 +316,7 @@ class ProjectUpdate extends Command @@ -309,6 +316,7 @@ class ProjectUpdate extends Command
309 'intro' => $item['short_description'] ?? '', 316 'intro' => $item['short_description'] ?? '',
310 'content' => $item['content'] ?? '', 317 'content' => $item['content'] ?? '',
311 'category_id' => $category_id, 318 'category_id' => $category_id,
  319 + 'keyword_id' => $keyword_id,
312 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '', 320 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '',
313 'gallery' => Arr::a2s($gallery), 321 'gallery' => Arr::a2s($gallery),
314 'seo_mate' => Arr::a2s([ 322 'seo_mate' => Arr::a2s([
@@ -333,6 +341,7 @@ class ProjectUpdate extends Command @@ -333,6 +341,7 @@ class ProjectUpdate extends Command
333 'intro' => $item['short_description'] ?? '', 341 'intro' => $item['short_description'] ?? '',
334 'content' => $item['content'] ?? '', 342 'content' => $item['content'] ?? '',
335 'category_id' => $category_id, 343 'category_id' => $category_id,
  344 + 'keyword_id' => $keyword_id,
336 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '', 345 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '',
337 'gallery' => Arr::a2s($gallery), 346 'gallery' => Arr::a2s($gallery),
338 'seo_mate' => Arr::a2s([ 347 'seo_mate' => Arr::a2s([
@@ -33,7 +33,7 @@ class UpdateLog extends Model @@ -33,7 +33,7 @@ class UpdateLog extends Model
33 $log->project_id = $project_id; 33 $log->project_id = $project_id;
34 $log->api_type = $type; 34 $log->api_type = $type;
35 $log->api_url = $url; 35 $log->api_url = $url;
36 - $log->sort = ($type == 'category' || $type == 'category_news') ? 0 : 1; 36 + $log->sort = ($type == 'category' || $type == 'category_news' || $type == 'tag') ? 0 : 1;
37 $log->collect_status = ($type == 'category' || $type == 'category_news' || $type == 'website_info' || $type == 'tag') ? 1 : 0; 37 $log->collect_status = ($type == 'category' || $type == 'category_news' || $type == 'website_info' || $type == 'tag') ? 1 : 0;
38 return $log->save(); 38 return $log->save();
39 } 39 }