xiaoyong931011
2023-04-10 11863ca3ac6a211fa41019b0ae3b2c1fbbdc3d40
src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java
@@ -71,19 +71,16 @@
            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(wallet.getBalance().compareTo(BigDecimal.ZERO) <= 0){
            throw new FebsException("金额不足");
        }
        if(withdrawalDto.getAmount().compareTo(wallet.getBalance()) > 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 +92,14 @@
        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());
    }
}