xiaoyong931011
2023-03-30 836e019db92b9871cba9d440c8159b35f79e1726
src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java
@@ -71,19 +71,28 @@
            throw new FebsException("未找到银行卡信息");
        }
        BigDecimal profit = mallMoneyFlowMapper.selectProfitByDateAndMemberId(memberId);
        MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId);
        if (profit != null) {
            // 可提现
            BigDecimal canMoney = wallet.getCommission().subtract(profit);
//        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(withdrawalDto.getAmount().compareTo(canMoney) > 0) {
                throw new FebsException("提现金额不足");
            }
//        BigDecimal profit = mallMoneyFlowMapper.selectProfitByDateAndMemberId(memberId);
        MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId);
        // 可提现
        BigDecimal canMoney = wallet.getBalance();
        if(withdrawalDto.getAmount().compareTo(canMoney) > 0) {
            throw new FebsException("提现金额不足");
        }
        BigDecimal serviceFee = cashOutSettingVo.getServiceFee().multiply(BigDecimal.valueOf(0.01));
        walletService.reduce(withdrawalDto.getAmount(), memberId, "commission");
        walletService.reduce(withdrawalDto.getAmount(), memberId, "balance");
        String orderNo = MallUtils.getOrderNum("W");
        MallMemberWithdraw withdraw = new MallMemberWithdraw();
@@ -95,6 +104,6 @@
        withdraw.setWtihdrawTypeId(mallMemberBank.getId());
        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().negate(), MoneyFlowTypeEnum.WITHDRAWAL.getValue(), orderNo, null, null, null, 1, FlowTypeEnum.BALANCE.getValue());
    }
}