feat: 在提现逻辑中添加频繁提现限制,用户需等待三分钟后再试

This commit is contained in:
lingling 2025-03-09 15:08:44 +08:00
parent 6ae1f5603a
commit d136ca240f
1 changed files with 26 additions and 15 deletions

View File

@ -31,7 +31,7 @@ class WithdrawController
/**
* 手续费
*/
protected static $handlingFee=0;
protected static $handlingFee = 0;
/**
* @Apidoc\Title("1.0 查询当前用户提现订单")
* @Apidoc\Url("api/withdraw/withdrawCashList")
@ -115,9 +115,20 @@ class WithdrawController
return ApiResponseApp::error(null, '每天只能提现三次');
}
$user = User::find($user_id);
if($money_no>$user->money){
if ($money_no > $user->money) {
return ApiResponseApp::error(null, '提现积分不足');
}
}
// 获取当前时间的 3 分钟前
$threeMinutesAgo = Carbon::now()->subMinutes(3);
// 使用 exists() 查询,判断是否有记录
if (Withdraw::where('user_id', $user_id)
->where('created_at', '>=', $threeMinutesAgo)
->exists()
) {
return ApiResponseApp::error(null, '提现频繁请三分钟后再试');
}
//提现金额
$rate = ExchangeRate::where('type', 'BDT')->get();
$money = (int)$money_no / 100 * $rate[0]['points'];
@ -136,7 +147,7 @@ class WithdrawController
UserRewardDao::base($user_id, 1, - ($money_no + self::$handlingFee), '提现');
return ApiResponseApp::success(null, '等待管理员审核');
}
//用户积分减少$money
UserRewardDao::base($user_id, 1, - ($money_no + self::$handlingFee), '提现');
$userbank = Userbank::where('id', $bank_id)->first();
@ -153,36 +164,36 @@ class WithdrawController
return ApiResponseApp::success(null, '转账成功');
} else {
$errorMsg = '';
if($res->ErrorMessage == "CheckIpAddressFailed"){
if ($res->ErrorMessage == "CheckIpAddressFailed") {
$errorMsg = 'IP 检查失败';
}
if($res->ErrorMessage == "CheckEncryptValueFailed "){
if ($res->ErrorMessage == "CheckEncryptValueFailed ") {
$errorMsg = '加密检查失败';
}
if($res->ErrorMessage == "PaymentChannelClosed"){
if ($res->ErrorMessage == "PaymentChannelClosed") {
$errorMsg = '平台休息中,暂不接单';
}
if($res->ErrorMessage == "InsufficientBalance"){
if ($res->ErrorMessage == "InsufficientBalance") {
$errorMsg = '余额不足';
}
if($res->ErrorMessage == "TryAgainLater"){
if ($res->ErrorMessage == "TryAgainLater") {
$errorMsg = '系统忙碌中,请稍后再试';
}
if($res->ErrorMessage == "DevError"){
if ($res->ErrorMessage == "DevError") {
$errorMsg = '程式错误,请联络开发人员';
}
if($res->ErrorMessage == "PayeeAccountNameFormatError"){
if ($res->ErrorMessage == "PayeeAccountNameFormatError") {
$errorMsg = '收款人帐号格式错误';
}
if($res->ErrorMessage == "PayeeAccountNumberFormatError"){
if ($res->ErrorMessage == "PayeeAccountNumberFormatError") {
$errorMsg = '收款人卡号格式错误';
}
if($errorMsg == ''){
if ($errorMsg == '') {
$errorMsg = '未知错误';
}
$withdraw->update([
'status' => 5, //
'status_text' => trans('支付错误:').$res->ErrorMessage
'status_text' => trans('支付错误:') . $res->ErrorMessage
]);
UserRewardDao::base($user_id, 1, $money_no + self::$handlingFee, '提现失败返还');
// if ($res->ErrorMessage == "PayeeAccountNameFormatError") {
@ -210,7 +221,7 @@ class WithdrawController
$withdraw = Withdraw::where('order_number', $orderId)->first();
//$failedMessage为null就是成功
if ($failedMessage != null) {
if($withdraw->status == 5){
if ($withdraw->status == 5) {
return;
}
$rate = ExchangeRate::where('type', 'BDT')->get();