|
@@ -508,9 +508,14 @@ public class WxPayServiceImpl implements WxPayService {
|
|
|
throw new BusinessException("存在未完结的订单,请完成所有订单完结之后重试");
|
|
throw new BusinessException("存在未完结的订单,请完成所有订单完结之后重试");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- var account = accountService.getAccountByUserId(userId);
|
|
|
|
|
- if (account.getBalance() <= 0) {
|
|
|
|
|
- throw new BusinessException("账户余额不足,无需退款");
|
|
|
|
|
|
|
+ // 行锁读取账户,防止并发退款请求同时通过余额校验造成重复退款
|
|
|
|
|
+ var account = accountService.lambdaQuery().eq(Account::getUserId, userId).last("FOR UPDATE").one();
|
|
|
|
|
+ if (account == null) {
|
|
|
|
|
+ throw new BusinessException("用户账户不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 退款金额以充值余额为准(纯赠款余额不可退),校验与冻结/退款口径一致
|
|
|
|
|
+ if (account.getRechargeBalance() <= 0) {
|
|
|
|
|
+ throw new BusinessException("充值余额不足,无需退款");
|
|
|
}
|
|
}
|
|
|
// // 校验余额大于优惠金额
|
|
// // 校验余额大于优惠金额
|
|
|
// if (account.getBalance() <= account.getDiscountAmount()) {
|
|
// if (account.getBalance() <= account.getDiscountAmount()) {
|