From 27cfb25fca116d371de1697fb49b7e53ec6e3031 Mon Sep 17 00:00:00 2001
From: dd <gitluke@outlook.com>
Date: Wed, 28 Jan 2026 02:04:54 +0800
Subject: [PATCH] 1
---
src/main/java/com/nq/service/impl/UserServiceImpl.java | 82 ++++++++++++++++++++++++++++++-----------
1 files changed, 60 insertions(+), 22 deletions(-)
diff --git a/src/main/java/com/nq/service/impl/UserServiceImpl.java b/src/main/java/com/nq/service/impl/UserServiceImpl.java
index 64b4d6c..12c3e04 100644
--- a/src/main/java/com/nq/service/impl/UserServiceImpl.java
+++ b/src/main/java/com/nq/service/impl/UserServiceImpl.java
@@ -11,6 +11,7 @@
import com.nq.pojo.*;
import com.nq.service.*;
import com.nq.utils.DateTimeUtil;
+import com.nq.utils.KeyUtils;
import com.nq.utils.PropertiesUtil;
import com.nq.utils.SymmetricCryptoUtil;
import com.nq.utils.ip.IpUtils;
@@ -109,9 +110,9 @@
@Autowired
IUserRechargeService userRechargeService;
- public ServerResponse reg(String yzmCode, String agentCode, String phone, String userPwd, HttpServletRequest request) {
- if (StringUtils.isBlank(agentCode) || StringUtils.isBlank(phone) ||
- StringUtils.isBlank(userPwd) || StringUtils.isBlank(yzmCode))
+ public ServerResponse reg(String agentCode,String phone, String userPwd, HttpServletRequest request) {
+ if (StringUtils.isBlank(phone) || StringUtils.isBlank(agentCode) ||
+ StringUtils.isBlank(userPwd))
{
return ServerResponse.createByErrorMsg("注册失败, 参数不能为空");
}
@@ -120,18 +121,13 @@
String keys = "AliyunSmsCode:" + phone;
String redis_yzm = RedisShardedPoolUtils.get(keys);
- log.info("redis_yzm = {},yzmCode = {}", redis_yzm, yzmCode);
-// if (!yzmCode.equals(redis_yzm) && !"6666".equals(yzmCode)) {
-// return ServerResponse.createByErrorMsg("注册失败, 验证码错误");
-// }
-
AgentUser agentUser = this.iAgentUserService.findByCode(agentCode);
if (agentUser == null) {
- return ServerResponse.createByErrorMsg("注册失败, 代理不存在");
+ return ServerResponse.createByErrorMsg("注册失败, 机构代码不存在");
}
if (agentUser.getIsLock().intValue() == 1) {
- return ServerResponse.createByErrorMsg("注册失败, 代理已被锁定");
+ return ServerResponse.createByErrorMsg("注册失败, 机构代码已被锁定");
}
@@ -142,14 +138,14 @@
User user = new User();
+ user.setPhone(phone);
user.setAgentId(agentUser.getId());
user.setAgentName(agentUser.getAgentName());
- user.setPhone(phone);
user.setUserPwd(SymmetricCryptoUtil.encryptPassword(userPwd));
user.setAccountType(Integer.valueOf(0));
- user.setIsLock(Integer.valueOf(1));
+ user.setIsLock(Integer.valueOf(0));
user.setIsActive(Integer.valueOf(0));
user.setRegTime(new Date());
@@ -178,12 +174,28 @@
int insertCount = this.userMapper.insert(user);
if (insertCount > 0) {
+ //用户注册成功重新代理机构码重新生成
+ String newAgentCode = generateUniqueAgentCode();
+ agentUser.setAgentCode(newAgentCode);
+ iAgentUserService.updateAgentCode(agentUser);
log.info("用户注册成功 手机 {} , ip = {} 地址 = {}", new Object[] { phone, uip, uadd });
return ServerResponse.createBySuccessMsg("注册成功.请登录");
}
return ServerResponse.createBySuccessMsg("注册出错, 请重试");
}
+ public String generateUniqueAgentCode() {
+ // 生成新的 agent code
+ String newAgentCode = KeyUtils.getAgentUniqueKey();
+
+ // 如果找到重复的 agent code,则递归重新生成
+ if (iAgentUserService.findByCode(newAgentCode) != null) {
+ return generateUniqueAgentCode(); // 递归调用
+ }
+
+ // 返回唯一的 agent code
+ return newAgentCode;
+ }
public ServerResponse login(String phone, String userPwd, HttpServletRequest request) {
@@ -1516,9 +1528,11 @@
BigDecimal sh_amt = user.getEnableAmt();
BigDecimal sh_amt_back = new BigDecimal("0");
+ BigDecimal enaleWithdrawAmt = user.getEnaleWithdrawAmt();
//0 加钱 1 减钱 2虚拟加钱
if (direction.intValue() == 0||direction.intValue()==2) {
sh_amt_back = sh_amt.add(new BigDecimal(amt));
+ enaleWithdrawAmt = enaleWithdrawAmt.add(new BigDecimal(amt));
} else if (direction.intValue() == 1) {
if (sh_amt.compareTo(new BigDecimal(amt)) == -1) {
@@ -1529,6 +1543,7 @@
return ServerResponse.createByErrorMsg("不存在此操作");
}
user.setEnableAmt(sh_amt_back);
+ user.setEnaleWithdrawAmt(enaleWithdrawAmt);
// BigDecimal hk_amt = user.getHkAmt();
//
@@ -1815,27 +1830,48 @@
PositionVO positionVO = this.iUserPositionService.findUserPositionAllProfitAndLose(user.getId());
userInfoVO.setAllFreezAmt(positionVO.getAllFreezAmt());
BigDecimal allProfitAndLose = positionVO.getAllProfitAndLose();
- userInfoVO.setAllProfitAndLose(allProfitAndLose);
+ BigDecimal profitAndLose = this.userPositionMapper.CountPositionAllProfitAndLoseByUserId(user.getId());
+ userInfoVO.setAllProfitAndLose(allProfitAndLose.add(profitAndLose));
// BigDecimal userAllAmt = user.getUserAmt();
BigDecimal userAllAmt = user.getEnableAmt();
- userAllAmt = userAllAmt.add(allProfitAndLose);
- userInfoVO.setUserAmt(userAllAmt);
+ if(null != allProfitAndLose){
+ userInfoVO.setAllProfitAndLose(allProfitAndLose);
+ userAllAmt = userAllAmt.add(allProfitAndLose);
+ }
+
+
userInfoVO.setEnableIndexAmt(user.getEnableIndexAmt());
userInfoVO.setEnaleWithdrawAmt(user.getEnaleWithdrawAmt());
userInfoVO.setHkAmt(user.getHkAmt());
-
+ userInfoVO.setPhotoUrl(user.getPhotoUrl());
BigDecimal historyProfitLoss = new BigDecimal(0);
- List<UserPosition> userPositions = this.userPositionMapper.findMyPositionByCodeAndSpell(user.getId(), "", "", 1);
+ BigDecimal buyAmtAutual = new BigDecimal(0);
+ List<UserPosition> userPositionscc = this.userPositionMapper.findMyPositionByCodeAndSpell(user.getId(), "", "", 0);
- if (userPositions.size() > 0) {
- for (UserPosition position : userPositions) {
+ if (userPositionscc.size() > 0) {
+ for (UserPosition position : userPositionscc) {
+ buyAmtAutual = buyAmtAutual.add(position.getBuyOrderPrice()
+ .multiply(new BigDecimal(position.getOrderNum()))
+ .divide(new BigDecimal(position.getOrderLever()), 2, RoundingMode.HALF_UP));
UserPositionVO userPositionVO = assembleUserPositionVO(position);
- historyProfitLoss = historyProfitLoss.add(userPositionVO.getAllProfitAndLose());
+ historyProfitLoss = historyProfitLoss.add(userPositionVO.getProfitAndLose());
+
}
}
+ userInfoVO.setBuyAmtAutual(buyAmtAutual);
+ userAllAmt = userAllAmt.add(buyAmtAutual);
+ userInfoVO.setUserAmt(userAllAmt);
userInfoVO.setHistoryProfitLoss(historyProfitLoss);
+// List<UserPosition> userPositions = this.userPositionMapper.findMyPositionByCodeAndSpell(user.getId(), "", "", 1);
+// if (userPositions.size() > 0) {
+// for (UserPosition position : userPositions) {
+// UserPositionVO userPositionVO = assembleUserPositionVO(position);
+// historyProfitLoss = historyProfitLoss.add(userPositionVO.getProfitAndLose());
+// }
+// }
+
// IndexPositionVO indexPositionVO = this.iUserIndexPositionService.findUserIndexPositionAllProfitAndLose(user.getId());
// BigDecimal allIndexProfitAndLose = indexPositionVO.getAllIndexProfitAndLose();
@@ -1916,7 +1952,8 @@
if (position.getSellOrderId() != null) {
BigDecimal subPrice = position.getSellOrderPrice().subtract(position.getBuyOrderPrice());
- profitAndLose = subPrice.multiply(new BigDecimal(position.getOrderNum().intValue())).multiply(new BigDecimal(position.getOrderLever())).setScale(2,4);
+// profitAndLose = subPrice.multiply(new BigDecimal(position.getOrderNum().intValue())).multiply(new BigDecimal(position.getOrderLever())).setScale(2,4);
+ profitAndLose = subPrice.multiply(new BigDecimal(position.getOrderNum().intValue())).setScale(2,4);
if ("买跌".equals(position.getOrderDirection())) {
profitAndLose = profitAndLose.negate();
}
@@ -1937,7 +1974,8 @@
}
BigDecimal subPrice = (new BigDecimal(nowPrice)).subtract(position.getBuyOrderPrice());
- profitAndLose = subPrice.multiply(new BigDecimal(position.getOrderNum().intValue())).multiply(new BigDecimal(position.getOrderLever())).setScale(2,4);
+// profitAndLose = subPrice.multiply(new BigDecimal(position.getOrderNum().intValue())).multiply(new BigDecimal(position.getOrderLever())).setScale(2,4);
+ profitAndLose = subPrice.multiply(new BigDecimal(position.getOrderNum().intValue())).setScale(2,4);
if ("买跌".equals(position.getOrderDirection())) {
profitAndLose = profitAndLose.negate();
}
--
Gitblit v1.9.3