From f25b39e0d5fcae415a8824fc03d42fe681e96bf8 Mon Sep 17 00:00:00 2001
From: zyy <zyy@email.com>
Date: Mon, 21 Jul 2025 17:17:48 +0800
Subject: [PATCH] 移除多余引用
---
src/main/java/com/nq/service/impl/UserPositionServiceImpl.java | 41 +++++++++++++++++++++++++----------------
1 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java b/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
index bb30fa6..c81c93c 100644
--- a/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
+++ b/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
@@ -88,14 +88,10 @@
@Autowired
StockMapper stockMapper;
@Autowired
- AgentAgencyFeeMapper agentAgencyFeeMapper;
- @Autowired
IAgentAgencyFeeService iAgentAgencyFeeService;
@Autowired
ISiteProductService iSiteProductService;
- @Autowired
- FundsApplyMapper fundsApplyMapper;
@Autowired
UserStockSubscribeMapper userStockSubscribeMapper;
@Resource
@@ -103,12 +99,6 @@
@Resource
UserIndexPositionMapper userIndexPositionMapper;
- @Autowired
- IStockFuturesService iStockFuturesService;
- @Autowired
- IStockCoinService iStockCoinService;
- @Autowired
- CurrencyUtils currencyUtils;
@Resource
StockDzMapper stockDzMapper;
@@ -187,10 +177,16 @@
return ServerResponse.createByErrorMsg("报价0,请稍后再试", request);
}
+
BigDecimal buyAmt = nowPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever));
+ BigDecimal finalBuyAmt = buyAmt;
+ //如果不是墨西哥币需要转换金额
+ if (!stock.getStockType().equals(EStockType.MX.getCode())) {
+ buyAmt = userAssetsServices.exchangeAmountByRate(stock.getStockType(), buyAmt);
+ }
BigDecimal orderFree = siteSettingBuyFee.multiply(buyAmt);
- BigDecimal fundratio = new BigDecimal(user.getFundRatio()).divide(new BigDecimal(100));
+ 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);
@@ -221,7 +217,7 @@
}
userPosition.setIsLock(Integer.valueOf(0));
userPosition.setOrderLever(lever);
- userPosition.setOrderTotalPrice(buyAmt);
+ userPosition.setOrderTotalPrice(finalBuyAmt);
// 手续费
userPosition.setOrderFee(orderFree);
@@ -1810,6 +1806,15 @@
return ServerResponse.createByErrorMsg("订单失败,配资不足", request);
}
+ BigDecimal newBuyAmt = buyAmt;
+ //如果不是墨西哥币需要转换金额
+ if (!stock.getStockType().equals(EStockType.MX.getCode())) {
+ newBuyAmt = userAssetsServices.exchangeAmountByRate(stock.getStockType(), buyAmt);
+ }
+ if(newBuyAmt.compareTo(userAssets.getAvailableBalance()) > 0){
+ return ServerResponse.createByErrorMsg("可用余额不足" + userAssets.getAvailableBalance(), request);
+ }
+
//判断审核开关
if(stockDz.getSwitchType() == 1) {
UserPosition userPosition = getUserPosition(dzId,num, user, stockDz, nowPrice, stock, buyAmt);
@@ -1822,9 +1827,10 @@
// 创建UserPosition对象
UserPosition userPosition = getUserPosition(dzId,num, user, stockDz, nowPrice, stock, buyAmt);
userPositionMapper.insert(userPosition);
- BigDecimal buy_fee_amt = siteSettingBuyFee.multiply(buyAmt);
- userAssetsServices.availablebalanceChange(stock.getStockType(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"","");
- iUserAssetsServices.availablebalanceChange(stock.getStockType(), userAssets.getUserId(), EUserAssets.HANDLING_CHARGE, buy_fee_amt, "", "");
+ BigDecimal buy_fee_amt = siteSettingBuyFee.multiply(newBuyAmt);
+ //已经转化 直接穿MEX类型
+ userAssetsServices.availablebalanceChange(EStockType.MX.getCode(), user.getId(), EUserAssets.BUY, newBuyAmt.negate(),"","");
+ iUserAssetsServices.availablebalanceChange(EStockType.MX.getCode(), userAssets.getUserId(), EUserAssets.HANDLING_CHARGE, buy_fee_amt, "", "");
return ServerResponse.createBySuccess("购买成功", request);
}
@@ -2177,6 +2183,9 @@
userPositionCheckDzService.updateById(userPositionCheckDz);
return ServerResponse.createBySuccess("审核成功", request);
}
+ if (orderNum > userPositionCheckDz.getOrderNum()) {
+ return ServerResponse.createByErrorMsg("输入数量大于用户买入数量", request);
+ }
User user = userMapper.selectById(userPositionCheckDz.getUserId());
StockDz stockDz = this.stockDzMapper.selectOne(new QueryWrapper<StockDz>().eq("id", userPositionCheckDz.getDzId()));
@@ -2206,7 +2215,7 @@
userPosition.setId(null);
userPosition.setDzId(stockDz.getId());
userPositionMapper.insert(userPosition);
- userAssetsServices.availablebalanceChange(userAssets.getAccectType(), user.getId(), EUserAssets.BUY, buyAmt.negate(), "", "");
+ userAssetsServices.availablebalanceChange(stockDz.getStockType(), user.getId(), EUserAssets.BUY, buyAmt.negate(), "", "");
return ServerResponse.createBySuccessMsg("审核成功,订单已转客户持仓", request);
} catch (Exception e) {
return ServerResponse.createByErrorMsg(e.getMessage());
--
Gitblit v1.9.3