diff --git a/app/Utils/API/PaymentNew.php b/app/Utils/API/PaymentNew.php index 3929bf6..ef329a6 100644 --- a/app/Utils/API/PaymentNew.php +++ b/app/Utils/API/PaymentNew.php @@ -111,9 +111,19 @@ class PaymentNew echo $responseBody; } - return $responseBody; + return json_decode($responseBody); } catch (\GuzzleHttp\Exception\RequestException $e) { Log::warning("请求支付api失未知失败:" . $e->getMessage()); + // 如果是 400 错误,可能有额外的请求错误信息 + if ($e->hasResponse()) { + $response = $e->getResponse(); + $httpCode = $response->getStatusCode(); + if ($httpCode == 400) { + $responseBody = $response->getBody()->getContents(); + Log::warning("请求支付api失败,状态码 400,响应体:" . $responseBody); + } + } + return json_decode($responseBody); } } /** @@ -152,16 +162,6 @@ class PaymentNew } } catch (\GuzzleHttp\Exception\RequestException $e) { Log::warning("请求支付api失未知失败:" . $e->getMessage()); - // 如果是 400 错误,可能有额外的请求错误信息 - if ($e->hasResponse()) { - $response = $e->getResponse(); - $httpCode = $response->getStatusCode(); - if ($httpCode == 400) { - $responseBody = $response->getBody()->getContents(); - Log::warning("请求支付api失败,状态码 400,响应体:" . $responseBody); - } - } - return -1; } } diff --git a/app/controller/api/WithdrawController.php b/app/controller/api/WithdrawController.php index 75a09eb..3946401 100644 --- a/app/controller/api/WithdrawController.php +++ b/app/controller/api/WithdrawController.php @@ -106,7 +106,7 @@ class WithdrawController $user_id = $request->data['id']; $today = date('Y-m-d'); //判断用户今天提现几次 - if(Withdraw::where('user_id',$user_id)->where('created_at', '>=', $today . " 00:00:00")->count()>=3){ + if (Withdraw::where('user_id', $user_id)->where('created_at', '>=', $today . " 00:00:00")->count() >= 3) { return ApiResponseApp::error(null, '每天只能提现三次'); } $user = User::find($user_id); @@ -133,16 +133,20 @@ class WithdrawController //获取刚刚存入数据库的id(订单号) $orderId = $withdraw->id; $res = PaymentNew::pushMoney($money, $userbank->bank_username, $userbank->account, $userbank->bank_name, $orderId); + // //逻辑错误需要修改 - if ($res['Success']) { + if ($res->Success) { $withdraw->update([ 'status' => 4, // 'status_text' => '等待银行打款', - 'order_number' => $res['TrackingNumber'] ?? null, + 'order_number' => $res->TrackingNumber ?? null, ]); return ApiResponseApp::success(null, '转账成功'); } else { - return ApiResponseApp::error(null, '转账失败'); + if ($res->ErrorMessage == "PayeeAccountNumberFormatError") { + return ApiResponseApp::error(null, '收款人帐号格式错误'); + } + return ApiResponseApp::error(null, '未知错误请联系客服'); } }