peter
2025-10-29 f3b9e9f5024c13c6e70711a3ec98b4538378bd85
src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
@@ -128,11 +128,13 @@
    @Autowired
    UserPositionCheckDzService userPositionCheckDzService;
    @Autowired
    UserPendingorderMapper userPendingorderMapper;
    @Transactional
    public ServerResponse buy(Integer stockId, Integer buyNum, Integer buyType, Integer lever, BigDecimal profitTarget, BigDecimal stopTarget, HttpServletRequest request) {
    public ServerResponse buy(Integer stockId, Integer buyNum, Integer buyType, Integer lever, BigDecimal profitTarget, BigDecimal stopTarget,BigDecimal preMarketPrice, HttpServletRequest request) {
        SiteProduct siteProduct = iSiteProductService.getProductSetting();
@@ -203,6 +205,25 @@
            if (stopTarget != null && stopTarget.compareTo(new BigDecimal("0")) > 0) {
                userPosition.setStopTargetPrice(stopTarget);
            }
            //判断是否盘前,和价格
            StockSetting stockSetting = tradingHourService.preMarketPrice(stock.getStockCode());
            if(null != preMarketPrice && preMarketPrice.compareTo(new BigDecimal(0)) > 0 && null != stockSetting && preMarketPrice.compareTo(new BigDecimal(stockSetting.getPrice())) != 0){
                //挂单
                UserPendingorder userPendingorder = new UserPendingorder();
                userPendingorder.setUserId(user.getId());
                userPendingorder.setStockId(String.valueOf(stockId));
                userPendingorder.setBuyNum(buyNum);
                userPendingorder.setBuyType(buyType);
                userPendingorder.setLever(lever);
                userPendingorder.setProfitTarget(profitTarget);
                userPendingorder.setStopTarget(stopTarget);
                userPendingorder.setNowPrice(new BigDecimal(0));
                userPendingorder.setTargetPrice(preMarketPrice);
                userPendingorder.setAddTime(new Date());
                userPendingorder.setStatus(0);
                userPendingorder.setBuyAmt(buyAmt);
                int ret = userPendingorderMapper.insert(userPendingorder);
            }else {
            userPosition.setPositionType(user.getAccountType());
            userPosition.setPositionSn(KeyUtils.getUniqueKey());
            userPosition.setUserId(user.getId());
@@ -234,6 +255,8 @@
            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);