13 files modified
1 files added
| | |
| | | <profile version="1.0"> |
| | | <option name="myName" value="Project Default" /> |
| | | <inspection_tool class="AliAccessStaticViaInstance" enabled="true" level="WARNING" enabled_by_default="true" /> |
| | | <inspection_tool class="AliArrayNamingShouldHaveBracket" enabled="true" level="WARNING" enabled_by_default="true" /> |
| | | <inspection_tool class="AliControlFlowStatementWithoutBraces" enabled="true" level="WARNING" enabled_by_default="true" /> |
| | | <inspection_tool class="AliDeprecation" enabled="true" level="WARNING" enabled_by_default="true" /> |
| | | <inspection_tool class="AliEqualsAvoidNull" enabled="true" level="WARNING" enabled_by_default="true" /> |
| | | <inspection_tool class="AliLongLiteralsEndingWithLowercaseL" enabled="true" level="WARNING" enabled_by_default="true" /> |
| | | <inspection_tool class="AliMissingOverrideAnnotation" enabled="true" level="WARNING" enabled_by_default="true" /> |
| | | <inspection_tool class="AliWrapperTypeEquality" enabled="true" level="WARNING" enabled_by_default="true" /> |
| | | <inspection_tool class="AlibabaAbstractClassShouldStartWithAbstractNaming" enabled="true" level="WARNING" enabled_by_default="true" /> |
| | | <inspection_tool class="AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc" enabled="true" level="WARNING" enabled_by_default="true" /> |
| | | <inspection_tool class="AlibabaAvoidApacheBeanUtilsCopy" enabled="true" level="WARNING" enabled_by_default="true" /> |
| | |
| | | <inspection_tool class="JavadocDeclaration" enabled="true" level="WARNING" enabled_by_default="true"> |
| | | <option name="ADDITIONAL_TAGS" value="date" /> |
| | | </inspection_tool> |
| | | <inspection_tool class="MapOrSetKeyShouldOverrideHashCodeEquals" enabled="true" level="WARNING" enabled_by_default="true" /> |
| | | <inspection_tool class="MissingJavadoc" enabled="true" level="WARNING" enabled_by_default="true"> |
| | | <option name="PACKAGE_SETTINGS"> |
| | | <Options> |
| | |
| | | @RequestParam("buyNum") Integer buyNum, |
| | | @RequestParam("buyType") Integer buyType, |
| | | @RequestParam("lever") Integer lever, |
| | | @RequestParam("password") String password, |
| | | @RequestParam(value = "password",required = false) String password, |
| | | @RequestParam(value = "profitTarget",required = false) |
| | | BigDecimal profitTarget,@RequestParam(value = "stopLoss",required = false) BigDecimal stopLoss, HttpServletRequest request) { |
| | | buyLock.lock(); |
| | |
| | | |
| | | |
| | | |
| | | US("US","美国股票","5",PropertiesUtil.getProperty("US_HTTP_API"),PropertiesUtil.getProperty("US_KEY"),"USD","$"); |
| | | 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","₹"); |
| | | IN("IN","印度股票","14", PropertiesUtil.getProperty("IN_HTTP_API"),PropertiesUtil.getProperty("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.IN.getCode().equals(code)){ |
| | | return IN; |
| | | } |
| | | return US; |
| | | } |
| | | |
| | |
| | | @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.US.getCode())){ |
| | | if(stockType.equals("dz")){ |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | stockList.addAll(stockMapper.findStockByType(orderBy,stockType,keyWords)); |
| | | stockList.addAll(stockMapper.findStockTypeDz(orderBy,stockType, keyWords)); |
| | | }else{ |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | stockList.addAll(stockMapper.findStockTypeDz(orderBy,EStockType.US.getCode(), keyWords)); |
| | | stockList.addAll(stockMapper.findStockByType(orderBy,stockType,keyWords)); |
| | | } |
| | | |
| | | List<StockListVO> stockListVOS = Lists.newArrayList(); |
| | |
| | | |
| | | userPosition.setOrderSpread(BigDecimal.ZERO); |
| | | userPositionMapper.insert(userPosition); |
| | | userAssetsServices.availablebalanceChange(EStockType.US.getCode(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"",""); |
| | | userAssetsServices.availablebalanceChange(stockDz.getStockType(), 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.US.getSymbol1()); |
| | | userRecharges.get(i).setChannelName(EStockType.US.getSymbol()); |
| | | userRecharges.get(i).setAssetsType(EStockType.getEStockTypeByCode(s.getAssetsType()).getSymbol1()); |
| | | userRecharges.get(i).setChannelName(EStockType.getEStockTypeByCode(s.getAssetsType()).getSymbol()); |
| | | } |
| | | |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | |
| | | return ServerResponse.createByErrorMsg("登录失败。账户锁定",request); |
| | | } |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.US.getCode(),user.getId()); |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.IN.getCode(),user.getId()); |
| | | this.iSiteLoginLogService.saveLog(user, request); |
| | | return ServerResponse.createBySuccess(user); |
| | | } |
| | |
| | | rUserAssets.setIsZf(userAssets.getIsZf()); |
| | | rUserAssets.setAmountToBeCovered(userAssets.getAmountToBeCovered().toString()); |
| | | BigDecimal rate = rateServices.currencyRate( |
| | | EStockType.getEStockTypeByCode(userAssets.getAccectType()),EStockType.US); |
| | | EStockType.getEStockTypeByCode(userAssets.getAccectType()),EStockType.getEStockTypeByCode(userAssets.getAccectType())); |
| | | |
| | | BigDecimal availableBalanceUSD = amt; |
| | | if(amt.compareTo(BigDecimal.ZERO)>0){ |
| | |
| | | } |
| | | }else{ |
| | | BigDecimal bound = new BigDecimal(model.getApplyNums()).multiply(stockSubscribe.getPrice()); |
| | | BigDecimal useEnaAmount = iUserAssetsServices.getAvailableBalance(EStockType.US.getCode(), user.getId()); |
| | | BigDecimal useEnaAmount = iUserAssetsServices.getAvailableBalance(stockSubscribe.getStockType(), 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.US.getCode(), user.getId(),EUserAssets.BUY,bound.negate(),"",""); |
| | | iUserAssetsServices.availablebalanceChange(stockSubscribe.getStockType(), 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.US.getCode(),userStockSubscribe.getUserId(), |
| | | iUserAssetsServices.availablebalanceChange(stockSubscribe.getStockType(),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.US.getCode(), |
| | | getAvailableBalance(stockSubscribe.getStockType(), |
| | | userStockSubscribe.getUserId()); |
| | | |
| | | BigDecimal multiply = userStockSubscribe.getBuyPrice().multiply(new BigDecimal(userStockSubscribe.getApplyNumber())); |
| | | if(bigDecimal.compareTo(multiply) <= 0){ |
| | | return ServerResponse.createByErrorMsg("余额不足",request); |
| | | } |
| | | iUserAssetsServices.availablebalanceChange(EStockType.US.getCode(),userStockSubscribe.getUserId(), |
| | | iUserAssetsServices.availablebalanceChange(stockSubscribe.getStockType(),userStockSubscribe.getUserId(), |
| | | EUserAssets.BUY,multiply.negate(),"",""); |
| | | userStockSubscribe.setDbMoney(BigDecimal.ZERO); |
| | | userStockSubscribeMapper.update1(userStockSubscribe); |
| | |
| | | /** |
| | | * 余额宝发放利息 |
| | | */ |
| | | @Scheduled(cron = "0 0/1 * * * ?") |
| | | // @Scheduled(cron = "0 0/1 * * * ?") |
| | | public void sendYEBMoney() { |
| | | if (isSendYEBMoney.get()) { // 判断任务是否在处理中 |
| | | return; |
| | |
| | | if (syncINStockDataLock.tryLock()) { |
| | | try { |
| | | syncINStockData.set(true); // 设置处理中标识为true |
| | | loadAllStock(EStockType.US); |
| | | loadAllStock(EStockType.IN); |
| | | } finally { |
| | | syncINStockDataLock.unlock(); |
| | | syncINStockData.set(false); // 设置处理中标识为false |
| | |
| | | loadAllCompanies(); |
| | | } |
| | | |
| | | /** |
| | | * 同步美国股票 |
| | | * */ |
| | | @Scheduled(cron = "0/10 * * * * ?") |
| | | public void synsUSStockData(){ |
| | | loadAllStock(EStockType.US); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 加载公司信息 |
| | |
| | | return retMap; |
| | | } |
| | | |
| | | @Bean |
| | | public Map<String, WebSocketClient> websocketInRunClientMap() { |
| | | |
| | | Map<String, WebSocketClient> retMap = new HashMap<>(2); |
| | | try { |
| | | WebSocketInClient webSocketInClient = new WebSocketInClient(new URI(PropertiesUtil.getProperty("IN_WS_URL")),EStockType.IN); |
| | | webSocketInClient.connect(); |
| | | webSocketInClient.setConnectionLostTimeout(0); |
| | | new Thread(() -> { |
| | | while (true) { |
| | | try { |
| | | Thread.sleep(8000); |
| | | webSocketInClient.send("heartbeat".getBytes()); |
| | | } catch (Exception e) { |
| | | webSocketInClient.reconnect(); |
| | | webSocketInClient.setConnectionLostTimeout(0); |
| | | } |
| | | } |
| | | }).start(); |
| | | } catch (Exception e) { |
| | | } |
| | | |
| | | |
| | | |
| | | return retMap; |
| | | } |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | package com.nq.ws; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.google.gson.reflect.TypeToken; |
| | | import com.nq.enums.EStockType; |
| | | import com.nq.pojo.StockRealTimeBean; |
| | | import com.nq.service.IMandatoryLiquidationService; |
| | | import com.nq.service.impl.MandatoryLiquidationService; |
| | | import com.nq.utils.ApplicationContextRegisterUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.java_websocket.client.WebSocketClient; |
| | | import org.java_websocket.handshake.ServerHandshake; |
| | | import org.springframework.context.ApplicationContext; |
| | | |
| | | import java.lang.reflect.Type; |
| | | import java.net.URI; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @program: dabaogp |
| | | * @description: |
| | | * @create: 2024-07-24 15:02 |
| | | **/ |
| | | @Slf4j |
| | | public class WebSocketInClient extends WebSocketClient { |
| | | private EStockType eStockType; |
| | | public WebSocketInClient(URI serverUri, |
| | | EStockType eStockType |
| | | ) { |
| | | super(serverUri); |
| | | this.eStockType = eStockType; |
| | | } |
| | | |
| | | @Override |
| | | public void onOpen(ServerHandshake serverHandshake) { |
| | | send(("key:"+ eStockType.getStockKey()+":"+eStockType.getContryId()).getBytes()); |
| | | } |
| | | |
| | | @Override |
| | | public void onMessage(String s) { |
| | | try { |
| | | ApplicationContext act = ApplicationContextRegisterUtil.getApplicationContext(); |
| | | MandatoryLiquidationService liquidationService = (MandatoryLiquidationService) act.getBean(IMandatoryLiquidationService.class); |
| | | StockRealTimeBean stockDetailBean = new Gson().fromJson(s, StockRealTimeBean.class); |
| | | liquidationService.RealTimeDataProcess(eStockType,stockDetailBean); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void onClose(int i, String s, boolean b) { |
| | | log.info("websocket 印度股票 关闭"+1); |
| | | } |
| | | |
| | | @Override |
| | | public void onError(Exception e) { |
| | | log.info("websocket 错误"); |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public static Map<String, Object> jsonToMap(String json) { |
| | | Gson gson = new Gson(); |
| | | Type type = new TypeToken<Map<String, Object>>(){}.getType(); |
| | | return gson.fromJson(json, type); |
| | | } |
| | | |
| | | @Override |
| | | public void onClose(int i, String s, boolean b) { |
| | |
| | | #股票key的地址 |
| | | US_HTTP_API = http://api-us.js-stock.top/ |
| | | US_WS_URL = ws://ws-us.js-stock.top |
| | | US_KEY = 4Z6dY7zcnsdfsdfZyBL4KDa00h |
| | | US_KEY = 9sudfjhwdsosdfZyBL4KDa00h |
| | | |
| | | |
| | | |
| | | #股票key的地址 |
| | | IN_HTTP_API = https://data.is4vc.com/v1/ |
| | | IN_WS_URL =wss://ws.is4vc.com/websocket-server/v1 |
| | | IN_KEY = r3ZAgtcYzuBizmqge2hK |
| | | |
| | | #?? ?? - ???? |
| | | admin.auth.email.subject=???? - ?????? |