KKSU
2025-01-03 ca4cfb6e80c47be9fcb3a3e1d4575cf2ed9f1f62
src/main/java/cc/mrbird/febs/mall/service/impl/RunVipServiceImpl.java
@@ -33,7 +33,6 @@
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -105,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);
@@ -202,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){
@@ -535,31 +538,16 @@
            BigDecimal subtract = amountAll.subtract(amountNow);
            if(subtract.compareTo(amount) <= 0){
                runVipGrow.setAmountNow(amountAll);
                mallCharge.setVipCode(runVipGrow.getLevelNext());
            }else{
                runVipGrow.setAmountNow(amountNow.add(amount).setScale(2, RoundingMode.DOWN));
                mallCharge.setVipCode(memberLevel);
            }
            runVipGrow.setAmount(amount);
            runVipGrowMapper.updateById(runVipGrow);
        }else{
            BigDecimal presentPrice = runVip.getPresentPrice();
            BigDecimal add = presentPrice.add(amount);
            BigDecimal presentPriceNext = runVipNext.getPresentPrice();
            runVipGrow = new RunVipGrow();
            runVipGrow.setMemberId(memberId);
            runVipGrow.setLevelNow(memberLevel);
            runVipGrow.setLevelNext(runVipNext.getVipCode());
            runVipGrow.setAmountAll(presentPriceNext);
            runVipGrow.setAmount(add);
            runVipGrow.setAmountNow(add);
            runVipGrowMapper.insert(runVipGrow);
            if(presentPriceNext.compareTo(add) <= 0){
                mallCharge.setVipCode(runVipGrow.getLevelNext());
            }
@@ -709,7 +697,7 @@
        ).stream().findFirst().orElse(null);
        if(runVipGrow != null){
            BigDecimal amountNow = runVipGrow.getAmountNow();
            reduceAmount = reduceAmount.add(amountNow);
            reduceAmount = amountNow;
        }
        apiReduceAmountVo.setReduceAmount(reduceAmount);
        return new FebsResponse().success().data(apiReduceAmountVo);