From bc2ed0635a25e2c80d8a50d3cd4df6a17de2a394 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 20 Aug 2024 21:09:50 +0800 Subject: [PATCH] =?UTF-8?q?feat(StoreFinanceFlowLogic):=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=86=E8=B4=A2=E5=8A=A1=E6=B5=81=E6=B0=B4=E9=80=80?= =?UTF-8?q?=E8=BF=98=E9=80=BB=E8=BE=91=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E5=95=86=E6=88=B7ID=E5=8F=82=E6=95=B0=EF=BC=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BA=86=E9=80=80=E6=AC=BE=E6=B5=81=E7=A8=8B=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E9=AB=98=E4=BA=86=E8=B5=84=E9=87=91=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=9A=84=E5=87=86=E7=A1=AE=E6=80=A7=EF=BC=8C=E5=B9=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E4=BA=86=E7=9B=B8=E5=85=B3API=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/logic/DemoPayNotifyLogic.php | 2 +- app/common/logic/PayNotifyLogic.php | 3 ++- app/common/logic/StoreFinanceFlowLogic.php | 21 +++++++++++++-------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/app/common/logic/DemoPayNotifyLogic.php b/app/common/logic/DemoPayNotifyLogic.php index 3576484c4..6f0e903bd 100644 --- a/app/common/logic/DemoPayNotifyLogic.php +++ b/app/common/logic/DemoPayNotifyLogic.php @@ -357,7 +357,7 @@ class DemoPayNotifyLogic extends BaseLogic //微信日志 user_order_refund $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1); //处理财务流水退还 - (new StoreFinanceFlowLogic())->store_finance_back($orderSn); + (new StoreFinanceFlowLogic())->store_finance_back($orderSn,$order['store_id']); self::addStock($order['id']); //微信 return true; // self::afterPay($order,$extra['transaction_id']); diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 2c525a636..681993271 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -324,7 +324,7 @@ class PayNotifyLogic extends BaseLogic StoreOrderCartInfo::where('oid', $order['id'])->update(['status' => OrderEnum::REFUND_STATUS_FINISH]); //处理财务流水退还 - (new StoreFinanceFlowLogic())->store_finance_back($orderSn); + (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(); @@ -393,6 +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']); return true; } diff --git a/app/common/logic/StoreFinanceFlowLogic.php b/app/common/logic/StoreFinanceFlowLogic.php index 9320689ae..7fd7b23da 100644 --- a/app/common/logic/StoreFinanceFlowLogic.php +++ b/app/common/logic/StoreFinanceFlowLogic.php @@ -176,39 +176,44 @@ class StoreFinanceFlowLogic extends BaseLogic * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ - public function store_finance_back($orderSn) + public function store_finance_back($orderSn, $store_id) { - $list=StoreFinanceFlow::where('order_sn', $orderSn) + $list = StoreFinanceFlow::where('order_sn', $orderSn) ->where(['financial_pm' => 1, 'status' => 1]) ->select(); foreach ($list as $k => $value) { //用户 switch ($value['type']) { case 0: - if ($value['financial_type'] == 12&& $value['other_uid']>0) { + if ($value['financial_type'] == 12 && $value['other_uid'] > 0) { $user = User::where('id', $value['other_uid'])->findOrEmpty(); $capitalFlowDao = new CapitalFlowLogic($user); - $user->now_money = bcsub($user['now_money'],$value['number'], 2); + $user->now_money = bcsub($user['now_money'], $value['number'], 2); $user->save(); // Log::error('aa'.$a); // Log::error('aa'.$user['now_money']); // Log::error('aa'.$value['number']); - $capitalFlowDao->userExpense('user_order_promotion_refund', 'system_back', $value['order_id'], $value['number'],'',$value['pay_type']); + $capitalFlowDao->userExpense('user_order_promotion_refund', 'system_back', $value['order_id'], $value['number'], '', $value['pay_type']); } break; //商户 case 1: + $store = SystemStore::where('id', $store_id)->find(); + $capitalFlowDao = new CapitalFlowLogic($store, 'store'); if ($value['number'] > 0 && $value['financial_type'] == 2) { SystemStore::where('id', $value['store_id'])->dec('store_money', $value['number'])->update(); + $capitalFlowDao->storeExpense('store_paid_deposit_dec', 'order', $value['order_id'],$value['number']); + } if ($value['number'] > 0 && $value['financial_type'] == 16) { SystemStore::where('id', $value['store_id'])->dec('attrition', $value['number'])->update(); + $capitalFlowDao->storeExpense('store_attrition_dec', 'order', $value['order_id'], $value['number']); + } break; } - } - $find = StoreFinanceFlow::where('order_sn', $orderSn)->where('financial_type', 11)->where('status',1)->find(); + $find = StoreFinanceFlow::where('order_sn', $orderSn)->where('financial_type', 11)->where('status', 1)->find(); if ($find && $find['number'] > 0) { SystemStore::where('id', $find['store_id'])->dec('paid_deposit', $find['number'])->update(); } @@ -220,7 +225,7 @@ class StoreFinanceFlowLogic extends BaseLogic // $value['financial_type'] = OrderEnum::PAY_BACK; // $value['create_time'] = time(); // } - StoreFinanceFlow::where('order_sn', $orderSn)->update(['status'=>-1]); + StoreFinanceFlow::where('order_sn', $orderSn)->update(['status' => -1]); // (new StoreFinanceFlow)->saveAll($data); } }