|
@@ -69,6 +69,7 @@ import java.io.UnsupportedEncodingException;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.net.URLDecoder;
|
|
import java.net.URLDecoder;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
@@ -139,6 +140,10 @@ public class CompanyUserServiceImpl implements ICompanyUserService
|
|
|
// @Autowired
|
|
// @Autowired
|
|
|
// private ICompanyUserRoleService userRoleService;
|
|
// private ICompanyUserRoleService userRoleService;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 邀请码缓存
|
|
|
|
|
+ */
|
|
|
|
|
+ private static final Map<Long, String> CODE_CACHE = new ConcurrentHashMap<>();
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 查询物业公司管理员信息
|
|
* 查询物业公司管理员信息
|
|
@@ -1178,5 +1183,37 @@ public class CompanyUserServiceImpl implements ICompanyUserService
|
|
|
public void stopLoginOverdue(Date thirtyDaysAgo) {
|
|
public void stopLoginOverdue(Date thirtyDaysAgo) {
|
|
|
companyUserMapper.stopLoginOverdue(thirtyDaysAgo);
|
|
companyUserMapper.stopLoginOverdue(thirtyDaysAgo);
|
|
|
}
|
|
}
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public String getInviteCodeByCompanyUserId(Long companyUserId) {
|
|
|
|
|
+ if (CODE_CACHE.containsKey(companyUserId)) {
|
|
|
|
|
+ return CODE_CACHE.get(companyUserId);
|
|
|
|
|
+ }
|
|
|
|
|
+ //是否存在
|
|
|
|
|
+ String code = companyUserMapper.selectCodeByUserId(companyUserId);
|
|
|
|
|
+ if (StringUtils.isNotBlank(code)) {
|
|
|
|
|
+ return code;
|
|
|
|
|
+ }
|
|
|
|
|
+ String inviteCode = generateBaseCode(companyUserId);
|
|
|
|
|
+ CompanyUser companyUser = new CompanyUser();
|
|
|
|
|
+ companyUser.setUserId(companyUserId);
|
|
|
|
|
+ companyUser.setInvitationCode(inviteCode);
|
|
|
|
|
+ companyUserMapper.updateCompanyUser(companyUser);
|
|
|
|
|
+ CODE_CACHE.put(companyUserId, inviteCode);
|
|
|
|
|
+ return inviteCode;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 生成基础邀请码
|
|
|
|
|
+ */
|
|
|
|
|
+ private static String generateBaseCode(Long salesId) {
|
|
|
|
|
+ // 简单的算法:销售ID经过简单变换
|
|
|
|
|
+ long transformed = (salesId * 31L + 12345L) % 1000000L;
|
|
|
|
|
+
|
|
|
|
|
+ // 决定长度:4-6位
|
|
|
|
|
+ int length = 4 + (int)(salesId % 3);
|
|
|
|
|
+
|
|
|
|
|
+ // 格式化为指定位数
|
|
|
|
|
+ return String.format("%0" + length + "d", transformed);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|