| | |
| | | |
| | | |
| | | import com.nq.dao.*; |
| | | import com.nq.enums.EStockType; |
| | | import com.nq.enums.EUserAssets; |
| | | import com.nq.pojo.*; |
| | | import com.nq.service.*; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.utils.DateTimeUtil; |
| | | import com.nq.utils.timeutil.DateTimeUtil; |
| | | import com.nq.utils.KeyUtils; |
| | | import com.nq.utils.redis.RedisShardedPoolUtils; |
| | | |
| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | UserCashDetailMapper userCashDetailMapper; |
| | | |
| | | @Resource |
| | | PayChnnelMapper payChnnelMapper; |
| | | SitePayMapper sitePayMapper; |
| | | |
| | | @Autowired |
| | | IUserAssetsServices userAssetsServices; |
| | | |
| | | |
| | | @Autowired |
| | | ISiteInfoService iSiteInfoService; |
| | | |
| | | @Resource |
| | | UserAssetsMapper userAssetsMapper; |
| | | public ServerResponse checkInMoney(int maxOrder, Integer userId) { |
| | | int count = this.userRechargeMapper.checkInMoney(0, userId); |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public ServerResponse inMoney(String amt, String payType, HttpServletRequest request) { |
| | | public ServerResponse inMoney(String amt, String payType, HttpServletRequest request) throws Exception { |
| | | if (StringUtils.isBlank(amt) || StringUtils.isBlank(payType)) { |
| | | return ServerResponse.createByErrorMsg("The parameter cannot be null"); |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | User user = this.userMapper.selectByPrimaryKey(userRecharge.getUserId()); |
| | | User user = this.userMapper.selectById(userRecharge.getUserId()); |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorMsg("用户不存在"); |
| | | } |
| | | BigDecimal userAmt_before = user.getUserAmt(); |
| | | BigDecimal enableAmt_before = user.getEnableAmt(); |
| | | user.setUserAmt(userAmt_before.add(userRecharge.getPayAmt())); |
| | | user.setEnableAmt(enableAmt_before.add(userRecharge.getPayAmt())); |
| | | int updateCount = this.userMapper.updateByPrimaryKeySelective(user); |
| | | int updateCount = this.userMapper.updateById(user); |
| | | if (updateCount > 0) { |
| | | log.info("1.修改用户资金成功"); |
| | | } else { |
| | |
| | | } |
| | | |
| | | |
| | | UserCashDetail ucd = new UserCashDetail(); |
| | | ucd.setAgentId(user.getAgentId()); |
| | | ucd.setAgentName(user.getAgentName()); |
| | | ucd.setUserId(user.getId()); |
| | | ucd.setUserName(user.getRealName()); |
| | | ucd.setDeType("用户充值"); |
| | | ucd.setDeAmt(userRecharge.getPayAmt()); |
| | | ucd.setDeSummary("用户充值成功,充值前总金额:" + userAmt_before + ",充值后总金额:" + user.getUserAmt() + ",充值前可用:" + enableAmt_before + ",充值后可用:" + user |
| | | .getEnableAmt()); |
| | | |
| | | ucd.setAddTime(new Date()); |
| | | ucd.setIsRead(Integer.valueOf(0)); |
| | | int insertCount = this.userCashDetailMapper.insert(ucd); |
| | | if (insertCount > 0) { |
| | | return ServerResponse.createBySuccessMsg("充值成功!"); |
| | | } |
| | | return ServerResponse.createByErrorMsg("充值失败"); |
| | | } |
| | | |
| | |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | |
| | | User user = this.iUserService.getCurrentUser(request); |
| | | |
| | | |
| | | List<UserRecharge> userRecharges = this.userRechargeMapper.findUserChargeList(user.getId(), payChannel, orderStatus); |
| | | |
| | | log.info("充值列表,增加用户 {} ,payChannel = {} , orderStatus = {}, 数量 = {}", new Object[]{user.getId(), payChannel, orderStatus, userRecharges.size()}); |
| | | |
| | | PageInfo pageInfo = new PageInfo(userRecharges); |
| | | |
| | | for (int i = 0; i <userRecharges.size() ; i++) { |
| | | SitePay s = sitePayMapper.selectById(userRecharges.get(i).getPayId()); |
| | | userRecharges.get(i).setAssetsType(EStockType.JP.getSymbol1()); |
| | | userRecharges.get(i).setChannelName(EStockType.JP.getSymbol()); |
| | | } |
| | | |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | | } |
| | |
| | | |
| | | |
| | | List<UserRecharge> userRecharges = this.userRechargeMapper.listByAdmin(agentId, userId, realName, state, begin_time, end_time); |
| | | |
| | | for (int i = 0; i < userRecharges.size(); i++) { |
| | | UserRecharge userRecharge = userRecharges.get(i); |
| | | PayChnnel payChnnel = payChnnelMapper.selectById(userRecharge.getPayChannel()); |
| | | userRecharge.setPayChannelType(payChnnel.getChannelDesc()); |
| | | User user = userMapper.selectById(userRecharge.getUserId()); |
| | | if (user != null) { |
| | | userRecharge.setUserPhone(user.getPhone()); |
| | | UserRecharge u =userRecharges.get(i); |
| | | User user = userMapper.selectById(u.getUserId()); |
| | | if(user != null){ |
| | | u.setUserPhone(user.getPhone()); |
| | | u.setNickName(user.getRealName()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | PageInfo pageInfo = new PageInfo(userRecharges); |
| | | |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | |
| | | |
| | | @Transactional |
| | | public ServerResponse updateState(Integer chargeId, Integer state) throws Exception { |
| | | UserRecharge userRecharge = this.userRechargeMapper.selectByPrimaryKey(chargeId); |
| | | UserRecharge userRecharge = this.userRechargeMapper.selectById(chargeId); |
| | | |
| | | if (userRecharge == null) { |
| | | return ServerResponse.createByErrorMsg("充值订单不存在"); |
| | |
| | | |
| | | |
| | | if (state.intValue() == 1) { |
| | | |
| | | User user = this.userMapper.selectByPrimaryKey(userRecharge.getUserId()); |
| | | User user = this.userMapper.selectById(userRecharge.getUserId()); |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorMsg("用户不存在"); |
| | | } |
| | | |
| | | PayChnnel payChnnel = payChnnelMapper.selectById(userRecharge.getPayChannel()); |
| | | |
| | | if (!payChnnel.getChannelName().equals("USDT")) { |
| | | BigDecimal user_amt = user.getUserAmt().add(userRecharge.getPayAmt()); |
| | | user.setUserAmt(user_amt); |
| | | BigDecimal user_enable_amt = user.getEnableAmt().add(userRecharge.getPayAmt()); |
| | | user.setEnableAmt(user_enable_amt); |
| | | } else { |
| | | BigDecimal user_amt = user.getUserIndexAmt().add(userRecharge.getPayAmt()); |
| | | user.setUserIndexAmt(user_amt); |
| | | BigDecimal user_enable_amt = user.getEnableIndexAmt().add(userRecharge.getPayAmt()); |
| | | user.setEnableIndexAmt(user_enable_amt); |
| | | } |
| | | int updateCount = this.userMapper.updateByPrimaryKeySelective(user); |
| | | if (updateCount > 0) { |
| | | log.info("修改用户资金成功!"); |
| | | } else { |
| | | log.error("修改用户资金出错,抛出异常"); |
| | | throw new Exception("修改用户资金出错,抛出异常"); |
| | | } |
| | | userAssetsServices.availablebalanceChange(EStockType.JP.getCode(), user.getId(), EUserAssets.TOP_UP,userRecharge.getPayAmt(),"",""); |
| | | } |
| | | |
| | | |
| | | userRecharge.setOrderStatus(Integer.valueOf((state.intValue() == 1) ? 1 : 2)); |
| | | |
| | | |
| | | userRecharge.setPayTime(new Date()); |
| | | int updateCount = this.userRechargeMapper.updateByPrimaryKeySelective(userRecharge); |
| | | if (updateCount > 0) { |
| | |
| | | return ServerResponse.createByErrorMsg("参数不能为空"); |
| | | } |
| | | |
| | | User user = this.userMapper.selectByPrimaryKey(userId); |
| | | User user = this.userMapper.selectById(userId); |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorMsg("找不到用户"); |
| | | } |
| | |
| | | userRecharge.setPayAmt(new BigDecimal(amt.intValue())); |
| | | userRecharge.setAddTime(new Date()); |
| | | userRecharge.setPayTime(new Date()); |
| | | |
| | | if (state.intValue() == 0) { |
| | | userRecharge.setOrderStatus(Integer.valueOf(0)); |
| | | } else if (state.intValue() == 1) { |
| | | userRecharge.setOrderSn(payChannel); |
| | | userRecharge.setPayChannel("2"); |
| | | userRecharge.setOrderStatus(Integer.valueOf(1)); |
| | | |
| | | user.setUserAmt(user.getUserAmt().add(new BigDecimal(amt.intValue()))); |
| | | user.setEnableAmt(user.getEnableAmt().add(new BigDecimal(amt.intValue()))); |
| | | this.userMapper.updateByPrimaryKeySelective(user); |
| | | } else if (state.intValue() == 2) { |
| | | userRecharge.setOrderStatus(Integer.valueOf(2)); |
| | | } else { |
| | | return ServerResponse.createByErrorMsg("订单状态不正确"); |
| | | } |
| | | |
| | | userRecharge.setOrderStatus(Integer.valueOf(1)); |
| | | userRecharge.setPayId(1); |
| | | userAssetsServices.availablebalanceChange(EStockType.JP.getCode(), |
| | | userId,EUserAssets.TOP_UP,new BigDecimal(amt),"",""); |
| | | int insertCount = this.userRechargeMapper.insert(userRecharge); |
| | | if (insertCount > 0) { |
| | | return ServerResponse.createBySuccessMsg("生成订单成功!"); |
| | |
| | | if (cId == null) { |
| | | return ServerResponse.createByErrorMsg("id不能为空"); |
| | | } |
| | | int updateCount = this.userRechargeMapper.deleteByPrimaryKey(cId); |
| | | int updateCount = this.userRechargeMapper.deleteById(cId); |
| | | if (updateCount > 0) { |
| | | return ServerResponse.createBySuccessMsg("删除成功"); |
| | | } |