|
|
@@ -261,16 +261,20 @@ class OrderClass extends BaseClass
|
|
|
}
|
|
|
$orderSn = $order->orderSn ?? '';
|
|
|
if ($order->status == self::ORDER_STATUS_CANCEL) {
|
|
|
- noticeUtil::push('注意,散客订单:' . $orderSn . ',付款成功但订单已取消,关键词 cancel_get_money', '15280215347');
|
|
|
$shopId = $order->shopId;
|
|
|
$shop = ShopClass::getById($shopId, true);
|
|
|
- if (!empty($shop)) {
|
|
|
- // HdRefundClass::onlyRefundAmount($shop, $order);
|
|
|
- // 恢复取消的订单,即:把订单的状态从取消状态变成待付款状态
|
|
|
- $res = self::recoverOrderToPay($order);
|
|
|
- if ($res == false) {
|
|
|
- noticeUtil::push('恢复取消的订单失败,订单号:' . $orderSn, '15280215347');
|
|
|
- }
|
|
|
+ if (empty($shop)) {
|
|
|
+ noticeUtil::push('注意,散客订单:' . $orderSn . ',付款成功但订单已取消,没有找到门店,关键词 cancel_get_money', '15280215347');
|
|
|
+ util::stop("SUCCESS");
|
|
|
+ }
|
|
|
+ Yii::$app->params['errorReport'] = 1;
|
|
|
+ try {
|
|
|
+ //恢复取消的订单
|
|
|
+ self::recoverOrderToPay($order);
|
|
|
+ } catch (\Exception $exception) {
|
|
|
+ $errMsg = $exception->getMessage();
|
|
|
+ noticeUtil::push('注意,散客订单:' . $orderSn . ',付款成功但订单已取消,原因' . $errMsg . ',关键词 cancel_get_money', '15280215347');
|
|
|
+ util::stop("SUCCESS");
|
|
|
}
|
|
|
}
|
|
|
if ($order->payStatus == 1) {
|
|
|
@@ -548,41 +552,39 @@ class OrderClass extends BaseClass
|
|
|
|
|
|
// 重新占用库存(与取消订单时的库存回滚相反)
|
|
|
$item = OrderItemClass::getByCondition(['orderSn' => $order->orderSn], true);
|
|
|
- if (!empty($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);
|
|
|
+ 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 {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- return true;
|
|
|
+ $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);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// 扣库存
|