作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !187
@@ -268,31 +268,10 @@ class ProjectUpdate extends Command @@ -268,31 +268,10 @@ class ProjectUpdate extends Command
268 } 268 }
269 //分类 269 //分类
270 $category_id = ''; 270 $category_id = '';
271 - //产品类型,2Featured Products,3Hot Products  
272 - $product_type = '';  
273 -  
274 if ($item['category'] ?? []) { 271 if ($item['category'] ?? []) {
275 - $type_arr = [];  
276 - $new_category = [];  
277 - foreach ($item['category'] as $cate) {  
278 - if ($cate['parent'] == 0 && $cate['name'] == 'Featured Products') {  
279 - $type_arr[] = 2;  
280 - } elseif ($cate['parent'] == 0 && $cate['name'] == 'Hot Products') {  
281 - $type_arr[] = 3;  
282 - } else {  
283 - $new_category[] = $cate['id'];  
284 - }  
285 - }  
286 -  
287 - if ($type_arr) {  
288 - $product_type = ',' . implode(',', $type_arr);  
289 - }  
290 -  
291 - if ($new_category) {  
292 - $category_arr = $category_model->list(['original_id' => ['in', $new_category]]); 272 + $category_arr = $category_model->list(['original_id' => ['in', array_column($item['category'], 'id')]]);
293 $category_id = $logic->getLastCategory(array_column($category_arr, 'id')); 273 $category_id = $logic->getLastCategory(array_column($category_arr, 'id'));
294 } 274 }
295 - }  
296 try { 275 try {
297 $item['ttile'] = $this->special2str($item['ttile'] ?? ''); 276 $item['ttile'] = $this->special2str($item['ttile'] ?? '');
298 $id = $model->insertGetId([ 277 $id = $model->insertGetId([
@@ -303,7 +282,6 @@ class ProjectUpdate extends Command @@ -303,7 +282,6 @@ class ProjectUpdate extends Command
303 'category_id' => $category_id, 282 'category_id' => $category_id,
304 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '', 283 'thumb' => isset($gallery[0]) ? Arr::a2s($gallery[0]) : '',
305 'gallery' => Arr::a2s($gallery), 284 'gallery' => Arr::a2s($gallery),
306 - 'product_type' => $product_type,  
307 'seo_mate' => Arr::a2s([ 285 'seo_mate' => Arr::a2s([
308 'title' => $item['ttile'], 286 'title' => $item['ttile'],
309 'keyword' => $item['keywords'] ?? '', 287 'keyword' => $item['keywords'] ?? '',
@@ -325,6 +303,12 @@ class ProjectUpdate extends Command @@ -325,6 +303,12 @@ class ProjectUpdate extends Command
325 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL; 303 echo 'date:' . date('Y-m-d H:i:s') . ', task_id: ' . $task->id . ', error: ' . $e->getMessage() . PHP_EOL;
326 continue; 304 continue;
327 } 305 }
  306 + } else {
  307 + if ($item['category'] ?? []) {
  308 + $category_arr = $category_model->list(['original_id' => ['in', array_column($item['category'], 'id')]]);
  309 + $category_id = $logic->getLastCategory(array_column($category_arr, 'id'));
  310 + $model->edit(['category_id', $category_id], ['id' => $product['id']]);
  311 + }
328 } 312 }
329 } 313 }
330 } 314 }
@@ -467,7 +451,7 @@ class ProjectUpdate extends Command @@ -467,7 +451,7 @@ class ProjectUpdate extends Command
467 DB::disconnect('custom_mysql'); 451 DB::disconnect('custom_mysql');
468 452
469 $task->status = UpdateLog::STATUS_COM;//同步完成 453 $task->status = UpdateLog::STATUS_COM;//同步完成
470 - if($is_flush){ 454 + if ($is_flush) {
471 $task->collect_status = UpdateLog::COLLECT_STATUS_UN; 455 $task->collect_status = UpdateLog::COLLECT_STATUS_UN;
472 } 456 }
473 $task->save(); 457 $task->save();