浏览代码

Merge branch 'package' of GameCenter/game-center into dev

zhimo 1 年之前
父节点
当前提交
96dfc65647

+ 168 - 180
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/GameDataServiceImpl.java

@@ -2552,201 +2552,189 @@ public class GameDataServiceImpl implements IGameDataService {
                 		round(IF(SUM(reg_num) >0, SUM(new_user_total_role_num) / SUM(reg_num), 0), 4) new_user_total_role_num_rate
                 	FROM
                 		ads_game_day
-                	"""
-                + criA +
+                """ + criA +
                 """
-                        	 ) a
-                        LEFT JOIN (
-                        	SELECT
-                        		game_id as b_game_id,
-                        		IFNULL(sum(buy_amount_count), 0) buy_amount_count,
-                        		IFNULL(sum(buy_amount), 0) buy_amount,
-                        		IFNULL(sum(nature_amount_count), 0) nature_amount_count,
-                        		IFNULL(sum(nature_amount), 0) nature_amount,
-                        		IFNULL(sum(amount_count), 0) amount_count,
-                        		IFNULL(sum(amount), 0) amount,
-                        		round(if(sum(buy_amount_count) > 0, sum(buy_amount) / sum(buy_amount_count), 0), 2) buy_avg_amount,
-                        		round(if(sum(nature_amount_count) > 0, sum(nature_amount) / sum(nature_amount_count), 0), 2) nature_avg_amount,
-                        		round(if(sum(amount_count) > 0, sum(amount) / sum(amount_count), 0), 2) avg_amount
-                        	FROM
-                        		game_ads.ads_game_day
-                        	"""
-                + criB +
+                     ) a
+                LEFT JOIN (
+                    SELECT
+                        game_id as b_game_id,
+                        game_name as b_game_name,
+                        IFNULL(sum(buy_amount_count), 0) buy_amount_count,
+                        IFNULL(sum(buy_amount), 0) buy_amount,
+                        IFNULL(sum(nature_amount_count), 0) nature_amount_count,
+                        IFNULL(sum(nature_amount), 0) nature_amount,
+                        IFNULL(sum(amount_count), 0) amount_count,
+                        IFNULL(sum(amount), 0) amount,
+                        round(if(sum(buy_amount_count) > 0, sum(buy_amount) / sum(buy_amount_count), 0), 2) buy_avg_amount,
+                        round(if(sum(nature_amount_count) > 0, sum(nature_amount) / sum(nature_amount_count), 0), 2) nature_avg_amount,
+                        round(if(sum(amount_count) > 0, sum(amount) / sum(amount_count), 0), 2) avg_amount
+                    FROM
+                        game_ads.ads_game_day
+                """ + criB +
                 """
-                            ) b
-                        ON a.game_id = b.b_game_id
-                        LEFT JOIN (
-                        	SELECT
-                        		game_id as c_game_id,
-                        		IFNULL(COUNT(DISTINCT user_id), 0) amount_num
-                        	FROM
-                        		game_ads.ads_information
-                        	"""
-                + criAmount +
+                    ) b
+                ON a.game_id = b.b_game_id and a.game_name = b.b_game_name
+                LEFT JOIN (
+                    SELECT
+                        game_id as c_game_id,
+                        IFNULL(COUNT(DISTINCT user_id), 0) amount_num
+                    FROM
+                        game_ads.ads_information
+                """ + criAmount +
                 """
-                        	GROUP BY
-                        		game_id) c
-                        ON a.game_id = c.c_game_id
-                        LEFT JOIN(
-                        	SELECT
-                        		game_id as d_game_id,
-                        		IFNULL(COUNT(DISTINCT user_id), 0) buy_amount_num
-                        	FROM
-                        		game_ads.ads_information
-                        	"""
-                + criAmount +
+                    GROUP BY
+                        game_id) c
+                ON a.game_id = c.c_game_id
+                LEFT JOIN(
+                    SELECT
+                        game_id as d_game_id,
+                        IFNULL(COUNT(DISTINCT user_id), 0) buy_amount_num
+                    FROM
+                        game_ads.ads_information
+                """ + criAmount +
                 """
-                        		AND NOT agent_id = 0
-                        	GROUP BY game_id) d
-                        ON a.game_id = d.d_game_id
-                        LEFT JOIN (
-                        	SELECT
-                        		game_id as e_game_id,
-                        		IFNULL(COUNT(DISTINCT user_id), 0) nature_amount_num
-                        	FROM
-                        		game_ads.ads_information
-                        	"""
-                + criAmount +
+                        AND NOT agent_id = 0
+                    GROUP BY game_id) d
+                ON a.game_id = d.d_game_id
+                LEFT JOIN (
+                    SELECT
+                        game_id as e_game_id,
+                        IFNULL(COUNT(DISTINCT user_id), 0) nature_amount_num
+                    FROM
+                        game_ads.ads_information
+                """ + criAmount +
                 """
-                        		AND agent_id = 0
-                        	GROUP BY game_id ) e
-                        ON a.game_id = e.e_game_id
-                        LEFT JOIN (
-                        	SELECT
-                        		game_id as f_game_id,
-                        		COUNT(DISTINCT user_id) buy_new_user_amount_num
-                        	FROM
-                        		game_ads.ads_information
-                            """
-                + criNewUser +
+                        AND agent_id = 0
+                    GROUP BY game_id ) e
+                ON a.game_id = e.e_game_id
+                LEFT JOIN (
+                    SELECT
+                        game_id as f_game_id,
+                        COUNT(DISTINCT user_id) buy_new_user_amount_num
+                    FROM
+                        game_ads.ads_information
+                """ + criNewUser +
                 """
-                        		AND NOT agent_id = 0
-                        	GROUP BY game_id) f
-                        ON a.game_id = f.f_game_id
-                        LEFT JOIN(
-                        	SELECT
-                        		game_id as g_game_id,
-                        		COUNT(tempA.num) as buy_new_user_again_num
-                        	FROM (
-                        			SELECT
-                        				game_id,
-                        				COUNT(user_id) num
-                        			FROM
-                        				game_ads.ads_information
-                        			"""
-                + criNewUser +
+                        AND NOT agent_id = 0
+                    GROUP BY game_id) f
+                ON a.game_id = f.f_game_id
+                LEFT JOIN(
+                    SELECT
+                        game_id as g_game_id,
+                        COUNT(tempA.num) as buy_new_user_again_num
+                    FROM (
+                            SELECT
+                                game_id,
+                                COUNT(user_id) num
+                            FROM
+                                game_ads.ads_information
+                """ + criNewUser +
                 """
-                        				AND NOT agent_id = 0
-                        			GROUP BY
-                        				user_id,
-                        				game_id
-                        			HAVING
-                        				COUNT(user_id) > 1 ) tempA
-                        	GROUP BY tempA.game_id) g
-                        ON a.game_id = g.g_game_id
-                        LEFT JOIN(
-                        	SELECT
-                        		game_id as h_game_id,
-                        		COUNT(DISTINCT user_id) as nature_new_user_amount_num
-                        	FROM
-                        		game_ads.ads_information
-                        	"""
-                + criNewUser +
+                                AND NOT agent_id = 0
+                            GROUP BY
+                                user_id,
+                                game_id
+                            HAVING
+                                COUNT(user_id) > 1 ) tempA
+                    GROUP BY tempA.game_id) g
+                ON a.game_id = g.g_game_id
+                LEFT JOIN(
+                    SELECT
+                        game_id as h_game_id,
+                        COUNT(DISTINCT user_id) as nature_new_user_amount_num
+                    FROM
+                        game_ads.ads_information
+                """ + criNewUser +
                 """
-                        		AND agent_id = 0
-                        	GROUP BY game_id) h
-                        ON a.game_id = h.h_game_id
-                        LEFT JOIN (
-                        	SELECT
-                        		game_id as i_game_id,
-                        		COUNT(tempB.num) as nature_new_user_again_num
-                        	FROM (
-                        			SELECT
-                        				game_id,
-                        				COUNT(user_id) num
-                        			FROM
-                        				game_ads.ads_information
-                        			"""
-                + criNewUser +
+                        AND agent_id = 0
+                    GROUP BY game_id) h
+                ON a.game_id = h.h_game_id
+                LEFT JOIN (
+                    SELECT
+                        game_id as i_game_id,
+                        COUNT(tempB.num) as nature_new_user_again_num
+                    FROM (
+                            SELECT
+                                game_id,
+                                COUNT(user_id) num
+                            FROM
+                                game_ads.ads_information
+                """ + criNewUser +
                 """
-                        				AND agent_id = 0
-                        			GROUP BY
-                        				user_id,
-                        				game_id
-                        			HAVING
-                        				COUNT(user_id) > 1 ) tempB
-                        		GROUP BY tempB.game_id ) i
-                        ON a.game_id = i.i_game_id
-                        LEFT JOIN (
-                        	SELECT
-                        		game_id as j_game_id,
-                        		COUNT(DISTINCT user_id) new_user_amount_num
-                        	FROM
-                        		game_ads.ads_information
-                        	"""
-                + criNewUser +
+                                AND agent_id = 0
+                            GROUP BY
+                                user_id,
+                                game_id
+                            HAVING
+                                COUNT(user_id) > 1 ) tempB
+                        GROUP BY tempB.game_id ) i
+                ON a.game_id = i.i_game_id
+                LEFT JOIN (
+                    SELECT
+                        game_id as j_game_id,
+                        COUNT(DISTINCT user_id) new_user_amount_num
+                    FROM
+                        game_ads.ads_information
                 """
-                        	GROUP BY game_id) j
-                        ON a.game_id = j.j_game_id
-                        LEFT JOIN (
-                        	SELECT
-                        		game_id as k_game_id,
-                        		COUNT(tempC.num) as new_user_again_num
-                        	FROM (
-                        			SELECT
-                        				game_id,
-                        				COUNT(user_id) num
-                        			FROM
-                        				game_ads.ads_information
-                        			"""
                 + criNewUser +
                 """
-                        			GROUP BY
-                        				user_id,
-                        				game_id
-                        			HAVING
-                        				COUNT(user_id) > 1 ) tempC
-                        		GROUP BY tempC.game_id ) k
-                        ON a.game_id = k.k_game_id
-                        LEFT JOIN (
-                        	SELECT
-                        		user_game_id ,
-                        		COUNT(DISTINCT role_user_id) as role_num
-                        	FROM
-                        		dw_create_role_detail
-                        """
-                + criRoleNum +
+                    GROUP BY game_id) j
+                ON a.game_id = j.j_game_id
+                LEFT JOIN (
+                    SELECT
+                        game_id as k_game_id,
+                        COUNT(tempC.num) as new_user_again_num
+                    FROM (
+                            SELECT
+                                game_id,
+                                COUNT(user_id) num
+                            FROM
+                                game_ads.ads_information
+                """ + criNewUser +
                 """
-                        	GROUP BY user_game_id
-                        ) l
-                        ON a.game_id = l.user_game_id
-                        LEFT JOIN (
-                        	SELECT
-                        		user_game_id ,
-                        		COUNT(DISTINCT role_user_id) as nature_role_num
-                        	FROM
-                        		dw_create_role_detail
-                        """
-                + criRoleNum +
+                            GROUP BY
+                                user_id,
+                                game_id
+                            HAVING
+                                COUNT(user_id) > 1 ) tempC
+                        GROUP BY tempC.game_id ) k
+                ON a.game_id = k.k_game_id
+                LEFT JOIN (
+                    SELECT
+                        user_game_id ,
+                        COUNT(DISTINCT role_user_id) as role_num
+                    FROM
+                        dw_create_role_detail
+                """ + criRoleNum +
                 """
-                        		AND user_agent_id = 0
-                        	GROUP BY user_game_id
-                        ) m
-                        ON a.game_id = m.user_game_id
-                        LEFT JOIN (
-                        	SELECT
-                        		user_game_id ,
-                        		COUNT(DISTINCT role_user_id) as buy_role_num
-                        	FROM
-                        		dw_create_role_detail
-                        """
-                + criRoleNum +
+                    GROUP BY user_game_id
+                ) l
+                ON a.game_id = l.user_game_id
+                LEFT JOIN (
+                    SELECT
+                        user_game_id ,
+                        COUNT(DISTINCT role_user_id) as nature_role_num
+                    FROM
+                        dw_create_role_detail
+                """ + criRoleNum +
                 """
-                        		AND NOT user_agent_id = 0
-                        	GROUP BY user_game_id
-                        ) n
-                        ON a.game_id = n.user_game_id
-                        """;
+                        AND user_agent_id = 0
+                    GROUP BY user_game_id
+                ) m
+                ON a.game_id = m.user_game_id
+                LEFT JOIN (
+                    SELECT
+                        user_game_id ,
+                        COUNT(DISTINCT role_user_id) as buy_role_num
+                    FROM
+                        dw_create_role_detail
+                """ + criRoleNum +
+                """
+                        AND NOT user_agent_id = 0
+                    GROUP BY user_game_id
+                ) n
+                ON a.game_id = n.user_game_id
+                """;
     }
 
     /**

+ 12 - 3
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/enums/GameAuthEnum.java

@@ -17,14 +17,19 @@ import java.util.Objects;
 public enum GameAuthEnum {
 
     /**
-     * 运营
+     * 超管
      */
-    PITCHER("PITCHER", "运营"),
+    ADMIN("ADMIN", "超管"),
 
     /**
      * 投手
      */
-    OPERATE("OPERATE", "投手");
+    PITCHER("PITCHER", "投手"),
+
+    /**
+     * 运营
+     */
+    OPERATE("OPERATE", "运营");
 
     /**
      * 角色
@@ -59,6 +64,10 @@ public enum GameAuthEnum {
     public static Map<String, String> getGameAuthMap() {
         Map<String, String> gameAuthMap = new HashMap<>(GameAuthEnum.values().length);
         for (GameAuthEnum gameAuthEnum : GameAuthEnum.values()) {
+            //前端不返回超管权限
+            if (Objects.equals(gameAuthEnum.getValue(), "ADMIN")) {
+                continue;
+            }
             gameAuthMap.put(gameAuthEnum.getValue(), gameAuthEnum.getName());
         }
         return gameAuthMap;

+ 4 - 2
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/pojo/vo/GameAuthUserVO.java

@@ -6,6 +6,8 @@ import lombok.Builder;
 import lombok.Data;
 import lombok.NoArgsConstructor;
 
+import java.util.List;
+
 /**
  * @author : lingfeng
  * @time : 2023-08-17
@@ -23,9 +25,9 @@ public class GameAuthUserVO {
     private Long userId;
 
     /**
-     * 游戏id
+     * 游戏id列表
      */
-    private Long gameId;
+    private List<Long> gameIdList;
 
     /**
      * 授权类型

+ 4 - 6
game-module/game-module-base/src/main/java/com/zanxiang/game/module/base/rpc/GameAuthRpc.java

@@ -2,8 +2,6 @@ package com.zanxiang.game.module.base.rpc;
 
 import com.zanxiang.game.module.base.pojo.vo.GameAuthUserVO;
 
-import java.util.List;
-
 /**
  * @author : lingfeng
  * @time : 2023-08-17
@@ -12,10 +10,10 @@ import java.util.List;
 public interface GameAuthRpc {
 
     /**
-     * 让游戏authby用户id
+     * 查询指定人的游戏列表, 查询自己则传null
      *
-     * @param userIds 用户id
-     * @return {@link List}<{@link GameAuthUserVO}>
+     * @param userId 用户id
+     * @return {@link GameAuthUserVO}
      */
-    List<GameAuthUserVO> getGameAuthByUserIds(List<Long> userIds);
+    GameAuthUserVO getGameAuthByUserIds(Long userId);
 }

+ 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服务启动成功 <权限修改提交3222> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 <权限修改提交321> ( ´・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 6 - 25
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/rpc/impl/GameAuthRpcImpl.java

@@ -1,18 +1,13 @@
 package com.zanxiang.game.module.manage.rpc.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.zanxiang.game.module.base.pojo.enums.GameAuthEnum;
 import com.zanxiang.game.module.base.pojo.vo.GameAuthUserVO;
 import com.zanxiang.game.module.base.rpc.GameAuthRpc;
-import com.zanxiang.game.module.manage.service.IGameAuthRoleService;
 import com.zanxiang.game.module.manage.service.IGameAuthService;
-import com.zanxiang.game.module.mybatis.entity.GameAuth;
-import com.zanxiang.game.module.mybatis.entity.GameAuthRole;
 import org.apache.dubbo.config.annotation.DubboService;
 import org.springframework.beans.factory.annotation.Autowired;
+import reactor.util.function.Tuple2;
 
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -23,30 +18,16 @@ import java.util.List;
 @DubboService
 public class GameAuthRpcImpl implements GameAuthRpc {
 
-    @Autowired
-    private IGameAuthRoleService gameAuthRoleService;
-
     @Autowired
     private IGameAuthService gameAuthService;
 
     @Override
-    public List<GameAuthUserVO> getGameAuthByUserIds(List<Long> userIds) {
-        List<GameAuthUserVO> list = new ArrayList<>();
-        userIds.forEach(userId -> {
-            GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()
-                    .eq(GameAuthRole::getUserId, userId));
-            List<GameAuth> gameAuthList = gameAuthService.list(new LambdaUpdateWrapper<GameAuth>()
-                    .eq(GameAuth::getUserId, userId));
-            gameAuthList.forEach(gameAuth -> list.add(this.transform(gameAuth, gameAuthRole.getAuthType())));
-        });
-        return list;
-    }
-
-    private GameAuthUserVO transform(GameAuth gameAuth, String authType) {
+    public GameAuthUserVO getGameAuthByUserIds(Long userId) {
+        Tuple2<String, List<Long>> tuple2 = gameAuthService.getUserGameList(userId.toString());
         return GameAuthUserVO.builder()
-                .userId(gameAuth.getUserId())
-                .gameId(gameAuth.getGameId())
-                .gameAuthEnum(GameAuthEnum.getByValue(authType))
+                .userId(userId)
+                .gameIdList(tuple2.getT2())
+                .gameAuthEnum(GameAuthEnum.getByValue(tuple2.getT1()))
                 .build();
     }
 }

+ 8 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IAgentService.java

@@ -84,4 +84,12 @@ public interface IAgentService extends IService<Agent> {
      * @return {@link Map}<{@link String}, {@link String}>
      */
     Map<String, String> channelTransform(String channel);
+
+    /**
+     * 通过id获取代理
+     *
+     * @param agentId 代理人身份证
+     * @return {@link AgentDTO}
+     */
+    AgentDTO getAgentById(long agentId);
 }

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

@@ -51,7 +51,7 @@ public interface IGameAuthService extends IService<GameAuth> {
     boolean deleteById(Long id);
 
     /**
-     * 得到用户游戏列表
+     * 查询指定人的游戏列表, 查询自己则传null
      *
      * @param userId 用户id
      * @return {@link Tuple2}<{@link String}, {@link List}<{@link Long}>>

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

@@ -11,13 +11,15 @@ import com.zanxiang.advertising.tencent.base.pojo.vo.UserActionSetRpcVO;
 import com.zanxiang.advertising.tencent.base.rpc.IAdAccountRpc;
 import com.zanxiang.advertising.tencent.base.rpc.IUserActionSetRpc;
 import com.zanxiang.erp.base.ErpServer;
-import com.zanxiang.erp.base.rpc.ISysUserGroupRpc;
+import com.zanxiang.erp.base.pojo.vo.SysGameUserGroupRpcVO;
+import com.zanxiang.erp.base.rpc.ISysGameUserGroupRpc;
 import com.zanxiang.erp.base.rpc.ISysUserRpc;
 import com.zanxiang.erp.security.util.SecurityUtil;
 import com.zanxiang.game.back.base.ServerInfo;
 import com.zanxiang.game.back.base.pojo.vo.GameBackPolicyRpcVO;
 import com.zanxiang.game.back.base.rpc.IGameBackPolicyRpc;
 import com.zanxiang.game.module.base.pojo.enums.AccountTypeEnum;
+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.params.AgentAddParam;
 import com.zanxiang.game.module.manage.pojo.params.AgentListParam;
@@ -26,8 +28,11 @@ import com.zanxiang.game.module.manage.pojo.vo.AgentChoiceVO;
 import com.zanxiang.game.module.manage.pojo.vo.AgentVO;
 import com.zanxiang.game.module.manage.pojo.vo.GameInfoVO;
 import com.zanxiang.game.module.manage.service.IAgentService;
+import com.zanxiang.game.module.manage.service.IGameAuthRoleService;
+import com.zanxiang.game.module.manage.service.IGameAuthService;
 import com.zanxiang.game.module.manage.service.IGameService;
 import com.zanxiang.game.module.mybatis.entity.Agent;
+import com.zanxiang.game.module.mybatis.entity.GameAuthRole;
 import com.zanxiang.game.module.mybatis.mapper.AgentMapper;
 import com.zanxiang.module.util.JsonUtil;
 import com.zanxiang.module.util.bean.BeanUtil;
@@ -72,7 +77,13 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
     private IGameBackPolicyRpc gameBackPolicyRpc;
 
     @DubboReference(providedBy = ErpServer.SERVER_DUBBO_NAME)
-    private ISysUserGroupRpc sysUserGroupRpc;
+    private ISysGameUserGroupRpc sysGameUserGroupRpc;
+
+    @Autowired
+    private IGameAuthRoleService gameAuthRoleService;
+
+    @Autowired
+    private IGameAuthService gameAuthService;
 
     @Override
     public IPage<AgentVO> listOfPage(AgentListParam param) {
@@ -212,73 +223,75 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
 
     @Override
     public Tuple2<List<Long>, List<AgentDTO>> getUserAgent(String account, String pitcherId, Long agentId) {
-        //组成员列表
-        List<Long> memberUserIdList = sysUserGroupRpc.memberUserId(SecurityUtil.getCompanyId(), SecurityUtil.getUserId()).getData();
-
-        log.error("查询组员 userId : {}, list : {}", SecurityUtil.getUserId(), JsonUtil.toString(memberUserIdList));
-
+        //判断是否是组长
+        SysGameUserGroupRpcVO sysGameUserGroupRpcVO = sysGameUserGroupRpc.getByGroupUser(SecurityUtil.getCompanyId(),
+                SecurityUtil.getUserId()).getData();
+        log.error("判断是否是组长, sysGameUserGroupRpcVO : {}", JsonUtil.toString(sysGameUserGroupRpcVO));
+        //判断运营
+        GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()
+                .eq(GameAuthRole::getUserId, SecurityUtil.getUserId()));
         //自然量查询
         if (Objects.equals(agentId, Agent.DEFAULT_AGENT)) {
-            //判断管理员或者组长
-            if (SecurityUtil.isAdmin() || CollectionUtils.isNotEmpty(memberUserIdList)) {
+            //超管, 运营, 组长可以查询自然量
+            if (SecurityUtil.isAdmin() || sysGameUserGroupRpcVO != null
+                    || Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.OPERATE.getValue())) {
                 return Tuples.of(Collections.singletonList(Agent.DEFAULT_AGENT), Collections.emptyList());
             }
             //非管理员或者组长不允许查询自然量
             return Tuples.of(Collections.emptyList(), Collections.emptyList());
         }
         //渠道列表
-        List<Agent> agentList;
-        List<AgentDTO> agentDTOList = new ArrayList<>();
-        boolean groupLeader = false;
-        //超管权限
+        List<Agent> agentList = new ArrayList<>();
+        //是否需要自然量
+        boolean defaultAgent = true;
+        //超管权限, 返回所有渠道
         if (SecurityUtil.isAdmin()) {
             agentList = super.list(new LambdaQueryWrapper<Agent>()
                     .eq(Strings.isNotBlank(account), Agent::getAccountId, account)
                     .eq(Strings.isNotBlank(pitcherId), Agent::getCreateBy, pitcherId)
                     .eq(agentId != null, Agent::getId, agentId));
-        } else {
-            //组长, 可查看自己或者组员数据
-            if (CollectionUtils.isNotEmpty(memberUserIdList)) {
-                groupLeader = true;
-                if (!memberUserIdList.contains(SecurityUtil.getUserId())) {
-                    memberUserIdList.add(SecurityUtil.getUserId());
-                }
+        } else if (Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.OPERATE.getValue())) {
+            //运营权限, 获取拥有的游戏的所有渠道
+            Tuple2<String, List<Long>> tuple2 = gameAuthService.getUserGameList(null);
+            if (CollectionUtils.isNotEmpty(tuple2.getT2())) {
                 agentList = super.list(new LambdaQueryWrapper<Agent>()
+                        .in(Agent::getGameId, tuple2.getT2())
                         .eq(Strings.isNotBlank(account), Agent::getAccountId, account)
                         .eq(Strings.isNotBlank(pitcherId), Agent::getCreateBy, pitcherId)
-                        .in(Strings.isBlank(pitcherId), Agent::getCreateBy, memberUserIdList)
-                        .eq(agentId != null, Agent::getId, agentId));
-            } else {
-                //组员, 只允许查看自己的数据
-                agentList = super.list(new LambdaQueryWrapper<Agent>()
-                        .eq(Strings.isNotBlank(account), Agent::getAccountId, account)
-                        .eq(Agent::getCreateBy, SecurityUtil.getUserId())
                         .eq(agentId != null, Agent::getId, agentId));
             }
+        } else if (sysGameUserGroupRpcVO != null) {
+            //组长权限, 获取组员id, 查询组内所有渠道
+            Collection<Long> memberUserIdList = sysGameUserGroupRpc.memberUserIds(SecurityUtil.getCompanyId(),
+                    SecurityUtil.getUserId()).getData();
+            log.error("获取组员信息, userId : {}, memberUserIdList : {}", SecurityUtil.getUserId(), JsonUtil.toString(memberUserIdList));
+            agentList = super.list(new LambdaQueryWrapper<Agent>()
+                    .eq(Strings.isNotBlank(account), Agent::getAccountId, account)
+                    .eq(Strings.isNotBlank(pitcherId), Agent::getCreateBy, pitcherId)
+                    .in(Strings.isBlank(pitcherId), Agent::getCreateBy, memberUserIdList)
+                    .eq(agentId != null, Agent::getId, agentId));
+        } else {
+            //组员, 只允许查看自己的数据
+            agentList = super.list(new LambdaQueryWrapper<Agent>()
+                    .eq(Strings.isNotBlank(account), Agent::getAccountId, account)
+                    .eq(Agent::getCreateBy, SecurityUtil.getUserId())
+                    .eq(agentId != null, Agent::getId, agentId));
+            defaultAgent = false;
         }
-        if (CollectionUtils.isNotEmpty(agentList)) {
-            //设置归属投手
-            List<Long> createByList = agentList.stream().map(Agent::getCreateBy).collect(Collectors.toList());
-            Map<Long, String> userMap = sysUserRpc.getUserNameByIds(createByList).getData();
-            agentDTOList = agentList.stream().map(agent -> {
-                AgentDTO agentDTO = BeanUtil.copy(agent, AgentDTO.class);
-                agentDTO.setCreateByName(userMap.get(agent.getCreateBy()));
-                return agentDTO;
-            }).collect(Collectors.toList());
-        }
-        //根据条件, 匹配渠道
-        if (CollectionUtils.isEmpty(agentDTOList) && !SecurityUtil.isAdmin()) {
-            return Tuples.of(Collections.emptyList(), Collections.emptyList());
+        //未指定搜索条件, 且可见自然量
+        if (Strings.isBlank(account) && Strings.isBlank(pitcherId) && agentId == null && defaultAgent) {
+            agentList.add(Agent.builder().id(Agent.DEFAULT_AGENT).agentName(Agent.DEFAULT_AGENT_NAME).build());
         }
+        //设置归属投手
+        List<Long> createByList = agentList.stream().map(Agent::getCreateBy).collect(Collectors.toList());
+        Map<Long, String> userMap = sysUserRpc.getUserNameByIds(createByList).getData();
+        List<AgentDTO> agentDTOList = agentList.stream().map(agent -> {
+            AgentDTO agentDTO = BeanUtil.copy(agent, AgentDTO.class);
+            agentDTO.setCreateByName(userMap.get(agent.getCreateBy()));
+            return agentDTO;
+        }).collect(Collectors.toList());
         //渠道id列表
         List<Long> agentIds = agentDTOList.stream().map(AgentDTO::getId).collect(Collectors.toList());
-        //未指定搜索条件
-        if (Strings.isBlank(account) && Strings.isBlank(pitcherId) && agentId == null) {
-            //管理员和组长可见自然量
-            if (SecurityUtil.isAdmin() || groupLeader) {
-                agentIds.add(Agent.DEFAULT_AGENT);
-            }
-        }
         //返回渠道列表
         return Tuples.of(agentIds, agentDTOList);
     }
@@ -292,16 +305,51 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent> implements
 
     @Override
     public List<AgentChoiceVO> agentChoiceList() {
-        List<AgentChoiceVO> choiceVOList = super.list(new LambdaQueryWrapper<Agent>()
-                .eq(!SecurityUtil.isAdmin(), Agent::getCreateBy, SecurityUtil.getUserId())
-        ).stream().map(agent -> BeanUtil.copy(agent, AgentChoiceVO.class)).collect(Collectors.toList());
-
-        //组成员列表
-        List<Long> memberUserIdList = sysUserGroupRpc.memberUserId(SecurityUtil.getCompanyId(), SecurityUtil.getUserId()).getData();
-        if (CollectionUtils.isNotEmpty(memberUserIdList)) {
-            choiceVOList.add(AgentChoiceVO.builder().id(Agent.DEFAULT_AGENT).agentName(Agent.DEFAULT_AGENT_NAME).build());
+        //判断是否是组长
+        SysGameUserGroupRpcVO sysGameUserGroupRpcVO = sysGameUserGroupRpc.getByGroupUser(SecurityUtil.getCompanyId(),
+                SecurityUtil.getUserId()).getData();
+        //判断运营
+        GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()
+                .eq(GameAuthRole::getUserId, SecurityUtil.getUserId()));
+        //渠道列表
+        List<Agent> agentList = new ArrayList<>();
+        //是否需要自然量
+        boolean defaultAgent = true;
+        //超管权限, 返回所有渠道
+        if (SecurityUtil.isAdmin()) {
+            agentList = super.list();
+        } else if (Objects.equals(gameAuthRole.getAuthType(), GameAuthEnum.OPERATE.getValue())) {
+            //运营权限, 获取拥有的游戏的所有渠道
+            Tuple2<String, List<Long>> tuple2 = gameAuthService.getUserGameList(null);
+            if (CollectionUtils.isNotEmpty(tuple2.getT2())) {
+                agentList = super.list(new LambdaQueryWrapper<Agent>().in(Agent::getGameId, tuple2.getT2()));
+            }
+        } else if (sysGameUserGroupRpcVO != null) {
+            //组长权限, 获取组员id, 查询组内所有渠道
+            Collection<Long> memberUserIdList = sysGameUserGroupRpc.memberUserIds(SecurityUtil.getCompanyId(),
+                    SecurityUtil.getUserId()).getData();
+            agentList = super.list(new LambdaQueryWrapper<Agent>().in(!SecurityUtil.isAdmin(), Agent::getCreateBy, memberUserIdList));
+        } else {
+            //组员权限, 组员返回自己拥有的渠道
+            agentList = super.list(new LambdaQueryWrapper<Agent>()
+                    .eq(!SecurityUtil.isAdmin(), Agent::getCreateBy, SecurityUtil.getUserId()));
+            defaultAgent = false;
+        }
+        //超管, 组长, 运营权限可以存在自然量搜索
+        if (defaultAgent) {
+            agentList.add(Agent.builder().id(Agent.DEFAULT_AGENT).agentName(Agent.DEFAULT_AGENT_NAME).build());
         }
-        return choiceVOList;
+        //返回渠道列表
+        return agentList.stream().map(agent -> BeanUtil.copy(agent, AgentChoiceVO.class)).collect(Collectors.toList());
+    }
+
+    @Override
+    public AgentDTO getAgentById(long agentId) {
+        Agent agent = super.getById(agentId);
+        Map<Long, String> userMap = sysUserRpc.getUserNameByIds(Collections.singletonList(agent.getCreateBy())).getData();
+        AgentDTO agentDTO = BeanUtil.copy(agent, AgentDTO.class);
+        agentDTO.setCreateByName(userMap.get(agent.getCreateBy()));
+        return agentDTO;
     }
 
     @Override

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

@@ -153,7 +153,7 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
             List<Long> gameIdList = super.list(new LambdaQueryWrapper<GameAuth>()
                     .eq(Strings.isNotBlank(userId), GameAuth::getUserId, Strings.isBlank(userId) ? null : Long.valueOf(userId))
             ).stream().map(GameAuth::getGameId).collect(Collectors.toList());
-            return Tuples.of("admin", gameIdList);
+            return Tuples.of(GameAuthEnum.ADMIN.getValue(), gameIdList);
         }
         //非超管权限
         GameAuthRole gameAuthRole = gameAuthRoleService.getOne(new LambdaQueryWrapper<GameAuthRole>()

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

@@ -206,7 +206,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
             }
         }
         //渠道账号
-        AgentDTO agentDTO = agentMap.get(orderVO.getAgentId());
+        AgentDTO agentDTO = agentMap.containsKey(orderVO.getAgentId()) ? agentMap.get(orderVO.getAgentId()) : agentService.getAgentById(orderVO.getAgentId());
         if (agentDTO != null) {
             orderVO.setAccountId(agentDTO.getAccountId());
             orderVO.setPitcherId(agentDTO.getCreateBy());