Update
parent
f1e6e2f204
commit
f60c6f2ea0
|
|
@ -23,7 +23,13 @@ class BalanceService
|
|||
$balance = $user->balance()->lockForUpdate()->first();
|
||||
|
||||
if (is_null($balance)) {
|
||||
throw new BalanceNotEnoughException();
|
||||
if ($changeBalance < 0) {
|
||||
throw new BalanceNotEnoughException();
|
||||
} else {
|
||||
$user->balance()->create();
|
||||
|
||||
$balance = $user->balance()->lockForUpdate()->first();
|
||||
}
|
||||
}
|
||||
|
||||
// 变更前余额
|
||||
|
|
|
|||
|
|
@ -23,7 +23,13 @@ class WalletService
|
|||
$wallet = $user->wallet()->lockForUpdate()->first();
|
||||
|
||||
if (is_null($wallet)) {
|
||||
throw new WalletNotEnoughException();
|
||||
if ($changeBalance < 0) {
|
||||
throw new WalletNotEnoughException();
|
||||
} else {
|
||||
$user->wallet()->create();
|
||||
|
||||
$wallet = $user->wallet()->lockForUpdate()->first();
|
||||
}
|
||||
}
|
||||
|
||||
// 变更前余额
|
||||
|
|
|
|||
Loading…
Reference in New Issue