|
|
@@ -10,6 +10,7 @@ use biz\shop\classes\ShopClass;
|
|
|
use biz\shop\classes\ShopExtClass;
|
|
|
use biz\shop\models\Shop;
|
|
|
use biz\stat\classes\StatOrderCountClass;
|
|
|
+use biz\stock\classes\GoodsStockRecordClass;
|
|
|
use biz\wx\classes\WxMessageClass;
|
|
|
use bizGhs\product\classes\ProductClass;
|
|
|
use bizGhs\stat\classes\StatYjClass;
|
|
|
@@ -322,41 +323,63 @@ class OrderClass extends BaseClass
|
|
|
//暂时只考虑花材库存的回滚
|
|
|
$orderSn = $order->orderSn ?? '';
|
|
|
$itemList = OrderItemClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
|
|
|
- if (empty($itemList)) {
|
|
|
- return false;
|
|
|
+ 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;
|
|
|
+ $bigNum = 0;
|
|
|
+ $smallNum = 0;
|
|
|
+ if ($unitType == 0) {
|
|
|
+ $bigNum = $item->num;
|
|
|
+ } else {
|
|
|
+ $smallNum = $item->num;
|
|
|
+ }
|
|
|
+ $itemId = $item->itemId ?? 0;
|
|
|
+ $stockInfo = ProductClass::addStock($itemId, $bigNum, $smallNum);
|
|
|
+ $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'] = $orderSn;
|
|
|
+ $recordData['relateName'] = '系统';
|
|
|
+ StockRecordClass::addSellStockOrderCancelRecord($recordData);
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- 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;
|
|
|
- $bigNum = 0;
|
|
|
- $smallNum = 0;
|
|
|
- if ($unitType == 0) {
|
|
|
- $bigNum = $item->num;
|
|
|
- } else {
|
|
|
- $smallNum = $item->num;
|
|
|
+ $goodsList = OrderGoodsClass::getAllByCondition(['orderSn' => $orderSn], null, '*', null, true);
|
|
|
+ if (!empty($goodsList)) {
|
|
|
+ foreach ($goodsList as $key => $info) {
|
|
|
+ $sjId = $info->sjId ?? 0;
|
|
|
+ $shopId = $info->shopId ?? 0;
|
|
|
+ $mainId = $info->mainId ?? 0;
|
|
|
+ $goodsId = $info->goodsId ?? 0;
|
|
|
+ $num = $info->num ?? 0;
|
|
|
+ $respond = \bizHd\goods\classes\GoodsClass::addStock($goodsId, $mainId, $num);
|
|
|
+ $oldStock = $respond['oldStock'] ?? 0;
|
|
|
+ $newStock = $respond['newStock'] ?? 0;
|
|
|
+ $data = [];
|
|
|
+ $data['sjId'] = $sjId;
|
|
|
+ $data['shopId'] = $shopId;
|
|
|
+ $data['mainId'] = $mainId;
|
|
|
+ $data['orderSn'] = $orderSn;
|
|
|
+ $data['goodsId'] = $goodsId;
|
|
|
+ $data['goodsNum'] = $num;
|
|
|
+ $data['oldStock'] = $oldStock;
|
|
|
+ $data['newStock'] = $newStock;
|
|
|
+ $data['relateName'] = '';
|
|
|
+ GoodsStockRecordClass::cancelOrder($data);
|
|
|
}
|
|
|
- $itemId = $item->itemId ?? 0;
|
|
|
- $stockInfo = ProductClass::addStock($itemId, $bigNum, $smallNum);
|
|
|
- $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'] = $orderSn;
|
|
|
- $recordData['relateName'] = '系统';
|
|
|
- StockRecordClass::addSellStockOrderCancelRecord($recordData);
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// 扣库存
|