| | |
| | | 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; |
| | |
| | | .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); |
| | |
| | | .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){ |
| | |
| | | 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()); |
| | | } |
| | |
| | | ).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); |