From 3a35e98f09c9320f8e1586d091b1c80c6c505610 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Thu, 12 Mar 2026 16:41:04 +0800
Subject: [PATCH] 1
---
src/main/java/com/nq/service/impl/UserServiceImpl.java | 65 +++++++++++++++++++-------------
1 files changed, 39 insertions(+), 26 deletions(-)
diff --git a/src/main/java/com/nq/service/impl/UserServiceImpl.java b/src/main/java/com/nq/service/impl/UserServiceImpl.java
index f632221..5950649 100644
--- a/src/main/java/com/nq/service/impl/UserServiceImpl.java
+++ b/src/main/java/com/nq/service/impl/UserServiceImpl.java
@@ -110,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("注册失败, 参数不能为空");
}
@@ -121,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("注册失败, 机构代码已被锁定");
}
@@ -143,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());
@@ -1533,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) {
@@ -1546,6 +1543,7 @@
return ServerResponse.createByErrorMsg("不存在此操作");
}
user.setEnableAmt(sh_amt_back);
+ user.setEnaleWithdrawAmt(enaleWithdrawAmt);
// BigDecimal hk_amt = user.getHkAmt();
//
@@ -1832,17 +1830,30 @@
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());
userInfoVO.setEnaleWithdrawAmt(user.getEnaleWithdrawAmt());
userInfoVO.setHkAmt(user.getHkAmt());
-
+ userInfoVO.setPhotoUrl(user.getPhotoUrl());
BigDecimal historyProfitLoss = new BigDecimal(0);
BigDecimal buyAmtAutual = new BigDecimal(0);
List<UserPosition> userPositionscc = this.userPositionMapper.findMyPositionByCodeAndSpell(user.getId(), "", "", 0);
@@ -1852,21 +1863,23 @@
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.getProfitAndLose());
+
}
}
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.getAllProfitAndLose());
- }
- }
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