zxhxx пре 1 година
родитељ
комит
bc34f4979d
1 измењених фајлова са 18 додато и 22 уклоњено
  1. 18 22
      Model/Cart/MCart.Class.php

+ 18 - 22
Model/Cart/MCart.Class.php

@@ -1772,35 +1772,31 @@ class MCart
             }
             $inventoryMap[$shopId] = $inventoryResult->getData();
         }
-        var_dump($skuIds)  ;
-        echo "----------------";
         //获取当前skuIds的主单位,及换算比例
         $skuConversionResult = $this->objMSku->getConversion($skuIds);
         if (!$skuConversionResult->isSuccess()) {
             return ResultWrapper::fail($skuConversionResult->getData(),$skuConversionResult->getErrorCode());
         }
         $skuConversionMapping = $skuConversionResult->getData();
-        var_dump($skuConversionMapping);
-        echo "----------------";
-        var_dump($data);
-        exit();
         foreach ($data as $key => &$goods) {
-            $thisSku = $skuConversionMapping[$goods['skuId']];
-            if (!isset($inventoryMap[$goods['shopId']])){
-                return ResultWrapper::fail('未获取到库存信息',ErrorCode::$paramError);
-            }
-            $row = $inventoryMap[$goods['shopId']];
-            $goods['inventoryNum'] = isset($row[$goods['skuId']]['num']) ? $row[$goods['skuId']]['num'] : 0;
-            $goods['costPrice'] = 0;
-            $goods['conversion'] = $thisSku['conversion'];//换算比例
-            //判断是否开启预售
-            if ($goods['isDistribution'] == StatusCode::$delete) {
-                //没有开启需要检测库存
-                if ($goods['inventoryNum'] < $goods['buyNum']) {
-                    $goods['isInvalid'] = StatusCode::$delete;
-                    $goods['invalidMsg'] = '商品库存不足';
-                    $this->invalidData[] = $goods;
-                    unset($data[$key]);
+            if(isset($skuConversionMapping[$goods['skuId']])) {
+                $thisSku = $skuConversionMapping[$goods['skuId']];
+                if (!isset($inventoryMap[$goods['shopId']])) {
+                    return ResultWrapper::fail('未获取到库存信息', ErrorCode::$paramError);
+                }
+                $row = $inventoryMap[$goods['shopId']];
+                $goods['inventoryNum'] = isset($row[$goods['skuId']]['num']) ? $row[$goods['skuId']]['num'] : 0;
+                $goods['costPrice'] = 0;
+                $goods['conversion'] = $thisSku['conversion'];//换算比例
+                //判断是否开启预售
+                if ($goods['isDistribution'] == StatusCode::$delete) {
+                    //没有开启需要检测库存
+                    if ($goods['inventoryNum'] < $goods['buyNum']) {
+                        $goods['isInvalid'] = StatusCode::$delete;
+                        $goods['invalidMsg'] = '商品库存不足';
+                        $this->invalidData[] = $goods;
+                        unset($data[$key]);
+                    }
                 }
             }
         }