From 1642b2ede863f7a56b0810198498f6f567692528 Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Wed, 13 Nov 2024 17:24:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=B7=B2=E7=9F=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/user/impl/BsUserServiceImpl.java | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java b/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java index c761917..8cccaad 100644 --- a/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java @@ -130,12 +130,13 @@ public class BsUserServiceImpl implements BsUserService { if (user.getInviteUserId() != null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已绑定过邀请人"); } - if (getUser(inviteUseId) == null) { + BsUser inviteUser = getUser(inviteUseId); + if (inviteUser == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的邀请人Id"); } BsUserParentRel userParentRel = new BsUserParentRel(); - userParentRel.setParentUserId(userParentRel.getParentUserId()); - userParentRel.setParentUserGrade(userParentRel.getParentUserGrade()); + userParentRel.setParentUserId(inviteUser.getId()); + userParentRel.setParentUserGrade(inviteUser.getGrade()); userParentRel.setUserId(userId); userParentRelService.editData(userParentRel); @@ -340,7 +341,7 @@ public class BsUserServiceImpl implements BsUserService { // 校验邀请码 BsUserInviteCode userInviteCode = userInviteCodeService.getDetail(inviteUseId); if (userInviteCode == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效的邀请码"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无效的邀请人Id"); } user.setInviteUserId(userInviteCode.getUserId()); } @@ -356,6 +357,18 @@ public class BsUserServiceImpl implements BsUserService { user.setStatus(UserStatusEnum.status1.getCode()); editData(user); + if (user.getInviteUserId() != null) { + BsUser inviteUser = getUser(inviteUseId); + if (inviteUser == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的邀请人Id"); + } + BsUserParentRel userParentRel = new BsUserParentRel(); + userParentRel.setParentUserId(inviteUser.getId()); + userParentRel.setParentUserGrade(inviteUser.getGrade()); + userParentRel.setUserId(user.getId()); + userParentRelService.editData(userParentRel); + } + // 创建账户 userAccountService.create(user.getId()); return user;