From f2b183dbe283f6060a56ce44e40e095622959a22 Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Wed, 4 Jun 2025 00:20:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=88=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=94=A8=E6=88=B7=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=9B=A2=E9=98=9F=E4=BF=A1=E6=81=AF=EF=BC=89=E4=B8=AD?= =?UTF-8?q?=E5=9B=A2=E9=98=9F=E6=80=BB=E4=BA=BA=E6=95=B0=E5=92=8C=E5=9B=A2?= =?UTF-8?q?=E9=98=9F=E6=80=BB=E6=94=B6=E7=9B=8A=E5=B1=9E=E6=80=A7=E4=B8=BA?= =?UTF-8?q?null=E7=9A=84bug=EF=BC=8C=E4=BB=A5=E5=8F=8A=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/userInfo/UserMainInfoController.java | 5 +++++ .../service/userInfo/impl/UserInfoServiceImpl.java | 11 +++++++++-- src/main/resources/application.yml | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/greenorange/promotion/controller/userInfo/UserMainInfoController.java b/src/main/java/com/greenorange/promotion/controller/userInfo/UserMainInfoController.java index 40b60e7..0fb61a3 100644 --- a/src/main/java/com/greenorange/promotion/controller/userInfo/UserMainInfoController.java +++ b/src/main/java/com/greenorange/promotion/controller/userInfo/UserMainInfoController.java @@ -31,6 +31,7 @@ import jakarta.validation.Valid; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -81,6 +82,7 @@ public class UserMainInfoController { userMainInfoMap.put(userMainInfo.getUserId(), userMainInfo); } List userMemberInfoVOList = new ArrayList<>(); + BigDecimal totalEarnings = BigDecimal.ZERO; for (UserInfo userInfo : userInfoList) { Long id = userInfo.getId(); UserInfo userInformation = userInfoMap.get(id); @@ -94,14 +96,17 @@ public class UserMainInfoController { .registerTime(userInformation.getCreateTime()) .build(); userMemberInfoVOList.add(userMemberInfoVO); + totalEarnings = totalEarnings.add(userMainInfo.getParentEarnings()); } UserInfo userInfo = userInfoService.getById(userId); UserTeamInfoVO userTeamInfoVO = commonService.copyProperties(userInfo, UserTeamInfoVO.class); userTeamInfoVO.setDirectAgentSize(userInfoList.size()); + userTeamInfoVO.setTeamEarnings(totalEarnings); LambdaQueryWrapper userMainInfoLambdaQueryWrapper = new LambdaQueryWrapper<>(); userMainInfoLambdaQueryWrapper.eq(UserMainInfo::getUserId, userId); UserMainInfo userMainInfo = userMainInfoService.getOne(userMainInfoLambdaQueryWrapper); + userTeamInfoVO.setTeamSize(userMainInfo.getTeamSize()); userTeamInfoVO.setInviteQrCode(userMainInfo.getInviteQrCode()); userTeamInfoVO.setUserMemberInfoVOList(userMemberInfoVOList); diff --git a/src/main/java/com/greenorange/promotion/service/userInfo/impl/UserInfoServiceImpl.java b/src/main/java/com/greenorange/promotion/service/userInfo/impl/UserInfoServiceImpl.java index 458e5fe..a1c25ad 100644 --- a/src/main/java/com/greenorange/promotion/service/userInfo/impl/UserInfoServiceImpl.java +++ b/src/main/java/com/greenorange/promotion/service/userInfo/impl/UserInfoServiceImpl.java @@ -142,11 +142,10 @@ public class UserInfoServiceImpl extends ServiceImpl String invitationCode = userInfoRegisterRequest.getInvitationCode(); LambdaQueryWrapper invitedLambdaQueryWrapper = new LambdaQueryWrapper<>(); - invitedLambdaQueryWrapper.eq(UserInfo::getInvitationCode, invitationCode); + invitedLambdaQueryWrapper.eq(UserInfo::getInvitationCode, invitationCode).eq(UserInfo::getUserRole, UserConstant.DEFAULT_ROLE); UserInfo parentUserInfo = this.getOne(invitedLambdaQueryWrapper); ThrowUtils.throwIf(parentUserInfo == null, ErrorCode.OPERATION_ERROR, "邀请码错误"); - UserInfo myUserInfo = commonService.copyProperties(userInfoRegisterRequest, UserInfo.class); // 判断当前用户是否是根节点 List userInfoList = commonService.findByFieldEqTargetField(UserInfo::getUserRole, UserConstant.DEFAULT_ROLE, this); @@ -160,6 +159,14 @@ public class UserInfoServiceImpl extends ServiceImpl UserMainInfo userMainInfo = new UserMainInfo(); userMainInfo.setUserId(myUserInfo.getId()); + // 批量更新父级用户团队人数 + List pathToRoot = this.findPathToRoot(myUserInfo.getId()); + List userMainInfoList = commonService.findByFieldInTargetField(pathToRoot, userMainInfoService, id -> id, UserMainInfo::getUserId); + for (UserMainInfo mainInfo : userMainInfoList) { + mainInfo.setTeamSize(mainInfo.getTeamSize() + 1); + } + userMainInfoService.updateBatchById(userMainInfoList); + // 生成邀请二维码 try { String view = wechatGetQrcodeService.getWxQrCode(myUserInfo.getInvitationCode()); diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index ad9a171..a17ec4c 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,4 +1,4 @@ spring: profiles: - active: dev + active: test