fix
Hentua
2023-04-25 386d014d8f0ed8bf139f645d851f547cd794732c
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,29 +72,25 @@
        if(ObjectUtil.isEmpty(mallMemberBank)){
            throw new FebsException("未找到银行卡信息");
        }
        if(ObjectUtil.isEmpty(mallMemberBank.getBankName())){
            throw new FebsException("请填写所属银行");
        }
        if(ObjectUtil.isEmpty(mallMemberBank.getSubbranchName())){
            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("提现金额不足");
//            }
//        }
//        BigDecimal profit = mallMoneyFlowMapper.selectProfitByDateAndMemberId(memberId);
        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().compareTo(canMoney) > 0) {
        if(withdrawalDto.getAmount().add(serviceFee).compareTo(canMoney) > 0) {
            throw new FebsException("提现金额不足");
        }
        BigDecimal serviceFee = cashOutSettingVo.getServiceFee().multiply(BigDecimal.valueOf(0.01));
        walletService.reduce(withdrawalDto.getAmount(), memberId, "balance");
        walletService.reduce(withdrawalDto.getAmount().add(serviceFee), memberId, "balance");
        String orderNo = MallUtils.getOrderNum("W");
        MallMemberWithdraw withdraw = new MallMemberWithdraw();
@@ -100,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.BALANCE.getValue());
        mallMemberService.addMoneyFlow(memberId, withdrawalDto.getAmount().add(serviceFee).negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), orderNo, null, null, null, 1, FlowTypeEnum.BALANCE.getValue());
    }
}