cqpCow 1 year ago
parent
commit
ffdb92a40c
1 changed files with 2 additions and 0 deletions
  1. 2 0
      app/Service/ImportService.php

+ 2 - 0
app/Service/ImportService.php

@@ -412,6 +412,7 @@ class ImportService extends Service
             ->where('top_depart_id',$top_depart_id)
             ->pluck('id','title')
             ->toArray();
+        $category_parent = array_unique(array_column($category,'parent'));
 
         $time = time();
 
@@ -447,6 +448,7 @@ class ImportService extends Service
             $tmp['code'] = $value['1'];
             if(empty($category[$value['2']])) return [false,'产品分类:' . $value['2'] . '不存在'];
             $tmp['product_category_id'] = $category[$value['2']];
+            if(in_array($tmp['product_category_id'],$category_parent)) return [false,'产品分类:' . $value['2'] . '下存在子分类,请将产品建与最底层分类下'];
             $parentsId = $this->findParentIds($tmp['product_category_id'], $category_list);
             array_unshift($parentsId, $tmp['product_category_id']);
             $result = array_reverse($parentsId);