KKSU
2023-12-13 e89fa51bb8592aae31ed345400c5a632e394739d
src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java
@@ -16,6 +16,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;
@@ -27,6 +28,8 @@
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
 * @author wzy
@@ -50,6 +53,12 @@
    public void withdrawal(WithdrawalDto withdrawalDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        MallMember mallMember = mallMemberService.getById(memberId);
        Integer outsideWith = mallMember.getOutsideWith() == null ? 2 :mallMember.getOutsideWith();
        if (1 != outsideWith) {
            throw new FebsException("功能升级中");
        }
        if (StrUtil.isBlank(mallMember.getTradePassword())) {
            throw new FebsException("未设置支付密码");
        }
@@ -64,6 +73,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));
        }
@@ -72,6 +95,15 @@
        if(ObjectUtil.isEmpty(mallMemberBank)){
            throw new FebsException("未找到银行卡信息");
        }
        if(ObjectUtil.isEmpty(mallMemberBank.getBankName())){
            throw new FebsException("请填写所属银行");
        }
        if(ObjectUtil.isEmpty(mallMemberBank.getSubbranchName())){
            throw new FebsException("请填写所属支行");
        }
//        if(ObjectUtil.isEmpty(mallMemberBank.getDigitalNo())){
//            throw new FebsException("请填写数字货币账号");
//        }
        MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId);
        // 可提现
@@ -99,7 +131,7 @@
            if("1".equals(voucherOnOff)){
                BigDecimal voucherCntDto = withdrawalDto.getVoucherCnt();
                if(voucherCntDto.compareTo(BigDecimal.ZERO) <= 0){
                    throw new FebsException("红豆不足");
                    throw new FebsException("能量不足");
                }
                //提现需要的凭证数量 = 提现金额 * 余额提现需要绿色凭证比例
                DataDictionaryCustom voucherPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
@@ -118,7 +150,7 @@
//                BigDecimal voucherCnt = wallet.getVoucherCnt();
                BigDecimal voucherFireCnt = wallet.getVoucherFireCnt();
                if(voucherFireCnt.compareTo(voucherPercentNeed) < 0){
                    throw new FebsException("红豆不足");
                    throw new FebsException("能量不足");
                }
//                walletService.reduce(voucherCntDto, memberId, "voucherCnt");