|
|
@@ -5,10 +5,13 @@ import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import com.ruoyi.dz.domain.DzAgent;
|
|
|
import com.ruoyi.dz.domain.DzCards;
|
|
|
+import com.ruoyi.dz.service.IDzAgentService;
|
|
|
import com.ruoyi.dz.service.IDzCardsService;
|
|
|
import com.ruoyi.dz.service.IDzSchoolService;
|
|
|
import com.ruoyi.dz.service.IDzClassesService;
|
|
|
+import com.ruoyi.enums.CardType;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@@ -66,6 +69,8 @@ public class SysUserController extends BaseController
|
|
|
private IDzSchoolService schoolService;
|
|
|
@Autowired
|
|
|
private IDzClassesService classesService;
|
|
|
+ @Autowired
|
|
|
+ private IDzAgentService agentService;
|
|
|
|
|
|
/**
|
|
|
* 获取用户列表
|
|
|
@@ -100,25 +105,26 @@ public class SysUserController extends BaseController
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
|
|
|
// 获取邀请码列表(邀请码是String类型,需要转换为Long类型的用户ID)
|
|
|
- List<String> inviteCodeUsernames = list.stream()
|
|
|
+ List<Long> inviteCodeUserIds = list.stream()
|
|
|
.map(SysUser::getInviteCode)
|
|
|
- .filter(inviteCode -> inviteCode != null && !inviteCode.isEmpty())
|
|
|
+ .filter(inviteCode -> StringUtils.isNotEmpty(inviteCode))
|
|
|
+ .map(inviteCode -> {
|
|
|
+ try {
|
|
|
+ return Long.parseLong(inviteCode);
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ })
|
|
|
.distinct().collect(Collectors.toList());
|
|
|
List<Long> cardIds = list.stream().map(SysUser::getCardId).filter(cardId -> cardId != null)
|
|
|
.distinct().collect(Collectors.toList());
|
|
|
|
|
|
- // 根据邀请码(即用户名)查询对应的用户信息,获取代理商名称
|
|
|
- Map<String, String> agentNameMap = new java.util.HashMap<>();
|
|
|
- if (CollectionUtils.isNotEmpty(inviteCodeUsernames)) {
|
|
|
- List<SysUser> agentList = userService.selectUserByUserNames(inviteCodeUsernames);
|
|
|
+ // 根据邀请码(即用户ID)查询对应的代理商信息
|
|
|
+ Map<Long, DzAgent> agentMap = new java.util.HashMap<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(inviteCodeUserIds)) {
|
|
|
+ List<DzAgent> agentList = agentService.selectDzAgentByAgentIds(inviteCodeUserIds);
|
|
|
if (CollectionUtils.isNotEmpty(agentList)) {
|
|
|
- agentNameMap = agentList.stream()
|
|
|
- .filter(agent -> agent.getUserName() != null && agent.getNickName() != null)
|
|
|
- .collect(Collectors.toMap(
|
|
|
- SysUser::getUserName,
|
|
|
- SysUser::getNickName,
|
|
|
- (existing, replacement) -> existing
|
|
|
- ));
|
|
|
+ agentMap = agentList.stream().collect(Collectors.toMap(DzAgent::getAgentId,agent -> agent,(existing, replacement) -> existing));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -126,9 +132,18 @@ public class SysUserController extends BaseController
|
|
|
if (CollectionUtils.isEmpty(cardIds)) {
|
|
|
// 即使没有cardIds,也要设置代理商名称
|
|
|
for (SysUser user : list) {
|
|
|
+ //设置卡类型
|
|
|
+ user.setUserType(String.valueOf(CardType.getNewVal(CardType.Common.getVal())));
|
|
|
if (user.getInviteCode() != null && !user.getInviteCode().isEmpty()) {
|
|
|
- if (agentNameMap.containsKey(user.getInviteCode())) {
|
|
|
- user.setAgentName(agentNameMap.get(user.getInviteCode()));
|
|
|
+ try {
|
|
|
+ Long inviteCodeUserId = Long.parseLong(user.getInviteCode());
|
|
|
+ DzAgent agent = agentMap.get(inviteCodeUserId);
|
|
|
+ if (agent != null && agent.getName() != null) {
|
|
|
+ user.setAgentName(agent.getName());
|
|
|
+ user.setDeptName(null!=agent.getDept()?agent.getDept().getDeptName():StringUtils.EMPTY);
|
|
|
+ }
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ // 邀请码不是有效的数字,忽略
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -181,16 +196,25 @@ public class SysUserController extends BaseController
|
|
|
if (user.getDept() != null && user.getDept().getDeptName() != null) {
|
|
|
user.setDeptName(user.getDept().getDeptName());
|
|
|
}
|
|
|
- // 设置代理商名称(从邀请码对应的用户获取)
|
|
|
+ // 设置代理商名称(从邀请码对应的代理商获取)
|
|
|
if (user.getInviteCode() != null && !user.getInviteCode().isEmpty()) {
|
|
|
- if (agentNameMap.containsKey(user.getInviteCode())) {
|
|
|
- user.setAgentName(agentNameMap.get(user.getInviteCode()));
|
|
|
+ try {
|
|
|
+ Long inviteCodeUserId = Long.parseLong(user.getInviteCode());
|
|
|
+ DzAgent agent = agentMap.get(inviteCodeUserId);
|
|
|
+ if (agent != null && agent.getName() != null) {
|
|
|
+ user.setAgentName(agent.getName());
|
|
|
+ user.setDeptName(null!=agent.getDept()?agent.getDept().getDeptName():StringUtils.EMPTY);
|
|
|
+ }
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
+ // 邀请码不是有效的数字,忽略
|
|
|
}
|
|
|
}
|
|
|
if (user.getCardId() != null) {
|
|
|
DzCards card = cardMap.get(user.getCardId());
|
|
|
if (card != null) {
|
|
|
user.setCardNo(card.getCardNo());
|
|
|
+ //设置卡类型
|
|
|
+ user.setUserType(String.valueOf(CardType.getNewVal(card.getType())));
|
|
|
// 设置注册学校名称(schoolId对应的学校名称)
|
|
|
if (card.getSchoolId() != null) {
|
|
|
user.setSchoolName(schoolMap.get(card.getSchoolId()));
|
|
|
@@ -207,7 +231,11 @@ public class SysUserController extends BaseController
|
|
|
if (card.getCampusClassId() != null) {
|
|
|
user.setCampusClassName(classMap.get(card.getCampusClassId()));
|
|
|
}
|
|
|
+ }else {
|
|
|
+ user.setUserType(String.valueOf(CardType.getNewVal(CardType.Common.getVal())));
|
|
|
}
|
|
|
+ }else {
|
|
|
+ user.setUserType(String.valueOf(CardType.getNewVal(CardType.Common.getVal())));
|
|
|
}
|
|
|
}
|
|
|
|