|
@@ -7,19 +7,18 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.zanxiang.game.module.base.utils.BeanUtils;
|
|
|
+import com.zanxiang.erp.security.util.SecurityUtil;
|
|
|
import com.zanxiang.game.module.manage.pojo.dto.*;
|
|
|
import com.zanxiang.game.module.manage.pojo.params.UserListParam;
|
|
|
import com.zanxiang.game.module.manage.pojo.params.UserUpdateParam;
|
|
|
-import com.zanxiang.game.module.manage.pojo.vo.GameUserVO;
|
|
|
import com.zanxiang.game.module.manage.pojo.vo.UserCardVO;
|
|
|
import com.zanxiang.game.module.manage.pojo.vo.UserListVO;
|
|
|
import com.zanxiang.game.module.manage.pojo.vo.UserVO;
|
|
|
import com.zanxiang.game.module.manage.service.*;
|
|
|
-import com.zanxiang.game.module.mybatis.entity.PromoAccount;
|
|
|
-import com.zanxiang.game.module.mybatis.entity.PromoChannel;
|
|
|
+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.bean.BeanUtil;
|
|
|
import com.zanxiang.module.util.encryption.Md5Util;
|
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -46,15 +45,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
@Autowired
|
|
|
private IGameService gameService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private IGameUserService gameUserService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IPromoChannelService promoChannelService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IPromoAccountService promoAccountService;
|
|
|
-
|
|
|
@Autowired
|
|
|
private IUserService userService;
|
|
|
|
|
@@ -67,19 +57,19 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
@Autowired
|
|
|
private IUserCardService userCardService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IAgentService agentService;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<UserListVO> list(UserListParam param) {
|
|
|
//渠道列表
|
|
|
- List<Long> agentIdList;
|
|
|
- if (param.getChannelId() == null) {
|
|
|
- agentIdList = promoChannelService.listByAccountOrPitcherId(param.getAccountId(), param.getPitcherId());
|
|
|
- } else {
|
|
|
- agentIdList = Collections.singletonList(param.getChannelId());
|
|
|
- }
|
|
|
+ List<AgentDTO> agentDTOList = agentService.listUserAgent(param.getAccountId(), param.getPitcherId(), param.getChannelId());
|
|
|
//根据条件, 匹配渠道
|
|
|
- if (agentIdList != null && agentIdList.isEmpty()) {
|
|
|
+ if (CollectionUtils.isEmpty(agentDTOList) && !SecurityUtil.isAdmin()) {
|
|
|
return new Page<>();
|
|
|
}
|
|
|
+ //渠道id列表
|
|
|
+ List<Long> agentIdList = agentDTOList.stream().map(AgentDTO::getId).collect(Collectors.toList());
|
|
|
//游戏条件处理
|
|
|
Map<Long, GameDTO> gameMap = gameService.gameCondition(param.getCpId(), param.getGameId(), param.getGameCategoryId());
|
|
|
//根据条件, 匹配不到游戏
|
|
@@ -88,7 +78,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
}
|
|
|
//玩家条件处理
|
|
|
Map<Long, UserDTO> userMap = userService.userCondition(param.getUserId(), agentIdList, param.getUserName(),
|
|
|
- param.getNickname(), param.getRegIp(), param.getAdId());
|
|
|
+ param.getNickname(), param.getRegIp());
|
|
|
//根据条件, 匹配不到玩家
|
|
|
if (userMap != null && userMap.isEmpty()) {
|
|
|
return new Page<>();
|
|
@@ -96,9 +86,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
//相关用户id
|
|
|
Set<Long> userIdSet = userMap == null ? null : userMap.keySet();
|
|
|
Map<Long, CpDTO> cpMap = cpService.cpMap();
|
|
|
- Map<Long, PromoChannelDTO> channelMap = promoChannelService.promoChannelMap();
|
|
|
+ Map<Long, AgentDTO> agentMap = agentDTOList.stream().collect(Collectors.toMap(AgentDTO::getId, Function.identity()));
|
|
|
Map<Long, GameCategoryDTO> gameCategoryMap = gameCategoryService.gameCategoryMap();
|
|
|
- Map<Long, PromoAccountDTO> promoAccountMap = promoAccountService.promoAccountMap();
|
|
|
//执行查询
|
|
|
return page(param.toPage(), new QueryWrapper<User>().lambda()
|
|
|
.eq(param.getUserId() != null, User::getId, param.getUserId())
|
|
@@ -117,19 +106,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
.le(param.getRechargeEndDate() != null, User::getLastRechargeTime, param.getRechargeEndDate() == null ? null : LocalDateTime.of(param.getRechargeEndDate(), LocalTime.MAX))
|
|
|
.gt(Objects.equals(param.getIsRecharge(), Boolean.TRUE), User::getRechargeCount, 0)
|
|
|
.eq(Objects.equals(param.getIsRecharge(), Boolean.FALSE), User::getRechargeCount, 0)
|
|
|
- .eq(param.getVipLevel() != null && param.getVipLevel() <= 10, User::getVipMax, param.getVipLevel())
|
|
|
- .gt(param.getVipLevel() != null && param.getVipLevel() > 10, User::getVipMax, param.getVipLevel())
|
|
|
.eq(param.getStatus() != null, User::getStatus, param.getStatus())
|
|
|
.eq(param.getChannelId() != null, User::getAgentId, param.getChannelId())
|
|
|
- .eq(param.getCustomerId() != null, User::getCustomerId, param.getCustomerId())
|
|
|
- .eq(param.getIsGs() != null, User::getIsGs, param.getIsGs())
|
|
|
.orderByDesc(User::getCreateTime)
|
|
|
- ).convert(u -> this.toVo(u, userMap, gameMap, promoAccountMap, channelMap, cpMap, gameCategoryMap));
|
|
|
+ ).convert(u -> this.toVo(u, userMap, gameMap, cpMap, gameCategoryMap, agentMap));
|
|
|
}
|
|
|
|
|
|
- private UserListVO toVo(User user, Map<Long, UserDTO> userMap, Map<Long, GameDTO> gameMap, Map<Long, PromoAccountDTO> promoAccountMap,
|
|
|
- Map<Long, PromoChannelDTO> channelMap, Map<Long, CpDTO> cpMap, Map<Long, GameCategoryDTO> gameCategoryMap) {
|
|
|
- UserListVO userListVO = BeanUtils.copy(user, UserListVO.class);
|
|
|
+ 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) {
|
|
|
+ UserListVO userListVO = BeanUtil.copy(user, UserListVO.class);
|
|
|
if (Objects.isNull(userListVO)) {
|
|
|
return null;
|
|
|
}
|
|
@@ -142,9 +127,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
userListVO.setRegIp(userDTO.getIp());
|
|
|
userListVO.setUsername(userDTO.getUsername());
|
|
|
userListVO.setNickname(userDTO.getNickname());
|
|
|
+ //渠道信息
|
|
|
userListVO.setAgentId(userDTO.getAgentId());
|
|
|
- userListVO.setChannel(channelMap.get(userDTO.getAgentId()) == null ? null : channelMap.get(userDTO.getAgentId()).getChannel());
|
|
|
- userListVO.setAdId(userDTO.getAdId());
|
|
|
+ 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) {
|
|
@@ -157,18 +149,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
userListVO.setCpId(gameDTO.getCpId());
|
|
|
userListVO.setCpName(cpMap.get(gameDTO.getCpId()) == null ? null : cpMap.get(gameDTO.getCpId()).getCpName());
|
|
|
}
|
|
|
- PromoChannelDTO promoChannelDTO = channelMap.get(userListVO.getAgentId());
|
|
|
- if (promoChannelDTO != null) {
|
|
|
- PromoAccountDTO promoAccountDTO = promoAccountMap.get(promoChannelDTO.getAccountId());
|
|
|
- if (promoAccountDTO != null) {
|
|
|
- userListVO.setAccountId(promoAccountDTO.getId());
|
|
|
- userListVO.setAccountName(promoAccountDTO.getName());
|
|
|
- userListVO.setPitcherId(promoAccountDTO.getPitcherId());
|
|
|
- userListVO.setPitcherName(promoAccountDTO.getPitcherName());
|
|
|
- userListVO.setMediaId(promoAccountDTO.getMediaId());
|
|
|
- userListVO.setMediaName(promoAccountDTO.getMediaName());
|
|
|
- }
|
|
|
- }
|
|
|
return userListVO;
|
|
|
}
|
|
|
|
|
@@ -197,7 +177,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
public UserVO getUserInfo(Long userId) {
|
|
|
//查询用户信息
|
|
|
User user = super.getById(userId);
|
|
|
- UserVO userVO = BeanUtils.copy(user, UserVO.class);
|
|
|
+ UserVO userVO = BeanUtil.copy(user, UserVO.class);
|
|
|
if (userVO == null) {
|
|
|
throw new BaseException("用户信息不存在!");
|
|
|
}
|
|
@@ -222,41 +202,35 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
userVO.setRegGame(gameDTO.getName());
|
|
|
}
|
|
|
//渠道
|
|
|
- PromoChannel promoChannel = promoChannelService.getById(user.getAgentId());
|
|
|
- if (promoChannel != null) {
|
|
|
- userVO.setChannelName(promoChannel.getChannel());
|
|
|
- PromoAccount promoAccount = promoAccountService.getById(promoChannel.getAccountId());
|
|
|
- userVO.setRegFrom(promoAccount.getAccount());
|
|
|
- }
|
|
|
- //vip等级
|
|
|
- GameUserVO maxVipGameUser = gameUserService.getMaxVipGameUser(userId);
|
|
|
- if (maxVipGameUser != null) {
|
|
|
- userVO.setVipMax(maxVipGameUser.getRoleVipMax());
|
|
|
+ Agent agent = agentService.getById(user.getAgentId());
|
|
|
+ if (agent != null) {
|
|
|
+ userVO.setChannelName(agent.getAgentName());
|
|
|
+ userVO.setRegFrom(agent.getAccountType());
|
|
|
}
|
|
|
return userVO;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Map<Long, UserDTO> userCondition(Long userId, List<Long> agentIdList, String userName, String nickname,
|
|
|
- String regIp, String adId) {
|
|
|
+ public Map<Long, UserDTO> userCondition(Long userId, List<Long> agentIdList, String userName, String nickname, String regIp) {
|
|
|
//用户信息条件处理
|
|
|
if (userId == null && CollectionUtils.isEmpty(agentIdList) && Strings.isBlank(userName)
|
|
|
- && Strings.isBlank(nickname) && Strings.isBlank(regIp) && Strings.isBlank(adId)) {
|
|
|
+ && Strings.isBlank(nickname) && Strings.isBlank(regIp)) {
|
|
|
return null;
|
|
|
}
|
|
|
//查询
|
|
|
List<User> userList = super.list(new LambdaQueryWrapper<User>()
|
|
|
.eq(userId != null, User::getId, userId)
|
|
|
- .eq(Strings.isNotBlank(adId), User::getAdId, adId)
|
|
|
.in(CollectionUtils.isNotEmpty(agentIdList), User::getAgentId, agentIdList)
|
|
|
.eq(Strings.isNotBlank(regIp), User::getIp, regIp)
|
|
|
.like(Strings.isNotBlank(userName), User::getUsername, userName)
|
|
|
.like(Strings.isNotBlank(nickname), User::getNickname, nickname)
|
|
|
- .select(User::getId, User::getUsername, User::getNickname, User::getIp, User::getCreateTime, User::getAgentId, User::getAdId));
|
|
|
+ .select(User::getId, User::getUsername, User::getNickname, User::getIp, User::getCreateTime, User::getAgentId));
|
|
|
if (CollectionUtils.isEmpty(userList)) {
|
|
|
return Collections.emptyMap();
|
|
|
}
|
|
|
- List<UserDTO> list = BeanUtils.copyList(userList, UserDTO.class);
|
|
|
+ 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()));
|
|
|
}
|
|
@@ -271,14 +245,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
|
|
|
if (CollectionUtils.isEmpty(userList)) {
|
|
|
return Collections.emptyMap();
|
|
|
}
|
|
|
- List<UserDTO> list = BeanUtils.copyList(userList, UserDTO.class);
|
|
|
+ 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()));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public UserDTO getById(Long userId) {
|
|
|
- return BeanUtils.copy(super.getById(userId), UserDTO.class);
|
|
|
+ return BeanUtil.copy(super.getById(userId), UserDTO.class);
|
|
|
}
|
|
|
|
|
|
}
|