package com.nq.utils;
|
|
import com.nq.service.IStockFuturesService;
|
import com.nq.service.IStockIndexService;
|
import com.nq.utils.redis.RedisShardedPoolUtils;
|
import com.nq.utils.stock.sina.StockApi;
|
import com.nq.vo.foreigncurrency.ExchangeVO;
|
import com.nq.vo.stock.MarketVO;
|
import com.nq.vo.stock.StockListVO;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import java.math.BigDecimal;
|
@Component
|
public class CurrencyUtils {
|
// private static IStockFuturesService iStockFuturesService;
|
|
@Autowired
|
IStockFuturesService iStockFuturesService;
|
@Autowired
|
IStockIndexService iStockIndexService;
|
//股票
|
public String getNowStockPrice(String stockGid, String coinCode) {
|
StockListVO stockListVO = new StockListVO();
|
BigDecimal price = new BigDecimal(0);
|
if (stockGid.contains("us")) {
|
String us = RedisShardedPoolUtils.get(stockGid, 2);
|
stockListVO = StockApi.otherStockListVO(us);
|
ExchangeVO exchangeVO = iStockFuturesService.queryExchangeVO(coinCode).getData();
|
price = new BigDecimal(stockListVO.getNowPrice()).multiply(new BigDecimal(exchangeVO.getNowPrice()));
|
}else if (stockGid.contains("hk")) {
|
String hk = RedisShardedPoolUtils.get(stockGid, 1);
|
stockListVO = StockApi.otherStockListVO(hk);
|
ExchangeVO exchangeVO = iStockFuturesService.queryExchangeVO(coinCode).getData();
|
price = new BigDecimal(stockListVO.getNowPrice()).multiply(new BigDecimal(exchangeVO.getNowPrice()));
|
}
|
return price.toString();
|
}
|
//指数
|
public BigDecimal getNowIndexPrice(String indexGid,String coinCode) {
|
|
MarketVO marketVO = this.iStockIndexService.querySingleIndex(indexGid);
|
ExchangeVO exchangeVO = iStockFuturesService.queryExchangeVO(coinCode).getData();
|
BigDecimal price = new BigDecimal(marketVO.getNowPrice()).multiply(new BigDecimal(exchangeVO.getNowPrice()));
|
|
return price;
|
}
|
}
|