Jelajahi Sumber

fix : 查询自测修改

bilingfeng 1 tahun lalu
induk
melakukan
579f8220dd

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/UserController.java

@@ -51,7 +51,7 @@ public class UserController {
 
     @ApiOperation(value = "玩家列表")
     @PostMapping(value = "/list")
-//    @PreAuthorize(permissionKey = "sdk:user:list")
+    @PreAuthorize(permissionKey = "sdk:user:list")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = UserListVO.class)})
     public ResultVO<IPage<UserListVO>> list(@Validated @RequestBody UserListParam param) {
         return ResultVO.ok(userService.list(param));

+ 12 - 7
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserRoleServiceImpl.java

@@ -98,6 +98,12 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
 
     @Override
     public IPage<GameUserRoleListVO> list(GameUserRoleListParam 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(null, null, param.getChannelId());
         //根据条件, 匹配渠道
@@ -106,20 +112,19 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
         }
         //渠道id
         List<Long> agentIdList = agentDTOList.stream().map(AgentDTO::getId).collect(Collectors.toList());
+        //管理员可见自然量数据
+        if (SecurityUtil.isAdmin()) {
+            agentIdList.add(0L);
+        }
         //玩家条件处理
-        Map<Long, UserDTO> userMap = userService.userCondition(param.getUserId(), agentIdList, param.getUserName(), param.getNickname(), param.getRegIp());
+        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, GameDTO> gameMap = gameService.gameCondition(param.getCpId(), param.getGameId(), param.getGameCategoryId());
-        //根据条件, 匹配不到游戏
-        if (gameMap != null && gameMap.isEmpty()) {
-            return new Page<>();
-        }
         Map<Long, CpDTO> cpMap = cpService.cpMap();
         Map<Long, GameCategoryDTO> gameCategoryMap = gameCategoryService.gameCategoryMap();
         Map<Long, AgentDTO> agentMap = agentDTOList.stream().collect(Collectors.toMap(AgentDTO::getId, Function.identity()));

+ 4 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserServiceImpl.java

@@ -67,6 +67,10 @@ public class GameUserServiceImpl extends ServiceImpl<GameUserMapper, GameUser> i
         }
         //渠道id
         List<Long> agentIdList = agentDTOList.stream().map(AgentDTO::getId).collect(Collectors.toList());
+        //管理员可见自然量数据
+        if (SecurityUtil.isAdmin()) {
+            agentIdList.add(0L);
+        }
         //玩家条件处理
         Map<Long, UserDTO> userMap = userService.userCondition(param.getUserId(), agentIdList, param.getUserName(),
                 param.getNickname(), null);

+ 8 - 7
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/OrderServiceImpl.java

@@ -105,6 +105,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         }
         //渠道id列表
         List<Long> agentIds = agentDTOList.stream().map(AgentDTO::getId).collect(Collectors.toList());
+        //管理员可见自然量数据
+        if (SecurityUtil.isAdmin()) {
+            agentIds.add(0L);
+        }
         //查询订单列表
         IPage<OrderVO> page = page(param.toPage(), getListWrapper(param, agentIds, "*")).convert(this::orderToVo);
         if (page.getTotal() == 0) {
@@ -112,7 +116,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         }
         //统计:订单金额与实付金额
         Order total = super.getOne(getListWrapper(param, agentIds, "IFNULL(SUM(amount),0) amount, IFNULL(SUM(real_amount),0) realAmount"));
-        HashMap<String, BigDecimal> totalData = new HashMap<>();
+        HashMap<String, BigDecimal> totalData = new HashMap<>(2);
         if (total == null) {
             totalData.put("totalOrderAmount", new BigDecimal("0.00"));
             totalData.put("totalRealAmount", new BigDecimal("0.00"));
@@ -130,12 +134,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         //渠道
         Map<Long, AgentDTO> agentMap = agentDTOList.stream().collect(Collectors.toMap(AgentDTO::getId, Function.identity()));
         //游戏信息
-        List<Long> gameIds = orderListVOList.stream().map(OrderVO::getGameId).collect(Collectors.toList());
-        List<Long> regGameIds = orderListVOList.stream().map(OrderVO::getRegGameId).collect(Collectors.toList());
-        Set<Long> gameIdSet = new HashSet<>();
-        gameIdSet.addAll(gameIds);
-        gameIdSet.addAll(regGameIds);
-        Map<Long, GameDTO> gameMap = gameService.gameMap(gameIdSet);
+        Map<Long, GameDTO> gameMap = gameService.gameMap(orderListVOList.stream()
+                .map(orderVO -> Arrays.asList(orderVO.getGameId(), orderVO.getRegGameId()))
+                .flatMap(List::stream).collect(Collectors.toSet()));
         //游戏分类信息
         Map<Long, GameCategoryDTO> gameCategoryMap = gameCategoryService.gameCategoryMap();
         //支付渠道列表

+ 39 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserCardServiceImpl.java

@@ -3,20 +3,32 @@ package com.zanxiang.game.module.manage.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 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.erp.security.util.SecurityUtil;
+import com.zanxiang.game.module.manage.pojo.dto.AgentDTO;
+import com.zanxiang.game.module.manage.pojo.dto.UserDTO;
 import com.zanxiang.game.module.manage.pojo.params.UserNameAuthListParam;
 import com.zanxiang.game.module.manage.pojo.vo.UserCardVO;
+import com.zanxiang.game.module.manage.service.IAgentService;
 import com.zanxiang.game.module.manage.service.IUserCardService;
+import com.zanxiang.game.module.manage.service.IUserService;
 import com.zanxiang.game.module.mybatis.entity.UserCard;
 import com.zanxiang.game.module.mybatis.mapper.UserCardMapper;
 import com.zanxiang.module.util.bean.BeanUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.logging.log4j.util.Strings;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
 import java.time.LocalTime;
+import java.util.List;
+import java.util.Map;
 import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
  * @author : lingfeng
@@ -27,10 +39,36 @@ import java.util.Objects;
 @Service
 public class UserCardServiceImpl extends ServiceImpl<UserCardMapper, UserCard> implements IUserCardService {
 
+    @Autowired
+    private IUserService userService;
+
+    @Autowired
+    private IAgentService agentService;
+
     @Override
     public IPage<UserCardVO> getUserCardList(UserNameAuthListParam param) {
+        //渠道列表
+        List<AgentDTO> agentDTOList = agentService.listUserAgent(null, null, null);
+        //根据条件, 匹配渠道
+        if (CollectionUtils.isEmpty(agentDTOList) && !SecurityUtil.isAdmin()) {
+            return new Page<>();
+        }
+        //渠道id
+        List<Long> agentIdList = agentDTOList.stream().map(AgentDTO::getId).collect(Collectors.toList());
+        //管理员可见自然量数据
+        if (SecurityUtil.isAdmin()) {
+            agentIdList.add(0L);
+        }
+        //玩家条件处理
+        Map<Long, UserDTO> userMap = userService.userCondition(param.getUserId(), agentIdList, param.getUserName(),
+                param.getNickname(), null);
+        //根据条件, 匹配不到玩家
+        if (userMap != null && userMap.isEmpty()) {
+            return new Page<>();
+        }
+        Set<Long> userIdSet = userMap == null ? null : userMap.keySet();
         return page(param.toPage(), new QueryWrapper<UserCard>().lambda()
-                .eq(param.getUserId() != null, UserCard::getUserId, param.getUserId())
+                .in(CollectionUtils.isNotEmpty(userIdSet), UserCard::getUserId, userIdSet)
                 .eq(Strings.isNotBlank(param.getUserName()), UserCard::getUsername, param.getUserName())
                 .eq(Strings.isNotBlank(param.getNickname()), UserCard::getNickname, param.getNickname())
                 .ge(param.getBeginDate() != null, UserCard::getRegTime, param.getBeginDate() == null ? null : LocalDateTime.of(param.getBeginDate(), LocalTime.MIN))

+ 37 - 60
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserServiceImpl.java

@@ -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