Просмотр исходного кода

商品可以添加一级分类

evoxwht 2 лет назад
Родитель
Сommit
7f2cf94e88

+ 1 - 1
crmeb/app/dao/product/product/StoreProductDao.php

@@ -122,7 +122,7 @@ class StoreProductDao extends BaseDao
         })->when(isset($where['cid']) && $where['cid'], function ($query) use ($where) {
             $query->whereIn('id', function ($query) use ($where) {
                 $query->name('store_product_cate')->whereIn('cate_id', function ($query) use ($where) {
-                    $query->name('store_category')->where('pid', $where['cid'])->field('id')->select();
+                    $query->name('store_category')->where('pid', $where['cid'])->whereOr('id', $where['cid'])->field('id')->select();
                 })->field('product_id')->select();
             });
         })->when(isset($where['coupon_category_id']) && $where['coupon_category_id'] != '', function ($query) use ($where) {

+ 5 - 5
crmeb/app/services/product/product/StoreCategoryServices.php

@@ -97,11 +97,11 @@ class StoreCategoryServices extends BaseServices
         if ($show !== '') $where['is_show'] = $show;
         if (!$type) $where['pid'] = 0;
         $data = get_tree_children($this->dao->getTierList($where, ['id', 'id as value', 'cate_name as label', 'cate_name as title', 'pid']), 'children', 'id');
-        foreach ($data as &$item) {
-            if (!isset($item['children'])) {
-                $item['disabled'] = true;
-            }
-        }
+//        foreach ($data as &$item) {
+//            if (!isset($item['children'])) {
+//                $item['disabled'] = true;
+//            }
+//        }
         return $data;
     }
 

+ 1 - 1
crmeb/app/services/product/product/StoreProductServices.php

@@ -620,7 +620,7 @@ class StoreProductServices extends BaseServices
                 $cateGory = $storeCategoryServices->getColumn([['id', 'IN', $cate_id]], 'id,pid', 'id');
                 foreach ($cate_id as $cid) {
                     if ($cid && isset($cateGory[$cid]['pid'])) {
-                        $cateData[] = ['product_id' => $id, 'cate_id' => $cid, 'cate_pid' => $cateGory[$cid]['pid'], 'status' => $data['is_show'], 'add_time' => $time];
+                        $cateData[] = ['product_id' => $id, 'cate_id' => $cid, 'cate_pid' => $cateGory[$cid]['pid'] ?: $cid, 'status' => $data['is_show'], 'add_time' => $time];
                     }
                 }
                 $storeProductCateServices->change($id, $cateData);