Ken 1 周之前
父節點
當前提交
2e4030ca61
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      app/Http/Controllers/admin/Wallet.php

+ 1 - 0
app/Http/Controllers/admin/Wallet.php

@@ -84,6 +84,7 @@ class Wallet extends Controller
             $wallet = WalletModel::where('member_id', $memberId)->first();
             $wallet = WalletModel::where('member_id', $memberId)->first();
             if (!$wallet) throw new Exception('用户不存在', HttpStatus::CUSTOM_ERROR);
             if (!$wallet) throw new Exception('用户不存在', HttpStatus::CUSTOM_ERROR);
             $available_balance = bcadd($wallet->available_balance, $amount, 10);
             $available_balance = bcadd($wallet->available_balance, $amount, 10);
+            if ($available_balance < 0) throw new Exception('可用余额不足', HttpStatus::CUSTOM_ERROR);
             $changeType = ($amount > 0 ? "人工充值" : "人工扣款");
             $changeType = ($amount > 0 ? "人工充值" : "人工扣款");
             BalanceLogService::addLog($memberId, $amount, $wallet->available_balance, $available_balance, $changeType, null, $remark);
             BalanceLogService::addLog($memberId, $amount, $wallet->available_balance, $available_balance, $changeType, null, $remark);
             $wallet->available_balance = $available_balance;
             $wallet->available_balance = $available_balance;