| | |
| | | package com.nq.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.google.gson.Gson; |
| | | import com.nq.common.CmcPayConfig; |
| | | import com.nq.common.ServerResponse; |
| | |
| | | import com.nq.pay.PayUtil; |
| | | import com.nq.pojo.*; |
| | | import com.nq.service.IPayService; |
| | | import com.nq.service.ISitePayService; |
| | | import com.nq.service.IUserAssetsServices; |
| | | import com.nq.service.IUserService; |
| | | import com.nq.utils.*; |
| | | import com.nq.utils.http.HttpClientUtil; |
| | | import com.nq.utils.pay.CmcPayOuterRequestUtil; |
| | | import com.nq.utils.pay.CmcPayTool; |
| | | import com.nq.utils.timeutil.DateTimeUtil; |
| | | import com.nq.vo.pay.GuoPayVO; |
| | | |
| | | import java.io.IOException; |
| | |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import static com.nq.utils.DateTimeUtil.STANDARD_FORMAT; |
| | | import static com.nq.utils.timeutil.DateTimeUtil.STANDARD_FORMAT; |
| | | |
| | | |
| | | @Service("iPayService") |
| | |
| | | UserMapper userMapper; |
| | | |
| | | @Resource |
| | | SitePayMapper sitePayMapper; |
| | | |
| | | |
| | | @Resource |
| | | IUserService userService; |
| | | |
| | | @Resource |
| | | IUserAssetsServices iUserAssetsServices; |
| | | |
| | | @Resource |
| | | UserWithdrawMapper userWithdrawMapper; |
| | | |
| | | @Resource |
| | |
| | | PayChnnelMapper payChnnelMapper; |
| | | |
| | | |
| | | @Resource |
| | | AgentUserMapper agentUserMapper; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | public ServerResponse flyPay(String payType, String payAmt, String currency, HttpServletRequest request) { |
| | | if( Integer.parseInt(payAmt)>=50000 || Integer.parseInt(payAmt)<100){ |
| | | return ServerResponse.createByErrorMsg("The maximum top-up amount is 100 and 50000"); |
| | | } |
| | | User user = this.iUserService.getCurrentRefreshUser(request); |
| | | if (user == null){ |
| | | return ServerResponse.createBySuccessMsg("Please Login"); |
| | | } |
| | | if(user.getRealName() == null || user.getRealName().isEmpty()){ |
| | | return ServerResponse.createByErrorMsg("Please authenticate with your real name"); |
| | | } |
| | | |
| | | |
| | | @Transactional |
| | | public ServerResponse flyPay(Integer payType, String payAmt, String currency, HttpServletRequest request) { |
| | | User user = iUserService.getCurrentUser(request); |
| | | SitePay sitePay = sitePayMapper.selectById(payType); |
| | | UserRecharge userRecharge = new UserRecharge(); |
| | | userRecharge.setUserId(user.getId()); |
| | | userRecharge.setNickName(user.getRealName()); |
| | | userRecharge.setAgentId(user.getAgentId()); |
| | | String ordersn = KeyUtils.getRechargeOrderSn(); |
| | | userRecharge.setOrderSn(ordersn); |
| | | userRecharge.setPayChannel(payType); |
| | | userRecharge.setPayChannel(sitePay.getChannelName()); |
| | | userRecharge.setPayAmt(new BigDecimal(payAmt)); |
| | | userRecharge.setOrderStatus(Integer.valueOf(0)); |
| | | userRecharge.setAddTime(new Date()); |
| | | int insertCount = this.userRechargeMapper.insert(userRecharge); |
| | | if (insertCount > 0) { |
| | | log.info("fly支付,创建支付订单成功!"); |
| | | } else { |
| | | log.info("fly支付,创建支付订单失败!"); |
| | | } |
| | | |
| | | |
| | | |
| | | PayChnnel payChnnel = payChnnelMapper.selectById(payType); |
| | | if(payChnnel.getChannelName().equals("USDT")){ |
| | | AgentUser agentUser = agentUserMapper.findAgentByAgentId(user.getAgentId()); |
| | | return ServerResponse.createBySuccess(agentUser.getOnLineServices()); |
| | | }else{ |
| | | if(payChnnel.getChannelDesc().equals("wowpay")){ |
| | | return rechargMethodWow(ordersn,payAmt); |
| | | }else if(payChnnel.getChannelDesc().equals("dzxum")){ |
| | | return rechargMethodDz(ordersn,payAmt); |
| | | }else if(payChnnel.getChannelDesc().equals("qeaepay")){ |
| | | return rechargMethodGe(ordersn,payAmt); |
| | | } else{ |
| | | return rechargMethodTop4(ordersn,payAmt); |
| | | } |
| | | } |
| | | |
| | | userRecharge.setPayId(payType); |
| | | userRecharge.setImg(currency); |
| | | userRechargeMapper.insert(userRecharge); |
| | | return ServerResponse.createBySuccess(""); |
| | | } |
| | | |
| | | |
| | |
| | | return ServerResponse.createByErrorMsg("后台通知,查不到订单"); |
| | | } |
| | | |
| | | User user = this.userMapper.selectByPrimaryKey(userRecharge.getUserId()); |
| | | User user = this.userMapper.selectById(userRecharge.getUserId()); |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorMsg("后台通知,查不到用户"); |
| | | } |
| | |
| | | int updateCount = this.userRechargeMapper.updateByPrimaryKeySelective(userRecharge); |
| | | if (updateCount > 0) { |
| | | log.info("后台通知,修改订单状态成功"); |
| | | |
| | | BigDecimal total_amt = user.getUserAmt().add(userRecharge.getPayAmt()); |
| | | total_amt = total_amt.divide(new BigDecimal(100)); |
| | | user.setUserAmt(total_amt); |
| | | BigDecimal total_enable = user.getEnableAmt().add(userRecharge.getPayAmt()); |
| | | user.setEnableAmt(total_enable); |
| | | int updateUserCount = this.userMapper.updateByPrimaryKeySelective(user); |
| | | int updateUserCount = this.userMapper.updateById(user); |
| | | if (updateUserCount > 0) { |
| | | return ServerResponse.createBySuccessMsg("后台通知 处理成功"); |
| | | } |