|
@@ -369,8 +369,8 @@ class Wallet extends BaseController
|
|
|
$params = request()->validate([
|
|
$params = request()->validate([
|
|
|
'amount' => ['required', 'numeric', 'min:0.01'],
|
|
'amount' => ['required', 'numeric', 'min:0.01'],
|
|
|
'channel' => ['required', 'string', 'in:DF001,DF002,DF005,JDpay,jdpay,NOwithdraw,ZIMUwithdraw,ZIMUcash,rgtx'],
|
|
'channel' => ['required', 'string', 'in:DF001,DF002,DF005,JDpay,jdpay,NOwithdraw,ZIMUwithdraw,ZIMUcash,rgtx'],
|
|
|
- 'bank_name' => ['required', 'string'],
|
|
|
|
|
- 'account' => ['required', 'string'],
|
|
|
|
|
|
|
+ 'bank_name' => ['nullable', 'string'],
|
|
|
|
|
+ 'account' => ['nullable', 'string'],
|
|
|
'card_no' => ['required', 'string'],
|
|
'card_no' => ['required', 'string'],
|
|
|
'safe_word' => ['required'],
|
|
'safe_word' => ['required'],
|
|
|
]);
|
|
]);
|
|
@@ -401,6 +401,9 @@ class Wallet extends BaseController
|
|
|
if ($check === false) {
|
|
if ($check === false) {
|
|
|
throw new Exception(lang("不支持此提现方式"));
|
|
throw new Exception(lang("不支持此提现方式"));
|
|
|
}
|
|
}
|
|
|
|
|
+ if (!ZimuPayService::isWithdrawChannel($params['channel']) && (empty($params['bank_name']) || empty($params['account']))) {
|
|
|
|
|
+ throw new Exception(lang("提现信息不完整"));
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$amount = $params['amount'];
|
|
$amount = $params['amount'];
|
|
|
//校验提现金额的限制
|
|
//校验提现金额的限制
|
|
@@ -408,6 +411,58 @@ class Wallet extends BaseController
|
|
|
throw new Exception(lang("提现金额超出限制"));
|
|
throw new Exception(lang("提现金额超出限制"));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if (ZimuPayService::isWithdrawChannel($params['channel'])) {
|
|
|
|
|
+ $serviceCharge = (new WithdrawService())->serviceCharge;
|
|
|
|
|
+ $real = bcsub($amount, $serviceCharge, 10);
|
|
|
|
|
+ $real = floatval($real);
|
|
|
|
|
+
|
|
|
|
|
+ if ($amount <= $serviceCharge) {
|
|
|
|
|
+ throw new Exception(lang("提现不能少于") . "{$serviceCharge} USDT");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ $wallet = WalletModel::where('member_id', $member_id)->first();
|
|
|
|
|
+ if (!$wallet) throw new Exception('钱包不存在', HttpStatus::CUSTOM_ERROR);
|
|
|
|
|
+ $balance = $wallet->available_balance;
|
|
|
|
|
+ $rate = Config::where('field', 'exchange_rate_rmb')->first()->val ?? 1;
|
|
|
|
|
+ $exchange_rate_difference = Config::where('field', 'exchange_rate_difference')->first()->val ?? 0;
|
|
|
|
|
+ $rate = bcadd($rate, $exchange_rate_difference, 2);
|
|
|
|
|
+ $rate_usdt_amount = bcdiv($balance, $rate, 2);
|
|
|
|
|
+ $rate_rmb_amount = bcmul($amount, $rate, 2);
|
|
|
|
|
+ if ($amount > $rate_usdt_amount) {
|
|
|
|
|
+ throw new Exception(lang("余额不足") . "{$serviceCharge} USDT");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
+ try {
|
|
|
|
|
+ $beforeBalance = $wallet->available_balance;
|
|
|
|
|
+ $afterBalance = bcsub($wallet->available_balance, $rate_rmb_amount, 2);
|
|
|
|
|
+ $wallet->available_balance = $afterBalance;
|
|
|
|
|
+ if (!$wallet->save()) throw new Exception('钱包更新失败!', HttpStatus::CUSTOM_ERROR);
|
|
|
|
|
+
|
|
|
|
|
+ $withdraw = Withdraw::create([
|
|
|
|
|
+ 'member_id' => $member_id,
|
|
|
|
|
+ 'amount' => $amount,
|
|
|
|
|
+ 'service_charge' => $serviceCharge,
|
|
|
|
|
+ 'to_account' => $real,
|
|
|
|
|
+ 'address' => $params['card_no'],
|
|
|
|
|
+ 'exchange_rate' => $rate,
|
|
|
|
|
+ 'status' => 0,
|
|
|
|
|
+ 'after_balance' => $afterBalance,
|
|
|
|
|
+ 'channel' => ZimuPayService::CHANNEL_WITHDRAW,
|
|
|
|
|
+ 'order_no' => PaymentOrderService::createOrderNo('zw_', $member_id),
|
|
|
|
|
+ ]);
|
|
|
|
|
+ BalanceLogService::addLog($member_id, bcmul(($amount * -1), $rate, 2), $beforeBalance, $afterBalance, '提现', $withdraw->id, '');
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ return $this->success($withdraw, '提交成功');
|
|
|
|
|
+ } catch (Exception $e) {
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ if ($e->getCode() === HttpStatus::CUSTOM_ERROR) {
|
|
|
|
|
+ return $this->error($e->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ throw $e;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if ($params['channel'] == 'rgtx') {
|
|
if ($params['channel'] == 'rgtx') {
|
|
|
|
|
|
|
|
DB::beginTransaction();
|
|
DB::beginTransaction();
|