From c114364ebfef1cbfa5234dd76c7d70cda5662f68 Mon Sep 17 00:00:00 2001
From: zyy <zyy@email.com>
Date: Tue, 15 Jul 2025 16:17:18 +0800
Subject: [PATCH] 新股修改

---
 src/main/java/com/nq/service/impl/UserPositionServiceImpl.java |  288 ++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 171 insertions(+), 117 deletions(-)

diff --git a/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java b/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
index 7265221..13455a5 100644
--- a/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
+++ b/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
@@ -29,6 +29,7 @@
 import com.nq.vo.position.PositionVO;
 import com.nq.vo.position.UserPositionVO;
 import com.nq.vo.stock.StockListVO;
+import com.nq.vo.stock.ai.StockAiOrderTypeVO;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
@@ -43,6 +44,7 @@
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
+import java.util.stream.Collectors;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 
@@ -137,105 +139,107 @@
         SiteProduct siteProduct = iSiteProductService.getProductSetting();
 
         User user = this.iUserService.getCurrentRefreshUser(request);
-        if (siteProduct.getRealNameDisplay() && user.getIsActive() != 2) {
-            return ServerResponse.createByErrorMsg("订单失败,请先实名认证", request);
-        }
-        // 手续费率
-        BigDecimal siteSettingBuyFee = new BigDecimal(iStockConfigServices.queryByKey(EConfigKey.BUY_HANDLING_CHARGE.getCode()).getCValue()) ;
+        synchronized (user.getId()){
+            if (siteProduct.getRealNameDisplay() && user.getIsActive() != 2) {
+                return ServerResponse.createByErrorMsg("订单失败,请先实名认证", request);
+            }
+            // 手续费率
+            BigDecimal siteSettingBuyFee = new BigDecimal(iStockConfigServices.queryByKey(EConfigKey.BUY_HANDLING_CHARGE.getCode()).getCValue()) ;
 
-        if (siteProduct.getRealNameDisplay() && user.getIsLock().intValue() == 1) {
-            return ServerResponse.createByErrorMsg("订单失败,帐户已被锁定", request);
-        }
+            if (siteProduct.getRealNameDisplay() && user.getIsLock().intValue() == 1) {
+                return ServerResponse.createByErrorMsg("订单失败,帐户已被锁定", request);
+            }
 
-        Stock stock = stockMapper.selectByPrimaryKey(stockId);
-        if (stock == null) {
-            return ServerResponse.createByErrorMsg("订单失败,股票代码不存在", request);
-        }
-        //判断股票是否在可交易时间段
-        Boolean b = tradingHourService.timeCheck(stock.getStockCode());
-        if (!b) {
-            return ServerResponse.createByErrorMsg("订单失败,不在交易时间之内", request);
-        }
+            Stock stock = stockMapper.selectByPrimaryKey(stockId);
+            if (stock == null) {
+                return ServerResponse.createByErrorMsg("订单失败,股票代码不存在", request);
+            }
+            //判断股票是否在可交易时间段
+            Boolean b = tradingHourService.timeCheck(stock.getStockCode(), stock.getStockType());
+            if (!b) {
+                return ServerResponse.createByErrorMsg("订单失败,不在交易时间之内", request);
+            }
 
 
-       StockConfig mainBuyConfig =  iStockConfigServices.queryByKey(EConfigKey.MIN_BUY.getCode());
+            StockConfig mainBuyConfig =  iStockConfigServices.queryByKey(EConfigKey.MIN_BUY.getCode());
 
-        if(buyNum<Integer.parseInt(mainBuyConfig.getCValue())){
-            return ServerResponse.createByErrorMsg("最低购买数量"+mainBuyConfig.getCValue(), request);
-        }
+            if(buyNum<Integer.parseInt(mainBuyConfig.getCValue())){
+                return ServerResponse.createByErrorMsg("最低购买数量"+mainBuyConfig.getCValue(), request);
+            }
 
-        UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId(stock.getStockType(), user.getId());
-        StockConfig maxBuyConfig =  iStockConfigServices.queryByKey(EConfigKey.MAX_BUY.getCode());
-        if(buyNum<Integer.parseInt(mainBuyConfig.getCValue())){
-            return ServerResponse.createByErrorMsg("最高购买数量"+maxBuyConfig.getCValue(), request);
-        }
-        if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){
-            return ServerResponse.createByErrorMsg("请先缴清待补资金", request);
-        }
-        if (stock.getIsLock() != 0) {
-            return ServerResponse.createByErrorMsg("订单失败,股票被锁定", request);
-        }
+            UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId(stock.getStockType(), user.getId());
+            StockConfig maxBuyConfig =  iStockConfigServices.queryByKey(EConfigKey.MAX_BUY.getCode());
+            if(buyNum<Integer.parseInt(mainBuyConfig.getCValue())){
+                return ServerResponse.createByErrorMsg("最高购买数量"+maxBuyConfig.getCValue(), request);
+            }
+            if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){
+                return ServerResponse.createByErrorMsg("请先缴清待补资金", request);
+            }
+            if (stock.getIsLock() != 0) {
+                return ServerResponse.createByErrorMsg("订单失败,股票被锁定", request);
+            }
 
-        if (!priceServices.isLimitUpBuy(stock.getStockCode())) {
-            return ServerResponse.createByErrorMsg("暂无配额", request);
-        }
+            if (!priceServices.isLimitUpBuy(stock.getStockCode())) {
+                return ServerResponse.createByErrorMsg("暂无配额", request);
+            }
 
-        //股票类型 现价 数据源的处理
-        BigDecimal nowPrice = priceServices.getNowPrice(stock.getStockCode());
+            //股票类型 现价 数据源的处理
+            BigDecimal nowPrice = priceServices.getNowPrice(stock.getStockCode());
 
-        if (nowPrice.compareTo(new BigDecimal("0")) == 0) {
-            return ServerResponse.createByErrorMsg("报价0,请稍后再试", request);
-        }
+            if (nowPrice.compareTo(new BigDecimal("0")) == 0) {
+                return ServerResponse.createByErrorMsg("报价0,请稍后再试", request);
+            }
 
-        BigDecimal buyAmt = nowPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever));
-        BigDecimal orderFree = siteSettingBuyFee.multiply(buyAmt);
+            BigDecimal buyAmt = nowPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever));
+            BigDecimal orderFree = siteSettingBuyFee.multiply(buyAmt);
 
-        BigDecimal   fundratio = new BigDecimal(user.getFundRatio()).divide(new BigDecimal(100));
-        BigDecimal availableBalance =  fundratio.multiply(userAssets.getAvailableBalance());
-        if (availableBalance.compareTo(buyAmt.add(orderFree)) < 0) {
-            return ServerResponse.createByErrorMsg("订单失败,配资不足", request);
-        }
-        UserPosition userPosition = new UserPosition();
-        if (profitTarget != null && profitTarget.compareTo(new BigDecimal("0")) > 0) {
-            userPosition.setProfitTargetPrice(profitTarget);
-        }
-        if (stopTarget != null && stopTarget.compareTo(new BigDecimal("0")) > 0) {
-            userPosition.setStopTargetPrice(stopTarget);
-        }
-        userPosition.setPositionType(user.getAccountType());
-        userPosition.setPositionSn(KeyUtils.getUniqueKey());
-        userPosition.setUserId(user.getId());
-        userPosition.setNickName(user.getRealName());
-        userPosition.setAgentId(user.getAgentId());
-        userPosition.setStockCode(stock.getStockCode());
-        userPosition.setStockName(stock.getStockName());
-        userPosition.setStockGid(stock.getStockType());
-        userPosition.setStockSpell(stock.getStockSpell());
-        userPosition.setBuyOrderId(GeneratePosition.getPositionId());
-        userPosition.setBuyOrderTime(new Date());
-        userPosition.setBuyOrderPrice(nowPrice);
-        userPosition.setOrderDirection((buyType.intValue() == 0) ? "买涨" : "买跌");
-        userPosition.setOrderNum(buyNum);
-        if (stock.getStockPlate() != null) {
-            userPosition.setStockPlate(stock.getStockPlate());
-        }
-        userPosition.setIsLock(Integer.valueOf(0));
-        userPosition.setOrderLever(lever);
-        userPosition.setOrderTotalPrice(buyAmt);
-        // 手续费
+            BigDecimal   fundratio = new BigDecimal(user.getFundRatio()).divide(new BigDecimal(100));
+            BigDecimal availableBalance =  fundratio.multiply(userAssets.getAvailableBalance());
+            if (availableBalance.compareTo(buyAmt.add(orderFree)) < 0) {
+                return ServerResponse.createByErrorMsg("订单失败,配资不足", request);
+            }
+            UserPosition userPosition = new UserPosition();
+            if (profitTarget != null && profitTarget.compareTo(new BigDecimal("0")) > 0) {
+                userPosition.setProfitTargetPrice(profitTarget);
+            }
+            if (stopTarget != null && stopTarget.compareTo(new BigDecimal("0")) > 0) {
+                userPosition.setStopTargetPrice(stopTarget);
+            }
+            userPosition.setPositionType(user.getAccountType());
+            userPosition.setPositionSn(KeyUtils.getUniqueKey());
+            userPosition.setUserId(user.getId());
+            userPosition.setNickName(user.getRealName());
+            userPosition.setAgentId(user.getAgentId());
+            userPosition.setStockCode(stock.getStockCode());
+            userPosition.setStockName(stock.getStockName());
+            userPosition.setStockGid(stock.getStockType());
+            userPosition.setStockSpell(stock.getStockSpell());
+            userPosition.setBuyOrderId(GeneratePosition.getPositionId());
+            userPosition.setBuyOrderTime(new Date());
+            userPosition.setBuyOrderPrice(nowPrice);
+            userPosition.setOrderDirection((buyType.intValue() == 0) ? "买涨" : "买跌");
+            userPosition.setOrderNum(buyNum);
+            if (stock.getStockPlate() != null) {
+                userPosition.setStockPlate(stock.getStockPlate());
+            }
+            userPosition.setIsLock(Integer.valueOf(0));
+            userPosition.setOrderLever(lever);
+            userPosition.setOrderTotalPrice(buyAmt);
+            // 手续费
 
-        userPosition.setOrderFee(orderFree);
-        userPosition.setOrderSpread(BigDecimal.ZERO);
-        userPosition.setSpreadRatePrice(BigDecimal.ZERO);
-        BigDecimal profit_and_lose = new BigDecimal("0");
-        userPosition.setProfitAndLose(profit_and_lose);
-        userPosition.setAllProfitAndLose(profit_and_lose.add(orderFree));
-        userPosition.setOrderStayDays(Integer.valueOf(0));
-        userPosition.setOrderStayFee(BigDecimal.ZERO);
-        userPositionMapper.insert(userPosition);
-        iUserAssetsServices.availablebalanceChange(stock.getStockType(), user.getId(), EUserAssets.BUY, buyAmt.negate(), "", "");
-        iUserAssetsServices.availablebalanceChange(stock.getStockType(), user.getId(), EUserAssets.HANDLING_CHARGE, orderFree, "", "");
-        return ServerResponse.createBySuccessMsg("下单成功", request);
+            userPosition.setOrderFee(orderFree);
+            userPosition.setOrderSpread(BigDecimal.ZERO);
+            userPosition.setSpreadRatePrice(BigDecimal.ZERO);
+            BigDecimal profit_and_lose = new BigDecimal("0");
+            userPosition.setProfitAndLose(profit_and_lose);
+            userPosition.setAllProfitAndLose(profit_and_lose.add(orderFree));
+            userPosition.setOrderStayDays(Integer.valueOf(0));
+            userPosition.setOrderStayFee(BigDecimal.ZERO);
+            userPositionMapper.insert(userPosition);
+            iUserAssetsServices.availablebalanceChange(EStockType.MX.getCode(), user.getId(), EUserAssets.BUY, buyAmt.negate(), "", "");
+            iUserAssetsServices.availablebalanceChange(EStockType.MX.getCode(), user.getId(), EUserAssets.HANDLING_CHARGE, orderFree, "", "");
+            return ServerResponse.createBySuccessMsg("下单成功", request);
+        }
     }
 
 
@@ -284,17 +288,24 @@
     @Transactional
     public ServerResponse sell(String positionSn, int doType) {
         UserPosition userPosition = this.userPositionMapper.findPositionBySn(positionSn);
-        BigDecimal siitteBuyFee = iSiteSettingService.getSiteSetting().getBuyFee();
-        Boolean b = tradingHourService.timeCheck(userPosition.getStockCode());
-        if (!b) {
-            return ServerResponse.createByErrorMsg("订单失败,不在交易时间之内");
-        }
         if (userPosition == null) {
             return ServerResponse.createByErrorMsg("平仓失败,订单不存在");
+        }
+        BigDecimal siitteBuyFee = iSiteSettingService.getSiteSetting().getBuyFee();
+        Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code", userPosition.getStockCode()));
+        if(null == stock){
+            return ServerResponse.createByErrorMsg("股票不存在,平仓失败");
+        }
+        Boolean b = tradingHourService.timeCheck(userPosition.getStockCode(), stock.getStockType());
+        if (!b) {
+            return ServerResponse.createByErrorMsg("订单失败,不在交易时间之内");
         }
         User user = this.userMapper.selectById(userPosition.getUserId());
         if (user == null) {
             return ServerResponse.createByErrorMsg("平仓失败,用户不存在");
+        }
+        if (user.getIsLock() == 1) {
+            return ServerResponse.createByErrorMsg("账户已被限制交易");
         }
         if (userPosition.getSellOrderId() != null) {
             return ServerResponse.createByErrorMsg("平仓失败, 订单已平仓");
@@ -302,7 +313,7 @@
         if (1 == userPosition.getIsLock().intValue()) {
             return ServerResponse.createByErrorMsg("this order is closed " + userPosition.getLockMsg());
         }
-        Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code", userPosition.getStockCode()));
+        //Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code", userPosition.getStockCode()));
         BigDecimal nowPrice = priceServices.getNowPrice(userPosition.getStockCode());
         if (nowPrice.compareTo(new BigDecimal("0")) != 1) {
             return ServerResponse.createByErrorMsg("报价0,平仓失败,请稍后再试");
@@ -331,15 +342,22 @@
     @Transactional
     public ServerResponse sell(String positionSn, int doType, Integer number,HttpServletRequest request) {
         UserPosition userPosition = this.userPositionMapper.findPositionBySn(positionSn);
+        if (userPosition == null) {
+            return ServerResponse.createByErrorMsg("平仓失败,订单不存在", request);
+        }
         if(null == number || number <= 0 || number > userPosition.getOrderNum()){
             return ServerResponse.createByErrorMsg("请输入正确的平仓数", request);
         }
         // 手续费率
         BigDecimal siitteBuyFee = new BigDecimal(iStockConfigServices.queryByKey(EConfigKey.SELL_HANDLING_CHARGE.getCode()).getCValue());
 
+        Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code", userPosition.getStockCode()));
+        if(null == stock){
+            return ServerResponse.createByErrorMsg("股票不存在,平仓失败", request);
+        }
         UserAssets userAssets = userAssetsMapper.selectOne(new LambdaQueryWrapper<UserAssets>()
                 .eq(UserAssets::getUserId, userPosition.getUserId())
-                .eq(UserAssets::getAccectType, "IN")
+                .eq(UserAssets::getAccectType, stock.getStockType())
         );
         if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){
             return ServerResponse.createByErrorMsg("请先缴清待补资金", request);
@@ -349,11 +367,8 @@
         if (null != stockSubscribe && DateUtil.date().before(stockSubscribe.getListDate())) {
             return ServerResponse.createByErrorMsg("股票未上市,不能平仓", request);
         }
-        Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code", userPosition.getStockCode()));
-        if(null == stock){
-            return ServerResponse.createByErrorMsg("股票不存在,平仓失败", request);
-        }
-        Boolean b = tradingHourService.timeCheck(userPosition.getStockCode());
+
+        Boolean b = tradingHourService.timeCheck(userPosition.getStockCode(), stock.getStockType());
         if (!b) {
             return ServerResponse.createByErrorMsg("订单失败,不在交易时间之内", request);
         }
@@ -366,12 +381,13 @@
                 return ServerResponse.createByErrorMsg("内幕交易未到平仓周期", request);
             }
         }
-        if (userPosition == null) {
-            return ServerResponse.createByErrorMsg("平仓失败,订单不存在", request);
-        }
+
         User user = this.userMapper.selectById(userPosition.getUserId());
         if (user == null) {
             return ServerResponse.createByErrorMsg("平仓失败,用户不存在", request);
+        }
+        if (user.getIsLock() == 1) {
+            return ServerResponse.createByErrorMsg("账户已被限制交易", request);
         }
         if (userPosition.getSellOrderId() != null) {
             return ServerResponse.createByErrorMsg("平仓失败, 订单已平仓", request);
@@ -1296,20 +1312,22 @@
             return ServerResponse.createByErrorMsg("无该申购记录");
         }
         StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new QueryWrapper<StockSubscribe>().eq("newlist_id", userStockSubscribe.getNewStockId()));
-        if (userStockSubscribe == null) {
+        if (stockSubscribe == null) {
             return ServerResponse.createByErrorMsg("该新股不存在");
         }
 
         Stock stock = stockMapper.selectOne(new LambdaQueryWrapper<Stock>().eq(Stock::getStockCode, userStockSubscribe.getNewCode()));
-
+        String stockType;
         UserPosition userPosition = new UserPosition();
 
         if(null == stock){
             userPosition.setStockCode(stockSubscribe.getCode());
             userPosition.setStockSpell(stockSubscribe.getName());
+            stockType = stockSubscribe.getStockType();
         }else{
             userPosition.setStockCode(stock.getStockCode());
             userPosition.setStockSpell(stock.getStockSpell());
+            stockType = stock.getStockType();
         }
 
         userPosition.setPositionType(1);
@@ -1322,7 +1340,7 @@
 //        StringBuffer gid = new StringBuffer();
 //        gid.append(stockSubscribe.getStockType()!=null?stockSubscribe.getStockType():"");
 //        gid.append(userStockSubscribe.getNewCode()!=null?userStockSubscribe.getNewCode():"stock code invaild");
-        userPosition.setStockGid(stock.getStockType());
+        userPosition.setStockGid(stockType);
         userPosition.setBuyOrderId(GeneratePosition.getPositionId());
         userPosition.setBuyOrderTime(new Date());
         userPosition.setBuyOrderPrice(userStockSubscribe.getBuyPrice());
@@ -1376,12 +1394,12 @@
         userPosition.setNewId(stockSubscribe.getNewlistId());
         int ret = 0;
         ret = this.userPositionMapper.insert(userPosition);
-        UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId("IN", userPosition.getUserId());
+        UserAssets userAssets = iUserAssetsServices.assetsByTypeAndUserId(stockType, userPosition.getUserId());
         if(null == userAssets){
             return ServerResponse.createByErrorMsg("新股转持仓失败");
         }
         userAssetsMapper.updateById(userAssets);
-        iUserAssetsServices.availablebalanceChange("IN", userAssets.getUserId(), EUserAssets.HANDLING_CHARGE, buy_fee_amt, "", "");
+        iUserAssetsServices.availablebalanceChange(stockType, userAssets.getUserId(), EUserAssets.HANDLING_CHARGE, buy_fee_amt, "", "");
         if (ret > 0) {
             userStockSubscribe.setStatus(5);
             userStockSubscribeMapper.update1(userStockSubscribe);
@@ -1657,7 +1675,7 @@
     /**
      * 大宗下单
      *
-     * @param stockCode
+     * @param dzId
      * @param password
      * @param num
      * @param request
@@ -1675,10 +1693,6 @@
         if (siteProduct.getRealNameDisplay() && user.getIsLock().intValue() == 1) {
             return ServerResponse.createByErrorMsg("Order failed, account has been locked");
         }
-        UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId("IN", user.getId());
-        if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){
-            return ServerResponse.createByErrorMsg("请先缴清待补资金", request);
-        }
         StockDz stockDz = this.stockDzMapper.selectOne(new QueryWrapper<StockDz>().eq("id", dzId));
         if (StringUtils.isNotEmpty(stockDz.getPassword()) && !Objects.equals(stockDz.getPassword(), password)) {
             return ServerResponse.createByErrorMsg("密码错误", request);
@@ -1688,6 +1702,11 @@
         }
         //价格处理
         Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code", stockDz.getStockCode()));
+
+        UserAssets userAssets = userAssetsServices.assetsByTypeAndUserId(stock.getStockType(), user.getId());
+        if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){
+            return ServerResponse.createByErrorMsg("请先缴清待补资金", request);
+        }
 
         if(stockDz.getStartTime().getTime() > new Date().getTime() || stockDz.getEndTime().getTime() < new Date().getTime()){
             return ServerResponse.createByErrorMsg("不在内幕交易时间之内", request);
@@ -1713,7 +1732,7 @@
         }
 
         //判断审核开关
-        if(stockDz.getSwitchType() == 1){
+        if(stockDz.getSwitchType() == 1) {
             UserPosition userPosition = getUserPosition(dzId,num, user, stockDz, nowPrice, stock, buyAmt);
             UserPositionCheckDz userPositionCheckDz = Convert.convert(UserPositionCheckDz.class, userPosition);
             userPositionCheckDz.setDzId(dzId);
@@ -1725,8 +1744,8 @@
         UserPosition userPosition = getUserPosition(dzId,num, user, stockDz, nowPrice, stock, buyAmt);
         userPositionMapper.insert(userPosition);
         BigDecimal buy_fee_amt = siteSettingBuyFee.multiply(buyAmt);
-        userAssetsServices.availablebalanceChange(EStockType.IN.getCode(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"","");
-        iUserAssetsServices.availablebalanceChange("IN", userAssets.getUserId(), EUserAssets.HANDLING_CHARGE, buy_fee_amt, "", "");
+        userAssetsServices.availablebalanceChange(stock.getStockType(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"","");
+        iUserAssetsServices.availablebalanceChange(stock.getStockType(), userAssets.getUserId(), EUserAssets.HANDLING_CHARGE, buy_fee_amt, "", "");
         return ServerResponse.createBySuccess("购买成功", request);
     }
 
@@ -1779,12 +1798,19 @@
     @Transactional
     public void stockConstraint(List<UserPosition> list) {
         try {
-            SiteSetting siteSetting = iSiteSettingService.getSiteSetting();
+            //SiteSetting siteSetting = iSiteSettingService.getSiteSetting();
+
+            List<String> stockCodeList = list.stream().map(UserPosition::getStockCode).collect(Collectors.toList());
+            List<Stock> stockList = stockMapper.selectList(new QueryWrapper<Stock>().in("stock_code", stockCodeList));
 
             for (UserPosition position : list) {
+                Stock stock = stockList.stream().filter(x -> x.getStockCode().equals(position.getStockCode())).findFirst().orElse(null);
+                if (stock == null) {
+                    stock = stockMapper.findStockByCode(position.getStockCode());
+                }
                 UserAssets userAssets = userAssetsMapper.selectOne(new LambdaQueryWrapper<UserAssets>()
                         .eq(UserAssets::getUserId, position.getUserId())
-                        .eq(UserAssets::getAccectType, "IN")
+                        .eq(UserAssets::getAccectType, stock.getStockType())
                 );
                 if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){
                     continue;
@@ -1804,6 +1830,34 @@
         }
     }
 
+    /**
+     * 获取大宗交易订单
+     * @param pageNum
+     * @param pageSize
+     * @param status
+     * @param request
+     * @return
+     */
+    @Override
+    public ServerResponse getDzOrderList(int pageNum, int pageSize, Integer status, HttpServletRequest request) {
+        try {
+            User user = iUserService.getCurrentUser(request);
+            if (user == null ){
+                return ServerResponse.createByErrorCodeMsg(401,"请先登录");
+            }
+            PageHelper.startPage(pageNum, pageSize);
+            List<UserPositionCheckDz> userPositionCheckDzs = userPositionCheckDzService.list(
+                            new QueryWrapper<UserPositionCheckDz>()
+                            .eq("user_id", user.getId()).eq(status != null,"check_type", status));
+            // 获取分页信息
+            PageInfo<UserPositionCheckDz> pageInfo = new PageInfo<>(userPositionCheckDzs);
+            return ServerResponse.createBySuccess(pageInfo);
+        } catch (Exception e) {
+            log.error("IUserPositionService getDzOrderList error", e);
+        }
+        return ServerResponse.createByError();
+    }
+
     private Result getResult(UserPosition position) {
         // 检查订单是否存在
         if (position == null) {

--
Gitblit v1.9.3