修复上个问题

This commit is contained in:
lingling 2025-02-22 13:49:15 +08:00
parent 60e316e089
commit ef841944b1
2 changed files with 19 additions and 15 deletions

View File

@ -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;
}
}

View File

@ -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, '未知错误请联系客服');
}
}