Bläddra i källkod

获取缓存itemId 从之前的GhsItem表 改为直接从GhsProduct表获取

林琦海 5 år sedan
förälder
incheckning
0fd4e18985

+ 2 - 2
app-ghs/controllers/ProductController.php

@@ -67,7 +67,7 @@ class ProductController extends BaseController
         $oftenItemIds = [];
         //$oftenItemIds = ProductClass::getOftenItemIds($shopId);
         //获取供应商下所有花材ID (itemIds)
-        $itemIdsInfo = ItemService::getGhsItemIds($this->sjId);
+        $itemIdsInfo = ProductClass::getGhsItemIds($this->sjId);
 
         //dd($itemInfoData);
         //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]
@@ -192,7 +192,7 @@ class ProductController extends BaseController
             $itemId = $productData['itemId'];
             //获取该花材的每扎成本价和每扎加价
             //自动调价=每扎成本价+每扎加价
-            $itemData = ItemClass::getItemData($itemId, $this->sjId);
+            // $itemData = ItemClass::getItemData($itemId, $this->sjId);
 //            if (!$itemData) {
 //                util::fail("出错拉");
 //            }

+ 1 - 1
app-hd/controllers/GhsProductController.php

@@ -38,7 +38,7 @@ class GhsProductController extends BaseController
         //常用的itemIds
         $oftenItemIds = ProductClass::getOftenItemIds($shopId);
         //获取供应商下所有花材ID (itemIds)
-        $itemIdsInfo = ItemService::getGhsItemIds($this->sjId);
+        $itemIdsInfo = ProductClass::getGhsItemIds($this->sjId);
 
         //dd($itemInfoData);
         //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]

+ 2 - 2
app-hd/controllers/ProductController.php

@@ -53,7 +53,7 @@ class ProductController extends BaseController
         //常用的itemIds
         $oftenItemIds = ProductClass::getOftenItemIds($shopId);
         //获取供应商下所有花材ID (itemIds)
-        $itemIdsInfo = ItemService::getGhsItemIds($this->sjId);
+        $itemIdsInfo = ProductClass::getGhsItemIds($this->sjId);
 
         //dd($itemInfoData);
         //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]
@@ -154,7 +154,7 @@ class ProductController extends BaseController
             //常用的itemIds
             $oftenItemIds = ProductClass::getOftenItemIds($shopId);
             //获取供应商下所有花材ID (itemIds)
-            $itemIdsInfo = ItemService::getGhsItemIds($sjId);
+            $itemIdsInfo = ProductClass::getGhsItemIds($sjId);
 
             //dd($itemInfoData);
             //组装数据: [{classId:'','className:'',child:[{itemInfoData}]}]

+ 1 - 1
biz-ghs/order/classes/CheckOrderClass.php

@@ -134,7 +134,7 @@ class CheckOrderClass extends BaseClass
 
         //获取itemId=>classId
         $sjId = $orderData['sjId'];
-        $itemIdClassIdMap = ItemClass::getItemIdClassIdMap($sjId);
+        $itemIdClassIdMap = ProductClass::getItemIdClassIdMap($sjId);
 
         if($orderInfo) {
             foreach ($orderInfo as $v) {

+ 28 - 0
biz-ghs/product/classes/ProductClass.php

@@ -1016,4 +1016,32 @@ class ProductClass extends BaseClass
     {
         return self::updateById($productId, ['delStatus' => $delStatus]);
     }
+
+    //获取itemId=>classId
+    public static function getItemIdClassIdMap($sjId)
+    {
+        $map = [];
+        $itemData = self::getGhsItemAll($sjId, "itemId,classId");
+        foreach ($itemData as $v) {
+            $map[$v['itemId']] = $v['classId'];
+        }
+        return $map;
+    }
+
+    //获取当前供应商下的所有item
+    public static function getGhsItemAll($sjId, $select = "*")
+    {
+        $where = [
+            'sjId' => $sjId
+        ];
+        $data = self::getAllList($select, $where);
+        return $data;
+    }
+
+    //获取所有的花材ID
+    public static function getGhsItemIds($sjId)
+    {
+        $data = self::getGhsItemAll($sjId, 'classId,itemId');
+        return $data;
+    }
 }