|
|
@@ -551,40 +551,42 @@ class OrderClass extends BaseClass
|
|
|
$order->save();
|
|
|
|
|
|
// 重新占用库存(与取消订单时的库存回滚相反)
|
|
|
- $item = OrderItemClass::getByCondition(['orderSn' => $order->orderSn], true);
|
|
|
- if (empty($item)) {
|
|
|
- return true;
|
|
|
- }
|
|
|
- $ptItemId = $item->ptItemId ?? 0;
|
|
|
- $sjId = $item->sjId ?? 0;
|
|
|
- $shopId = $item->shopId ?? 0;
|
|
|
- $mainId = $item->mainId ?? 0;
|
|
|
- $ratio = $item->ratio ?? 20;
|
|
|
- $unitType = $item->unitType ?? 0;
|
|
|
- if ($unitType == 0) {
|
|
|
- $bigNum = $item->num;
|
|
|
- $smallNum = 0;
|
|
|
- } else {
|
|
|
- $bigNum = 0;
|
|
|
- $smallNum = $item->num;
|
|
|
- }
|
|
|
- $itemId = $item->itemId ?? 0;
|
|
|
-
|
|
|
- // 重新扣减库存(占用库存)
|
|
|
- $stockInfo = ProductClass::decreaseStock($itemId, $bigNum, $smallNum, true);
|
|
|
- $recordData = [];
|
|
|
- $recordData['sjId'] = $sjId;
|
|
|
- $recordData['shopId'] = $shopId;
|
|
|
- $recordData['mainId'] = $mainId;
|
|
|
- $recordData['itemId'] = $ptItemId;
|
|
|
- $recordData['itemNum'] = ProductClass::mergeItemNum($bigNum, $smallNum, $ratio);
|
|
|
- $recordData['oldStock'] = $stockInfo['oldStock'];
|
|
|
- $recordData['newStock'] = $stockInfo['newStock'];
|
|
|
- $recordData['productId'] = $itemId;
|
|
|
- $recordData['orderSn'] = $order->orderSn;
|
|
|
- $recordData['relateName'] = '恢复取消的订单';
|
|
|
- StockRecordClass::hdKdAddRecord($recordData);
|
|
|
+ $orderSn = $order->orderSn ?? '';
|
|
|
+ $itemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
|
|
|
+ if (!empty($itemList)) {
|
|
|
+ foreach ($itemList as $item) {
|
|
|
+ $ptItemId = $item->ptItemId ?? 0;
|
|
|
+ $sjId = $item->sjId ?? 0;
|
|
|
+ $shopId = $item->shopId ?? 0;
|
|
|
+ $mainId = $item->mainId ?? 0;
|
|
|
+ $ratio = $item->ratio ?? 20;
|
|
|
+ $unitType = $item->unitType ?? 0;
|
|
|
+ if ($unitType == 0) {
|
|
|
+ $bigNum = $item->num;
|
|
|
+ $smallNum = 0;
|
|
|
+ } else {
|
|
|
+ $bigNum = 0;
|
|
|
+ $smallNum = $item->num;
|
|
|
+ }
|
|
|
+ $itemId = $item->itemId ?? 0;
|
|
|
|
|
|
+ // 重新扣减库存(占用库存)
|
|
|
+ $stockInfo = ProductClass::decreaseStock($itemId, $bigNum, $smallNum, true);
|
|
|
+ $recordData = [];
|
|
|
+ $recordData['sjId'] = $sjId;
|
|
|
+ $recordData['shopId'] = $shopId;
|
|
|
+ $recordData['mainId'] = $mainId;
|
|
|
+ $recordData['itemId'] = $ptItemId;
|
|
|
+ $recordData['itemNum'] = ProductClass::mergeItemNum($bigNum, $smallNum, $ratio);
|
|
|
+ $recordData['oldStock'] = $stockInfo['oldStock'];
|
|
|
+ $recordData['newStock'] = $stockInfo['newStock'];
|
|
|
+ $recordData['productId'] = $itemId;
|
|
|
+ $recordData['orderSn'] = $order->orderSn;
|
|
|
+ $recordData['relateName'] = '恢复取消的订单';
|
|
|
+ StockRecordClass::hdKdAddRecord($recordData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
// 扣库存
|