From ec69ae6c092447fc6406447f5b7d7fe65d7166e4 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 22 Nov 2024 15:54:10 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E8=AE=A2=E5=8D=95):=20=E9=87=8D?= =?UTF-8?q?=E6=9E=84=E9=80=80=E6=AC=BE=E9=80=BB=E8=BE=91=E5=B9=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=BA=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 注释掉现金支付方式下的退款操作 - 新增更新产品库存的逻辑 - 优化退款流程,确保库存和销量的准确更新 --- app/admin/logic/store_order/StoreOrderLogic.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/admin/logic/store_order/StoreOrderLogic.php b/app/admin/logic/store_order/StoreOrderLogic.php index 9eae12c4b..61cc44f0d 100644 --- a/app/admin/logic/store_order/StoreOrderLogic.php +++ b/app/admin/logic/store_order/StoreOrderLogic.php @@ -145,7 +145,7 @@ class StoreOrderLogic extends BaseLogic } //现金支付 if ($detail['pay_type'] = PayEnum::CASH_PAY) { - PayNotifyLogic::cash_refund($params['order_id']); + // PayNotifyLogic::cash_refund($params['order_id']); self::refundProduct($detail, $params); return '退款成功'; @@ -189,6 +189,7 @@ class StoreOrderLogic extends BaseLogic { $refund_price = $params['refund_price']; $refund_num = 0; + $updateData=[]; foreach ($params['product_arr'] as $k => $v) { $find = StoreOrderCartInfo::where('oid', $detail['id'])->where('product_id', $v['product_id'])->find(); if ($find) { @@ -208,6 +209,12 @@ class StoreOrderLogic extends BaseLogic $value['update_time'] = strtotime($value['update_time']); StoreFinanceFlowProduct::create($value); } + $updateData[] = [ + 'id' => $v['product_id'], + 'store_id' => $find['store_id'], + 'stock' => ['inc',$v['cart_num']], + 'sales' => ['dec', $v['cart_num']] + ]; } } $village_uid = StoreFinanceFlow::where('order_id', $detail['id'])->where('financial_type', 14)->value('other_uid'); @@ -217,6 +224,7 @@ class StoreOrderLogic extends BaseLogic $detail['refund_price']=$refund_price; StoreOrder::where('id', $detail['id'])->inc('refund_price',$refund_price)->inc('refund_num',$refund_num)->update(); CommissionnLogic::setStore($detail, $village_uid, $brigade_uid, $transaction_id); + (new StoreBranchProduct())->saveAll($updateData); } }