KKSU
2025-01-03 ca4cfb6e80c47be9fcb3a3e1d4575cf2ed9f1f62
fix(mall): 修复余额不足时的支付异常

- 在 RunVipServiceImpl 中增加了对余额为零或负数的检查
- 在支付流程的关键步骤中添加了异常抛出,以防止无效交易
- 优化了代码结构,提高了支付系统的健壮性
1 files modified
9 ■■■■ changed files
src/main/java/cc/mrbird/febs/mall/service/impl/RunVipServiceImpl.java 9 ●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/impl/RunVipServiceImpl.java
@@ -107,6 +107,9 @@
            reduceAmount = runVipGrow.getAmountNow();
        }
        presentAmount = presentAmount.subtract(reduceAmount);
        if(BigDecimal.ZERO.compareTo(presentAmount) >= 0){
            throw new FebsException("支付异常,请刷新页面重试");
        }
        Long addressId = apiGoChargeDto.getAddressId();
        MallMemberPayment mallMemberPayment = mallMemberPaymentMapper.selectById(addressId);
@@ -200,10 +203,12 @@
                        .orderByDesc(RunVipGrow::getId)
        ).stream().findFirst().orElse(null);
        if(runVipGrow != null){
            BigDecimal amountNow = runVipGrow.getAmountNow();
            reduceAmount = reduceAmount.add(amountNow);
            reduceAmount = runVipGrow.getAmountNow();
        }
        presentAmount = presentAmount.subtract(reduceAmount);
        if(BigDecimal.ZERO.compareTo(presentAmount) >= 0){
            throw new FebsException("支付异常,请刷新页面重试");
        }
        MallMemberWallet mallMemberWallet = mallMemberWalletMapper.selectWalletByMemberId(memberId);
        if(mallMemberWallet.getCommission().compareTo(BigDecimal.ZERO) <= 0){