瀏覽代碼

fix : 权限修改提交

bilingfeng 1 年之前
父節點
當前提交
33b0e77a49
共有 12 個文件被更改,包括 151 次插入66 次删除
  1. 1 1
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/ManageApplication.java
  2. 11 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IGameAuthService.java
  3. 3 2
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IGameService.java
  4. 6 6
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/AgentServiceImpl.java
  5. 27 0
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameAuthServiceImpl.java
  6. 15 17
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameRemitLogServiceImpl.java
  7. 17 14
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameServiceImpl.java
  8. 11 2
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserRoleServiceImpl.java
  9. 11 2
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserServiceImpl.java
  10. 25 8
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/OrderServiceImpl.java
  11. 12 11
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserCardServiceImpl.java
  12. 12 3
      game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserServiceImpl.java

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

@@ -21,7 +21,7 @@ public class ManageApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功 <dubbo升级3.0, 角色权限3> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 <权限修改提交> ( ´・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 11 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IGameAuthService.java

@@ -7,6 +7,9 @@ import com.zanxiang.game.module.manage.pojo.params.GameAuthListParam;
 import com.zanxiang.game.module.manage.pojo.params.GameAuthUpdateParam;
 import com.zanxiang.game.module.manage.pojo.vo.GameAuthVO;
 import com.zanxiang.game.module.mybatis.entity.GameAuth;
+import reactor.util.function.Tuple2;
+
+import java.util.List;
 
 /**
  * @author : lingfeng
@@ -46,4 +49,12 @@ public interface IGameAuthService extends IService<GameAuth> {
      * @return boolean
      */
     boolean deleteById(Long id);
+
+    /**
+     * 得到用户游戏列表
+     *
+     * @param userId 用户id
+     * @return {@link Tuple2}<{@link String}, {@link List}<{@link Long}>>
+     */
+    Tuple2<String, List<Long>> getUserGameList(String userId);
 }

+ 3 - 2
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IGameService.java

@@ -50,7 +50,7 @@ public interface IGameService extends IService<Game> {
      * @param gameIds 游戏id
      * @return {@link List}<{@link GameInfoVO}>
      */
-    List<GameInfoVO> infoByIds(Collection<Long>  gameIds);
+    List<GameInfoVO> infoByIds(Collection<Long> gameIds);
 
     /**
      * 根据id查询游戏信息
@@ -66,9 +66,10 @@ public interface IGameService extends IService<Game> {
      * @param cpId           : cp唯一键
      * @param gameId         : 游戏id
      * @param gameCategoryId : 分类id
+     * @param gameIdList     游戏id列表
      * @return {@link Map}<{@link Long}, {@link GameDTO}>
      */
-    Map<Long, GameDTO> gameCondition(Long cpId, Long gameId, Long gameCategoryId);
+    Map<Long, GameDTO> gameCondition(List<Long> gameIdList, Long cpId, Long gameId, Long gameCategoryId);
 
     /**
      * 根据主键id删除

+ 6 - 6
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/AgentServiceImpl.java

@@ -217,7 +217,7 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
         //自然量查询
         if (Objects.equals(agentId, Agent.DEFAULT_AGENT)) {
             //判断管理员或者组长
-            if (SecurityUtil.isManager() || CollectionUtils.isNotEmpty(memberUserIdList)) {
+            if (SecurityUtil.isAdmin() || CollectionUtils.isNotEmpty(memberUserIdList)) {
                 return Tuples.of(Collections.singletonList(Agent.DEFAULT_AGENT), Collections.emptyList());
             }
             //非管理员或者组长不允许查询自然量
@@ -228,7 +228,7 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
         List<AgentDTO> agentDTOList = new ArrayList<>();
         boolean groupLeader = false;
         //超管权限
-        if (SecurityUtil.isManager()) {
+        if (SecurityUtil.isAdmin()) {
             agentList = super.list(new LambdaQueryWrapper<Agent>()
                     .eq(Strings.isNotBlank(account), Agent::getAccountId, account)
                     .eq(Strings.isNotBlank(pitcherId), Agent::getCreateBy, pitcherId)
@@ -264,7 +264,7 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
             }).collect(Collectors.toList());
         }
         //根据条件, 匹配渠道
-        if (CollectionUtils.isEmpty(agentDTOList) && !SecurityUtil.isManager()) {
+        if (CollectionUtils.isEmpty(agentDTOList) && !SecurityUtil.isAdmin()) {
             return Tuples.of(Collections.emptyList(), Collections.emptyList());
         }
         //渠道id列表
@@ -272,7 +272,7 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
         //未指定搜索条件
         if (Strings.isBlank(account) && Strings.isBlank(pitcherId) && agentId == null) {
             //管理员和组长可见自然量
-            if (SecurityUtil.isManager() || groupLeader) {
+            if (SecurityUtil.isAdmin() || groupLeader) {
                 agentIds.add(Agent.DEFAULT_AGENT);
             }
         }
@@ -283,14 +283,14 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
     @Override
     public List<AgentAccountChoiceVO> agentAccountChoiceList() {
         return super.list(new LambdaQueryWrapper<Agent>()
-                .eq(!SecurityUtil.isManager(), Agent::getCreateBy, SecurityUtil.getUserId())
+                .eq(!SecurityUtil.isAdmin(), Agent::getCreateBy, SecurityUtil.getUserId())
         ).stream().map(agent -> BeanUtil.copy(agent, AgentAccountChoiceVO.class)).collect(Collectors.toList());
     }
 
     @Override
     public List<AgentChoiceVO> agentChoiceList() {
         List<AgentChoiceVO> choiceVOList = super.list(new LambdaQueryWrapper<Agent>()
-                .eq(!SecurityUtil.isManager(), Agent::getCreateBy, SecurityUtil.getUserId())
+                .eq(!SecurityUtil.isAdmin(), Agent::getCreateBy, SecurityUtil.getUserId())
         ).stream().map(agent -> BeanUtil.copy(agent, AgentChoiceVO.class)).collect(Collectors.toList());
         choiceVOList.add(AgentChoiceVO.builder().id(Agent.DEFAULT_AGENT).agentName(Agent.DEFAULT_AGENT_NAME).build());
         return choiceVOList;

+ 27 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameAuthServiceImpl.java

@@ -25,12 +25,16 @@ import com.zanxiang.module.util.bean.BeanUtil;
 import com.zanxiang.module.util.exception.BaseException;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
+import org.apache.logging.log4j.util.Strings;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import reactor.util.function.Tuple2;
+import reactor.util.function.Tuples;
 
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @author : lingfeng
@@ -141,4 +145,27 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
     public boolean deleteById(Long id) {
         return super.removeById(id);
     }
+
+    @Override
+    public Tuple2<String, List<Long>> getUserGameList(String userId) {
+        //超管权限
+        if (SecurityUtil.isAdmin()) {
+            List<Long> gameIdList = super.list(new LambdaQueryWrapper<GameAuth>()
+                    .eq(Strings.isNotBlank(userId), GameAuth::getUserId, userId)
+            ).stream().map(GameAuth::getGameId).collect(Collectors.toList());
+            return Tuples.of("admin", gameIdList);
+        }
+        //非超管权限
+        GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()
+                .eq(GameAuthRole::getUserId, userId));
+        if (gameAuthRole == null) {
+            throw new BaseException("参数错误, 无法查询到用户的权限角色信息");
+        }
+        List<Long> gameIdList = super.list(new LambdaQueryWrapper<GameAuth>()
+                .eq(Strings.isBlank(userId), GameAuth::getUserId, SecurityUtil.getUserId())
+                .eq(Strings.isNotBlank(userId), GameAuth::getUserId, userId)
+        ).stream().map(GameAuth::getGameId).collect(Collectors.toList());
+        //返回角色权限以及游戏
+        return Tuples.of(gameAuthRole.getAuthType(), gameIdList);
+    }
 }

+ 15 - 17
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameRemitLogServiceImpl.java

@@ -1,21 +1,21 @@
 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.base.pojo.enums.GameAuthEnum;
 import com.zanxiang.game.module.manage.pojo.dto.AgentDTO;
 import com.zanxiang.game.module.manage.pojo.dto.GameDTO;
 import com.zanxiang.game.module.manage.pojo.params.GameRemitLogListParam;
 import com.zanxiang.game.module.manage.pojo.vo.GameRemitLogVO;
 import com.zanxiang.game.module.manage.service.IAgentService;
+import com.zanxiang.game.module.manage.service.IGameAuthService;
 import com.zanxiang.game.module.manage.service.IGameRemitLogService;
 import com.zanxiang.game.module.manage.service.IGameService;
-import com.zanxiang.game.module.manage.service.IUserService;
 import com.zanxiang.game.module.mybatis.entity.GameRemitLog;
-import com.zanxiang.game.module.mybatis.entity.User;
 import com.zanxiang.game.module.mybatis.mapper.GameRemitLogMapper;
 import com.zanxiang.module.util.bean.BeanUtil;
 import lombok.extern.slf4j.Slf4j;
@@ -28,7 +28,6 @@ import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.util.List;
 import java.util.Objects;
-import java.util.stream.Collectors;
 
 /**
  * @author : lingfeng
@@ -46,27 +45,26 @@ public class GameRemitLogServiceImpl extends ServiceImpl<GameRemitLogMapper, Gam
     private IAgentService agentService;
 
     @Autowired
-    private IUserService userService;
+    private IGameAuthService gameAuthService;
 
     @Override
     public IPage<GameRemitLogVO> listOfPage(GameRemitLogListParam param) {
-        //渠道获取
-        Tuple2<List<Long>, List<AgentDTO>> tuple2 = agentService.getUserAgent(null, null, null);
-        if (CollectionUtils.isEmpty(tuple2.getT1())) {
-            return new Page<>();
-        }
-        //查询渠道的用户
-        List<Long> userIdList = userService.list(new LambdaQueryWrapper<User>()
-                .in(User::getAgentId, tuple2.getT1())
-        ).stream().map(User::getId).collect(Collectors.toList());
-        if (CollectionUtils.isEmpty(userIdList)) {
+        //游戏获取
+        Tuple2<String, List<Long>> gameTuple = gameAuthService.getUserGameList(null);
+        List<Long> gameIdList = gameTuple.getT2();
+        if (!SecurityUtil.isAdmin() && CollectionUtils.isEmpty(gameIdList)) {
             return new Page<>();
         }
-        if (param.getUserId() != null && !userIdList.contains(param.getUserId())) {
+        //渠道获取
+        Tuple2<List<Long>, List<AgentDTO>> tuple2 = agentService.getUserAgent(null, null, null);
+        List<Long> agentIdList = tuple2.getT1();
+        if (Objects.equals(gameTuple.getT1(), GameAuthEnum.OPERATE.getValue()) && CollectionUtils.isEmpty(agentIdList)) {
             return new Page<>();
         }
+        //查询
         return page(param.toPage(), new QueryWrapper<GameRemitLog>().lambda()
-                .in(CollectionUtils.isNotEmpty(userIdList), GameRemitLog::getUserId, userIdList)
+                .in(!SecurityUtil.isAdmin(), GameRemitLog::getGameId, gameIdList)
+                .in(CollectionUtils.isNotEmpty(agentIdList), GameRemitLog::getAgentId, agentIdList)
                 .eq(param.getUserId() != null, GameRemitLog::getUserId, param.getUserId())
                 .eq(param.getGameId() != null, GameRemitLog::getGameId, param.getGameId())
                 .eq(Strings.isNotBlank(param.getMerchantOrderNo()), GameRemitLog::getMerchantOrderNo, param.getMerchantOrderNo())

+ 17 - 14
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameServiceImpl.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.game.module.base.pojo.dto.H5GameConfigDTO;
 import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
@@ -29,7 +30,7 @@ import org.apache.logging.log4j.util.Strings;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.CollectionUtils;
+import reactor.util.function.Tuple2;
 
 import java.time.LocalDateTime;
 import java.util.*;
@@ -57,6 +58,9 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements IG
     @Autowired
     private IGameAppletService gameAppletService;
 
+    @Autowired
+    private IGameAuthService gameAuthService;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean gameAddOrUpdate(GameAddParam param) {
@@ -223,7 +227,12 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements IG
 
     @Override
     public List<GameChoiceVO> choiceList() {
+        Tuple2<String, List<Long>> tuple2 = gameAuthService.getUserGameList(null);
+        if (CollectionUtils.isEmpty(tuple2.getT2())) {
+            return Collections.emptyList();
+        }
         return super.list(new LambdaQueryWrapper<Game>()
+                .in(Game::getId, tuple2.getT2())
                 .select(Game::getId, Game::getName, Game::getCategory))
                 .stream()
                 .map(game -> BeanUtil.copy(game, GameChoiceVO.class))
@@ -239,28 +248,22 @@ public class GameServiceImpl extends ServiceImpl<GameMapper, Game> implements IG
     }
 
     @Override
-    public Map<Long, GameDTO> gameCondition(Long cpId, Long gameId, Long gameCategoryId) {
+    public Map<Long, GameDTO> gameCondition(List<Long> gameIdList, Long cpId, Long gameId, Long gameCategoryId) {
         //游戏条件判断
         if (cpId == null && gameId == null && gameCategoryId == null) {
             return null;
         }
-        List<GameDTO> gameList = this.getGameList(cpId, gameId, gameCategoryId);
-        if (CollectionUtils.isEmpty(gameList)) {
-            return Collections.emptyMap();
-        }
-        return gameList.stream().collect(Collectors.toMap(GameDTO::getId, Function.identity()));
-    }
-
-    private List<GameDTO> getGameList(Long cpId, Long gameId, Long gameCategoryId) {
-        if (cpId == null && gameId == null && gameCategoryId == null) {
-            return Collections.emptyList();
-        }
-        return super.list(new LambdaQueryWrapper<Game>()
+        List<GameDTO> gameList = super.list(new LambdaQueryWrapper<Game>()
                 .eq(cpId != null, Game::getCpId, cpId)
+                .in(CollectionUtils.isNotEmpty(gameIdList), Game::getId, gameIdList)
                 .eq(gameId != null, Game::getId, gameId)
                 .eq(gameCategoryId != null, Game::getCategory, gameCategoryId)
                 .select(Game::getId, Game::getCpId, Game::getName, Game::getCategory)
         ).stream().map(game -> BeanUtil.copy(game, GameDTO.class)).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(gameList)) {
+            return Collections.emptyMap();
+        }
+        return gameList.stream().collect(Collectors.toMap(GameDTO::getId, Function.identity()));
     }
 
     @Override

+ 11 - 2
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserRoleServiceImpl.java

@@ -6,6 +6,7 @@ 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.pojo.enums.GameAuthEnum;
 import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
 import com.zanxiang.game.module.base.util.DateUtils;
 import com.zanxiang.game.module.manage.pojo.dto.*;
@@ -54,6 +55,9 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
     @Autowired
     private IGameServerService gameServerService;
 
+    @Autowired
+    private IGameAuthService gameAuthService;
+
     @Override
     public GameUserRole getLastGameUserRoleName(Long userId, Long gameId) {
         return super.getOne(new LambdaQueryWrapper<GameUserRole>()
@@ -103,8 +107,13 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
 
     @Override
     public IPage<GameUserRoleListVO> list(GameUserRoleListParam param) {
+        //游戏获取
+        Tuple2<String, List<Long>> gameTuple = gameAuthService.getUserGameList(param.getPitcherId());
+        if (CollectionUtils.isEmpty(gameTuple.getT2())) {
+            return new Page<>();
+        }
         //游戏条件处理
-        Map<Long, GameDTO> gameMap = gameService.gameCondition(param.getCpId(), param.getGameId(), param.getGameCategoryId());
+        Map<Long, GameDTO> gameMap = gameService.gameCondition(gameTuple.getT2(), param.getCpId(), param.getGameId(), param.getGameCategoryId());
         //根据条件, 匹配不到游戏
         if (gameMap != null && gameMap.isEmpty()) {
             return new Page<>();
@@ -113,7 +122,7 @@ public class GameUserRoleServiceImpl extends ServiceImpl<GameUserRoleMapper, Gam
         Tuple2<List<Long>, List<AgentDTO>> tuple2 = agentService.getUserAgent(param.getAccountId(), param.getPitcherId(), param.getChannelId());
         List<Long> agentIdList = tuple2.getT1();
         List<AgentDTO> agentDTOList = tuple2.getT2();
-        if (CollectionUtils.isEmpty(agentIdList)) {
+        if (Objects.equals(gameTuple.getT1(), GameAuthEnum.OPERATE.getValue()) && CollectionUtils.isEmpty(agentIdList)) {
             return new Page<>();
         }
         //玩家条件处理

+ 11 - 2
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameUserServiceImpl.java

@@ -5,6 +5,7 @@ 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.pojo.enums.GameAuthEnum;
 import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
 import com.zanxiang.game.module.base.util.DateUtils;
 import com.zanxiang.game.module.manage.pojo.dto.AgentDTO;
@@ -58,10 +59,18 @@ public class GameUserServiceImpl extends ServiceImpl<GameUserMapper, GameUser> i
     @Autowired
     private IGameUserRoleService gameUserRoleService;
 
+    @Autowired
+    private IGameAuthService gameAuthService;
+
     @Override
     public IPage<GameUserListVO> gameUserList(GameUserListParam param) {
+        //游戏获取
+        Tuple2<String, List<Long>> gameTuple = gameAuthService.getUserGameList(param.getPitcherId());
+        if (CollectionUtils.isEmpty(gameTuple.getT2())) {
+            return new Page<>();
+        }
         //游戏条件处理
-        Map<Long, GameDTO> gameMap = gameService.gameCondition(param.getCpId(), param.getGameId(), param.getGameCategoryId());
+        Map<Long, GameDTO> gameMap = gameService.gameCondition(gameTuple.getT2(), param.getCpId(), param.getGameId(), param.getGameCategoryId());
         //根据条件, 匹配不到游戏
         if (gameMap != null && gameMap.isEmpty()) {
             return new Page<>();
@@ -70,7 +79,7 @@ public class GameUserServiceImpl extends ServiceImpl<GameUserMapper, GameUser> i
         Tuple2<List<Long>, List<AgentDTO>> tuple2 = agentService.getUserAgent(param.getAccountId(), param.getPitcherId(), param.getChannelId());
         List<Long> agentIdList = tuple2.getT1();
         List<AgentDTO> agentDTOList = tuple2.getT2();
-        if (CollectionUtils.isEmpty(agentIdList)) {
+        if (Objects.equals(gameTuple.getT1(), GameAuthEnum.OPERATE.getValue()) && CollectionUtils.isEmpty(agentIdList)) {
             return new Page<>();
         }
         //玩家条件处理

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

@@ -7,6 +7,7 @@ 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.base.pojo.enums.GameAuthEnum;
 import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
 import com.zanxiang.game.module.base.pojo.enums.PayDeviceEnum;
 import com.zanxiang.game.module.base.pojo.enums.PayWayEnum;
@@ -73,6 +74,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
     @Autowired
     private IGameServerService gameServerService;
 
+    @Autowired
+    private IGameAuthService gameAuthService;
+
     @Override
     public IPage<UserOrderListVO> orderList(UserOrderListParam param) {
         //执行查询
@@ -106,10 +110,16 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
 
     @Override
     public OrderListVO orderList(OrderParam param) {
+        //游戏获取
+        Tuple2<String, List<Long>> gameTuple = gameAuthService.getUserGameList(param.getPitcherId());
+        if (CollectionUtils.isEmpty(gameTuple.getT2())) {
+            return new OrderListVO(param.toPage().getSize());
+        }
         //渠道获取
         Tuple2<List<Long>, List<AgentDTO>> tuple2 = agentService.getUserAgent(param.getAccountId(), param.getPitcherId(), param.getChannelId());
         List<Long> agentIds = tuple2.getT1();
-        if (CollectionUtils.isEmpty(agentIds)) {
+        //投手没有渠道, 看不见数据
+        if (Objects.equals(gameTuple.getT1(), GameAuthEnum.OPERATE.getValue()) && CollectionUtils.isEmpty(agentIds)) {
             return new OrderListVO(param.toPage().getSize());
         }
         //查询用户id和名字条件
@@ -122,12 +132,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         //区服筛选
         List<String> serverIdList = gameServerService.listServerId(param.getGameId(), param.getServerName());
         //查询订单列表
-        IPage<OrderVO> page = page(param.toPage(), getListWrapper(param, agentIds, userIds, serverIdList, "*")).convert(this::toVO);
+        IPage<OrderVO> page = page(param.toPage(), getListWrapper(param, gameTuple, agentIds, userIds, serverIdList, "*")).convert(this::toVO);
         if (page.getTotal() == 0) {
             return new OrderListVO(param.toPage().getSize());
         }
         //统计:订单金额与实付金额
-        Order total = super.getOne(getListWrapper(param, agentIds, userIds, serverIdList, "IFNULL(SUM(amount),0) amount, IFNULL(SUM(real_amount),0) realAmount"));
+        Order total = super.getOne(getListWrapper(param, gameTuple, agentIds, userIds, serverIdList, "IFNULL(SUM(amount),0) amount, IFNULL(SUM(real_amount),0) realAmount"));
         HashMap<String, BigDecimal> totalData = new HashMap<>(2);
         if (total == null) {
             totalData.put("totalOrderAmount", new BigDecimal("0.00"));
@@ -223,9 +233,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         }
     }
 
-    private LambdaQueryWrapper<Order> getListWrapper(OrderParam param, List<Long> agentIdList, List<Long> userIdList,
-                                                     List<String> serverIdList, String select) {
+    private LambdaQueryWrapper<Order> getListWrapper(OrderParam param, Tuple2<String, List<Long>> gameTuple, List<Long> agentIdList,
+                                                     List<Long> userIdList, List<String> serverIdList, String select) {
         return new QueryWrapper<Order>().select(select).lambda()
+                .in(!SecurityUtil.isAdmin(), Order::getGameId, gameTuple.getT2())
                 .eq(Strings.isNotBlank(param.getOrderId()), Order::getOrderId, param.getOrderId())
                 .eq(Strings.isNotBlank(param.getCpOrderId()), Order::getCpOrderId, param.getCpOrderId())
                 .eq(Strings.isNotBlank(param.getMerchantOrderNo()), Order::getMerchantOrderNo, param.getMerchantOrderNo())
@@ -236,7 +247,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
                 .like(Strings.isNotBlank(param.getRoleName()), Order::getRoleName, param.getRoleName())
                 .eq(param.getCpId() != null, Order::getCpId, param.getCpId())
                 .eq(param.getGameId() != null, Order::getGameId, param.getGameId())
-                .in(CollectionUtils.isNotEmpty(agentIdList), Order::getAgentId, agentIdList)
+                .in(Objects.equals(gameTuple.getT1(), GameAuthEnum.OPERATE.getValue()), Order::getAgentId, agentIdList)
                 .eq(Strings.isNotBlank(param.getDeviceSystem()), Order::getDeviceSystem, param.getDeviceSystem())
                 .eq(param.getIsSwitch() != null, Order::getIsSwitch, param.getIsSwitch())
                 .eq(Strings.isNotBlank(param.getProductName()), Order::getProductName, param.getProductName())
@@ -262,6 +273,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         if (!SecurityUtil.isAdmin()) {
             throw new BaseException("没有下载权限");
         }
+        //游戏获取
+        Tuple2<String, List<Long>> gameTuple = gameAuthService.getUserGameList(param.getPitcherId());
+        List<Long> gameIdList = gameTuple.getT2();
+        if (CollectionUtils.isEmpty(gameIdList)) {
+            throw new BaseException("参数错误, 未配置游戏权限");
+        }
         //渠道获取
         Tuple2<List<Long>, List<AgentDTO>> tuple2 = agentService.getUserAgent(param.getAccountId(), param.getPitcherId(), param.getChannelId());
         List<Long> agentIds = tuple2.getT1();
@@ -277,8 +294,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         //excel下载
         WebExcelUtil.httpExport(response, "游戏订单", OrderExcelVO.class, ((pageNumber, pageSize) -> {
             //查询订单
-            List<OrderVO> orderVOList = page(new Page<>(pageNumber, pageSize), this.getListWrapper(param, agentIds, userIds, serverIdList, "*"))
-                    .convert(this::toVO).getRecords();
+            List<OrderVO> orderVOList = page(new Page<>(pageNumber, pageSize), this.getListWrapper(param, gameTuple,
+                    agentIds, userIds, serverIdList, "*")).convert(this::toVO).getRecords();
             //商户列表
             Map<String, PayMerchantDTO> payMerchantMap = payMerchantService.payMerchantMap();
             //cp信息

+ 12 - 11
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserCardServiceImpl.java

@@ -6,6 +6,7 @@ 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.GameDTO;
 import com.zanxiang.game.module.manage.pojo.dto.UserDTO;
@@ -25,9 +26,7 @@ import reactor.util.function.Tuple2;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.util.List;
-import java.util.Map;
 import java.util.Objects;
-import java.util.Set;
 
 /**
  * @author : lingfeng
@@ -50,21 +49,23 @@ public class UserCardServiceImpl extends ServiceImpl<UserCardMapper, UserCard> i
     @Autowired
     private IGameService gameService;
 
+    @Autowired
+    private IGameAuthService gameAuthService;
+
     @Override
     public IPage<UserCardVO> getUserCardList(UserNameAuthListParam param) {
+        //游戏获取
+        Tuple2<String, List<Long>> gameTuple = gameAuthService.getUserGameList(null);
+        List<Long> gameIdList = gameTuple.getT2();
+        if (!SecurityUtil.isAdmin() && CollectionUtils.isEmpty(gameIdList)) {
+            return new Page<>();
+        }
         //渠道获取
         Tuple2<List<Long>, List<AgentDTO>> tuple2 = agentService.getUserAgent(null, null, null);
         List<Long> agentIdList = tuple2.getT1();
-        //玩家条件处理
-        Map<Long, UserDTO> userMap = userService.userCondition(param.getUserId(), agentIdList, param.getUserName(),
-                param.getNickname(), null, null, 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()
-                .in(CollectionUtils.isNotEmpty(userIdSet), UserCard::getUserId, userIdSet)
+                .in(!SecurityUtil.isAdmin(), UserCard::getGameId, gameIdList)
+                .in(CollectionUtils.isNotEmpty(agentIdList), UserCard::getAgentId, agentIdList)
                 .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))

+ 12 - 3
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/UserServiceImpl.java

@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.corp.base.CorpServer;
 import com.zanxiang.corp.base.pojo.dto.CorpExternalUserDTO;
 import com.zanxiang.corp.base.rpc.ICorpExternalUserServiceRpc;
+import com.zanxiang.game.module.base.pojo.enums.GameAuthEnum;
 import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
 import com.zanxiang.game.module.base.util.DateUtils;
 import com.zanxiang.game.module.manage.pojo.dto.AgentDTO;
@@ -80,6 +81,9 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
     @Autowired
     private IGameUserService gameUserService;
 
+    @Autowired
+    private IGameAuthService gameAuthService;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean appletToH5(Long userId, String mobile) {
@@ -181,8 +185,13 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
 
     @Override
     public IPage<UserListVO> list(UserListParam param) {
+        //游戏获取
+        Tuple2<String, List<Long>> gameTuple = gameAuthService.getUserGameList(param.getPitcherId());
+        if (CollectionUtils.isEmpty(gameTuple.getT2())) {
+            return new Page<>();
+        }
         //游戏条件处理
-        Map<Long, GameDTO> gameMap = gameService.gameCondition(param.getCpId(), param.getGameId(), param.getGameCategoryId());
+        Map<Long, GameDTO> gameMap = gameService.gameCondition(gameTuple.getT2(), param.getCpId(), param.getGameId(), param.getGameCategoryId());
         //根据条件, 匹配不到游戏
         if (gameMap != null && gameMap.isEmpty()) {
             return new Page<>();
@@ -191,7 +200,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements IU
         Tuple2<List<Long>, List<AgentDTO>> tuple2 = agentService.getUserAgent(param.getAccountId(), param.getPitcherId(), param.getChannelId());
         List<Long> agentIdList = tuple2.getT1();
         List<AgentDTO> agentDTOList = tuple2.getT2();
-        if (CollectionUtils.isEmpty(agentIdList)) {
+        if (Objects.equals(gameTuple.getT1(), GameAuthEnum.OPERATE.getValue()) && CollectionUtils.isEmpty(agentIdList)) {
             return new Page<>();
         }
         Map<Long, CpDTO> cpMap = cpService.cpMap();
@@ -214,7 +223,7 @@ 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())
-                .in(CollectionUtils.isNotEmpty(agentIdList), User::getAgentId, agentIdList)
+                .in(Objects.equals(gameTuple.getT1(), GameAuthEnum.OPERATE.getValue()), User::getAgentId, agentIdList)
                 .apply(param.getRegPayIntervalTimeMin() != null, "if(last_recharge_time is not null, TIMESTAMPDIFF(minute, create_time, last_recharge_time), null) >= {0}", param.getRegPayIntervalTimeMin())
                 .apply(param.getRegPayIntervalTimeMax() != null, "if(last_recharge_time is not null, TIMESTAMPDIFF(minute, create_time, last_recharge_time), null) <= {0}", param.getRegPayIntervalTimeMax())
                 .orderByDesc(User::getCreateTime)