KKSU
2024-01-05 22316f91223df0535d67bdc34deeb9d4cb4fbf71
src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java
@@ -53,6 +53,12 @@
    public void withdrawal(WithdrawalDto withdrawalDto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        MallMember mallMember = mallMemberService.getById(memberId);
        Integer outsideWith = mallMember.getOutsideWith() == null ? 2 :mallMember.getOutsideWith();
        if (1 != outsideWith) {
            throw new FebsException("功能升级中");
        }
        if (StrUtil.isBlank(mallMember.getTradePassword())) {
            throw new FebsException("未设置支付密码");
        }
@@ -69,9 +75,14 @@
        //每日提现额度上限
        BigDecimal allCashOut = cashOutSettingVo.getAllCashOut();
        if(withdrawalDto.getAmount().compareTo(allCashOut) > 0){
            throw new FebsException("每日限额为"+cashOutSettingVo.getAllCashOut().setScale(2,BigDecimal.ROUND_DOWN));
        }
        List<MallMemberWithdraw> mallMemberWithdrawListDone = this.baseMapper.selectListByMemberIdAndDate(memberId,new Date());
        if(CollUtil.isNotEmpty(mallMemberWithdrawListDone)){
            if (withdrawalDto.getAmount().compareTo(allCashOut) >= 0) {
            BigDecimal amountTCAll = mallMemberWithdrawListDone.stream().map(MallMemberWithdraw::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
            amountTCAll = amountTCAll.add(withdrawalDto.getAmount());
            if (amountTCAll.compareTo(allCashOut) > 0) {
                throw new FebsException("每日限额为"+cashOutSettingVo.getAllCashOut().setScale(2,BigDecimal.ROUND_DOWN));
            }
        }