From 115b19f56521e1ea60b82706b911c258fb388f95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E7=8B=BC?= <2468023037@qq.com> Date: Fri, 21 Feb 2025 08:49:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=93=E6=AC=BE=E6=96=B0=E5=A2=9E2?= =?UTF-8?q?=E4=B8=AA=E7=8A=B6=E6=80=81=EF=BC=8C=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/api/WithdrawController.php | 39 ++++++++++------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/app/controller/api/WithdrawController.php b/app/controller/api/WithdrawController.php index 2c9305f..ff25528 100644 --- a/app/controller/api/WithdrawController.php +++ b/app/controller/api/WithdrawController.php @@ -17,6 +17,8 @@ use App\dao\UserRewardDao; use hg\apidoc\annotation as Apidoc; use Carbon\Carbon; +use support\Log; + /** * @Apidoc\Title("提现订单") */ @@ -105,47 +107,37 @@ class WithdrawController //提现金额 $rate = ExchangeRate::where('type', 'BDT')->get(); $money = $money_no / 100 * $rate[0]['points']; - var_dump($money); + $withdraw = Withdraw::create([ + 'user_id' => $user_id, + 'amount' => $money, + 'status' => 1, + 'createtime2' => date('Y-m-d H:i:s'), + 'username' => $user->username, + 'status_text' => '申请中', + ]); //大于1000等待管理员审核 if ($money >= 1000) { - Withdraw::create([ - 'user_id' => $user_id, - 'amount' => $money, - 'status' => 1, - 'createtime2' => date('Y-m-d H:i:s'), - 'username' => $user->username, - 'status_text' => '申请中', - ]); return ApiResponseApp::success(null, '等待管理员审核'); } //用户积分减少$money UserRewardDao::base($user_id, 1, - ($money_no + 300), '提现'); $userbank = Userbank::where('id', $bank_id)->first(); - //存入数据库 - $withdraw = Withdraw::create([ - 'user_id' => $user_id, - 'amount' => $money, - 'status' => 1, - 'createtime2' => date('Y-m-d H:i:s'), - 'username' => $user->username, - 'status_text' => '申请中', - ]); + //获取刚刚存入数据库的id(订单号) $orderId = $withdraw->id; $res = PaymentNew::pushMoney($money, $userbank->bank_username, $userbank->account, $userbank->bank_name,$orderId); // //逻辑错误需要修改 if ($res['Success']) { $withdraw->update([ - 'status' => 2, // - 'status_text' => '已到账', + 'status' => 4, // + 'status_text' => '等待银行打款', 'order_number' => $res['TrackingNumber'] ?? null, ]); return ApiResponseApp::success(null, '转账成功'); } else { return ApiResponseApp::error(null, '转账失败'); } - return ApiResponseApp::success(null, '转账成功'); } @@ -157,14 +149,15 @@ class WithdrawController public function callback(Request $request) { $callbackData = $request->all(); - + // 记录回调数据以便调试 + Log::info('Payment Callback Received:', $callbackData); $orderId = $callbackData['TrackingNumber'] ?? null; $failedMessage = $callbackData['FailedMessage'] ?? null; $withdraw = Withdraw::where('order_number', $orderId)->first(); //$failedMessage为null就是成功 if ($failedMessage != null) { $withdraw->update([ - 'status' => 3, + 'status' => 5, 'status_text' => '支付失败: ' . $failedMessage, ]); }