|
@@ -18,7 +18,6 @@ import com.zanxiang.game.module.manage.service.*;
|
|
|
import com.zanxiang.game.module.mybatis.entity.Agent;
|
|
|
import com.zanxiang.game.module.mybatis.entity.User;
|
|
|
import com.zanxiang.game.module.mybatis.mapper.UserMapper;
|
|
|
-import com.zanxiang.module.util.JsonUtil;
|
|
|
import com.zanxiang.module.util.bean.BeanUtil;
|
|
|
import com.zanxiang.module.util.encryption.Md5Util;
|
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
@@ -30,7 +29,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
-import java.util.*;
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -46,9 +48,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
@Autowired
|
|
|
private IGameService gameService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private IUserService userService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private ICpService cpService;
|
|
|
|
|
@@ -63,45 +62,38 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
|
|
|
@Override
|
|
|
public IPage<UserListVO> list(UserListParam param) {
|
|
|
- log.error("查询用户列表, param : {}", JsonUtil.toString(param));
|
|
|
+ //游戏条件处理
|
|
|
+ Map<Long, GameDTO> gameMap = gameService.gameCondition(param.getCpId(), param.getGameId(), param.getGameCategoryId());
|
|
|
+ //根据条件, 匹配不到游戏
|
|
|
+ if (gameMap != null && gameMap.isEmpty()) {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
//渠道列表
|
|
|
List<AgentDTO> agentDTOList = agentService.listUserAgent(param.getAccountId(), param.getPitcherId(), param.getChannelId());
|
|
|
//根据条件, 匹配渠道
|
|
|
if (CollectionUtils.isEmpty(agentDTOList) && !SecurityUtil.isAdmin()) {
|
|
|
return new Page<>();
|
|
|
}
|
|
|
- log.error("agentDTOList : {}, isAdmin : {}", agentDTOList, SecurityUtil.isAdmin());
|
|
|
//渠道id列表
|
|
|
List<Long> agentIdList = agentDTOList.stream().map(AgentDTO::getId).collect(Collectors.toList());
|
|
|
- //游戏条件处理
|
|
|
- Map<Long, GameDTO> gameMap = gameService.gameCondition(param.getCpId(), param.getGameId(), param.getGameCategoryId());
|
|
|
- //根据条件, 匹配不到游戏
|
|
|
- if (gameMap != null && gameMap.isEmpty()) {
|
|
|
- return new Page<>();
|
|
|
+ //管理员可见自然量数据
|
|
|
+ if (SecurityUtil.isAdmin()) {
|
|
|
+ agentIdList.add(0L);
|
|
|
}
|
|
|
- //玩家条件处理
|
|
|
- Map<Long, UserDTO> userMap = userService.userCondition(param.getUserId(), agentIdList, param.getUserName(),
|
|
|
- param.getNickname(), param.getRegIp());
|
|
|
- //根据条件, 匹配不到玩家
|
|
|
- if (userMap != null && userMap.isEmpty()) {
|
|
|
- return new Page<>();
|
|
|
- }
|
|
|
- //相关用户id
|
|
|
- Set<Long> userIdSet = userMap == null ? null : userMap.keySet();
|
|
|
Map<Long, CpDTO> cpMap = cpService.cpMap();
|
|
|
- Map<Long, AgentDTO> agentMap = agentDTOList.stream().collect(Collectors.toMap(AgentDTO::getId, Function.identity()));
|
|
|
Map<Long, GameCategoryDTO> gameCategoryMap = gameCategoryService.gameCategoryMap();
|
|
|
+ Map<Long, AgentDTO> agentMap = agentDTOList.stream().collect(Collectors.toMap(AgentDTO::getId, Function.identity()));
|
|
|
//执行查询
|
|
|
return page(param.toPage(), new QueryWrapper<User>().lambda()
|
|
|
.eq(param.getUserId() != null, User::getId, param.getUserId())
|
|
|
.like(Strings.isNotBlank(param.getUserName()), User::getUsername, param.getUserName())
|
|
|
.like(Strings.isNotBlank(param.getNickname()), User::getNickname, param.getNickname())
|
|
|
.eq(Strings.isNotBlank(param.getMobile()), User::getMobile, param.getMobile())
|
|
|
- .in(CollectionUtils.isNotEmpty(userIdSet), User::getId, userIdSet)
|
|
|
- .isNotNull(Objects.equals(param.getIsBindMobile(), Boolean.TRUE), User::getMobile)
|
|
|
- .isNull(Objects.equals(param.getIsBindMobile(), Boolean.FALSE), User::getMobile)
|
|
|
+ .eq(Strings.isNotBlank(param.getRegIp()), User::getIp, param.getRegIp())
|
|
|
.eq(Objects.equals(param.getIsAuth(), Boolean.FALSE), User::getAuthentication, 0)
|
|
|
.ne(Objects.equals(param.getIsAuth(), Boolean.TRUE), User::getAuthentication, 0)
|
|
|
+ .isNotNull(Objects.equals(param.getIsBindMobile(), Boolean.TRUE), User::getMobile)
|
|
|
+ .isNull(Objects.equals(param.getIsBindMobile(), Boolean.FALSE), User::getMobile)
|
|
|
.in(CollectionUtils.isNotEmpty(gameMap), User::getGameId, CollectionUtils.isEmpty(gameMap) ? null : gameMap.keySet())
|
|
|
.ge(param.getBeginDate() != null, User::getCreateTime, param.getBeginDate() == null ? null : LocalDateTime.of(param.getBeginDate(), LocalTime.MIN))
|
|
|
.le(param.getEndDate() != null, User::getCreateTime, param.getEndDate() == null ? null : LocalDateTime.of(param.getEndDate(), LocalTime.MAX))
|
|
@@ -110,41 +102,30 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
.gt(Objects.equals(param.getIsRecharge(), Boolean.TRUE), User::getRechargeCount, 0)
|
|
|
.eq(Objects.equals(param.getIsRecharge(), Boolean.FALSE), User::getRechargeCount, 0)
|
|
|
.eq(param.getStatus() != null, User::getStatus, param.getStatus())
|
|
|
- .eq(param.getChannelId() != null, User::getAgentId, param.getChannelId())
|
|
|
+ .in(CollectionUtils.isNotEmpty(agentIdList), User::getAgentId, agentIdList)
|
|
|
.orderByDesc(User::getCreateTime)
|
|
|
- ).convert(u -> this.toVo(u, userMap, gameMap, cpMap, gameCategoryMap, agentMap));
|
|
|
+ ).convert(u -> this.toVo(u, gameMap, cpMap, gameCategoryMap, agentMap));
|
|
|
}
|
|
|
|
|
|
- private UserListVO toVo(User user, Map<Long, UserDTO> userMap, Map<Long, GameDTO> gameMap, Map<Long, CpDTO> cpMap,
|
|
|
- Map<Long, GameCategoryDTO> gameCategoryMap, Map<Long, AgentDTO> agentMap) {
|
|
|
+ private UserListVO toVo(User user, Map<Long, GameDTO> gameMap, Map<Long, CpDTO> cpMap, Map<Long, GameCategoryDTO> gameCategoryMap,
|
|
|
+ Map<Long, AgentDTO> agentMap) {
|
|
|
UserListVO userListVO = BeanUtil.copy(user, UserListVO.class);
|
|
|
if (Objects.isNull(userListVO)) {
|
|
|
return null;
|
|
|
}
|
|
|
+ //手机号隐藏
|
|
|
userListVO.setMobile(user.getShowPhoneNum());
|
|
|
- UserDTO userDTO = CollectionUtils.isEmpty(userMap) ? null : userMap.get(userListVO.getId());
|
|
|
- if (userDTO == null) {
|
|
|
- userDTO = this.getById(userListVO.getId());
|
|
|
- }
|
|
|
- if (userDTO != null) {
|
|
|
- userListVO.setRegIp(userDTO.getIp());
|
|
|
- userListVO.setUsername(userDTO.getUsername());
|
|
|
- userListVO.setNickname(userDTO.getNickname());
|
|
|
- //渠道信息
|
|
|
- userListVO.setAgentId(userDTO.getAgentId());
|
|
|
- AgentDTO lastAgentDTO = agentMap.get(userDTO.getAgentId());
|
|
|
- if (lastAgentDTO != null) {
|
|
|
- userListVO.setAgentName(lastAgentDTO.getAgentName());
|
|
|
- userListVO.setAccountId(lastAgentDTO.getId());
|
|
|
- userListVO.setPitcherId(lastAgentDTO.getCreateBy());
|
|
|
- userListVO.setPitcherName(lastAgentDTO.getCreateByName());
|
|
|
- userListVO.setAccountType(lastAgentDTO.getAccountType());
|
|
|
- }
|
|
|
- }
|
|
|
- GameDTO gameDTO = CollectionUtils.isEmpty(gameMap) ? null : gameMap.get(userListVO.getGameId());
|
|
|
- if (gameDTO == null) {
|
|
|
- gameDTO = gameService.getById(userListVO.getGameId());
|
|
|
- }
|
|
|
+ //渠道信息
|
|
|
+ AgentDTO agentDTO = agentMap.get(userListVO.getAgentId());
|
|
|
+ if (agentDTO != null) {
|
|
|
+ userListVO.setAgentName(agentDTO.getAgentName());
|
|
|
+ userListVO.setAccountId(agentDTO.getId());
|
|
|
+ userListVO.setPitcherId(agentDTO.getCreateBy());
|
|
|
+ userListVO.setPitcherName(agentDTO.getCreateByName());
|
|
|
+ userListVO.setAccountType(agentDTO.getAccountType());
|
|
|
+ }
|
|
|
+ //游戏信息
|
|
|
+ GameDTO gameDTO = CollectionUtils.isNotEmpty(gameMap) ? gameMap.get(userListVO.getGameId()) : gameService.getById(userListVO.getGameId());
|
|
|
if (gameDTO != null) {
|
|
|
userListVO.setGameName(gameDTO.getName());
|
|
|
userListVO.setGameCategoryId(gameDTO.getCategory());
|
|
@@ -231,11 +212,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
if (CollectionUtils.isEmpty(userList)) {
|
|
|
return Collections.emptyMap();
|
|
|
}
|
|
|
- List<UserDTO> list = userList.stream()
|
|
|
+ return userList.stream()
|
|
|
.map(user -> BeanUtil.copy(user, UserDTO.class))
|
|
|
- .collect(Collectors.toList());
|
|
|
- //构造返回
|
|
|
- return list.stream().collect(Collectors.toMap(UserDTO::getId, Function.identity()));
|
|
|
+ .collect(Collectors.toMap(UserDTO::getId, Function.identity()));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -248,10 +227,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
if (CollectionUtils.isEmpty(userList)) {
|
|
|
return Collections.emptyMap();
|
|
|
}
|
|
|
- List<UserDTO> list = userList.stream().map(user -> BeanUtil.copy(user, UserDTO.class))
|
|
|
- .collect(Collectors.toList());
|
|
|
- //构造返回
|
|
|
- return list.stream().collect(Collectors.toMap(UserDTO::getId, Function.identity()));
|
|
|
+ return userList.stream().map(user -> BeanUtil.copy(user, UserDTO.class))
|
|
|
+ .collect(Collectors.toMap(UserDTO::getId, Function.identity()));
|
|
|
}
|
|
|
|
|
|
@Override
|