From c1af5cf94920702b6aa962881365116542e88ab0 Mon Sep 17 00:00:00 2001 From: KKSU <15274802129@163.com> Date: Tue, 30 Jul 2024 09:42:46 +0800 Subject: [PATCH] 后台 --- src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java index f67580b..d69c527 100644 --- a/src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java +++ b/src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java @@ -17,6 +17,7 @@ import cc.mrbird.febs.mall.service.IMallMemberWithdrawService; import cc.mrbird.febs.mall.service.MallMemberService; import cc.mrbird.febs.mall.vo.CashOutSettingVo; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.SecureUtil; @@ -28,6 +29,8 @@ import org.springframework.transaction.annotation.Transactional; import java.math.BigDecimal; +import java.util.Date; +import java.util.List; /** * @author wzy @@ -65,6 +68,20 @@ cashOutSettingVo = JSONObject.parseObject(dic.getValue(), CashOutSettingVo.class); } + //每日提现额度上限 + BigDecimal allCashOut = cashOutSettingVo.getAllCashOut(); + if(withdrawalDto.getAmount().compareTo(allCashOut) > 0){ + throw new FebsException("限额:"+cashOutSettingVo.getAllCashOut().setScale(2,BigDecimal.ROUND_DOWN)); + } + List<MallMemberWithdraw> mallMemberWithdrawListDone = this.baseMapper.selectListByMemberIdAndDate(memberId,new Date()); + if(CollUtil.isNotEmpty(mallMemberWithdrawListDone)){ + BigDecimal amountTCAll = mallMemberWithdrawListDone.stream().map(MallMemberWithdraw::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add); + amountTCAll = amountTCAll.add(withdrawalDto.getAmount()); + if (amountTCAll.compareTo(allCashOut) > 0) { + throw new FebsException("限额:"+cashOutSettingVo.getAllCashOut().setScale(2,BigDecimal.ROUND_DOWN)); + } + } + if (withdrawalDto.getAmount().compareTo(cashOutSettingVo.getMinCashOut()) < 0) { throw new FebsException("最小提现金额为"+cashOutSettingVo.getMinCashOut().setScale(2,BigDecimal.ROUND_DOWN)); } @@ -78,12 +95,26 @@ if(wallet.getBalance().compareTo(BigDecimal.ZERO) <= 0){ throw new FebsException("金额不足"); } + if(wallet.getEquityLimit().compareTo(BigDecimal.ZERO) <= 0){ + throw new FebsException("权益积分不足"); + } if(withdrawalDto.getAmount().compareTo(wallet.getBalance()) > 0) { throw new FebsException("金额不足"); } + if(withdrawalDto.getAmount().compareTo(wallet.getEquityLimit()) > 0) { + throw new FebsException("权益积分不足"); + } + +// BigDecimal commission = wallet.getCommission(); +// if(withdrawalDto.getAmount().compareTo(commission) > 0){ +// throw new FebsException("金额不足"); +// } + BigDecimal serviceFee = cashOutSettingVo.getServiceFee().multiply(BigDecimal.valueOf(0.01)); - walletService.reduce(withdrawalDto.getAmount(), memberId, "balance"); + walletService.reduce(withdrawalDto.getAmount(), memberId, "balance");//减少余额 + walletService.reduce(withdrawalDto.getAmount(), memberId, "equityLimit");//减少权益积分 +// walletService.reduce(withdrawalDto.getAmount(), memberId, "commission"); String orderNo = MallUtils.getOrderNum("W"); MallMemberWithdraw withdraw = new MallMemberWithdraw(); @@ -99,6 +130,16 @@ mallMemberService.addMoneyFlow(memberId, withdrawalDto.getAmount().negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), + orderNo, + null, + null, + null, + 1, + FlowTypeEnum.BALANCE.getValue()); + + mallMemberService.addMoneyFlow(memberId, + withdrawalDto.getAmount().negate(), + MoneyFlowTypeEnum.REDUCE_EQUITY_LIMIT.getValue(), orderNo, null, null, @@ -166,13 +207,24 @@ 1, FlowTypeEnum.SCORE.getValue()); + mallMemberService.addMoneyFlow(memberId, + scoreAmount.subtract(amountFee), + MoneyFlowTypeEnum.SCORE_TO_CASH.getValue(), + orderNo, + null, + null, + null, + 1, + FlowTypeEnum.BALANCE.getValue()); + //卖出规则:卖出即销毁减少,70%现金到帐.30%回流底池,意味卖出后全网积分变少了,回流的30%到池子后.积分的价格变高了 DataDictionaryCustom poolCashDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode( PerkEnum.POOL_CASH.getType(), PerkEnum.POOL_CASH.getCode() ); BigDecimal poolCash = new BigDecimal(poolCashDic.getValue()); - poolCash = poolCash.add(amountFee); + //先减去百分之百的提现金额在加上30%的回流金额 + poolCash = poolCash.subtract(scoreAmount).add(amountFee); dataDictionaryCustomMapper.updateDicValueByTypeAndCode( PerkEnum.POOL_CASH.getType(), PerkEnum.POOL_CASH.getCode(), @@ -192,7 +244,7 @@ ); if(poolScore.compareTo(BigDecimal.ZERO) > 0 && poolCash.compareTo(BigDecimal.ZERO) > 0){ - BigDecimal divide = poolCash.divide(poolScore, 2, BigDecimal.ROUND_DOWN); + BigDecimal divide = poolCash.divide(poolScore, 8, BigDecimal.ROUND_DOWN); dataDictionaryCustomMapper.updateDicValueByTypeAndCode( PerkEnum.POOL_SCORE_PRICE.getType(), PerkEnum.POOL_SCORE_PRICE.getCode(), -- Gitblit v1.9.1