peter
2025-11-15 b8301f003ffec987f9e2ececf2c708a16e29116f
修改购买金额问题
1 files modified
8 ■■■■■ changed files
src/main/java/com/nq/service/impl/UserPositionServiceImpl.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
@@ -208,6 +208,7 @@
            }
            //判断是否盘前,和价格
            StockSetting stockSetting = tradingHourService.preMarketPrice(stock.getStockCode());
            BigDecimal buyAmtNew = BigDecimal.ZERO;
            if(null != preMarketPrice && preMarketPrice.compareTo(new BigDecimal(0)) > 0 && null != stockSetting && preMarketPrice.compareTo(new BigDecimal(stockSetting.getPrice())) != 0){
                //挂单
                UserPendingorder userPendingorder = new UserPendingorder();
@@ -222,7 +223,8 @@
                userPendingorder.setTargetPrice(preMarketPrice);
                userPendingorder.setAddTime(new Date());
                userPendingorder.setStatus(0);
                userPendingorder.setBuyAmt(preMarketPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever)));
                buyAmtNew = preMarketPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever));
                userPendingorder.setBuyAmt(buyAmtNew);
                int ret = userPendingorderMapper.insert(userPendingorder);
                buyAmt = userPendingorder.getBuyAmt();
                orderFree = siteSettingBuyFee.multiply(buyAmt);
@@ -248,7 +250,7 @@
                userPosition.setOrderLever(lever);
                userPosition.setOrderTotalPrice(buyAmt);
                // 手续费
                buyAmtNew = buyAmt;
                userPosition.setOrderFee(orderFree);
                userPosition.setOrderSpread(BigDecimal.ZERO);
                userPosition.setSpreadRatePrice(BigDecimal.ZERO);
@@ -260,7 +262,7 @@
                userPositionMapper.insert(userPosition);
            }
            iUserAssetsServices.availablebalanceChange(stock.getStockType(), user.getId(), EUserAssets.BUY, buyAmt.negate(), "", "");
            iUserAssetsServices.availablebalanceChange(stock.getStockType(), user.getId(), EUserAssets.BUY, buyAmtNew.negate(), "", "");
            iUserAssetsServices.availablebalanceChange(stock.getStockType(), user.getId(), EUserAssets.HANDLING_CHARGE, orderFree, "", "");
            return ServerResponse.createBySuccessMsg("下单成功", request);
        }