From 25e4c6e9e903a6035777b0a6b304df307711ba5d Mon Sep 17 00:00:00 2001
From: peter <14100000001@qq.com>
Date: Sat, 15 Nov 2025 14:22:01 +0800
Subject: [PATCH] 修改购买金额问题
---
src/main/java/com/nq/service/impl/UserPositionServiceImpl.java | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java b/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
index 15fc5c1..2857d0f 100644
--- a/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
+++ b/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
@@ -208,7 +208,6 @@
}
//判断是否盘前,和价格
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();
@@ -223,8 +222,7 @@
userPendingorder.setTargetPrice(preMarketPrice);
userPendingorder.setAddTime(new Date());
userPendingorder.setStatus(0);
- buyAmtNew = preMarketPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever));
- userPendingorder.setBuyAmt(buyAmtNew);
+ userPendingorder.setBuyAmt(preMarketPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever)));
int ret = userPendingorderMapper.insert(userPendingorder);
buyAmt = userPendingorder.getBuyAmt();
orderFree = siteSettingBuyFee.multiply(buyAmt);
@@ -240,7 +238,13 @@
userPosition.setStockSpell(stock.getStockSpell());
userPosition.setBuyOrderId(GeneratePosition.getPositionId());
userPosition.setBuyOrderTime(new Date());
- userPosition.setBuyOrderPrice(null == preMarketPrice ? nowPrice : preMarketPrice);
+// userPosition.setBuyOrderPrice(null == preMarketPrice ? nowPrice : preMarketPrice);
+ if(null == preMarketPrice){
+ userPosition.setBuyOrderPrice(nowPrice);
+ }else {
+ userPosition.setBuyOrderPrice(preMarketPrice);
+ buyAmt = preMarketPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever));
+ }
userPosition.setOrderDirection((buyType.intValue() == 0) ? "买涨" : "买跌");
userPosition.setOrderNum(buyNum);
if (stock.getStockPlate() != null) {
@@ -250,7 +254,6 @@
userPosition.setOrderLever(lever);
userPosition.setOrderTotalPrice(buyAmt);
// 手续费
- buyAmtNew = buyAmt;
userPosition.setOrderFee(orderFree);
userPosition.setOrderSpread(BigDecimal.ZERO);
userPosition.setSpreadRatePrice(BigDecimal.ZERO);
@@ -262,7 +265,7 @@
userPositionMapper.insert(userPosition);
}
- iUserAssetsServices.availablebalanceChange(stock.getStockType(), user.getId(), EUserAssets.BUY, buyAmtNew.negate(), "", "");
+ iUserAssetsServices.availablebalanceChange(stock.getStockType(), user.getId(), EUserAssets.BUY, buyAmt.negate(), "", "");
iUserAssetsServices.availablebalanceChange(stock.getStockType(), user.getId(), EUserAssets.HANDLING_CHARGE, orderFree, "", "");
return ServerResponse.createBySuccessMsg("下单成功", request);
}
--
Gitblit v1.9.3