fix
Hentua
2023-04-25 6c98fa6643e00e6a31b87d58184b6470f990e76f
src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java
@@ -2,8 +2,10 @@
import cc.mrbird.febs.common.enumerates.DataDictionaryEnum;
import cc.mrbird.febs.common.enumerates.FlowTypeEnum;
import cc.mrbird.febs.common.enumerates.GreenScoreEnum;
import cc.mrbird.febs.common.enumerates.MoneyFlowTypeEnum;
import cc.mrbird.febs.common.exception.FebsException;
import cc.mrbird.febs.common.utils.AppContants;
import cc.mrbird.febs.common.utils.LoginUserUtil;
import cc.mrbird.febs.common.utils.MallUtils;
import cc.mrbird.febs.mall.dto.WithdrawalDto;
@@ -70,20 +72,25 @@
        if(ObjectUtil.isEmpty(mallMemberBank)){
            throw new FebsException("未找到银行卡信息");
        }
        BigDecimal profit = mallMoneyFlowMapper.selectProfitByDateAndMemberId(memberId);
        MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId);
        if (profit != null) {
            // 可提现
            BigDecimal canMoney = wallet.getCommission().subtract(profit);
            if(withdrawalDto.getAmount().compareTo(canMoney) > 0) {
                throw new FebsException("提现金额不足");
            }
        if(ObjectUtil.isEmpty(mallMemberBank.getBankName())){
            throw new FebsException("请填写所属银行");
        }
        if(ObjectUtil.isEmpty(mallMemberBank.getSubbranchName())){
            throw new FebsException("请填写所属支行");
        }
        BigDecimal serviceFee = cashOutSettingVo.getServiceFee().multiply(BigDecimal.valueOf(0.01));
        walletService.reduce(withdrawalDto.getAmount(), memberId, "commission");
        MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId);
        BigDecimal serviceFeePercent = cashOutSettingVo.getServiceFee().multiply(BigDecimal.valueOf(0.01));
        BigDecimal serviceFee = serviceFeePercent.multiply(withdrawalDto.getAmount());
        // 可提现
        BigDecimal canMoney = wallet.getBalance();
        if(withdrawalDto.getAmount().add(serviceFee).compareTo(canMoney) > 0) {
            throw new FebsException("提现金额不足");
        }
        walletService.reduce(withdrawalDto.getAmount().add(serviceFee), memberId, "commission");
        String orderNo = MallUtils.getOrderNum("W");
        MallMemberWithdraw withdraw = new MallMemberWithdraw();
@@ -91,10 +98,11 @@
        withdraw.setMemberId(memberId);
        withdraw.setAmount(withdrawalDto.getAmount());
        withdraw.setStatus(1);
        withdraw.setAmountFee(serviceFee.multiply(withdrawalDto.getAmount()));
        withdraw.setAmountFee(serviceFee);
        withdraw.setWtihdrawTypeId(mallMemberBank.getId());
        withdraw.setRemark(AppContants.MEMBER_WITHDRAW_NORMAL);
        this.baseMapper.insert(withdraw);
        mallMemberService.addMoneyFlow(memberId, withdrawalDto.getAmount().negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), orderNo, null, null, null, 1, FlowTypeEnum.COMMISSION.getValue());
        mallMemberService.addMoneyFlow(memberId, withdrawalDto.getAmount().add(serviceFee).negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), orderNo, null, null, null, 1, FlowTypeEnum.BALANCE.getValue());
    }
}