From 86587c1ffa0bdfa2a171dce96540c7617dd44dec Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Wed, 28 Jan 2026 18:33:54 +0800
Subject: [PATCH] 1
---
src/main/java/com/nq/service/impl/UserServiceImpl.java | 59 +++++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/src/main/java/com/nq/service/impl/UserServiceImpl.java b/src/main/java/com/nq/service/impl/UserServiceImpl.java
index 16191f9..5950649 100644
--- a/src/main/java/com/nq/service/impl/UserServiceImpl.java
+++ b/src/main/java/com/nq/service/impl/UserServiceImpl.java
@@ -110,8 +110,8 @@
@Autowired
IUserRechargeService userRechargeService;
- public ServerResponse reg(String phone, String userPwd, HttpServletRequest request) {
- if (StringUtils.isBlank(phone) ||
+ public ServerResponse reg(String agentCode,String phone, String userPwd, HttpServletRequest request) {
+ if (StringUtils.isBlank(phone) || StringUtils.isBlank(agentCode) ||
StringUtils.isBlank(userPwd))
{
return ServerResponse.createByErrorMsg("注册失败, 参数不能为空");
@@ -121,6 +121,16 @@
String keys = "AliyunSmsCode:" + phone;
String redis_yzm = RedisShardedPoolUtils.get(keys);
+
+ AgentUser agentUser = this.iAgentUserService.findByCode(agentCode);
+ if (agentUser == null) {
+ return ServerResponse.createByErrorMsg("注册失败, 机构代码不存在");
+ }
+ if (agentUser.getIsLock().intValue() == 1) {
+ return ServerResponse.createByErrorMsg("注册失败, 机构代码已被锁定");
+ }
+
+
User dbuser = this.userMapper.findByPhone(phone);
if (dbuser != null) {
return ServerResponse.createByErrorMsg("注册失败, 手机号已注册");
@@ -129,6 +139,8 @@
User user = new User();
user.setPhone(phone);
+ user.setAgentId(agentUser.getId());
+ user.setAgentName(agentUser.getAgentName());
user.setUserPwd(SymmetricCryptoUtil.encryptPassword(userPwd));
@@ -163,6 +175,9 @@
if (insertCount > 0) {
//用户注册成功重新代理机构码重新生成
+ String newAgentCode = generateUniqueAgentCode();
+ agentUser.setAgentCode(newAgentCode);
+ iAgentUserService.updateAgentCode(agentUser);
log.info("用户注册成功 手机 {} , ip = {} 地址 = {}", new Object[] { phone, uip, uadd });
return ServerResponse.createBySuccessMsg("注册成功.请登录");
}
@@ -1513,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) {
@@ -1526,6 +1543,7 @@
return ServerResponse.createByErrorMsg("不存在此操作");
}
user.setEnableAmt(sh_amt_back);
+ user.setEnaleWithdrawAmt(enaleWithdrawAmt);
// BigDecimal hk_amt = user.getHkAmt();
//
@@ -1812,11 +1830,24 @@
PositionVO positionVO = this.iUserPositionService.findUserPositionAllProfitAndLose(user.getId());
userInfoVO.setAllFreezAmt(positionVO.getAllFreezAmt());
BigDecimal allProfitAndLose = positionVO.getAllProfitAndLose();
- userInfoVO.setAllProfitAndLose(allProfitAndLose);
-
-// BigDecimal userAllAmt = user.getUserAmt();
+ BigDecimal profitAndLose = this.userPositionMapper.CountPositionAllProfitAndLoseByUserId(user.getId());
BigDecimal userAllAmt = user.getEnableAmt();
- userAllAmt = userAllAmt.add(allProfitAndLose);
+
+
+ // 初始化总盈亏为0
+ BigDecimal totalProfitAndLose = BigDecimal.ZERO;
+
+ // 累加各个盈亏(安全处理null值)
+ if (allProfitAndLose != null) {
+ totalProfitAndLose = totalProfitAndLose.add(allProfitAndLose);
+ }
+ if (profitAndLose != null) {
+ totalProfitAndLose = totalProfitAndLose.add(profitAndLose);
+ }
+ userInfoVO.setAllProfitAndLose(totalProfitAndLose);
+ if(null != allProfitAndLose){
+ userAllAmt = userAllAmt.add(allProfitAndLose);
+ }
userInfoVO.setEnableIndexAmt(user.getEnableIndexAmt());
@@ -1840,15 +1871,15 @@
userInfoVO.setBuyAmtAutual(buyAmtAutual);
userAllAmt = userAllAmt.add(buyAmtAutual);
userInfoVO.setUserAmt(userAllAmt);
-
- 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());
- }
- }
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();
--
Gitblit v1.9.3