From 0c74d36f29e8279d9061d57466b3f488a4e1b89f Mon Sep 17 00:00:00 2001
From: peter <14100000001@qq.com>
Date: Tue, 30 Dec 2025 17:20:14 +0800
Subject: [PATCH] 新增港股

---
 src/main/java/com/nq/service/impl/UserServiceImpl.java |   57 +++++++++++++++++++++++----------------------------------
 1 files changed, 23 insertions(+), 34 deletions(-)

diff --git a/src/main/java/com/nq/service/impl/UserServiceImpl.java b/src/main/java/com/nq/service/impl/UserServiceImpl.java
index f632221..5cbab4a 100644
--- a/src/main/java/com/nq/service/impl/UserServiceImpl.java
+++ b/src/main/java/com/nq/service/impl/UserServiceImpl.java
@@ -7,6 +7,7 @@
 import com.google.common.collect.Lists;
 import com.nq.common.ServerResponse;
 import com.nq.config.StockPoll;
+import com.nq.config.StockType;
 import com.nq.dao.*;
 import com.nq.pojo.*;
 import com.nq.service.*;
@@ -45,6 +46,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.RequestParam;
 
 @Service("iUserService")
 public class UserServiceImpl implements IUserService {
@@ -255,15 +257,13 @@
         }
     }
 
-    public ServerResponse addOption(String code, HttpServletRequest request) {
+    public ServerResponse addOption(String stockType, String code, HttpServletRequest request) {
         User user = getCurrentUser(request);
         if (user == null) {
             return ServerResponse.createBySuccessMsg("請先登錄");
         }
+
         String stockcode = code;
-        if(code.contains("hf")){
-            stockcode = code.split("_")[1];
-        }
         stockcode = stockcode.replace("sh","").replace("sz","").replace("bj","");
         StockOption dboption = this.stockOptionMapper.findMyOptionIsExistByCode(user.getId(), stockcode);
 
@@ -293,7 +293,11 @@
 //                stock.setIsLock(0);
 //            }
         } else {
-            stock = this.stockMapper.findStockByCode(code);
+            if(StockType.HK.getCode().equals(stockType)) {
+                stock = stockMapper.findStockByCodeAndType(stockType,code);
+            }else {
+                stock = this.stockMapper.findStockByCode(code);
+            }
         }
         if (stock == null) {
             return ServerResponse.createByErrorMsg("添加失败,股票不存在");
@@ -302,7 +306,14 @@
         stockOption.setUserId(user.getId());
         stockOption.setStockId(stock.getId());
         stockOption.setAddTime(new Date());
-        stockOption.setStockCode(stock.getStockCode());
+
+        if(StockType.HK.getCode().equals(stockType)) {
+            stockOption.setStockCode(stock.getStockGid());
+            stockOption.setStockType(StockType.HK.getCode());
+        }else {
+            stockOption.setStockCode(stock.getStockCode());
+            stockOption.setStockType(StockType.A.getCode());
+        }
         stockOption.setStockName(stock.getStockName());
         stockOption.setStockGid(stock.getStockGid());
         stockOption.setIsLock(stock.getIsLock());
@@ -1867,31 +1878,6 @@
             }
         }
         userInfoVO.setHistoryProfitLoss(historyProfitLoss);
-
-//        IndexPositionVO indexPositionVO = this.iUserIndexPositionService.findUserIndexPositionAllProfitAndLose(user.getId());
-//        BigDecimal allIndexProfitAndLose = indexPositionVO.getAllIndexProfitAndLose();
-//        userInfoVO.setAllIndexProfitAndLose(allIndexProfitAndLose);
-//        userInfoVO.setAllIndexFreezAmt(indexPositionVO.getAllIndexFreezAmt());
-//
-//        BigDecimal userAllIndexAmt = user.getUserIndexAmt();
-//        userAllIndexAmt = userAllIndexAmt.add(allIndexProfitAndLose);
-//        userInfoVO.setUserIndexAmt(userAllIndexAmt);
-//
-//        userInfoVO.setEnableFuturesAmt(user.getEnableFutAmt());
-//
-//
-//        FuturesPositionVO futuresPositionVO = this.iUserFuturesPositionService.findUserFuturesPositionAllProfitAndLose(user.getId());
-//
-//        userInfoVO.setAllFuturesFreezAmt(futuresPositionVO.getAllFuturesDepositAmt());
-//
-//
-//        BigDecimal allFuturesProfitAndLose = futuresPositionVO.getAllFuturesProfitAndLose();
-//        userInfoVO.setAllFuturesProfitAndLose(allFuturesProfitAndLose);
-
-
-//        BigDecimal userAllFuturesAmt = user.getUserFutAmt();
-//        userAllFuturesAmt = userAllFuturesAmt.add(allFuturesProfitAndLose);
-//        userInfoVO.setUserFuturesAmt(userAllFuturesAmt);
         userInfoVO.setDjzj(user.getDjzj());
         return userInfoVO;
     }
@@ -1960,16 +1946,19 @@
             StockCoin stockCoin = new StockCoin();
             stockListVO = SinaStockApi.assembleLideStockListVO(LiDeDataUtils.getStock(position.getStockCode()));
             if (org.springframework.util.ObjectUtils.isEmpty(stockListVO)) {
-                stockListVO = SinaStockApi.assembleStockListVO(SinaStockApi.getSinaStock(position.getStockGid()));
+                if(StockType.HK.getCode().equals(position.getStockType())){
+                    stockListVO = SinaStockApi.assembleStockListVOHk(SinaStockApi.getSinaStock(position.getStockType()+position.getStockGid()));
+                }else {
+                    stockListVO = SinaStockApi.assembleStockListVO(SinaStockApi.getSinaStock(position.getStockGid()));
+                }
+
             }
-            //    stockListVO = SinaStockApi.assembleStockListVO(SinaStockApi.getSinaStock(position.getStockGid()));
             nowPrice = stockListVO.getNowPrice();
             if (nowPrice == null) {
                 nowPrice = String.valueOf(0);
             }
 
             BigDecimal subPrice = (new BigDecimal(nowPrice)).subtract(position.getBuyOrderPrice());
-//            profitAndLose = subPrice.multiply(new BigDecimal(position.getOrderNum().intValue())).multiply(new BigDecimal(position.getOrderLever())).setScale(2,4);
             profitAndLose = subPrice.multiply(new BigDecimal(position.getOrderNum().intValue())).setScale(2,4);
             if ("买跌".equals(position.getOrderDirection())) {
                 profitAndLose = profitAndLose.negate();

--
Gitblit v1.9.3