From 375d91504593e0e39caf4a75e3fe087ce742c600 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Thu, 22 Aug 2024 17:43:51 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=92=8C=E6=94=AF=E4=BB=98=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=BB=A5=E4=BC=98=E5=8C=96=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E5=92=8C=E8=B4=A2=E5=8A=A1=E6=B5=81=E6=B0=B4=E7=9A=84=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/order/OrderLogic.php | 19 ++----------------- app/common/logic/PayNotifyLogic.php | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 548a82138..1569872b7 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -340,32 +340,17 @@ class OrderLogic extends BaseLogic $order = StoreOrder::create($_order); $goods_list = $orderInfo['cart_list']; - $updateData = []; - $updateDataTwo = []; + foreach ($goods_list as $k => $v) { $goods_list[$k]['oid'] = $order->id; $goods_list[$k]['uid'] = $uid; $goods_list[$k]['cart_id'] = implode(',', $cartId); $goods_list[$k]['delivery_id'] = $params['store_id']; //商家id - - $id = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $params['store_id'])->value('id'); - if ($id) { - $updateData[] = [ - 'id' => $id, - 'sales' => ['inc', $v['cart_num']], - 'stock' => ['dec', $v['cart_num']], - ]; - } - $updateDataTwo[] = [ - 'id' => $v['product_id'], - 'sales' => ['inc', $v['cart_num']] - ]; } (new StoreOrderCartInfo())->saveAll($goods_list); $where = ['is_pay' => 0]; Cart::whereIn('id', $cartId)->where($where)->update(['is_pay' => 1]); - (new StoreBranchProduct())->saveAll($updateData); - (new StoreProduct())->saveAll($updateDataTwo); + Db::commit(); return $order; } catch (\Exception $e) { diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 681993271..3b1a47d38 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -19,6 +19,7 @@ use app\common\model\store_cash_finance_flow\StoreCashFinanceFlow; use app\common\model\store_finance_flow\StoreFinanceFlow; use app\common\model\store_order\StoreOrder; use app\common\model\store_order_cart_info\StoreOrderCartInfo; +use app\common\model\store_product\StoreProduct; use app\common\model\store_product_log\StoreProductLog; use app\common\model\system_store\SystemStore; use app\common\model\user\User; @@ -324,7 +325,7 @@ class PayNotifyLogic extends BaseLogic StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]); //处理财务流水退还 - (new StoreFinanceFlowLogic())->store_finance_back($orderSn,$order['store_id']); + (new StoreFinanceFlowLogic())->store_finance_back($orderSn, $order['store_id']); if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) { if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额支付 $user = User::where('id', $order['uid'])->findOrEmpty(); @@ -358,7 +359,6 @@ class PayNotifyLogic extends BaseLogic $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $order['pay_price'], '', 1); self::addStock($order['id']); //微信 return true; - // self::afterPay($order,$extra['transaction_id']); } /** @@ -393,7 +393,7 @@ class PayNotifyLogic extends BaseLogic //增加数量 self::addStock($order['id']); StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]); - (new StoreFinanceFlowLogic())->store_finance_back($orderSn,$order['store_id']); + (new StoreFinanceFlowLogic())->store_finance_back($orderSn, $order['store_id']); return true; } @@ -572,7 +572,25 @@ class PayNotifyLogic extends BaseLogic */ public static function afterPay($order, $transaction_id = 0) { + $updateData = []; + $updateDataTwo = []; StoreOrderCartInfo::where('oid', $order['id'])->update(['is_pay' => 1]); + $arr = StoreOrderCartInfo::where('oid', $order['id'])->field('id,oid,product_id,store_id,cart_num')->select(); + foreach ($arr as $k => $v) { + $updateData[] = [ + 'store_id' => $v['store_id'], + 'product_id' => $v['product_id'], + 'sales' => ['inc', $v['cart_num']], + 'stock' => ['dec', $v['cart_num']], + ]; + + $updateDataTwo[] = [ + 'id' => $v['product_id'], + 'sales' => ['inc', $v['cart_num']] + ]; + } + (new StoreBranchProduct())->saveAll($updateData); + (new StoreProduct())->saveAll($updateDataTwo); $financeLogic = new StoreFinanceFlowLogic(); $off_activity = Config::where('name', 'off_activity')->value('value'); $village_uid = 0;