| | |
| | | |
| | | |
| | | SiteSetting siteSetting = this.iSiteSettingService.getSiteSetting(); |
| | | |
| | | SiteProduct siteProduct = iSiteProductService.getProductSetting(); |
| | | if ((new BigDecimal(amt)).compareTo(new BigDecimal(siteSetting.getWithMinAmt().intValue())) == -1) { |
| | | |
| | | return ServerResponse.createByErrorMsg("出金金额不得低于" + siteSetting.getWithMinAmt() + "元"); |
| | |
| | | Calendar c = Calendar.getInstance(); |
| | | c.setTime(today); |
| | | int weekday = c.get(Calendar.DAY_OF_WEEK); |
| | | if (weekday == 1) { |
| | | if (weekday == 1 && siteProduct.getTranWithdrawDisplay()) { |
| | | return ServerResponse.createByErrorMsg("周末或节假日不能出金!"); |
| | | } |
| | | if (weekday == 7) { |
| | | if (weekday == 7 && siteProduct.getTranWithdrawDisplay()) { |
| | | return ServerResponse.createByErrorMsg("周末或节假日不能出金!"); |
| | | } |
| | | |
| | |
| | | |
| | | int with_time_end = siteSetting.getWithTimeEnd().intValue(); |
| | | |
| | | SiteProduct siteProduct = iSiteProductService.getProductSetting(); |
| | | if(!siteProduct.getTranWithdrawDisplay()){ |
| | | return ServerResponse.createByErrorMsg("提款失败,当前不能出金!"); |
| | | } |
| | | if(siteProduct.getHolidayDisplay()){ |
| | | // if(!siteProduct.getTranWithdrawDisplay()){ |
| | | // return ServerResponse.createByErrorMsg("提款失败,当前不能出金!"); |
| | | // } |
| | | |
| | | if(siteProduct.getHolidayDisplay() && siteProduct.getTranWithdrawDisplay()){ |
| | | return ServerResponse.createByErrorMsg("周末或节假日不能出金!"); |
| | | } |
| | | |
| | | if (!WithDrawUtils.checkIsWithTime(with_time_begin, with_time_end)) { |
| | | if (!WithDrawUtils.checkIsWithTime(with_time_begin, with_time_end) && siteProduct.getTranWithdrawDisplay()) { |
| | | |
| | | return ServerResponse.createByErrorMsg("提款失败,提款时间" + with_time_begin + "点 - " + with_time_end + "点 之间"); |
| | | |
| | |
| | | |
| | | |
| | | synchronized (UserWithdrawServiceImpl.class){ |
| | | //可取港币资金 |
| | | BigDecimal hkAmt=user.getEnaleWithdrawAmt(); |
| | | BigDecimal withdrawAmt = new BigDecimal(amt); |
| | | BigDecimal enableWithdrawAmt = user.getEnaleWithdrawAmt() == null ? BigDecimal.ZERO : user.getEnaleWithdrawAmt(); |
| | | BigDecimal enableAmt = user.getEnableAmt() == null ? BigDecimal.ZERO : user.getEnableAmt(); |
| | | |
| | | int compareAmt = hkAmt.compareTo(new BigDecimal(amt)); |
| | | |
| | | if (compareAmt == -1) { |
| | | if (enableWithdrawAmt.compareTo(withdrawAmt) < 0) { |
| | | |
| | | return ServerResponse.createByErrorMsg("提现失败,用户可取港币资金不足"); |
| | | |
| | | } |
| | | |
| | | BigDecimal reckon_hkAmt = hkAmt.subtract(new BigDecimal(amt)); |
| | | if (enableAmt.compareTo(withdrawAmt) < 0) { |
| | | |
| | | user.setEnaleWithdrawAmt(reckon_hkAmt); |
| | | return ServerResponse.createByErrorMsg("提现失败,用户可用资金不足"); |
| | | |
| | | log.info("提现前,港币金额={},提现后,港币金额={}",hkAmt,reckon_hkAmt); |
| | | } |
| | | |
| | | BigDecimal reckonEnableWithdrawAmt = enableWithdrawAmt.subtract(withdrawAmt); |
| | | |
| | | user.setEnaleWithdrawAmt(reckonEnableWithdrawAmt); |
| | | |
| | | log.info("提现申请,用户 {} 冻结可取资金,原金额 = {} , 冻结后 = {}", user.getId(), enableWithdrawAmt, reckonEnableWithdrawAmt); |
| | | |
| | | int updateUserCount = this.userMapper.updateByPrimaryKeySelective(user); |
| | | |
| | |
| | | |
| | | User user = this.userMapper.selectByPrimaryKey(userWithdraw.getUserId()); |
| | | |
| | | user.setUserAmt(user.getUserAmt().add(userWithdraw.getWithAmt())); |
| | | |
| | | user.setEnableAmt(user.getEnableAmt().add(userWithdraw.getWithAmt())); |
| | | |
| | | user.setEnaleWithdrawAmt(user.getEnaleWithdrawAmt().add(userWithdraw.getWithAmt())); |
| | | BigDecimal enableWithdrawAmt = user.getEnaleWithdrawAmt() == null ? BigDecimal.ZERO : user.getEnaleWithdrawAmt(); |
| | | user.setEnaleWithdrawAmt(enableWithdrawAmt.add(userWithdraw.getWithAmt())); |
| | | |
| | | int updateUserCount = this.userMapper.updateByPrimaryKeySelective(user); |
| | | |
| | | if (updateUserCount > 0) { |
| | | |
| | | log.info("反还用户资金,总 {} 可用 {}", user.getUserAmt(), user.getEnableAmt()); |
| | | log.info("用户取消提现,返还可取资金 {}", userWithdraw.getWithAmt()); |
| | | |
| | | return ServerResponse.createBySuccessMsg("取消成功"); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | @Transactional |
| | | public ServerResponse updateState(Integer withId, Integer state, String authMsg) throws Exception { |
| | | |
| | | UserWithdraw userWithdraw = this.userWithdrawMapper.selectByPrimaryKey(withId); |
| | |
| | | } |
| | | |
| | | |
| | | if (state.intValue() == 1) { |
| | | |
| | | User user = this.userMapper.selectByPrimaryKey(userWithdraw.getUserId()); |
| | | |
| | | if (user == null) { |
| | | |
| | | return ServerResponse.createByErrorMsg("用户不存在"); |
| | | |
| | | } |
| | | |
| | | BigDecimal withAmt = userWithdraw.getWithAmt(); |
| | | BigDecimal enableAmt = user.getEnableAmt() == null ? BigDecimal.ZERO : user.getEnableAmt(); |
| | | |
| | | if (enableAmt.compareTo(withAmt) < 0) { |
| | | |
| | | return ServerResponse.createByErrorMsg("用户可用资金不足,无法完成提现"); |
| | | |
| | | } |
| | | |
| | | BigDecimal afterEnableAmt = enableAmt.subtract(withAmt); |
| | | |
| | | user.setEnableAmt(afterEnableAmt); |
| | | |
| | | log.info("管理员确认提现成功,扣减用户 {} 可用资金,原金额 = {} , 扣减后 = {}", user.getId(), enableAmt, afterEnableAmt); |
| | | |
| | | int updateCount = this.userMapper.updateByPrimaryKeySelective(user); |
| | | |
| | | if (updateCount <= 0) { |
| | | |
| | | throw new Exception("修改用户资金出错,抛出异常"); |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | if (state.intValue() == 2) { |
| | | |
| | | |
| | |
| | | |
| | | } |
| | | |
| | | //计算返还的总港币金额 |
| | | BigDecimal hkAmt = user.getHkAmt().add(userWithdraw.getWithAmt()); |
| | | BigDecimal enableWithdrawAmt = user.getEnaleWithdrawAmt() == null ? BigDecimal.ZERO : user.getEnaleWithdrawAmt(); |
| | | BigDecimal refundAmt = enableWithdrawAmt.add(userWithdraw.getWithAmt()); |
| | | |
| | | log.info("管理员确认提现订单失败,返还用户 {} 总资金,原金额 = {} , 返还后 = {}", new Object[]{user.getId(), user.getHkAmt(), hkAmt}); |
| | | log.info("管理员确认提现订单失败,返还用户 {} 可取资金,原金额 = {} , 返还后 = {}", user.getId(), enableWithdrawAmt, refundAmt); |
| | | |
| | | user.setHkAmt(hkAmt); |
| | | user.setEnaleWithdrawAmt(refundAmt); |
| | | int updateCount = this.userMapper.updateByPrimaryKeySelective(user); |
| | | |
| | | if (updateCount > 0) { |