| | |
| | | } |
| | | } |
| | | |
| | | @RequestMapping({"juhenewpayNotify.do"}) |
| | | @ResponseBody |
| | | public JSONObject juhenewpayNotify(HttpServletRequest request, HttpServletResponse response) throws IOException { |
| | | System.out.println("============开始回调==============="); |
| | | LinkedMap map = new LinkedMap(); |
| | | String orderno = (String) request.getParameter("orderno"); |
| | | String amount = (String) request.getParameter("payamount"); |
| | | String[] arr = orderno.split("_"); |
| | | map.put("payamount", request.getParameter("payamount")); |
| | | map.put("orderno", orderno); |
| | | map.put("status", (String) request.getParameter("status")); |
| | | log.info("回调创建订单前map==="+map.toString()); |
| | | // @RequestMapping({"juhenewpayNotify.do"}) |
| | | // @ResponseBody |
| | | // public JSONObject juhenewpayNotify(HttpServletRequest request, HttpServletResponse response) throws IOException { |
| | | // System.out.println("============开始回调==============="); |
| | | // LinkedMap map = new LinkedMap(); |
| | | // String orderno = (String) request.getParameter("orderno"); |
| | | // String amount = (String) request.getParameter("payamount"); |
| | | // String[] arr = orderno.split("_"); |
| | | // map.put("payamount", request.getParameter("payamount")); |
| | | // map.put("orderno", orderno); |
| | | // map.put("status", (String) request.getParameter("status")); |
| | | // log.info("回调创建订单前map==="+map.toString()); |
| | | // |
| | | // JSONObject jsonObj = new JSONObject(); |
| | | // Map<String,Object> json = new HashMap<String,Object>(); |
| | | // |
| | | // |
| | | // if ("1".equals((String) request.getParameter("status"))) { |
| | | // // 这里编写用户业务逻辑代码,如存储订单状态,自动发货等 |
| | | // //TODO |
| | | // if (amount != null & !StringUtils.isEmpty(amount)) { |
| | | // System.out.println("============更新用户金额==============="); |
| | | // Double aDouble = Double.valueOf(amount); |
| | | // Integer integer = aDouble.intValue(); |
| | | // //判断是否回调成功 |
| | | // UserRecharge userRecharge = this.userRechargeMapper.findUserRechargeByOrderSn(orderno); |
| | | // if(userRecharge == null){ |
| | | // System.out.println("============ 充值完成==============="); |
| | | // iUserRechargeService.createOrder("ST",Integer.valueOf(arr[0]), 1, aDouble.intValue(), orderno); |
| | | // jsonObj.put("reason", "success"); |
| | | // } else { |
| | | // System.out.println("============充值失败,已回调成功无需重复回调==============="); |
| | | // jsonObj.put("reason", "error"); |
| | | // } |
| | | // } else{ |
| | | // jsonObj.put("reason", "error"); |
| | | // } |
| | | // System.out.println("============回调成功并结束==============="); |
| | | // //jsonObj.putAll(map); |
| | | // return jsonObj; |
| | | // } else { |
| | | // System.out.println("============回调失败并结束==============="); |
| | | // jsonObj.put("reason", "error"); |
| | | // return jsonObj; |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | JSONObject jsonObj = new JSONObject(); |
| | | Map<String,Object> json = new HashMap<String,Object>(); |
| | | |
| | | |
| | | if ("1".equals((String) request.getParameter("status"))) { |
| | | // 这里编写用户业务逻辑代码,如存储订单状态,自动发货等 |
| | | //TODO |
| | | if (amount != null & !StringUtils.isEmpty(amount)) { |
| | | System.out.println("============更新用户金额==============="); |
| | | Double aDouble = Double.valueOf(amount); |
| | | Integer integer = aDouble.intValue(); |
| | | //判断是否回调成功 |
| | | UserRecharge userRecharge = this.userRechargeMapper.findUserRechargeByOrderSn(orderno); |
| | | if(userRecharge == null){ |
| | | System.out.println("============ 充值完成==============="); |
| | | iUserRechargeService.createOrder(Integer.valueOf(arr[0]), 1, aDouble.intValue(), orderno); |
| | | jsonObj.put("reason", "success"); |
| | | } else { |
| | | System.out.println("============充值失败,已回调成功无需重复回调==============="); |
| | | jsonObj.put("reason", "error"); |
| | | } |
| | | } else{ |
| | | jsonObj.put("reason", "error"); |
| | | } |
| | | System.out.println("============回调成功并结束==============="); |
| | | //jsonObj.putAll(map); |
| | | return jsonObj; |
| | | } else { |
| | | System.out.println("============回调失败并结束==============="); |
| | | jsonObj.put("reason", "error"); |
| | | return jsonObj; |
| | | } |
| | | |
| | | } |
| | | |
| | | @RequestMapping({"juheh5payNotify.do"}) |
| | | @ResponseBody |
| | | public void juheh5payNotify(HttpServletRequest request, HttpServletResponse response) throws IOException { |
| | | System.out.println("============开始回调==============="); |
| | | LinkedMap map = new LinkedMap(); |
| | | String orderno = (String) request.getParameter("name"); |
| | | String amount = (String) request.getParameter("money"); |
| | | String[] arr = orderno.split("_"); |
| | | map.put("money", request.getParameter("money")); |
| | | map.put("name", orderno); |
| | | log.info("回调创建订单前map==="+map.toString()); |
| | | |
| | | JSONObject jsonObj = new JSONObject(); |
| | | Map<String,Object> json = new HashMap<String,Object>(); |
| | | |
| | | |
| | | //if ("200".equals((String) request.getParameter("status"))) { |
| | | // 这里编写用户业务逻辑代码,如存储订单状态,自动发货等 |
| | | //TODO |
| | | if (amount != null & !StringUtils.isEmpty(amount)) { |
| | | System.out.println("============更新用户金额==============="); |
| | | Double aDouble = Double.valueOf(amount); |
| | | Integer integer = aDouble.intValue(); |
| | | //判断是否回调成功 |
| | | UserRecharge userRecharge = this.userRechargeMapper.findUserRechargeByOrderSn(orderno); |
| | | if(userRecharge == null){ |
| | | System.out.println("============充值完成==============="); |
| | | iUserRechargeService.createOrder(Integer.valueOf(arr[0]), 1, aDouble.intValue(), orderno); |
| | | } else { |
| | | System.out.println("============充值失败,已回调成功无需重复回调==============="); |
| | | } |
| | | } else{ |
| | | } |
| | | System.out.println("============回调成功并结束==============="); |
| | | //jsonObj.putAll(map); |
| | | response.getWriter().write("success"); |
| | | /*} else { |
| | | System.out.println("============回调失败并结束==============="); |
| | | response.getWriter().write("error"); |
| | | }*/ |
| | | |
| | | } |
| | | // @RequestMapping({"juheh5payNotify.do"}) |
| | | // @ResponseBody |
| | | // public void juheh5payNotify(HttpServletRequest request, HttpServletResponse response) throws IOException { |
| | | // System.out.println("============开始回调==============="); |
| | | // LinkedMap map = new LinkedMap(); |
| | | // String orderno = (String) request.getParameter("name"); |
| | | // String amount = (String) request.getParameter("money"); |
| | | // String[] arr = orderno.split("_"); |
| | | // map.put("money", request.getParameter("money")); |
| | | // map.put("name", orderno); |
| | | // log.info("回调创建订单前map==="+map.toString()); |
| | | // |
| | | // JSONObject jsonObj = new JSONObject(); |
| | | // Map<String,Object> json = new HashMap<String,Object>(); |
| | | // |
| | | // |
| | | // //if ("200".equals((String) request.getParameter("status"))) { |
| | | // // 这里编写用户业务逻辑代码,如存储订单状态,自动发货等 |
| | | // //TODO |
| | | // if (amount != null & !StringUtils.isEmpty(amount)) { |
| | | // System.out.println("============更新用户金额==============="); |
| | | // Double aDouble = Double.valueOf(amount); |
| | | // Integer integer = aDouble.intValue(); |
| | | // //判断是否回调成功 |
| | | // UserRecharge userRecharge = this.userRechargeMapper.findUserRechargeByOrderSn(orderno); |
| | | // if(userRecharge == null){ |
| | | // System.out.println("============充值完成==============="); |
| | | // iUserRechargeService.createOrder(Integer.valueOf(arr[0]), 1, aDouble.intValue(), orderno); |
| | | // } else { |
| | | // System.out.println("============充值失败,已回调成功无需重复回调==============="); |
| | | // } |
| | | // } else{ |
| | | // } |
| | | // System.out.println("============回调成功并结束==============="); |
| | | // //jsonObj.putAll(map); |
| | | // response.getWriter().write("success"); |
| | | // /*} else { |
| | | // System.out.println("============回调失败并结束==============="); |
| | | // response.getWriter().write("error"); |
| | | // }*/ |
| | | // |
| | | // } |
| | | |
| | | @RequestMapping({"flyNotify.do"}) |
| | | @ResponseBody |
| | |
| | | @RequestMapping("getGoldCrudeOil.do") |
| | | @ResponseBody |
| | | public ServerResponse getGoldCrudeOil(HttpServletRequest request) { |
| | | |
| | | String gold = RedisShardedPoolUtils.get(RedisKeyConstant.gold); |
| | | String crudeOil = RedisShardedPoolUtils.get(RedisKeyConstant.crude_oil); |
| | | HashMap<String,String> map = new HashMap<>(); |
| | | map.put(new GoogleTranslateUtil().translate("GOLD",request.getHeader("lang")),gold); |
| | | map.put(new GoogleTranslateUtil().translate("CRUDE OIL",request.getHeader("lang")),crudeOil); |
| | | return ServerResponse.createBySuccess(map); |
| | | |
| | | HashMap<String,HashMap> hashMap = new HashMap<>(); |
| | | |
| | | HashMap<String,String> goldMap = new HashMap<>(); |
| | | String goldName = new GoogleTranslateUtil().translate("GOLD", request.getHeader("lang")); |
| | | goldMap.put(goldName,gold); |
| | | hashMap.put("GOLD",goldMap); |
| | | |
| | | HashMap<String,String> crudOilMap = new HashMap<>(); |
| | | String crudeOilName = new GoogleTranslateUtil().translate("CRUDE OIL", request.getHeader("lang")); |
| | | crudOilMap.put(crudeOilName,crudeOil); |
| | | hashMap.put("CRUDE OIL",crudOilMap); |
| | | |
| | | return ServerResponse.createBySuccess(hashMap); |
| | | } |
| | | |
| | | |
| | |
| | | import com.nq.pojo.MoneyLog; |
| | | import com.nq.pojo.SiteSpread; |
| | | import com.nq.pojo.StockConfig; |
| | | import com.nq.service.IMoneyLogServces; |
| | | import com.nq.service.ISiteSpreadService; |
| | | import com.nq.service.IStockConfigServices; |
| | | import com.nq.service.IUserService; |
| | | import com.nq.service.*; |
| | | |
| | | import com.nq.utils.PropertiesUtil; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | MoneyLogMapper moneyLogMapper; |
| | | |
| | | |
| | | //注册 |
| | | @RequestMapping(value = {"reg.do"}, method = {RequestMethod.POST}) |
| | |
| | | moneyLogPage.setRecords(records); |
| | | return ServerResponse.createBySuccess(moneyLogPage); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | public ServerResponse updateayChnnel( |
| | | @RequestParam("id") Integer id, |
| | | @RequestParam("amt") String amt, |
| | | @RequestParam("type") String type |
| | | @RequestParam("type") String type, |
| | | @RequestParam("accectType") String accectType |
| | | |
| | | ){ |
| | | return iUserAssetsServices.updateUserAssets(id,amt,type); |
| | | } |
| | | |
| | | @RequestMapping("transfer.do") |
| | | @ResponseBody |
| | | public ServerResponse transfer( |
| | | @RequestParam("userId") Integer userId, |
| | | @RequestParam("disbursementAccount") String disbursementAccount, |
| | | @RequestParam("depositAccount") String depositAccount, |
| | | @RequestParam("amt") String amt, HttpServletRequest request |
| | | ){ |
| | | return iUserAssetsServices.transfer(userId,disbursementAccount,depositAccount,amt,request); |
| | | return iUserAssetsServices.updateUserAssets(id,amt,type,accectType); |
| | | } |
| | | } |
| | |
| | | return serverResponse; |
| | | } |
| | | |
| | | //创建资金管理 充值订单 |
| | | @RequestMapping({"createOrder.do"}) |
| | | @ResponseBody |
| | | public ServerResponse createOrder(@RequestParam(value = "userId", required = false) Integer userId, @RequestParam(value = "state", required = false) Integer state, @RequestParam(value = "amt", required = false) Integer amt, @RequestParam(value = "payChannel", required = false) String payChannel) { |
| | | return this.iUserRechargeService.createOrder(userId, state, amt, payChannel); |
| | | } |
| | | // //创建资金管理 充值订单 |
| | | // @RequestMapping({"createOrder.do"}) |
| | | // @ResponseBody |
| | | // public ServerResponse createOrder(@RequestParam(value = "userId", required = false) Integer userId, |
| | | // @RequestParam(value = "state", required = false) Integer state, |
| | | // @RequestParam(value = "amt", required = false) Integer amt, |
| | | // @RequestParam(value = "payChannel", required = false) String payChannel) { |
| | | // return this.iUserRechargeService.createOrder(userId, state, amt, payChannel); |
| | | // } |
| | | |
| | | //删除资金管理 充值列表订单信息 |
| | | @RequestMapping({"del.do"}) |
| | |
| | | @Autowired |
| | | IUserRechargeService iUserRechargeService; |
| | | |
| | | |
| | | @Autowired |
| | | IUserAssetsServices iUserAssetsServices; |
| | | |
| | | @Autowired |
| | | IApplyLeverServices iApplyLeverServices; |
| | |
| | | return this.iUserStockSubscribeService.userSubmit(id,request); |
| | | } |
| | | |
| | | @RequestMapping({"transfer.do"}) |
| | | // @RequestMapping({"transfer.do"}) |
| | | // @ResponseBody |
| | | // public ServerResponse transfer(@RequestParam("fromType") String fromType, @RequestParam("toType") String toType, |
| | | // @RequestParam("amt") String amt, HttpServletRequest request) { |
| | | // return iUserService.transfer(fromType, toType, amt,request); |
| | | // } |
| | | |
| | | @RequestMapping("transfer.do") |
| | | @ResponseBody |
| | | public ServerResponse transfer(@RequestParam("fromType") String fromType, @RequestParam("toType") String toType, |
| | | @RequestParam("amt") String amt, HttpServletRequest request) { |
| | | return iUserService.transfer(fromType, toType, amt,request); |
| | | public ServerResponse transfer( |
| | | @RequestParam("userId") Integer userId, |
| | | @RequestParam("disbursementAccount") String disbursementAccount, |
| | | @RequestParam("depositAccount") String depositAccount, |
| | | @RequestParam("amt") String amt, HttpServletRequest request |
| | | ){ |
| | | return iUserAssetsServices.transfer(userId,disbursementAccount,depositAccount,amt,request); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.pojo.User; |
| | | import com.nq.pojo.UserRecharge; |
| | | import com.nq.service.IUserRechargeService; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.nq.service.IUserService; |
| | | import com.nq.utils.KeyUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | |
| | | @Controller |
| | |
| | | |
| | | @Autowired |
| | | IUserRechargeService iUserRechargeService; |
| | | |
| | | @Autowired |
| | | IUserService iUserService; |
| | | |
| | | //分页查询所有充值记录 |
| | | @RequestMapping({"list.do"}) |
| | |
| | | public ServerResponse inMoney(String amt, String payType, HttpServletRequest request) { |
| | | return this.iUserRechargeService.inMoney(amt, payType, request); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping("saveUserRecharge.do") |
| | | @ResponseBody |
| | | public ServerResponse saveUserRecharge( |
| | | @RequestParam("amt") String amt, |
| | | HttpServletRequest request |
| | | |
| | | ){ |
| | | User user = this.iUserService.getCurrentRefreshUser(request); |
| | | return iUserRechargeService.saveUserRecharge(user.getId(),amt,request); |
| | | } |
| | | } |
| | |
| | | |
| | | import java.util.List; |
| | | |
| | | public class RPageInfo extends PageInfo { |
| | | public class RPageInfo<T> extends PageInfo<T> { |
| | | |
| | | private String stockType; |
| | | |
| | |
| | | |
| | | |
| | | |
| | | ServerResponse updateUserAssets(Integer id, String amt,String type); |
| | | ServerResponse updateUserAssets(Integer id, String amt, String type, String accectType); |
| | | |
| | | |
| | | List<UserAssets> assetsByUserId(Integer userId); |
| | |
| | | |
| | | ServerResponse updateState(Integer paramInteger1, Integer paramInteger2) throws Exception; |
| | | |
| | | ServerResponse createOrder(Integer paramInteger1, Integer paramInteger2, Integer paramInteger3, String paramString); |
| | | ServerResponse createOrder(String accectType, Integer paramInteger1, Integer paramInteger2, Integer paramInteger3, String paramString); |
| | | |
| | | ServerResponse del(Integer paramInteger); |
| | | |
| | |
| | | BigDecimal CountTotalRechargeAmountByTime(Integer paramInteger); |
| | | |
| | | List<UserRecharge> exportByAdmin( Integer agentId, Integer userId, String realName, Integer state, String beginTime, String endTime, HttpServletRequest request); |
| | | |
| | | ServerResponse saveUserRecharge(Integer id, String amt, HttpServletRequest request); |
| | | } |
| | |
| | | |
| | | // 批量抓取新闻 |
| | | for (int type : types) { |
| | | String url = apiUrl + "stock-markets?key=" + apiKey + "&type=" + type; |
| | | String url = apiUrl + "stock-markets?key=" + apiKey + "&country_id=52&type=" + type; |
| | | addNews(type, url); |
| | | } |
| | | } |
| | |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | if (stockList.size() > 0){ |
| | | stockListVOS.addAll(Objects.requireNonNull(StockApi.getStockReailTimes(stockList))); |
| | | } |
| | | RPageInfo pageInfo = new RPageInfo(); |
| | | RPageInfo<StockListVO> pageInfo = new RPageInfo<StockListVO>(); |
| | | |
| | | |
| | | if(null != orderBy && orderBy.equals("asc")){ |
| | | stockListVOS = stockListVOS.stream().sorted(Comparator.comparing(StockListVO::getHcrate)).collect(Collectors.toList()); |
| | | } |
| | | |
| | | if(null != orderBy && orderBy.equals("desc")){ |
| | | stockListVOS = stockListVOS.stream() |
| | | .sorted(Comparator.comparing(StockListVO::getHcrate).reversed()) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | pageInfo.setList(stockListVOS); |
| | | pageInfo.setStockType(stockType); |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | |
| | | if ((key.equals("CRUDE OIL") && fields.length == 7) || (key.equals("GOLD") && fields.length == 5)) { |
| | | kData kData = new kData(); |
| | | kData.setT(convDate(fields[0],interval)); |
| | | kData.setC(price); |
| | | kData.setC(fields[4]); |
| | | kData.setO(fields[1]); |
| | | kData.setH(fields[2]); |
| | | kData.setL(fields[3]); |
| | | if(key.equals("CRUDE OIL")){ |
| | | kData.setV(fields[4]); |
| | | kData.setVo(fields[5]); |
| | | kData.setV(fields[5]); |
| | | kData.setVo(fields[6]); |
| | | }else{ |
| | | kData.setV("0"); |
| | | kData.setVo("0"); |
| | |
| | | } |
| | | } |
| | | } |
| | | kDataList.get(kDataList.size() - 1).setC(price); |
| | | return kDataList; |
| | | } |
| | | |
| | |
| | | package com.nq.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.dao.*; |
| | | import com.nq.enums.EStockType; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * 用户资产 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class UserAssetsServices implements IUserAssetsServices { |
| | | public class UserAssetsServices extends ServiceImpl<UserAssetsMapper, UserAssets> implements IUserAssetsServices { |
| | | |
| | | @Resource |
| | | UserAssetsMapper userAssetsMapper; |
| | |
| | | @Autowired |
| | | UserPositionMapper userPositionMapper; |
| | | |
| | | @Autowired |
| | | StockConfigMapper stockConfigMapper; |
| | | |
| | | @Override |
| | | public UserAssets assetsByTypeAndUserId(String accetType, Integer userId) { |
| | | if(accetType.equals("SZHB")){ |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ServerResponse updateUserAssets(Integer id, String amt,String type) { |
| | | UserAssets userAssets = userAssetsMapper.selectById(id); |
| | | public ServerResponse updateUserAssets(Integer id, String amt, String type, String accectType) { |
| | | UserAssets userAssets = userAssetsMapper.selectOne(new LambdaQueryWrapper<>(UserAssets.class) |
| | | .eq(UserAssets::getId,id) |
| | | .eq(UserAssets::getAccectType,accectType) |
| | | ); |
| | | UserPosition userPosition = userPositionMapper.selectOne(new LambdaQueryWrapper<UserPosition>().gt(UserPosition::getAmountToBeCovered, BigDecimal.ZERO).eq(UserPosition::getUserId,userAssets.getUserId())); |
| | | // 0 入款 1是扣钱 2 是充值 3 是提币 |
| | | BigDecimal bigAmt = new BigDecimal(amt); |
| | |
| | | } |
| | | }else{ |
| | | if(type.equals("2")){ |
| | | return userRechargeService.createOrder(userAssets.getUserId(),1,bigAmt.intValue(),"1"); |
| | | return userRechargeService.createOrder(accectType,userAssets.getUserId(),1,bigAmt.intValue(),"1"); |
| | | }else{ |
| | | return ServerResponse.createBySuccess(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | public void saveUserRecharge(Integer userId ,BigDecimal amt){ |
| | | User user = this.userMapper.selectById(userId); |
| | | if (user == null) { |
| | | return; |
| | | } |
| | | 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("1"); |
| | | userRecharge.setPayAmt(new BigDecimal(amt.intValue())); |
| | | userRecharge.setAddTime(new Date()); |
| | | userRecharge.setPayTime(new Date()); |
| | | userRecharge.setOrderStatus(Integer.valueOf(0)); |
| | | userRecharge.setPayId(1); |
| | | userRechargeMapper.insert(userRecharge); |
| | | } |
| | | |
| | | |
| | |
| | | // 执行转账操作 |
| | | try { |
| | | synchronized (userId){ |
| | | performTransfer(disbursement, deposit, transferAmount); |
| | | performTransfer(disbursementAccount,disbursement, deposit, transferAmount); |
| | | } |
| | | return ServerResponse.createBySuccess("划转成功", request); |
| | | } catch (Exception e) { |
| | |
| | | } |
| | | |
| | | // 执行转账操作 |
| | | private void performTransfer(UserAssets disbursement, UserAssets deposit, BigDecimal transferAmount) { |
| | | // 更新转出账户余额 |
| | | disbursement.setAvailableBalance(disbursement.getAvailableBalance().subtract(transferAmount)); |
| | | userAssetsMapper.updateById(disbursement); |
| | | |
| | | // 更新转入账户余额 |
| | | deposit.setAvailableBalance(deposit.getAvailableBalance().add(transferAmount)); |
| | | userAssetsMapper.updateById(deposit); |
| | | private void performTransfer(String disbursementAccount,UserAssets disbursement, UserAssets deposit, BigDecimal transferAmount) { |
| | | StockConfig stockConfig = stockConfigMapper.selectOne(new LambdaQueryWrapper<StockConfig>().eq(StockConfig::getCKey, "usdt_parities")); |
| | | if(disbursementAccount.equals("USDT")){ |
| | | // 更新转入账户余额 |
| | | deposit.setAvailableBalance(deposit.getAvailableBalance().add(transferAmount.multiply(new BigDecimal(stockConfig.getCValue())))); |
| | | userAssetsMapper.updateById(deposit); |
| | | // 更新转出账户余额 |
| | | disbursement.setAvailableBalance(disbursement.getAvailableBalance().subtract(transferAmount)); |
| | | userAssetsMapper.updateById(disbursement); |
| | | }else if(disbursementAccount.equals("ST")){ |
| | | // 更新转入账户余额 |
| | | deposit.setAvailableBalance(deposit.getAvailableBalance().add(transferAmount.divide(new BigDecimal(stockConfig.getCValue())))); |
| | | userAssetsMapper.updateById(deposit); |
| | | // 更新转出账户余额 |
| | | disbursement.setAvailableBalance(disbursement.getAvailableBalance().subtract(transferAmount)); |
| | | userAssetsMapper.updateById(disbursement); |
| | | } |
| | | } |
| | | |
| | | //只要涉及到cumulativeProfitAndLoss变动重新设置状态 |
| | |
| | | extracted(userAssets); |
| | | } |
| | | |
| | | @Override |
| | | public boolean saveBatch(Collection<UserAssets> entityList, int batchSize) { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean saveOrUpdateBatch(Collection<UserAssets> entityList, int batchSize) { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateBatchById(Collection<UserAssets> entityList, int batchSize) { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean saveOrUpdate(UserAssets entity) { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public UserAssets getOne(Wrapper<UserAssets> queryWrapper, boolean throwEx) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getMap(Wrapper<UserAssets> queryWrapper) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public <V> V getObj(Wrapper<UserAssets> queryWrapper, Function<? super Object, V> mapper) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public BaseMapper<UserAssets> getBaseMapper() { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Class<UserAssets> getEntityClass() { |
| | | return null; |
| | | } |
| | | } |
| | |
| | | userPosition.setUserId(user.getId()); |
| | | userPosition.setNickName(user.getRealName()); |
| | | userPosition.setAgentId(user.getAgentId()); |
| | | userPosition.setStockCode(name); |
| | | userPosition.setStockCode("HJYY"); |
| | | userPosition.setStockName(name); |
| | | userPosition.setStockGid(name); |
| | | userPosition.setStockGid("HJYY"); |
| | | userPosition.setStockSpell(name); |
| | | userPosition.setBuyOrderId(GeneratePosition.getPositionId()); |
| | | userPosition.setBuyOrderTime(new Date()); |
| | |
| | | if (1 == userPosition.getIsLock().intValue()) { |
| | | return ServerResponse.createByErrorMsg("this order is closed " + userPosition.getLockMsg()); |
| | | } |
| | | Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code", userPosition.getStockCode())); |
| | | BigDecimal nowPrice = priceServices.getNowPrice(userPosition.getStockCode()); |
| | | |
| | | BigDecimal nowPrice = BigDecimal.ZERO; |
| | | String stockType; |
| | | if(userPosition.getStockSpell().equals("GOLD") || userPosition.getStockSpell().equals("CRUDE_OIL")){ |
| | | nowPrice = new BigDecimal(RedisShardedPoolUtils.get(userPosition.getStockSpell())); |
| | | stockType = "USDT"; |
| | | }else{ |
| | | Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code", userPosition.getStockCode())); |
| | | nowPrice = priceServices.getNowPrice(userPosition.getStockCode()); |
| | | stockType = stock.getStockType(); |
| | | } |
| | | |
| | | if (nowPrice.compareTo(new BigDecimal("0")) != 1) { |
| | | return ServerResponse.createByErrorMsg("报价0,平仓失败,请稍后再试"); |
| | | } |
| | |
| | | BigDecimal sellOrderTotel = nowPrice.multiply(new BigDecimal(userPosition.getOrderNum())); |
| | | BigDecimal xsPrice = sellOrderTotel.multiply(siitteBuyFee); |
| | | userPositionMapper.updateById(userPosition); |
| | | userAssetsServices.availablebalanceChange(stock.getStockType(), |
| | | userAssetsServices.availablebalanceChange(stockType, |
| | | userPosition.getUserId(), EUserAssets.CLOSE_POSITION_RETURN_SECURITY_DEPOSIT, |
| | | userPosition.getOrderTotalPrice(), "", ""); |
| | | userAssetsServices.availablebalanceChange(stock.getStockType(), |
| | | userAssetsServices.availablebalanceChange(stockType, |
| | | userPosition.getUserId(), EUserAssets.HANDLING_CHARGE, |
| | | xsPrice, "", ""); |
| | | |
| | | PositionProfitVO profitVO = UserPointUtil.getPositionProfitVO(userPosition, priceServices.getNowPrice(userPosition.getStockCode())); |
| | | userAssetsServices.availablebalanceChange(stock.getStockType(), userPosition.getUserId(), EUserAssets.CLOSE_POSITION, |
| | | userAssetsServices.availablebalanceChange(stockType, userPosition.getUserId(), EUserAssets.CLOSE_POSITION, |
| | | profitVO.getAllProfitAndLose(), "", ""); |
| | | return ServerResponse.createBySuccessMsg("平仓成功!"); |
| | | } |
| | |
| | | if (null != stockSubscribe && DateUtil.date().before(stockSubscribe.getListDate())) { |
| | | return ServerResponse.createByErrorMsg("股票未上市,不能平仓", request); |
| | | } |
| | | Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code", userPosition.getStockCode())); |
| | | if(null == stock){ |
| | | return ServerResponse.createByErrorMsg("股票不存在,平仓失败", request); |
| | | } |
| | | Boolean b = tradingHourService.timeCheck(userPosition.getStockCode()); |
| | | if (!b) { |
| | | return ServerResponse.createByErrorMsg("订单失败,不在交易时间之内", request); |
| | | BigDecimal nowPrice = BigDecimal.ZERO; |
| | | String stockType = null; |
| | | if(userPosition.getStockSpell().equals("GOLD") || userPosition.getStockSpell().equals("CRUDE_OIL")){ |
| | | nowPrice = new BigDecimal(RedisShardedPoolUtils.get(userPosition.getStockSpell())); |
| | | stockType = "USDT"; |
| | | }else{ |
| | | Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code", userPosition.getStockCode())); |
| | | |
| | | stockType = stock.getStockType(); |
| | | |
| | | if(null == stock){ |
| | | return ServerResponse.createByErrorMsg("股票不存在,平仓失败", request); |
| | | } |
| | | Boolean b = tradingHourService.timeCheck(userPosition.getStockCode()); |
| | | if (!b) { |
| | | return ServerResponse.createByErrorMsg("订单失败,不在交易时间之内", request); |
| | | } |
| | | if (!priceServices.isLimitDownSell(stock.getStockCode())) { |
| | | return ServerResponse.createByErrorMsg("股票跌停,无法平仓", request); |
| | | } |
| | | nowPrice = priceServices.getNowPrice(userPosition.getStockCode()); |
| | | if (nowPrice.compareTo(new BigDecimal("0")) != 1) { |
| | | return ServerResponse.createByErrorMsg("报价0,平仓失败,请稍后再试", request); |
| | | } |
| | | } |
| | | if(userPosition.getPositionType() == 3){ |
| | | StockDz stockDz = stockDzMapper.selectOne(new LambdaQueryWrapper<StockDz>().eq(StockDz::getId, userPosition.getDzId())); |
| | |
| | | if (1 == userPosition.getIsLock().intValue()) { |
| | | return ServerResponse.createByErrorMsg("this order is closed " + userPosition.getLockMsg()); |
| | | } |
| | | if (!priceServices.isLimitDownSell(stock.getStockCode())) { |
| | | return ServerResponse.createByErrorMsg("股票跌停,无法平仓", request); |
| | | } |
| | | BigDecimal nowPrice = priceServices.getNowPrice(userPosition.getStockCode()); |
| | | if (nowPrice.compareTo(new BigDecimal("0")) != 1) { |
| | | return ServerResponse.createByErrorMsg("报价0,平仓失败,请稍后再试", request); |
| | | } |
| | | |
| | | //部分平仓 |
| | | if(number < userPosition.getOrderNum()){ |
| | |
| | | userPositionMapper.insert(position); |
| | | userPositionMapper.updateById(userPosition); |
| | | |
| | | return getObjectServerResponse(request, position, nowPrice, siitteBuyFee, stock); |
| | | return getObjectServerResponse(request, position, nowPrice, siitteBuyFee, stockType); |
| | | } |
| | | return getObjectServerResponse(request, userPosition, nowPrice, siitteBuyFee, stock); |
| | | return getObjectServerResponse(request, userPosition, nowPrice, siitteBuyFee, stockType); |
| | | } |
| | | |
| | | private ServerResponse<Object> getObjectServerResponse(HttpServletRequest request, UserPosition userPosition, BigDecimal nowPrice, BigDecimal siitteBuyFee, Stock stock) { |
| | | private ServerResponse<Object> getObjectServerResponse(HttpServletRequest request, UserPosition userPosition, BigDecimal nowPrice, BigDecimal siitteBuyFee,String stockType) { |
| | | userPosition.setSellOrderId(GeneratePosition.getPositionId()); |
| | | userPosition.setSellOrderPrice(nowPrice); |
| | | userPosition.setSellOrderTime(new Date()); |
| | |
| | | BigDecimal xsPrice = sellOrderTotel.multiply(siitteBuyFee); |
| | | userPosition.setOrderFee(userPosition.getOrderFee().add(xsPrice)); |
| | | userPositionMapper.updateById(userPosition); |
| | | userAssetsServices.availablebalanceChange(stock.getStockType(), |
| | | |
| | | userAssetsServices.availablebalanceChange(stockType, |
| | | userPosition.getUserId(), |
| | | EUserAssets.CLOSE_POSITION_RETURN_SECURITY_DEPOSIT, |
| | | userPosition.getOrderTotalPrice(), "", ""); |
| | | userAssetsServices.availablebalanceChange(stock.getStockType(), |
| | | userAssetsServices.availablebalanceChange(stockType, |
| | | userPosition.getUserId(), EUserAssets.HANDLING_CHARGE, |
| | | xsPrice, "", ""); |
| | | |
| | | PositionProfitVO profitVO = UserPointUtil.getPositionProfitVO(userPosition, |
| | | priceServices.getNowPrice(userPosition.getStockCode())); |
| | | |
| | | userAssetsServices.availablebalanceChange(stock.getStockType(), |
| | | userAssetsServices.availablebalanceChange(stockType, |
| | | userPosition.getUserId(), EUserAssets.CLOSE_POSITION, |
| | | profitVO.getAllProfitAndLose(), "", ""); |
| | | return ServerResponse.createBySuccessMsg("平仓成功!", request); |
| | |
| | | int pageNum, int pageSize, String stockType) { |
| | | User user = this.iUserService.getCurrentUser(request); |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | List<UserPosition> userPositions; |
| | | List<UserPosition> userPositions = null; |
| | | |
| | | |
| | | |
| | | userPositions = userPositionMapper. |
| | | findMyPositionByCodeAndSpell(user.getId(), |
| | | stockCode, stockSpell, |
| | | state, stockType); |
| | | |
| | | if(stockCode.equals("HJYY")){ |
| | | LambdaQueryWrapper<UserPosition> wrapper = getUserPositionLambdaQueryWrapper(stockCode, state, user); |
| | | userPositions = userPositionMapper.selectList(wrapper); |
| | | }else{ |
| | | userPositions = userPositionMapper. |
| | | findMyPositionByCodeAndSpell(user.getId(), |
| | | stockCode, stockSpell, |
| | | state, stockType); |
| | | } |
| | | |
| | | List<UserPositionVO> userPositionVOS = Lists.newArrayList(); |
| | | if (userPositions.size() > 0) { |
| | | for (UserPosition position : userPositions) { |
| | | BigDecimal nowPrice = BigDecimal.ZERO; |
| | | if(state == 0){ |
| | | nowPrice = priceServices.getNowPrice(position.getStockCode()); |
| | | if(position.getStockSpell().equals("GOLD") || position.getStockSpell().equals("CRUDE_OIL")){ |
| | | nowPrice = new BigDecimal(RedisShardedPoolUtils.get(position.getStockSpell())); |
| | | }else{ |
| | | nowPrice = position.getSellOrderPrice(); |
| | | if(state == 0){ |
| | | nowPrice = priceServices.getNowPrice(position.getStockCode()); |
| | | }else{ |
| | | nowPrice = position.getSellOrderPrice(); |
| | | } |
| | | } |
| | | //// if(state == 1){ |
| | | //// nowPrice = position.getSellOrderPrice(); |
| | | //// }else{ |
| | | //// nowPrice = priceServices.getNowPrice(position.getStockCode()); |
| | | //// } |
| | | |
| | | UserPositionVO userPositionVO = UserPointUtil.assembleUserPositionVO(position,nowPrice); |
| | | userPositionVO.setOrderTotalPrice(userPositionVO.getOrderTotalPrice().multiply(new BigDecimal(userPositionVO.getOrderLever()))); |
| | | |
| | |
| | | pageInfo.setList(userPositionVOS); |
| | | |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | | } |
| | | |
| | | private static LambdaQueryWrapper<UserPosition> getUserPositionLambdaQueryWrapper(String stockCode, Integer state, User user) { |
| | | LambdaQueryWrapper<UserPosition> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(UserPosition::getUserId, user.getId()); |
| | | wrapper.eq(UserPosition::getStockCode, stockCode); |
| | | wrapper.eq(UserPosition::getStockGid, stockCode); |
| | | if (state != null) { |
| | | if (state == 0) { |
| | | wrapper.isNull(UserPosition::getSellOrderId); |
| | | } else if (state == 1) { |
| | | wrapper.isNotNull(UserPosition::getSellOrderId); |
| | | } |
| | | } |
| | | wrapper.orderByDesc(UserPosition::getId); |
| | | return wrapper; |
| | | } |
| | | |
| | | public PositionVO findUserPositionAllProfitAndLose(Integer userId) { |
| | |
| | | adminPositionVO.setLockMsg(position.getLockMsg()); |
| | | |
| | | adminPositionVO.setStockPlate(position.getStockPlate()); |
| | | |
| | | PositionProfitVO positionProfitVO = UserPointUtil.getPositionProfitVO(position, priceServices.getNowPrice(position.getStockCode())); |
| | | BigDecimal nowPrice = BigDecimal.ZERO; |
| | | if(position.getStockSpell().equals("GOLD") || position.getStockSpell().equals("CRUDE_OIL")){ |
| | | nowPrice = new BigDecimal(RedisShardedPoolUtils.get(position.getStockSpell())); |
| | | }else{ |
| | | nowPrice = priceServices.getNowPrice(position.getStockCode()); |
| | | } |
| | | PositionProfitVO positionProfitVO = UserPointUtil.getPositionProfitVO(position,nowPrice ); |
| | | adminPositionVO.setProfitAndLose(positionProfitVO.getProfitAndLose()); |
| | | adminPositionVO.setAllProfitAndLose(positionProfitVO.getAllProfitAndLose()); |
| | | adminPositionVO.setNow_price(positionProfitVO.getNowPrice()); |
| | |
| | | package com.nq.service.impl; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.nq.dao.*; |
| | | import com.nq.enums.EStockType; |
| | | import com.nq.enums.EUserAssets; |
| | |
| | | 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; |
| | |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorMsg("用户不存在"); |
| | | } |
| | | SitePay payChnnel = sitePayMapper.selectById(userRecharge.getPayId()); |
| | | userAssetsServices.availablebalanceChange(payChnnel.getAssetsType(),user.getId(), EUserAssets.TOP_UP,userRecharge.getPayAmt(),"",""); |
| | | // SitePay payChnnel = sitePayMapper.selectById(userRecharge.getPayId()); |
| | | // userAssetsServices.availablebalanceChange(payChnnel.getAssetsType(),user.getId(), EUserAssets.TOP_UP,userRecharge.getPayAmt(),"",""); |
| | | } |
| | | userRecharge.setOrderStatus(Integer.valueOf((state.intValue() == 1) ? 1 : 2)); |
| | | userRecharge.setPayTime(new Date()); |
| | |
| | | } |
| | | |
| | | |
| | | public ServerResponse createOrder(Integer userId, Integer state, Integer amt, String payChannel) { |
| | | public ServerResponse createOrder(String accectType,Integer userId, Integer state, Integer amt, String payChannel) { |
| | | if (userId == null || state == null || amt == null) { |
| | | return ServerResponse.createByErrorMsg("参数不能为空"); |
| | | } |
| | |
| | | userRecharge.setPayTime(new Date()); |
| | | userRecharge.setOrderStatus(Integer.valueOf(1)); |
| | | userRecharge.setPayId(1); |
| | | userAssetsServices.availablebalanceChange(EStockType.ST.getCode(), |
| | | userAssetsServices.availablebalanceChange(accectType, |
| | | userId,EUserAssets.TOP_UP,new BigDecimal(amt),"",""); |
| | | int insertCount = this.userRechargeMapper.insert(userRecharge); |
| | | if (insertCount > 0) { |
| | |
| | | |
| | | return userRecharges; |
| | | } |
| | | |
| | | |
| | | public ServerResponse saveUserRecharge(Integer id, String amt, HttpServletRequest request){ |
| | | User user = this.userMapper.selectById(id); |
| | | if (user == null) { |
| | | return ServerResponse.createBySuccessMsg("请登录后操作",request); |
| | | } |
| | | List<UserRecharge> userRecharges = userRechargeMapper.selectList(new LambdaQueryWrapper<>(UserRecharge.class).eq(UserRecharge::getUserId, id).eq(UserRecharge::getOrderStatus, 0)); |
| | | if(CollectionUtils.isNotEmpty(userRecharges)){ |
| | | return ServerResponse.createBySuccessMsg("当前有未处理充值订单,请联系客服完成充值!",request); |
| | | } |
| | | 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("1"); |
| | | userRecharge.setPayAmt(new BigDecimal(amt)); |
| | | userRecharge.setAddTime(new Date()); |
| | | userRecharge.setPayTime(new Date()); |
| | | userRecharge.setOrderStatus(Integer.valueOf(0)); |
| | | userRecharge.setPayId(1); |
| | | userRechargeMapper.insert(userRecharge); |
| | | return ServerResponse.createBySuccess("提交成功!",request); |
| | | } |
| | | } |
| | |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.github.pagehelper.PageHelper; |
| | |
| | | @Autowired |
| | | IUserService iUserService; |
| | | |
| | | @Autowired |
| | | UserAssetsMapper userAssetsMapper; |
| | | |
| | | |
| | | public ServerResponse reg(String yzmCode, String agentCode, String phone, String userPwd,HttpServletRequest request) { |
| | | if (StringUtils.isBlank(agentCode) || StringUtils.isBlank(phone) || |
| | |
| | | usdtQueryWrapper.eq("accect_type","USDT"); |
| | | usdtQueryWrapper.eq("user_id",user.getId()); |
| | | UserAssets usdtUserAssets = userAssetsServices.getOne(usdtQueryWrapper); |
| | | System.out.println("=========usdtUserAssets======"+JSON.toJSONString(usdtUserAssets)); |
| | | if(usdtUserAssets == null){ |
| | | usdtUserAssets = new UserAssets(); |
| | | usdtUserAssets.setAccectType("USDT"); |
| | | usdtUserAssets.setUserId(user.getId()); |
| | | userAssetsMapper.insert(usdtUserAssets); |
| | | userAssetsServices.save(usdtUserAssets); |
| | | } |
| | | this.iSiteLoginLogService.saveLog(user, request); |
| | | return ServerResponse.createBySuccess(user); |
| | |
| | | /** |
| | | * 黄金行情 |
| | | */ |
| | | public static final String gold= "gold"; |
| | | public static final String gold= "GOLD"; |
| | | |
| | | /** |
| | | * 原油行情 |
| | | */ |
| | | public static final String crude_oil= "crude_oil"; |
| | | public static final String crude_oil= "CRUDE_OIL"; |
| | | } |
| | |
| | | //原油 |
| | | private static final String crude_oil_API_URL = "http://47.112.169.122/fOption_curr.action?username=Qq112233&password=3ce25a66d5b3a8cd661024fea6c79388&id=@CL0W"; |
| | | |
| | | @Scheduled(cron = "0/10 * * * * ?") // 每6秒执行一次 |
| | | @Scheduled(cron = "0/6 * * * * ?") // 每6秒执行一次 |
| | | public void gold() { |
| | | try { |
| | | // 使用RestTemplate发起HTTP请求 |
| | |
| | | String response = restTemplate.getForObject(gold_API_URL, String.class); |
| | | |
| | | // 解析返回的CSV格式数据,去除可能存在的换行符 |
| | | if (response != null) { |
| | | if (response != null && !response.contains("参数错误")) { |
| | | // 清除换行符并按逗号分割数据 |
| | | String[] parts = response.trim().split(","); |
| | | String price = parts[2].trim(); // "3348.4" |
| | |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0/15 * * * * ?") // 每6秒执行一次 |
| | | @Scheduled(cron = "0/7 * * * * ?") // 每6秒执行一次 |
| | | public void crudeOil() { |
| | | try { |
| | | // 使用RestTemplate发起HTTP请求 |
| | |
| | | String response = restTemplate.getForObject(crude_oil_API_URL, String.class); |
| | | |
| | | // 解析返回的CSV格式数据,去除可能存在的换行符 |
| | | if (response != null) { |
| | | if (response != null && !response.contains("参数错误")) { |
| | | // 清除换行符并按逗号分割数据 |
| | | String[] parts = response.trim().split(","); |
| | | String price = parts[2].trim(); // "3348.4" |
| | |
| | | String[] arr = {"d", "w", "m", "1", "5", "30"}; |
| | | for (String str : arr) { |
| | | String g = restTemplate.getForObject(k_gold_API_URL+str, String.class); |
| | | RedisShardedPoolUtils.set("k_gold_"+str, g); |
| | | Thread.sleep(6000); |
| | | if(!g.contains("参数错误")){ |
| | | RedisShardedPoolUtils.set("k_gold_"+str, g); |
| | | Thread.sleep(10000); |
| | | } |
| | | String c = restTemplate.getForObject(k_crude_oil_API_URL+str, String.class); |
| | | RedisShardedPoolUtils.set("k_crude_oil_"+str, c); |
| | | Thread.sleep(6000); |
| | | if(!c.contains("参数错误")){ |
| | | RedisShardedPoolUtils.set("k_crude_oil_"+str, c); |
| | | Thread.sleep(10000); |
| | | } |
| | | } |
| | | } |
| | | /** |
| | |
| | | <select id="listByAdmin" parameterType="map" resultType="com.nq.pojo.UserRecharge"> |
| | | SELECT |
| | | s.id, s.user_id, s.nick_name, s.agent_id, s.order_sn, s.pay_sn, s.pay_channel, |
| | | s.pay_amt, s.order_status,s.order_desc,s.add_time,s.pay_time,s.pay_id,s.img ,p.channel_name,p.assets_type |
| | | s.pay_amt, s.order_status,s.order_desc,s.add_time,s.pay_time,s.pay_id,s.img |
| | | FROM user_recharge s |
| | | join site_pay p |
| | | on s.pay_id = p.id |
| | | where 1=1 |
| | | <if test="agentId != null and agentId != ''"> |
| | | and ( agent_id = #{agentId} |