From 01f4d9749498432aae85873d8a8b119ffec867ec Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Wed, 5 Jun 2024 13:37:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=85=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/PayController.php | 4 ++++ app/api/controller/user/UserController.php | 2 +- app/common/logic/PayNotifyLogic.php | 23 +++++++--------------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/app/api/controller/PayController.php b/app/api/controller/PayController.php index ded81e91a..42c1df249 100644 --- a/app/api/controller/PayController.php +++ b/app/api/controller/PayController.php @@ -37,6 +37,10 @@ class PayController extends BaseApiController PayNotifyLogic::handle('wechat_common', $ciphertext['out_trade_no'], $ciphertext); $app->wechat->success(); break; + case 'recharge': + PayNotifyLogic::handle('recharge', $ciphertext['out_trade_no'], $ciphertext); + $app->wechat->success(); + break; } } } diff --git a/app/api/controller/user/UserController.php b/app/api/controller/user/UserController.php index bafb2f34d..1a118bf11 100644 --- a/app/api/controller/user/UserController.php +++ b/app/api/controller/user/UserController.php @@ -72,7 +72,7 @@ class UserController extends BaseApiController $params['channel_type'] = $this->userInfo['terminal']; $order = UserLogic::recharge($params); $redirectUrl = $params['redirect'] ?? '/pages/payment/payment'; - $result = PaymentLogic::pay(PayEnum::WECHAT_PAY, 'StoreOrder', $order, $this->userInfo['terminal'], $redirectUrl); + $result = PaymentLogic::pay(PayEnum::WECHAT_PAY, 'recharge', $order, $this->userInfo['terminal'], $redirectUrl); if (PaymentLogic::hasError()) { return $this->fail(PaymentLogic::getError(), $params); } diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index 96458d2ab..cb5179ce0 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -8,6 +8,7 @@ use app\common\model\pay\PayNotify; use app\common\model\store_finance_flow\StoreFinanceFlow; use app\common\model\store_order\StoreOrder; use app\common\model\user\User; +use app\common\model\user\UserRecharge; use app\common\service\PushService; use support\Log; use think\facade\Db; @@ -107,26 +108,16 @@ class PayNotifyLogic extends BaseLogic } - public static function store_order($orderSn, $extra = []) + public static function recharge($orderSn, $extra = []) { - $order = StoreOrder::where('order_id', $orderSn)->findOrEmpty(); + $order = UserRecharge::where('order_id', $orderSn)->findOrEmpty(); if ($order->isEmpty() || $order->paid == PayEnum::ISPAID) { return true; } - if ($order->pay_type != 10) { - $order->pay_price = bcdiv($extra['amount']['payer_total'], 100, 2); - $order->paid = 1; - $order->pay_time = time(); - $order->status = 1; - $order->save(); - } else { - $extra['transaction_id'] = time(); - } - if ($order->pay_type == 9) { - $order->status = 2; - } - self::afterPay($order); - + $order->price = bcdiv($extra['amount']['payer_total'], 100, 2); + $order->paid = 1; + $order->pay_time = time(); + $order->save(); return true; }