release- 邀请码不能是自己的

release-2024-04-25
huangyw 2 days ago
parent 8576a038b4
commit ff3894d916

@ -39,6 +39,7 @@ public class ErrorConstants {
public final static String USER_STATUS_ERROR = "用户状态错误"; public final static String USER_STATUS_ERROR = "用户状态错误";
public final static String USER_NAME_ALREADY_EXISTS = "用户名已存在"; public final static String USER_NAME_ALREADY_EXISTS = "用户名已存在";
public final static String USER_INVITE_CODE_NOT_EXIST = "邀请码不存在"; public final static String USER_INVITE_CODE_NOT_EXIST = "邀请码不存在";
public static final String USER_INVITE_CODE_CANNOT_BE_SELF = "邀请码不能是自己的";
public static final String DEFAULT_ADDRESS_CANNOT_BE_ADDED_AGAIN = "请勿重复添加默认地址!"; public static final String DEFAULT_ADDRESS_CANNOT_BE_ADDED_AGAIN = "请勿重复添加默认地址!";
// 会员部分 // 会员部分

@ -291,6 +291,10 @@ public class UserInfoService {
if (StringUtils.isNotBlank(invitationCode)) { if (StringUtils.isNotBlank(invitationCode)) {
UserInfo userInfoDaoByInvitationCode = userInfoDao.findByInvitationCode(invitationCode); UserInfo userInfoDaoByInvitationCode = userInfoDao.findByInvitationCode(invitationCode);
if (null != userInfoDaoByInvitationCode) { if (null != userInfoDaoByInvitationCode) {
// 不能自己邀请自己
if (userInfo.getId().equals(userInfoDaoByInvitationCode.getId())) {
throw new BizException(ErrorConstants.USER_INVITE_CODE_CANNOT_BE_SELF);
}
// 设置邀请人 // 设置邀请人
userInfo.setInvitationUserId(userInfoDaoByInvitationCode.getId()); userInfo.setInvitationUserId(userInfoDaoByInvitationCode.getId());
this.update(userInfo); this.update(userInfo);
@ -926,10 +930,11 @@ public class UserInfoService {
return invitationCode; return invitationCode;
} }
/** /**
* *
* @return *
*/ * @return
*/
private static String generateUniqueInvitationCode() { private static String generateUniqueInvitationCode() {
String firstTwoChars = RandomStringUtils.random(2, true, false).toUpperCase(); String firstTwoChars = RandomStringUtils.random(2, true, false).toUpperCase();
String lastFourChars = RandomStringUtils.randomNumeric(4); String lastFourChars = RandomStringUtils.randomNumeric(4);

Loading…
Cancel
Save