From 26581a43d52f6f6e62607c51b8224cdc50191a80 Mon Sep 17 00:00:00 2001
From: jack <zengjieli93@163.com>
Date: Mon, 22 Apr 2024 18:07:29 +0800
Subject: [PATCH] 增加流水日志
---
src/main/java/com/nq/service/impl/PriceServicesImpl.java | 71 ++++++++++++++++++++++++++++++++++-
1 files changed, 68 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/nq/service/impl/PriceServicesImpl.java b/src/main/java/com/nq/service/impl/PriceServicesImpl.java
index 56f1aad..2d818b4 100644
--- a/src/main/java/com/nq/service/impl/PriceServicesImpl.java
+++ b/src/main/java/com/nq/service/impl/PriceServicesImpl.java
@@ -1,14 +1,16 @@
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;
@@ -27,6 +29,12 @@
@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));
@@ -45,4 +53,61 @@
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;
+ }
}
--
Gitblit v1.9.3