6
0
Fork 0

添加批零提现到银行卡需要支付密码

release
vine_liutk 2022-02-18 16:29:49 +08:00
parent 0e53eb73d3
commit e3c5ce45dc
1 changed files with 11 additions and 2 deletions

View File

@ -8,6 +8,7 @@ use App\Endpoint\Api\Http\Resources\Dealer\WalletToBankLogResource;
use App\Endpoint\Api\Http\Resources\Dealer\WalletToBankLogSimpleResource; use App\Endpoint\Api\Http\Resources\Dealer\WalletToBankLogSimpleResource;
use App\Enums\DealerWalletAction; use App\Enums\DealerWalletAction;
use App\Exceptions\BizException; use App\Exceptions\BizException;
use App\Exceptions\PayPasswordIncorrectException;
use App\Helpers\Paginator as PaginatorHelper; use App\Helpers\Paginator as PaginatorHelper;
use App\Models\DealerWalletToBankLog; use App\Models\DealerWalletToBankLog;
use App\Services\Dealer\WalletService; use App\Services\Dealer\WalletService;
@ -41,10 +42,18 @@ class WalletController extends Controller
{ {
$input = $request->validate([ $input = $request->validate([
'amount' => ['bail', 'required', 'int', 'min:1'], 'amount' => ['bail', 'required', 'int', 'min:1'],
'pay_password' => ['bail', 'required', 'string'],
], [], [
'amount' => '提现金额',
'pay_password' => '支付密码',
]); ]);
$user = $request->user(); $user = $request->user();
$amount = Arr::get($input, 'amount', 0); $amount = Arr::get($input, 'amount', 0);
//验证支付密码
if (! $user->wallet?->verifyPassword($input['pay_password'] ?? '')) {
throw new PayPasswordIncorrectException();
}
if (empty($user->dealer->pay_info)) { if (empty($user->dealer->pay_info)) {
throw new BizException('请先绑定设置收款信息'); throw new BizException('请先绑定设置收款信息');
@ -69,7 +78,7 @@ class WalletController extends Controller
$rate = app_settings('dealer.withdraw_fee_rate', '0.00');//手续费率 $rate = app_settings('dealer.withdraw_fee_rate', '0.00');//手续费率
// $rate = 0; // $rate = 0;
//计算手续费(四舍五入) //计算手续费(四舍五入)
$serviceAmount = round(bcdiv($rate, 100, 4)*$amount); $serviceAmount = round(bcdiv($rate, 100, 4) * $amount);
//生成提现记录 //生成提现记录
$log = DealerWalletToBankLog::create([ $log = DealerWalletToBankLog::create([
@ -77,7 +86,7 @@ class WalletController extends Controller
'amount'=> bcdiv($amount, 100, 2), 'amount'=> bcdiv($amount, 100, 2),
'rate' => $rate, 'rate' => $rate,
'service_amount' => bcdiv($serviceAmount, 100, 2), 'service_amount' => bcdiv($serviceAmount, 100, 2),
'account_amount' => bcdiv($amount-$serviceAmount, 100, 2), 'account_amount' => bcdiv($amount - $serviceAmount, 100, 2),
]); ]);
//减去用户可提金额 //减去用户可提金额