6
0
Fork 0
release
李静 2021-12-28 11:54:00 +08:00
parent f1e6e2f204
commit f60c6f2ea0
2 changed files with 14 additions and 2 deletions

View File

@ -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();
}
}
// 变更前余额

View File

@ -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();
}
}
// 变更前余额