From 38a92bc8a3eb615ed3a93381e1a24891de45e9f9 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Sun, 07 Jul 2024 14:02:12 +0800
Subject: [PATCH] 1
---
src/main/java/com/nq/service/impl/UserPositionServiceImpl.java | 42 +++++++++++++++++++++++++++++++-----------
1 files changed, 31 insertions(+), 11 deletions(-)
diff --git a/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java b/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
index 6bdb651..9eb87e6 100644
--- a/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
+++ b/src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
@@ -1,5 +1,6 @@
package com.nq.service.impl;
+import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.nq.dao.*;
@@ -123,6 +124,8 @@
@Autowired
IStockConfigServices iStockConfigServices;
+ @Autowired
+ UserPositionCheckDzService userPositionCheckDzService;
@@ -1183,7 +1186,7 @@
if (userStockSubscribe == null) {
return ServerResponse.createByErrorMsg("无该申购记录");
}
- StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new QueryWrapper<StockSubscribe>().eq("code", userStockSubscribe.getNewCode()).eq("type",userStockSubscribe.getType()));
+ StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new QueryWrapper<StockSubscribe>().eq("newlist_id", userStockSubscribe.getNewStockId()));
if (userStockSubscribe == null) {
return ServerResponse.createByErrorMsg("该新股不存在");
}
@@ -1201,8 +1204,10 @@
userPosition.setStockCode(stock.getStockCode());
userPosition.setStockSpell(stock.getStockSpell());
userPosition.setStockName(userStockSubscribe.getNewName());
- userPosition.setStockGid(stockSubscribe.getStockType() + userStockSubscribe.getNewCode());
-
+ StringBuffer gid = new StringBuffer();
+ gid.append(stockSubscribe.getStockType()!=null?stockSubscribe.getStockType():"");
+ gid.append(userStockSubscribe.getNewCode()!=null?userStockSubscribe.getNewCode():"stock code invaild");
+ userPosition.setStockGid(gid.toString());
userPosition.setBuyOrderId(GeneratePosition.getPositionId());
userPosition.setBuyOrderTime(new Date());
userPosition.setBuyOrderPrice(userStockSubscribe.getBuyPrice());
@@ -1258,6 +1263,7 @@
return ServerResponse.createByErrorMsg("新股转持仓失败");
}
userAssets.setFreezeMoney(userAssets.getFreezeMoney().add(userPosition.getOrderTotalPrice()));
+ userAssets.setFreezeMoney(userAssets.getFreezeMoney()!=null?userAssets.getFreezeMoney().setScale(2,BigDecimal.ROUND_UP):null);
userAssetsMapper.updateById(userAssets);
if (ret > 0) {
userStockSubscribe.setStatus(5);
@@ -1543,7 +1549,7 @@
* @return
*/
@Transactional
- public ServerResponse buyDz(String stockCode, String password, Integer num, HttpServletRequest request) throws Exception {
+ public ServerResponse buyDz(Integer dzId, String password, Integer num, HttpServletRequest request) throws Exception {
/*实名认证开关开启*/
SiteProduct siteProduct = iSiteProductService.getProductSetting();
User user = this.iUserService.getCurrentRefreshUser(request);
@@ -1558,8 +1564,8 @@
if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){
return ServerResponse.createByErrorMsg("请先缴清待补资金", request);
}
- StockDz stockDz = this.stockDzMapper.selectOne(new QueryWrapper<StockDz>().eq("stock_code", stockCode));
- if (!Objects.equals(stockDz.getPassword(), password)) {
+ 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);
}
if (stockDz.getIsLock() != 0) {
@@ -1571,7 +1577,8 @@
if(stockDz.getStartTime().getTime() > new Date().getTime() || stockDz.getEndTime().getTime() < new Date().getTime()){
return ServerResponse.createByErrorMsg("不在内幕交易时间之内", request);
}
- BigDecimal nowPrice = priceServices.getNowPrice(stockCode).multiply(stockDz.getDiscount());
+// BigDecimal nowPrice = priceServices.getNowPrice(stockDz.getStockCode()).multiply(stockDz.getDiscount());
+ BigDecimal nowPrice = stockDz.getNowPrice();
if (nowPrice.compareTo(new BigDecimal("0")) == 0) {
return ServerResponse.createByErrorMsg("股票价格0,请重试", request);
@@ -1586,7 +1593,23 @@
return ServerResponse.createByErrorMsg("订单失败,配资不足", request);
}
+ //判断审核开关
+ if(stockDz.getSwitchType() == 1){
+ UserPosition userPosition = getUserPosition(num, user, stockDz, nowPrice, stock, buyAmt);
+ UserPositionCheckDz userPositionCheckDz = Convert.convert(UserPositionCheckDz.class, userPosition);
+ userPositionCheckDz.setDzId(dzId);
+ userPositionCheckDzService.save(userPositionCheckDz);
+ return ServerResponse.createBySuccess("购买成功,等待审核", request);
+ }
+
// 创建UserPosition对象
+ UserPosition userPosition = getUserPosition(num, user, stockDz, nowPrice, stock, buyAmt);
+ userPositionMapper.insert(userPosition);
+ userAssetsServices.availablebalanceChange(EStockType.IN.getCode(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"","");
+ return ServerResponse.createBySuccess("购买成功", request);
+ }
+
+ private UserPosition getUserPosition(Integer num, User user, StockDz stockDz, BigDecimal nowPrice, Stock stock, BigDecimal buyAmt) {
UserPosition userPosition = new UserPosition();
userPosition.setPositionType(3);
userPosition.setPositionSn(KeyUtils.getUniqueKey());
@@ -1615,11 +1638,8 @@
userPosition.setAllProfitAndLose(all_profit_and_lose);
userPosition.setOrderStayDays(Integer.valueOf(0));
userPosition.setOrderStayFee(new BigDecimal("0"));
-
userPosition.setOrderSpread(BigDecimal.ZERO);
- userPositionMapper.insert(userPosition);
- userAssetsServices.availablebalanceChange(EStockType.IN.getCode(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"","");
- return ServerResponse.createBySuccess("购买成功", request);
+ return userPosition;
}
@Override
--
Gitblit v1.9.3