From e63f08bb358dd2d53a1bece9fb7654ff196c113b Mon Sep 17 00:00:00 2001
From: KKSU <15274802129@163.com>
Date: Thu, 09 Jan 2025 18:03:58 +0800
Subject: [PATCH] refactor(mall): 优化 BigDecimal 的舍入方式
---
src/main/java/cc/mrbird/febs/mall/service/impl/RunVipServiceImpl.java | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/RunVipServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/RunVipServiceImpl.java
index d55972e..d46432f 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/RunVipServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/RunVipServiceImpl.java
@@ -104,10 +104,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("支付异常,请刷新页面重试");
+ }
Long addressId = apiGoChargeDto.getAddressId();
MallMemberPayment mallMemberPayment = mallMemberPaymentMapper.selectById(addressId);
@@ -201,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){
@@ -545,7 +549,7 @@
BigDecimal presentPriceNext = runVipNext.getPresentPrice();
if(presentPriceNext.compareTo(add) <= 0){
- mallCharge.setVipCode(runVipGrow.getLevelNext());
+ mallCharge.setVipCode(runVipNext.getVipCode());
}
}
mallChargeMapper.insert(mallCharge);
--
Gitblit v1.9.1