| | |
| | | |
| | | 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; |
| | |
| | | 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"); |
| | | int index = walletService.reduce(withdrawalDto.getAmount().add(serviceFee), memberId, "balance"); |
| | | if (index == 2) { |
| | | throw new FebsException("请刷新页面"); |
| | | } |
| | | String orderNo = MallUtils.getOrderNum("W"); |
| | | |
| | | MallMemberWithdraw withdraw = new MallMemberWithdraw(); |
| | |
| | | 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()); |
| | | } |
| | | } |