林琦海 5 лет назад
Родитель
Сommit
ef044dba39

+ 5 - 4
app/ghs/controllers/ProductController.php

@@ -33,6 +33,7 @@ class ProductController extends BaseController
         $itemIdsInfo = ItemService::getGhsItemIds($this->sjId);
 
         $itemIds = array_column($itemIdsInfo,'itemId');
+
         if($py){
             $pyNameItemIds = ItemClass::getItemIdsByPyName($py);
             $itemIds = array_intersect($itemIds,$pyNameItemIds);
@@ -45,16 +46,16 @@ class ProductController extends BaseController
             if(!$shopId){
                 $shopId = $this->shopId;
             }
-          
+
             $waringItemIds = ProductClass::getItemIdsWarning($this->sjId,$shopId);
             $itemIds = array_intersect($itemIds,$waringItemIds);
         }
 
 
-        $itemInfoData = ProductClass::getProductInfoByItemIds($itemIds);
+        $itemInfoData = ProductClass::getProductInfoByItemIds($itemIds,$this->shopId);
 
         //常用的itemIds
-        $oftenItemIds = ProductClass::getOftenItemIds($this->sjId);
+        $oftenItemIds = ProductClass::getOftenItemIds($this->shopId);
 
         //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]
         $data = ProductService::assembleData($classIds,$itemIdsInfo,$itemInfoData,$oftenItemIds);
@@ -74,7 +75,7 @@ class ProductController extends BaseController
             $pyNameItemIds = ItemClass::getItemIdsByPyName($pyName);
             $itemIds = array_intersect($itemIds,$pyNameItemIds);
         }
-        $data = ProductClass::getProductInfoByItemIds($itemIds);
+        $data = ProductClass::getProductInfoByItemIds($itemIds,$this->shopId);
         util::success($data);
     }
 

+ 4 - 4
biz-ghs/product/classes/ProductClass.php

@@ -19,9 +19,9 @@ class ProductClass extends BaseClass
     const LOCK_PRICE = 'lock_price'; //改价锁
 
     //根据itemIds获取相应的花材信息
-    public static function getProductInfoByItemIds(array $itemIds)
+    public static function getProductInfoByItemIds(array $itemIds,$shopId)
     {
-        $where = ['itemId' => ['in', $itemIds], 'delStatus' => 0];
+        $where = ['itemId' => ['in', $itemIds], 'delStatus' => 0,'shopId'=>$shopId];
         $data = self::getAllList('*', $where);
         $data = self::groupItemBaseInfo($data);
         return $data;
@@ -131,9 +131,9 @@ class ProductClass extends BaseClass
 
 
     //获取常用的itemIds
-    public static function getOftenItemIds($merchantId)
+    public static function getOftenItemIds($shopId)
     {
-        $data = self::getAllList("itemId", ['merchantId' => $merchantId], 'actualSold desc');
+        $data = self::getAllList("itemId", ['shopId' => $shopId], 'actualSold desc');
         if ($data) {
             $data = array_column($data, 'itemId');
         }

+ 9 - 5
biz-ghs/product/services/ProductService.php

@@ -53,6 +53,7 @@ class ProductService extends BaseService
             ]
         ];
         $classData = [];
+
         foreach ($classIds as $v){
             $classId = $v['id'];
             if($classId > 0 ){
@@ -61,12 +62,15 @@ class ProductService extends BaseService
                 $tmp['className'] = $v['name'];
                 $items = $classMapItem[$classId]??[];
                 if($items){
-                    foreach ($itemInfoData as $v){
-                        if(in_array($v['itemId'],$items)){
-                            $v['classId'] = $classId; //前端要求增加classId 2021.1.31 linqh
-                            $tmp['child'][] = $v;
-
+                    if($itemInfoData){
+                        foreach ($itemInfoData as $v){
+                            if(in_array($v['itemId'],$items)){
+                                $v['classId'] = $classId; //前端要求增加classId 2021.1.31 linqh
+                                $tmp['child'][] = $v;
+                            }
                         }
+                    }else{
+                        $tmp['child'] = [];
                     }
                 }else{
                     $tmp['child'] = [];