| | |
| | | public BigDecimal canMoney() { |
| | | Long memberId = LoginUserUtil.getLoginUser().getId(); |
| | | MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | | BigDecimal profit = mallMoneyFlowMapper.selectProfitByDateAndMemberId(memberId); |
| | | |
| | | BigDecimal canMoney = wallet.getCommission(); |
| | | if (profit != null) { |
| | | if(canMoney.compareTo(BigDecimal.ZERO) > 0) { |
| | | canMoney = canMoney.subtract(profit); |
| | | } |
| | | } |
| | | return canMoney.compareTo(BigDecimal.ZERO) < 1 ? BigDecimal.ZERO : canMoney; |
| | | return wallet.getBalance(); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId); |
| | | BigDecimal profit = mallMoneyFlowMapper.selectProfitByDateAndMemberId(memberId); |
| | | |
| | | BigDecimal serviceFeePercent = cashOutSettingVo.getServiceFee().multiply(BigDecimal.valueOf(0.01)); |
| | | BigDecimal serviceFee = serviceFeePercent.multiply(withdrawalDto.getAmount()); |
| | | // 可提现 |
| | | BigDecimal canMoney = wallet.getCommission(); |
| | | if (profit != null) { |
| | | if(canMoney.subtract(serviceFee).compareTo(BigDecimal.ZERO) > 0) { |
| | | canMoney = canMoney.subtract(profit); |
| | | } |
| | | } |
| | | BigDecimal canMoney = wallet.getBalance(); |
| | | |
| | | if(withdrawalDto.getAmount().compareTo(canMoney) > 0) { |
| | | if(withdrawalDto.getAmount().add(serviceFee).compareTo(canMoney) > 0) { |
| | | throw new FebsException("提现金额不足"); |
| | | } |
| | | |
| | |
| | | withdraw.setRemark(AppContants.MEMBER_WITHDRAW_NORMAL); |
| | | this.baseMapper.insert(withdraw); |
| | | |
| | | mallMemberService.addMoneyFlow(memberId, withdrawalDto.getAmount().add(serviceFee).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()); |
| | | } |
| | | } |
| | |
| | | continue; |
| | | } |
| | | |
| | | walletService.add(direct, parent.getId(), "commission"); |
| | | moneyFlowService.addMoneyFlow(parent.getId(), direct, MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.COMMISSION.getValue()); |
| | | walletService.add(direct, parent.getId(), "balance"); |
| | | moneyFlowService.addMoneyFlow(parent.getId(), direct, MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.BALANCE.getValue()); |
| | | moneyFlowService.addMoneyFlow(parent.getId(), direct.negate(), MoneyFlowTypeEnum.RECOMMEND_BONUS.getValue(), orderInfo.getOrderNo(), FlowTypeEnum.SCORE.getValue()); |
| | | } |
| | | // =======隔代奖== end ===== |
| | |
| | | } |
| | | |
| | | income = map.get("amount"); |
| | | walletService.add(income, memberId, "commission"); |
| | | moneyFlowService.addMoneyFlow(memberId, income, type, orderNo, FlowTypeEnum.COMMISSION.getValue()); |
| | | walletService.add(income, memberId, "balance"); |
| | | moneyFlowService.addMoneyFlow(memberId, income, type, orderNo, FlowTypeEnum.BALANCE.getValue()); |
| | | moneyFlowService.addMoneyFlow(memberId, income.negate(), type, orderNo, FlowTypeEnum.SCORE.getValue()); |
| | | return income; |
| | | } |