feat: 优化 WithdrawController 中积分计算逻辑,使用 accumulated 和 fee 属性
This commit is contained in:
parent
578cbfa203
commit
fd1de9794d
|
@ -81,10 +81,11 @@ class WithdrawController
|
|||
//是否同意转账
|
||||
$type = $request->post('type');
|
||||
|
||||
$rate = ExchangeRate::where('type', 'BDT')->get();
|
||||
//计算积分
|
||||
$money = $amount * 100 / $rate[0]['points'] + 300;
|
||||
$Withdraw = Withdraw::where('id', $id)->first();
|
||||
|
||||
//计算积分
|
||||
$money = $Withdraw->accumulated + $Withdraw->fee;
|
||||
|
||||
if($Withdraw->status != 1){
|
||||
return ApiResponse::error(400,[],'请勿重复点击');
|
||||
}
|
||||
|
|
|
@ -130,8 +130,8 @@ class WithdrawController
|
|||
return ApiResponseApp::error(null, '提现频繁请三分钟后再试');
|
||||
}
|
||||
//提现金额
|
||||
$rate = ExchangeRate::where('type', 'BDT')->get();
|
||||
$money = (int)$money_no / 100 * $rate[0]['points'];
|
||||
$rate = ExchangeRate::where('type', 'BDT')->first();
|
||||
$money = (int)$money_no / 100 * $rate->points;
|
||||
|
||||
$withdraw = Withdraw::create([
|
||||
'user_id' => $user_id,
|
||||
|
@ -140,6 +140,8 @@ class WithdrawController
|
|||
'createtime2' => date('Y-m-d H:i:s'),
|
||||
'username' => $user->username,
|
||||
'status_text' => '申请中',
|
||||
'accumulated'=>$money_no,
|
||||
'fee'=>0
|
||||
]);
|
||||
//大于1000积分等待管理员审核
|
||||
if ($money_no >= 100000) {
|
||||
|
@ -224,8 +226,7 @@ class WithdrawController
|
|||
if ($withdraw->status == 5) {
|
||||
return;
|
||||
}
|
||||
$rate = ExchangeRate::where('type', 'BDT')->get();
|
||||
$money = $amount * 100 / $rate[0]['points'] + 300;
|
||||
$money = $withdraw->accumulated + $withdraw->fee;
|
||||
UserRewardDao::base($withdraw->user_id, 1, $money, '提现失败返还');
|
||||
$withdraw->update([
|
||||
'status' => 5,
|
||||
|
|
Loading…
Reference in New Issue