From 5804bf6daf32a6dfe85f2b8f34008e7ac67d6465 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E7=8B=BC?= <2468023037@qq.com> Date: Thu, 20 Feb 2025 23:45:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E9=93=B6=E8=A1=8C?= =?UTF-8?q?=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Utils/API/PaymentNew.php | 5 +-- app/controller/api/WithdrawController.php | 48 +++++++++++++---------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/app/Utils/API/PaymentNew.php b/app/Utils/API/PaymentNew.php index 8b48614..6afbd9e 100644 --- a/app/Utils/API/PaymentNew.php +++ b/app/Utils/API/PaymentNew.php @@ -73,9 +73,6 @@ class PaymentNew } // Guzzle HTTP client $client = new Client(); - // var_dump($orderId); - var_dump(1111111111111111111111111111111111111111111); - var_dump($PaymentChannelId); // 请求数据 $payload = [ "Amount" => $money, @@ -86,7 +83,7 @@ class PaymentNew "PayeeBankName" => $payeeBankName, "PayeeIFSCCode" => "", "PaymentChannelId" => $PaymentChannelId, - "ShopInformUrl" => "http://149.129.107.38", + "ShopInformUrl" => "http:/38.54.94.131/api/withdraw/callback", "ShopOrderId" => $orderId . "", "ShopUserLongId" => "776ae472-d4fc-435c-9639-be5763138d95" ]; diff --git a/app/controller/api/WithdrawController.php b/app/controller/api/WithdrawController.php index 98a45f4..2c9305f 100644 --- a/app/controller/api/WithdrawController.php +++ b/app/controller/api/WithdrawController.php @@ -126,40 +126,48 @@ class WithdrawController $withdraw = Withdraw::create([ 'user_id' => $user_id, 'amount' => $money, - 'status' => 2, + 'status' => 1, 'createtime2' => date('Y-m-d H:i:s'), 'username' => $user->username, - 'status_text' => '已到账', + 'status_text' => '申请中', ]); //获取刚刚存入数据库的id(订单号) $orderId = $withdraw->id; - PaymentNew::pushMoney($money, $userbank->bank_username, $userbank->account, $userbank->bank_name,$orderId); - // var_dump($res); + $res = PaymentNew::pushMoney($money, $userbank->bank_username, $userbank->account, $userbank->bank_name,$orderId); // //逻辑错误需要修改 - // if ($res['Success'] == 200) { - // Withdraw::create([ - // 'user_id' => $user_id, - // 'amount' => $money, - // 'status' => 2, - // 'createtime2' => date('Y-m-d H:i:s'), - // 'username' => $user->username, - // 'status_text' => '已到账', - // ]); - // return ApiResponseApp::success(null, '转账成功'); - // } else { - // return ApiResponseApp::error(null, '转账失败'); - // } - // return ApiResponseApp::success(null, '转账成功'); + if ($res['Success']) { + $withdraw->update([ + 'status' => 2, // + 'status_text' => '已到账', + 'order_number' => $res['TrackingNumber'] ?? null, + ]); + return ApiResponseApp::success(null, '转账成功'); + } else { + return ApiResponseApp::error(null, '转账失败'); + } + return ApiResponseApp::success(null, '转账成功'); } /** * @Apidoc\Title("请求回调") * @Apidoc\Url("api/withdraw/callback") - * @Apidoc\Method("GET") + * @Apidoc\Method("POST") */ public function callback(Request $request) { - var_dump($request->all()); + $callbackData = $request->all(); + + $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_text' => '支付失败: ' . $failedMessage, + ]); + } + } }