无关风月
2025-01-16 ec7528bb6cc65d3bce1c33d59e48ea5bc81c7782
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/WithdrawalRequestsServiceImpl.java
@@ -59,27 +59,30 @@
        LoginUser loginUserApplet = tokenService.getLoginUserApplet();
        AppUser appUser = appUserService.getById(loginUserApplet.getUserid());
        Integer vipId = appUser.getVipId();
        VipSetting vipSetting = vipSettingService.getVipSettingById(vipId);
        BigDecimal withdrawableAmount = appUser.getWithdrawableAmount();
        BigDecimal vipWithdrawalMinAmount = vipSetting.getVipWithdrawalMinAmount();
        if (vipWithdrawalMinAmount.compareTo(withdrawableAmount) > 0) {
            throw new ServiceException("提现失败,提现门槛为:"+vipWithdrawalMinAmount+"元!");
        }
        if (appUser.getWithdrawableAmount().compareTo(withdrawalAmount) < 0) {
            throw new ServiceException("提现失败,可提现金额不足!");
        }
        Integer vipId = appUser.getVipId();
        VipSetting vipSetting = vipSettingService.getVipSettingById(vipId);
        if (vipSetting.getVipWithdrawalRole() == 0) {
            throw new ServiceException("提现失败,当前会员等级不允许提现!");
        }
        BigDecimal vipWithdrawalMinAmount = vipSetting.getVipWithdrawalMinAmount();
        if (withdrawalAmount.compareTo(vipWithdrawalMinAmount) < 0) {
            throw new ServiceException("提现失败,提现金额不能小于" + vipWithdrawalMinAmount + "元!");
        }
        // 提现手续费
        BigDecimal vipWithdrawalFee = vipSetting.getVipWithdrawalFee()
                .divide(VIP_WITHDRAWAL_FEE_DENOMINATOR, 2, RoundingMode.HALF_UP);
        // 减去手续费
        BigDecimal multiply = params.getWithdrawalAmount().multiply(vipWithdrawalFee);
        params.setWithdrawalAmount(params.getWithdrawalAmount()
                .subtract(multiply));
        params.setWithdrawalAmount(params.getWithdrawalAmount().subtract(multiply));
        WithdrawalRequests withdrawalRequests = new WithdrawalRequests();
        BeanUtils.copyBeanProp(withdrawalRequests, params);
@@ -92,14 +95,13 @@
            withdrawalRequests.setBankCardNumber(appUserBank.getBankNumber());
        }
        withdrawalRequests.setWithdrawalAmount(withdrawalAmount);
        withdrawalRequests.setArrivalAmount(withdrawalRequests.getWithdrawalAmount());
        withdrawalRequests.setArrivalAmount(params.getWithdrawalAmount());
        withdrawalRequests.setServiceCharge(multiply);
        withdrawalRequests.setDelFlag(0);
        withdrawalRequests.setAppUserId(SecurityUtils.getUserId());
        withdrawalRequests.setAuditStatus(1);
        save(withdrawalRequests);
        //修改用户的可提现金额
        BigDecimal withdrawableAmount = appUser.getWithdrawableAmount();
        BigDecimal withdrawnAmount = appUser.getWithdrawnAmount();
        BigDecimal balance = appUser.getBalance();
        appUser.setWithdrawableAmount(withdrawableAmount.subtract(withdrawalAmount).setScale(2, RoundingMode.HALF_EVEN));
@@ -109,6 +111,7 @@
        //添加变动明细
        BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord();
        balanceChangeRecord.setAppUserId(appUser.getId());
        balanceChangeRecord.setVipId(appUser.getVipId());
        balanceChangeRecord.setOrderId(withdrawalRequests.getId());
        balanceChangeRecord.setChangeType(2);
        balanceChangeRecord.setBeforeAmount(balance);