adjust logic, avoide race condition
Some checks failed
Build and Push Backend / docker (push) Failing after 6s
Some checks failed
Build and Push Backend / docker (push) Failing after 6s
This commit is contained in:
@@ -57,13 +57,12 @@ public class WithdrawalServiceImpl extends ServiceImpl<WithdrawalRequestMapper,
|
||||
throw new CustomException("收款码确认已过期,请重新确认");
|
||||
}
|
||||
|
||||
BigDecimal available = earningsService.getAvailableAmount(clerkId, now);
|
||||
if (available.compareTo(amount) < 0) {
|
||||
throw new CustomException("可提现余额不足");
|
||||
}
|
||||
// pick and reserve lines
|
||||
List<EarningsLineEntity> lines = earningsService.findWithdrawable(clerkId, amount, now);
|
||||
if (lines.isEmpty()) throw new CustomException("可提现余额不足");
|
||||
if (lines.isEmpty()) {
|
||||
BigDecimal latestAvailable = earningsService.getAvailableAmount(clerkId, now);
|
||||
throw new CustomException("可提现余额不足或已被锁定,当前可用:" + latestAvailable);
|
||||
}
|
||||
|
||||
// Reserve lines FIRST with temp ID (fail fast before creating request)
|
||||
String tempWithdrawalId = "TEMP_" + IdUtils.getUuid();
|
||||
|
||||
Reference in New Issue
Block a user