| | |
| | | package com.nq.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.nq.dao.StockDzMapper; |
| | | import com.nq.dao.StockMapper; |
| | | import com.nq.dao.StockSettingMapper; |
| | | import com.nq.pojo.Stock; |
| | | import com.nq.pojo.StockRealTimeBean; |
| | | import com.nq.pojo.StockSetting; |
| | | import com.nq.enums.EConfigKey; |
| | | import com.nq.pojo.*; |
| | | import com.nq.service.IPriceServices; |
| | | import com.nq.service.IStockConfigServices; |
| | | import com.nq.utils.redis.RedisKeyUtil; |
| | | import com.nq.utils.timeutil.TimeUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | @Resource |
| | | StockMapper stockMapper; |
| | | |
| | | @Autowired |
| | | IStockConfigServices iStockConfigServices; |
| | | |
| | | @Resource |
| | | StockDzMapper stockDZMapper; |
| | | |
| | | @Override |
| | | public BigDecimal getNowPrice(String stockCode) { |
| | | Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code",stockCode)); |
| | |
| | | StockRealTimeBean stockRealTimeBean = RedisKeyUtil.getCacheRealTimeStock(stock); |
| | | return new BigDecimal(stockRealTimeBean.getLast()); |
| | | } |
| | | |
| | | @Override |
| | | public BigDecimal getNowPrice(String stockCode, String stockType) { |
| | | BigDecimal nowPrice = getNowPrice(stockCode); |
| | | if (!stockType.equals("DZ")){ |
| | | return nowPrice; |
| | | } |
| | | QueryWrapper queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("stock_code",stockCode); |
| | | StockDz stockDz = stockDZMapper.selectOne(queryWrapper); |
| | | if(stockDz == null){ |
| | | return nowPrice;} |
| | | return nowPrice.multiply(stockDz.getDiscount()); |
| | | } |
| | | |
| | | @Override |
| | | public boolean isLimitUpBuy(String stockCode) { |
| | | Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code",stockCode)); |
| | | StockRealTimeBean stockRealTimeBean = RedisKeyUtil.getCacheRealTimeStock(stock); |
| | | BigDecimal pcp = new BigDecimal(stockRealTimeBean.getPcp()); |
| | | StockConfig stockConfig = iStockConfigServices.queryByKey(EConfigKey.LIMIT_UP_POINT.getCode()); |
| | | if(stockConfig == null){ |
| | | return true; |
| | | } |
| | | |
| | | |
| | | if(pcp.compareTo(new BigDecimal(0))<0){ |
| | | return true; |
| | | } |
| | | |
| | | if(new BigDecimal(stockConfig.getCValue()).compareTo(pcp)>0){ |
| | | StockConfig limitConfig = iStockConfigServices.queryByKey(EConfigKey.LIMIT_UP_IS_BUY.getCode()); |
| | | if(limitConfig.getCValue().equals("1")){ |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean isLimitDownSell(String stockCode) { |
| | | Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code",stockCode)); |
| | | StockRealTimeBean stockRealTimeBean = RedisKeyUtil.getCacheRealTimeStock(stock); |
| | | BigDecimal pcp = new BigDecimal(stockRealTimeBean.getPcp()); |
| | | StockConfig stockConfig = iStockConfigServices.queryByKey(EConfigKey.LIMIT_DOWN_POINT.getCode()); |
| | | if(stockConfig == null){ |
| | | return true; |
| | | } |
| | | |
| | | if(new BigDecimal(stockConfig.getCValue()).compareTo(pcp)<=0){ |
| | | StockConfig limitConfig = iStockConfigServices.queryByKey(EConfigKey.LIMIT_DOWN_IS_SELL.getCode()); |
| | | if(limitConfig.getCValue().equals("1")){ |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |