| | |
| | | |
| | | 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); |
| | |
| | | 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)); |