允许余额为负数
This commit is contained in:
parent
4d1cdf643d
commit
01bb962623
@ -59,17 +59,16 @@ public function toDrops($amount = 1)
|
|||||||
try {
|
try {
|
||||||
$lock->block(5);
|
$lock->block(5);
|
||||||
|
|
||||||
// if user balance <= 0
|
|
||||||
if ($this->balance < $amount) {
|
|
||||||
throw new BalanceNotEnoughException('余额不足');
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->balance -= $amount;
|
$this->balance -= $amount;
|
||||||
$this->save();
|
$this->save();
|
||||||
|
|
||||||
// increment user drops
|
// increment user drops
|
||||||
Cache::increment($cache_key, $total);
|
Cache::increment($cache_key, $total);
|
||||||
|
|
||||||
|
// if user balance <= 0
|
||||||
|
if ($this->balance < $amount) {
|
||||||
|
throw new BalanceNotEnoughException('余额不足');
|
||||||
|
}
|
||||||
} catch (LockTimeoutException) {
|
} catch (LockTimeoutException) {
|
||||||
throw new CommonException('暂时无法处理此请求,请稍后再试。');
|
throw new CommonException('暂时无法处理此请求,请稍后再试。');
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
Reference in New Issue
Block a user