允许余额为负数

This commit is contained in:
iVampireSP.com 2022-09-04 01:19:41 +08:00
parent 4d1cdf643d
commit 01bb962623
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -59,17 +59,16 @@ public function toDrops($amount = 1)
try {
$lock->block(5);
// if user balance <= 0
if ($this->balance < $amount) {
throw new BalanceNotEnoughException('余额不足');
}
$this->balance -= $amount;
$this->save();
// increment user drops
Cache::increment($cache_key, $total);
// if user balance <= 0
if ($this->balance < $amount) {
throw new BalanceNotEnoughException('余额不足');
}
} catch (LockTimeoutException) {
throw new CommonException('暂时无法处理此请求,请稍后再试。');
} finally {