Ken 1 週間 前
コミット
3af5129204
1 ファイル変更14 行追加11 行削除
  1. 14 11
      app/Services/WithdrawService.php

+ 14 - 11
app/Services/WithdrawService.php

@@ -382,22 +382,25 @@ class WithdrawService
         }
 
 
-        $withdraw = new Withdraw();
-        $withdraw->member_id = $chatId;
-        $withdraw->amount = $amount;
-        $withdraw->service_charge = $serviceCharge;
-        $withdraw->to_account = $real;
-        $withdraw->address = $address;
-        $withdraw->exchange_rate = $rate;
-        $withdraw->status = 0;
-        $withdraw->after_balance = bcdiv($wallet->available_balance, $rate, 2);
-        $withdraw->save();
         $wallet = Wallet::where('member_id', $chatId)->first();
         $changeAmount = bcmul(($amount * -1), $rate, 2);
         $beforeBalance = $wallet->available_balance;
         $afterBalance = bcsub($wallet->available_balance, $rate_rmb_amount, 2);
         $wallet->available_balance = $afterBalance;
         $wallet->save();
+
+        Withdraw::create([
+            'member_id' => $chatId,
+            'amount' => $amount,
+            'service_charge' => $serviceCharge,
+            'to_account' => $real,
+            'address' => $address,
+            'exchange_rate' => $rate,
+            'status' => 0,
+            'after_balance' => bcdiv($wallet->available_balance, $rate, 2)
+        ]);
+
+
         BalanceLogService::addLog($chatId, $changeAmount, $beforeBalance, $afterBalance, '提现', $withdraw->id, '');
         $temp = floatval($afterBalance);
         $text = "✅ " . lang("提现申请已提交!") . "\n\n";
@@ -467,7 +470,7 @@ class WithdrawService
 
         $amountRmb = bcmul($rate, $amount, 2);
 
-        if($amountRmb < 100){
+        if ($amountRmb < 100) {
             return [[
                 'chat_id' => $chatId,
                 'text' => lang("提现不能少于100 RMB,请重试"),