| | |
| | | |
| | | |
| | | |
| | | US("US","美国股票","5",PropertiesUtil.getProperty("US_HTTP_API"),PropertiesUtil.getProperty("US_KEY"),"USD","$"), |
| | | HK("HK","香港股票","39",PropertiesUtil.getProperty("HK_HTTP_API"),PropertiesUtil.getProperty("HK_KEY"),"HKD","HK$"), |
| | | MAS("MAS","马来西亚股票","42",PropertiesUtil.getProperty("MAS_HTTP_API"),PropertiesUtil.getProperty("MAS_KEY"),"MYR","RM"), |
| | | |
| | | IN("IN","印度股票","14", PropertiesUtil.getProperty("IN_HTTP_API"),PropertiesUtil.getProperty("JS_IN_KEY"),"INR","₹"); |
| | | US("US","美国股票","5",PropertiesUtil.getProperty("US_HTTP_API"),PropertiesUtil.getProperty("US_KEY"),"USD","$"); |
| | | // HK("HK","香港股票","39",PropertiesUtil.getProperty("HK_HTTP_API"),PropertiesUtil.getProperty("HK_KEY"),"HKD","HK$"), |
| | | // MAS("MAS","马来西亚股票","42",PropertiesUtil.getProperty("MAS_HTTP_API"),PropertiesUtil.getProperty("MAS_KEY"),"MYR","RM"), |
| | | // |
| | | // IN("IN","印度股票","14", PropertiesUtil.getProperty("IN_HTTP_API"),PropertiesUtil.getProperty("JS_IN_KEY"),"INR","₹"); |
| | | // TH("TH","泰国股票","41",PropertiesUtil.getProperty("TH_HTTP_API"),PropertiesUtil.getProperty("TH_KEY")), |
| | | // HG("HG","韩国股票","11",PropertiesUtil.getProperty("HG_HTTP_API"),PropertiesUtil.getProperty("HG_KEY")), |
| | | // SZHB("SZHB","数字货币","41",PropertiesUtil.getProperty("SZHB_HTTP_API"),PropertiesUtil.getProperty("SZHB_KEY")); |
| | |
| | | } |
| | | |
| | | public static EStockType getEStockTypeByCode(String code){ |
| | | if(EStockType.US.getCode().equals(code)){ |
| | | return US; |
| | | |
| | | }else if(EStockType.HK.getCode().equals(code)){ |
| | | return HK; |
| | | }else if(EStockType.MAS.getCode().equals(code)){ |
| | | return MAS; |
| | | }else if(EStockType.IN.getCode().equals(code)){ |
| | | return IN; |
| | | }else{ |
| | | return MAS; |
| | | } |
| | | return US; |
| | | } |
| | | |
| | | public String getContryId() { |
| | |
| | | import com.nq.pojo.*; |
| | | import com.nq.service.IPriceServices; |
| | | import com.nq.service.IStockConfigServices; |
| | | import com.nq.utils.PropertiesUtil; |
| | | import com.nq.utils.http.HttpClientRequest; |
| | | import com.nq.utils.redis.RedisKeyUtil; |
| | | import com.nq.utils.timeutil.TimeUtil; |
| | |
| | | import java.io.BufferedReader; |
| | | import java.io.InputStreamReader; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URI; |
| | | import java.net.URL; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | |
| | | } |
| | | |
| | | public String doGet(String pid){ |
| | | String apiUrl = "http://api-in-2.js-stock.top/stock?pid="+pid+"&key=eVKtHt7aG4m6ozwWL9qG"; |
| | | String apiUrl = PropertiesUtil.getProperty("US_HTTP_API")+"stock?pid="+pid+"&key="+PropertiesUtil.getProperty("US_KEY"); |
| | | try { |
| | | URL url = new URL(apiUrl); |
| | | HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
| | |
| | | @Override |
| | | public ServerResponse getStockByType(int pageNum, int pageSize, String orderBy, String keyWords, String stockType, HttpServletRequest request) { |
| | | List<Stock> stockList = new ArrayList<>(); |
| | | if(stockType.equals(EStockType.IN.getCode())){ |
| | | if(stockType.equals(EStockType.US.getCode())){ |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | stockList.addAll(stockMapper.findStockByType(orderBy,stockType,keyWords)); |
| | | }else{ |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | stockList.addAll(stockMapper.findStockTypeDz(orderBy,EStockType.IN.getCode(), keyWords)); |
| | | stockList.addAll(stockMapper.findStockTypeDz(orderBy,EStockType.US.getCode(), keyWords)); |
| | | } |
| | | |
| | | List<StockListVO> stockListVOS = Lists.newArrayList(); |
| | |
| | | /*股票日线-K线*/ |
| | | @Override |
| | | public Object getKData(String pid, String interval, String stockType) { |
| | | |
| | | EStockType eStockType = EStockType.getEStockTypeByCode(stockType); |
| | | if(eStockType == EStockType.IN){ |
| | | Object object = HttpUtil.get(eStockType.stockUrl + "api/all/getKData.do?pid=" + pid + "&interval=" + interval + "&stockType=in"); |
| | | Gson gson = new Gson(); |
| | | List<kData> dataList = gson.fromJson(object.toString(), new TypeToken<List<kData>>(){}.getType()); |
| | | |
| | | Stock stock = stockMapper.selectOne(new LambdaQueryWrapper<Stock>().eq(Stock::getStockCode, pid).eq(Stock::getStockType, "IN")); |
| | | BigDecimal nowPrice = iPriceServices.getNowPrice(stock.getStockCode()); |
| | | Map singleStock = getSingleStock(stock.getStockCode()); |
| | | StockVO stockVO = (StockVO)singleStock.get("stock"); |
| | | // 修改 List 中的最后一条数据 |
| | | kData lastData = dataList.get(dataList.size() - 1); |
| | | lastData.setC(nowPrice.toString()); |
| | | lastData.setO(stockVO.getOpen_px()); |
| | | lastData.setH(stockVO.getToday_max()); |
| | | lastData.setL(stockVO.getToday_min()); |
| | | return gson.toJson(dataList); |
| | | |
| | | } |
| | | // if(eStockType == EStockType.US){ |
| | | // Object object = HttpUtil.get(eStockType.stockUrl + "api/all/getKData.do?pid=" + pid + "&interval=" + interval + "&stockType=in"); |
| | | // Gson gson = new Gson(); |
| | | // List<kData> dataList = gson.fromJson(object.toString(), new TypeToken<List<kData>>(){}.getType()); |
| | | // |
| | | // Stock stock = stockMapper.selectOne(new LambdaQueryWrapper<Stock>().eq(Stock::getStockCode, pid).eq(Stock::getStockType, "IN")); |
| | | // BigDecimal nowPrice = iPriceServices.getNowPrice(stock.getStockCode()); |
| | | // Map singleStock = getSingleStock(stock.getStockCode()); |
| | | // StockVO stockVO = (StockVO)singleStock.get("stock"); |
| | | // // 修改 List 中的最后一条数据 |
| | | // kData lastData = dataList.get(dataList.size() - 1); |
| | | // lastData.setC(nowPrice.toString()); |
| | | // lastData.setO(stockVO.getOpen_px()); |
| | | // lastData.setH(stockVO.getToday_max()); |
| | | // lastData.setL(stockVO.getToday_min()); |
| | | // return gson.toJson(dataList); |
| | | // |
| | | // } |
| | | return HttpUtil.get(eStockType.stockUrl + "kline?pid=" + pid + "&interval=" + interval + "&key=" + eStockType.stockKey); |
| | | } |
| | | |
| | |
| | | |
| | | userPosition.setOrderSpread(BigDecimal.ZERO); |
| | | userPositionMapper.insert(userPosition); |
| | | userAssetsServices.availablebalanceChange(EStockType.IN.getCode(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"",""); |
| | | userAssetsServices.availablebalanceChange(EStockType.US.getCode(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"",""); |
| | | return ServerResponse.createBySuccess("购买成功", request); |
| | | } |
| | | |
| | |
| | | |
| | | for (int i = 0; i <userRecharges.size() ; i++) { |
| | | SitePay s = sitePayMapper.selectById(userRecharges.get(i).getPayId()); |
| | | userRecharges.get(i).setAssetsType(EStockType.IN.getSymbol1()); |
| | | userRecharges.get(i).setChannelName(EStockType.IN.getSymbol()); |
| | | userRecharges.get(i).setAssetsType(EStockType.US.getSymbol1()); |
| | | userRecharges.get(i).setChannelName(EStockType.US.getSymbol()); |
| | | } |
| | | |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | |
| | | userRecharge.setPayTime(new Date()); |
| | | userRecharge.setOrderStatus(Integer.valueOf(1)); |
| | | userRecharge.setPayId(1); |
| | | userAssetsServices.availablebalanceChange(EStockType.IN.getCode(), |
| | | userAssetsServices.availablebalanceChange(EStockType.US.getCode(), |
| | | userId,EUserAssets.TOP_UP,new BigDecimal(amt),"",""); |
| | | int insertCount = this.userRechargeMapper.insert(userRecharge); |
| | | if (insertCount > 0) { |
| | |
| | | if (user.getIsLogin().intValue() == 1) { |
| | | return ServerResponse.createByErrorMsg("登录失败。账户锁定",request); |
| | | } |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.IN.getCode(),user.getId()); |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.US.getCode(),user.getId()); |
| | | this.iSiteLoginLogService.saveLog(user, request); |
| | | return ServerResponse.createBySuccess(user); |
| | | } |
| | |
| | | |
| | | int insertCount = this.userMapper.insert(user); |
| | | dbUser = userMapper.selectOne(queryWrapper); |
| | | userAssetsServices.getAvailableBalance(EStockType.IN.getCode(),dbUser.getId() ); |
| | | userAssetsServices.availablebalanceChange(EStockType.IN.getCode(),dbUser.getId(),EUserAssets.TOP_UP,new BigDecimal(amt),"",""); |
| | | userAssetsServices.getAvailableBalance(EStockType.US.getCode(),dbUser.getId() ); |
| | | userAssetsServices.availablebalanceChange(EStockType.US.getCode(),dbUser.getId(),EUserAssets.TOP_UP,new BigDecimal(amt),"",""); |
| | | if (insertCount > 0) { |
| | | return ServerResponse.createBySuccessMsg("Success"); |
| | | } |
| | |
| | | } |
| | | }else{ |
| | | BigDecimal bound = new BigDecimal(model.getApplyNums()).multiply(stockSubscribe.getPrice()); |
| | | BigDecimal useEnaAmount = iUserAssetsServices.getAvailableBalance(EStockType.IN.getCode(), user.getId()); |
| | | BigDecimal useEnaAmount = iUserAssetsServices.getAvailableBalance(EStockType.US.getCode(), user.getId()); |
| | | if(useEnaAmount.compareTo(bound)<0){ |
| | | return ServerResponse.createByErrorMsg("余额不足,配售失败",request); |
| | | } |
| | |
| | | model.setType(stockSubscribe.getType()); |
| | | model.setDbMoney(BigDecimal.ZERO); |
| | | ret = userStockSubscribeMapper.insert(model); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.IN.getCode(), user.getId(),EUserAssets.BUY,bound.negate(),"",""); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.US.getCode(), user.getId(),EUserAssets.BUY,bound.negate(),"",""); |
| | | if (ret > 0) { |
| | | return ServerResponse.createBySuccessMsg("配售成功",request); |
| | | } else { |
| | |
| | | } |
| | | BigDecimal cCount = new BigDecimal(model.getApplyNums()-model.getApplyNumber()); |
| | | BigDecimal tMoney = stockSubscribe.getPrice().multiply(cCount); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.IN.getCode(),userStockSubscribe.getUserId(), |
| | | iUserAssetsServices.availablebalanceChange(EStockType.US.getCode(),userStockSubscribe.getUserId(), |
| | | EUserAssets.TOP_UP,tMoney,"",""); |
| | | model.setBond(stockSubscribe.getPrice().multiply(BigDecimal.valueOf(model.getApplyNumber()))); |
| | | model.setDbMoney(BigDecimal.ZERO); |
| | |
| | | userStockSubscribe.setSubmitTime(DateTimeUtil.getCurrentDate()); |
| | | userStockSubscribe.setStatus(4); |
| | | BigDecimal bigDecimal = iUserAssetsServices. |
| | | getAvailableBalance(EStockType.IN.getCode(), |
| | | getAvailableBalance(EStockType.US.getCode(), |
| | | userStockSubscribe.getUserId()); |
| | | |
| | | BigDecimal multiply = userStockSubscribe.getBuyPrice().multiply(new BigDecimal(userStockSubscribe.getApplyNumber())); |
| | | if(bigDecimal.compareTo(multiply) <= 0){ |
| | | return ServerResponse.createByErrorMsg("余额不足",request); |
| | | } |
| | | iUserAssetsServices.availablebalanceChange(EStockType.IN.getCode(),userStockSubscribe.getUserId(), |
| | | iUserAssetsServices.availablebalanceChange(EStockType.US.getCode(),userStockSubscribe.getUserId(), |
| | | EUserAssets.BUY,multiply.negate(),"",""); |
| | | userStockSubscribe.setDbMoney(BigDecimal.ZERO); |
| | | userStockSubscribeMapper.update1(userStockSubscribe); |
| | |
| | | if (syncINStockDataLock.tryLock()) { |
| | | try { |
| | | syncINStockData.set(true); // 设置处理中标识为true |
| | | loadAllStock(EStockType.IN); |
| | | loadAllStock(EStockType.US); |
| | | } finally { |
| | | syncINStockDataLock.unlock(); |
| | | syncINStockData.set(false); // 设置处理中标识为false |
| | |
| | | |
| | | Map<String, WebSocketClient> retMap = new HashMap<>(2); |
| | | try { |
| | | WebsocketRunClient websocketRunClient = new WebsocketRunClient(new URI(PropertiesUtil.getProperty("IN_WS_URL")),EStockType.IN); |
| | | WebsocketRunClient websocketRunClient = new WebsocketRunClient(new URI(PropertiesUtil.getProperty("US_WS_URL")),EStockType.US); |
| | | websocketRunClient.connect(); |
| | | websocketRunClient.setConnectionLostTimeout(0); |
| | | new Thread(() -> { |
| | |
| | | |
| | | @Override |
| | | public void onClose(int i, String s, boolean b) { |
| | | log.info("websocket 印度股票 关闭"+1); |
| | | log.info("websocket 美国股票 关闭"+1); |
| | | } |
| | | |
| | | @Override |
| | |
| | | // ApplicationContext act = ApplicationContextRegisterUtil.getApplicationContext(); |
| | | // MandatoryLiquidationService liquidationService = (MandatoryLiquidationService) act.getBean(IMandatoryLiquidationService.class); |
| | | // StockRealTimeBean stockDetailBean = new Gson().fromJson(args[0].toString(), StockRealTimeBean.class); |
| | | // liquidationService.RealTimeDataProcess(EStockType.IN,stockDetailBean); |
| | | // liquidationService.RealTimeDataProcess(EStockType.US,stockDetailBean); |
| | | // }catch (Exception e){ |
| | | // log.error("socket数据存入缓存错误:", e.getMessage()); |
| | | // } |
| | |
| | | |
| | | |
| | | #股票key的地址 |
| | | IN_HTTP_API = https://data.is4vc.com/ |
| | | IN_WS_URL =ws://ws.is4vc.com:8001/websocket-server |
| | | IN_KEY = r3ZAgtcYzuBizmqge2hK |
| | | IN_NEW_HTTP_API = http://api-in-2.js-stock.top/ |
| | | IN_NEW_KEY = eVKtHt7aG4m6ozwWL9qG |
| | | |
| | | JS_IN_HTTP_API = http://api-in-2-socket.js-stock.top |
| | | JS_IN_WS_URL =ws://api-in-2-ws.js-stock.top |
| | | JS_IN_KEY = eVKtHt7aG4m6ozwWL9qG |
| | | |
| | | US_HTTP_API = http://api-us.js-stock.top/ |
| | | US_WS_URL = ws://ws-us.js-stock.top |
| | | US_KEY = jZFrku4RGQjP87Hmq5tm |
| | | |
| | | HK_HTTP_API = http://test.js-stock.top/ |
| | | HK_WS_URL = ws://test-ws.js-stock.top |
| | | HK_KEY = mG8QQDdjGuLjLnrryd0B |
| | | |
| | | |
| | | #HK_HTTP_API = http://api-v1.js-stock.top/ |
| | | #HK_WS_URL = ws://api-v1-ws.js-stock.top |
| | | #HK_KEY = QgiqrYYZem1WWXWbHeT7 |
| | | |
| | | |
| | | HG_HTTP_API = http://test.js-stock.top/ |
| | | HG_WS_URL = ws://test-ws.js-stock.top |
| | | HG_KEY = mG8QQDdjGuLjLnrryd0B |
| | | |
| | | |
| | | |
| | | TH_HTTP_API = http://test.js-stock.top/ |
| | | TH_WS_URL = ws://api-in-ws.js-stock.top |
| | | TH_KEY = GBZAcUPLKZzDMDjvV9Ea |
| | | |
| | | MAS_HTTP_API = http://api-ms.js-stock.top/ |
| | | MAS_WS_URL = ws://api-ms-ws.js-stock.top |
| | | MAS_KEY = PQWyZGrw7wRqdoWrvnY9 |
| | | |
| | | SZHB_HTTP_API = https://api.huobi.pro/ |
| | | SZHB_WS_URL = ws://api-in-ws.js-stock.top |
| | | SZHB_KEY = GBZAcUPLKZzDMDjvV9Ea |
| | | |
| | | US_KEY = 4Z6dY7zcnsdfsdfZyBL4KDa00h |
| | | |
| | | |
| | | |