|
@@ -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]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|