Explorar o código

Merge remote-tracking branch 'origin/package' into package

bilingfeng hai 1 mes
pai
achega
7d1322f65b

+ 11 - 4
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/controller/RoleManageController.java

@@ -68,9 +68,9 @@ public class RoleManageController {
     }
 
     @ApiOperation(value = "角色ip登录详情列表")
-    @PreAuthorize(permissionKey = "roleManage:ipInfo:listOfPage")
-    @PostMapping("/roleIpDetail/listOfPage")
-    public ResultVO<Page<Map>> roleIpDetailListOfPage(@RequestBody RoleIpInfoParamDTO dto) {
+    @PreAuthorize(permissionKey = "roleManage:ipInfo:list")
+    @PostMapping("/roleIpDetail/list")
+    public ResultVO<List<Map>> roleIpDetailListOfPage(@RequestBody RoleIpInfoParamDTO dto) {
         return ResultVO.ok(roleManageService.roleIpDetailListOfPage(dto));
     }
 
@@ -81,13 +81,20 @@ public class RoleManageController {
         return ResultVO.ok(roleManageService.roleDetailListOfPage(dto));
     }
 
-    @ApiOperation(value = "查询玩家详情列表")
+//    @ApiOperation(value = "查询玩家详情列表")
     @PreAuthorize(permissionKey = "roleManage:userDetail:listOfPage")
     @PostMapping("/userDetail/listOfPage")
     public ResultVO<Page<Map>> userDetailListOfPage(@RequestBody RoleIpInfoParamDTO dto) {
         return ResultVO.ok(roleManageService.userDetailListOfPage(dto));
     }
 
+    @ApiOperation(value = "查询玩家详情列表")
+    @PreAuthorize(permissionKey = "roleManage:userDetail:list")
+    @PostMapping("/userDetail/list")
+    public ResultVO<List<Map>> userDetailList(@RequestBody RoleIpInfoParamDTO dto) {
+        return ResultVO.ok(roleManageService.userDetailList(dto));
+    }
+
     @ApiOperation(value = "游戏帮派列表")
     @PreAuthorize(permissionKey = "roleManage:gameCountry:list")
     @PostMapping("/gameCountryList")

+ 23 - 1
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/IRoleManageService.java

@@ -78,12 +78,20 @@ public interface IRoleManageService {
      */
     List<Map> gameCountryList(GameCountryParamDTO dto);
 
+
+
     /**
      * 角色ip登录详情
      * @param dto
      * @return
      */
-    Page<Map> roleIpDetailListOfPage(RoleIpInfoParamDTO dto);
+    List<Map> roleIpDetailListOfPage(RoleIpInfoParamDTO dto);
+
+
+    List<Map> ipDetailList(RoleIpInfoParamDTO dto);
+
+    List<Map> ipCountList(List<String> ip);
+
 
     /**
      * 根据ip查询角色详情列表
@@ -98,4 +106,18 @@ public interface IRoleManageService {
      * @return
      */
     Page<Map> userDetailListOfPage(RoleIpInfoParamDTO dto);
+
+    /**
+     * 查询玩家详情列表2
+     * @param dto
+     * @return
+     */
+    List<Map> userDetailList(RoleIpInfoParamDTO dto);
+
+
+
+    List<Map> userDetailList(List<Long> userIds,RoleIpInfoParamDTO dto);
+
+
+
 }

+ 127 - 81
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/RoleManageServiceImpl.java

@@ -30,9 +30,11 @@ import org.nutz.dao.pager.Pager;
 import org.nutz.dao.sql.Criteria;
 import org.nutz.dao.sql.Sql;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StopWatch;
 
+import javax.annotation.Resource;
 import java.time.LocalTime;
 import java.util.*;
 import java.util.function.Function;
@@ -56,6 +58,10 @@ public class RoleManageServiceImpl implements IRoleManageService {
     @DubboReference(providedBy = ServerInfo.SERVER_DUBBO_NAME)
     private ICPSendMsgRpc sendMsgRpc;
 
+    @Resource
+    @Lazy
+    private IRoleManageService baseService;
+
 
     /**
      * 角色充值排行榜
@@ -1064,31 +1070,50 @@ public class RoleManageServiceImpl implements IRoleManageService {
     }
 
     @Override
-    public Page<Map> roleIpDetailListOfPage(RoleIpInfoParamDTO dto) {
+    public List<Map> roleIpDetailListOfPage(RoleIpInfoParamDTO dto) {
         if (dto.getRoleId() == null) {
             throw new BaseException("角色id不能为空");
         }
+        List<Map> maps = baseService.ipDetailList(dto);
+        if (CollectionUtils.isEmpty(maps)) {
+            return null;
+        }
+        Map map = maps.get(0);
+        String ipCountIp = String.valueOf(map.get("ip_count_ip"));
+        if (StringUtils.isEmpty(ipCountIp)) {
+            return null;
+        }
+        return baseService.ipCountList(Arrays.stream(ipCountIp.split(",")).map(String::trim).collect(Collectors.toList()));
+    }
+
+    @Override
+    public List<Map> ipDetailList(RoleIpInfoParamDTO dto) {
         Criteria criteria = Cnd.cri();
         criteria.where().andEquals("role_id", dto.getRoleId());
-        if (dto.getExcludeUserId() != null) {
-            criteria.where().andNotEquals("user_id", dto.getExcludeUserId());
-        }
+        String ipDetailListSql = getIpDetailListSql(criteria);
+        Sql sql = Sqls.create(ipDetailListSql);
+        sql.setCallback(Sqls.callback.maps());
+        dao.execute(sql);
+        return sql.getList(Map.class);
+    }
 
-        //分页对象
-        Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
-        //查询总记录数
-        Sql countSql = Sqls.create(getRoleIpDetailListCountSql(criteria));
-        countSql.setCallback(Sqls.callback.integer());
-        dao.execute(countSql);
-        pager.setRecordCount(countSql.getInt());
-        String roleIpDetailListSql = getRoleIpDetailListSql(criteria);
-        Sql sql = Sqls.create(roleIpDetailListSql);
+    @Override
+    public List<Map> ipCountList(List<String> ip) {
+        Criteria criteria = Cnd.cri();
+        criteria.where().andInStrList("ip", ip);
+        String ipCountList = getIpCountList(criteria);
+        Sql sql = Sqls.create(ipCountList);
         sql.setCallback(Sqls.callback.maps());
-        sql.setPager(pager);
         dao.execute(sql);
-        //查询结果
-        List<Map> list = sql.getList(Map.class);
-        return new Page<>(list, pager);
+        return sql.getList(Map.class);
+    }
+
+    private String getIpCountList(Criteria criteria) {
+        return """
+                select ip,count(distinct role_id) as ipRoleCount  from  dm_game_order.t_user_login_log 
+                 """ + criteria + """
+                 group by ip
+                """;
     }
 
     @Override
@@ -1132,6 +1157,36 @@ public class RoleManageServiceImpl implements IRoleManageService {
         return new Page<>(list, pager);
     }
 
+    @Override
+    public List<Map> userDetailList(RoleIpInfoParamDTO dto) {
+        if (dto.getRoleId() == null) {
+            throw new BaseException("角色id不能为空");
+        }
+        List<Map> maps = baseService.ipDetailList(dto);
+        if (CollectionUtils.isEmpty(maps)) {
+            return null;
+        }
+        Map map = maps.get(0);
+        String userCountGroup = String.valueOf(map.get("user_count_group"));
+        if (StringUtils.isEmpty(userCountGroup)) {
+            return null;
+        }
+        return baseService.userDetailList(Arrays.stream(userCountGroup.split(",")).map(String::trim).map(Long::valueOf).collect(Collectors.toList()), dto);
+    }
+
+    @Override
+    public List<Map> userDetailList(List<Long> userIds, RoleIpInfoParamDTO dto) {
+        Criteria criteria = Cnd.cri();
+        criteria.where().andInList("user_id", userIds);
+        Criteria orderCriteria = getUserDetailOrderSql(dto);
+        String userDetailListSql = getUserDetailListSql(criteria, orderCriteria);
+        Sql sql = Sqls.create(userDetailListSql);
+        sql.setCallback(Sqls.callback.maps());
+        dao.execute(sql);
+        //查询结果
+        return sql.getList(Map.class);
+    }
+
     private Criteria getUserDetailOrderSql(RoleIpInfoParamDTO dto) {
         Criteria criteria = Cnd.cri();
         //主表添加排序条件
@@ -1148,55 +1203,54 @@ public class RoleManageServiceImpl implements IRoleManageService {
 
     private String getUserDetailListSql(Criteria criteria, Criteria orderCriteria) {
         return """
-                  select * from (select a.user_id  userId,
-                                       any_value(a.user_name) userName,
-                                       any_value(b.agent_id) agentId ,
-                                       any_value(IF(b.agent_id = 0, '自然量', pa.agent_name)) agentGame,
-                                       any_value(b.create_time) createTime,
-                                       any_value(b.game_id) gameId,
-                                       any_value(d.game_name) gameName,
-                                       any_value(b.ip) ip,
-                                       any_value(IFNULL(c.total_amount,0)) totalAmount,
-                                       any_value((select count(1) from dm_game_order.t_game_user_role where user_id = b.id)) as userRoleCount,
-                                       MAX(ab.game_id) as lastLoginGameId,
-                                       MAX(ab.game_name) as lastLoginGame,
-                                       MAX(ab.last_login_time) as lastLoginTime,
-                                       any_value(ab.last_order_time) as lastOrderTime
-                                from game_ads.role_ip_monitor a
-                                         left join dm_game_order.t_game_user b on a.user_id = b.id and source_system = 'ZX_ONE'
-                                    left join dm_game_order.t_pitcher_agent pa on pa.id = b.agent_id and pa.source_system = 'ZX_ONE'
-                                         left join game_ads.ads_player_recharge_ranking c on b.id = c.pitcher_id and c.source_system = 'ZX_ONE'
-                                    left join (
-                                          SELECT
-                                              a.user_id,
-                    a.game_id,
-                    b.game_name,
-                    a.create_time AS last_login_time,
-                    latest_order.last_order_time
-                FROM
-                    dm_game_order.t_user_login_log a
-                LEFT JOIN
-                    dm_game_order.t_game b
-                    ON a.game_id = b.id
-                    AND b.source_system = 'ZX_ONE'
-                LEFT JOIN
-                    (SELECT
-                         user_id,
-                         MAX(create_time) AS last_order_time
-                     FROM
-                         dm_game_order.t_game_order
-                     WHERE
-                         source_system = 'ZX_ONE'
-                     GROUP BY
-                         user_id) latest_order
-                    ON a.user_id = latest_order.user_id
-                ORDER BY
-                    a.create_time DESC
-                                ) ab on ab.user_id = b.id
-                                left join dm_game_order.t_game d on b.game_id = d.id and d.source_system = 'ZX_ONE'
-                                  """ + criteria + """
-                group by a.user_id) a
-                   """ + orderCriteria;
+                select * from (select b.id,
+                                                      any_value(b.username) userName,
+                                                      any_value(b.agent_id) agentId ,
+                                                      any_value(IF(b.agent_id = 0, '自然量', pa.agent_name)) agentGame,
+                                                      any_value(b.create_time) createTime,
+                                                      any_value(b.game_id) gameId,
+                                                      any_value(d.game_name) gameName,
+                                                      any_value(b.ip) ip,
+                                                      any_value(IFNULL(c.total_amount,0)) totalAmount,
+                                                      any_value((select count(1) from dm_game_order.t_game_user_role where user_id = b.id)) as userRoleCount,
+                                                      MAX(ab.game_id) as lastLoginGameId,
+                                                      MAX(ab.game_name) as lastLoginGame,
+                                                      MAX(ab.last_login_time) as lastLoginTime,
+                                                      any_value(ab.last_order_time) as lastOrderTime
+                                               from dm_game_order.t_game_user b
+                                                   left join dm_game_order.t_pitcher_agent pa on pa.id = b.agent_id and pa.source_system = 'ZX_ONE'
+                                                        left join game_ads.ads_player_recharge_ranking c on b.id = c.pitcher_id and c.source_system = 'ZX_ONE'
+                                                   left join (
+                                                         SELECT
+                                                             a.user_id,
+                                   a.game_id,
+                                   b.game_name,
+                                   a.create_time AS last_login_time,
+                                   latest_order.last_order_time
+                               FROM
+                                   dm_game_order.t_user_login_log a
+                               LEFT JOIN
+                                   dm_game_order.t_game b
+                                   ON a.game_id = b.id
+                                   AND b.source_system = 'ZX_ONE'
+                               LEFT JOIN
+                                   (SELECT
+                                        user_id,
+                                        MAX(create_time) AS last_order_time
+                                    FROM
+                                        dm_game_order.t_game_order
+                                    WHERE
+                                        source_system = 'ZX_ONE'
+                                    GROUP BY
+                                        user_id) latest_order
+                                   ON a.user_id = latest_order.user_id
+                               ORDER BY
+                                   a.create_time DESC
+                                               ) ab on ab.user_id = b.id
+                                               left join dm_game_order.t_game d on b.game_id = d.id and d.source_system = 'ZX_ONE'
+                                               """ + criteria + """
+                                 group by b.id) a
+                """ + orderCriteria;
     }
 
     private String getUserDetailCountSql(Criteria criteria) {
@@ -1287,25 +1341,17 @@ public class RoleManageServiceImpl implements IRoleManageService {
         return criteria;
     }
 
-    private String getRoleIpDetailListCountSql(Criteria criteria) {
-        return """
-                select count(1) from (select distinct a.ip,(select count(distinct role_id) from  dm_game_order.t_user_login_log where ip = a.ip) from dm_game_order.t_user_login_log a
-                               """
-                + criteria +
-                """
-                                            ) a
-                        """;
-    }
 
     /**
      * ipRoleCount 同ip的角色数量
      */
-    private String getRoleIpDetailListSql(Criteria criteria) {
+    private String getIpDetailListSql(Criteria criteria) {
         return """
-                 select distinct a.ip,(select count(distinct role_id)  from  dm_game_order.t_user_login_log where ip = a.ip) as ipRoleCount from dm_game_order.t_user_login_log a
+                 select * from game_ads.role_ip_monitor
                 """ + criteria;
     }
 
+
     private String getCountryListSql(Criteria criteria) {
         return """
                 select country,server_id as serverId,parent_name as gameName,server_name as serverName,parent_game_id as gameId from dm_game_order.t_server_country
@@ -1341,11 +1387,11 @@ public class RoleManageServiceImpl implements IRoleManageService {
             cri.where().andEquals("server_id", dto.getServerId());
         }
         cri.where().andInList("game_id", Arrays.asList(35L, 36L, 10035L));
-        if(dto.getCountryLevel()!=null&&dto.getCountryLevel()==0){
-            cri.where().andLTE("role_level",13);
+        if (dto.getCountryLevel() != null && dto.getCountryLevel() == 0) {
+            cri.where().andLTE("role_level", 13);
         }
-        if(dto.getCountryLevel()!=null&&dto.getCountryLevel()==1){
-            cri.where().andGT("role_level",13);
+        if (dto.getCountryLevel() != null && dto.getCountryLevel() == 1) {
+            cri.where().andGT("role_level", 13);
         }
         return cri;
     }