|
@@ -989,6 +989,12 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
if (StringUtils.isBlank(dto.getSortFiled())) {
|
|
|
criA.getOrderBy().orderBy("a.create_time", dto.getSortType());
|
|
|
} else {
|
|
|
+ if (dto.getSortFiled().equals("ip_role_count_filter")) {
|
|
|
+ dto.setSortFiled("role_count_group_filters_count");
|
|
|
+ }
|
|
|
+ if (dto.getSortFiled().equals("role_user_ip_count_filter")) {
|
|
|
+ dto.setSortFiled("role_user_group_filters_count");
|
|
|
+ }
|
|
|
criA.getOrderBy().orderBy(dto.getSortFiled(), dto.getSortType());
|
|
|
}
|
|
|
//列表sql
|
|
@@ -1037,7 +1043,7 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
dto.setSortType(OrderByEnum.DESC.getOrderType());
|
|
|
}
|
|
|
if (StringUtils.isBlank(dto.getSortFiled())) {
|
|
|
- criA.getOrderBy().orderBy("role_total_amount", dto.getSortType());
|
|
|
+ criA.getOrderBy().orderBy("roleTotalAmount", dto.getSortType());
|
|
|
} else {
|
|
|
criA.getOrderBy().orderBy(dto.getSortFiled(), dto.getSortType());
|
|
|
}
|
|
@@ -1076,12 +1082,12 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
}
|
|
|
List<Map> maps = baseService.ipDetailList(dto);
|
|
|
if (CollectionUtils.isEmpty(maps)) {
|
|
|
- return null;
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
Map map = maps.get(0);
|
|
|
String ipCountIp = String.valueOf(map.get("ip_count_ip"));
|
|
|
if (StringUtils.isEmpty(ipCountIp)) {
|
|
|
- return null;
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
return baseService.ipCountList(Arrays.stream(ipCountIp.split(",")).map(String::trim).collect(Collectors.toList()));
|
|
|
}
|
|
@@ -1090,6 +1096,9 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
public List<Map> ipDetailList(RoleIpInfoParamDTO dto) {
|
|
|
Criteria criteria = Cnd.cri();
|
|
|
criteria.where().andEquals("role_id", dto.getRoleId());
|
|
|
+ if(CollectionUtils.isNotEmpty(dto.getGameId())){
|
|
|
+ criteria.where().andInList("game_id", dto.getGameId());
|
|
|
+ }
|
|
|
String ipDetailListSql = getIpDetailListSql(criteria);
|
|
|
Sql sql = Sqls.create(ipDetailListSql);
|
|
|
sql.setCallback(Sqls.callback.maps());
|
|
@@ -1101,6 +1110,12 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
public List<Map> ipCountList(List<String> ip) {
|
|
|
Criteria criteria = Cnd.cri();
|
|
|
criteria.where().andInStrList("ip", ip);
|
|
|
+ criteria.where().andNotIsNull("ip");
|
|
|
+ criteria.where().andNotEquals("ip","null");
|
|
|
+ criteria.where().andNotEquals("ip","");
|
|
|
+ criteria.where().andNotIsNull("role_id");
|
|
|
+ criteria.where().andNotEquals("role_id","null");
|
|
|
+ criteria.where().andNotEquals("role_id","");
|
|
|
String ipCountList = getIpCountList(criteria);
|
|
|
Sql sql = Sqls.create(ipCountList);
|
|
|
sql.setCallback(Sqls.callback.maps());
|
|
@@ -1117,74 +1132,70 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<Map> roleDetailListOfPage(RoleIpInfoParamDTO dto) {
|
|
|
- Criteria criteria = getRoleDetailSqlByQuery(dto);
|
|
|
- //分页对象
|
|
|
- Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
|
|
|
- //查询总记录数
|
|
|
- Sql countSql = Sqls.create(getRoleDetailCountSql(criteria));
|
|
|
- countSql.setCallback(Sqls.callback.integer());
|
|
|
- dao.execute(countSql);
|
|
|
- pager.setRecordCount(countSql.getInt());
|
|
|
- String roleIpDetailListSql = getRoleDetailList(criteria);
|
|
|
- Sql sql = Sqls.create(roleIpDetailListSql);
|
|
|
- sql.setCallback(Sqls.callback.maps());
|
|
|
- sql.setPager(pager);
|
|
|
- dao.execute(sql);
|
|
|
- //查询结果
|
|
|
- List<Map> list = sql.getList(Map.class);
|
|
|
- return new Page<>(list, pager);
|
|
|
+ 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 new ArrayList<>();
|
|
|
+ }
|
|
|
+ Map map = maps.get(0);
|
|
|
+ String userCountGroup = String.valueOf(map.get("user_count_group"));
|
|
|
+ if (StringUtils.isEmpty(userCountGroup)) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ return baseService.userDetailList(Arrays.stream(userCountGroup.split(",")).map(String::trim).map(Long::valueOf).collect(Collectors.toList()), dto);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<Map> userDetailListOfPage(RoleIpInfoParamDTO dto) {
|
|
|
- Criteria criteria = getUserDetailSqlByQuery(dto);
|
|
|
- //分页对象
|
|
|
- Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
|
|
|
- //查询总记录数
|
|
|
- Sql countSql = Sqls.create(getUserDetailCountSql(criteria));
|
|
|
- countSql.setCallback(Sqls.callback.integer());
|
|
|
- dao.execute(countSql);
|
|
|
- pager.setRecordCount(countSql.getInt());
|
|
|
+ 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());
|
|
|
- sql.setPager(pager);
|
|
|
dao.execute(sql);
|
|
|
//查询结果
|
|
|
- List<Map> list = sql.getList(Map.class);
|
|
|
- return new Page<>(list, pager);
|
|
|
+ return sql.getList(Map.class);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map> userDetailList(RoleIpInfoParamDTO dto) {
|
|
|
+ public List<Map> roleDetailList(RoleIpInfoParamDTO dto) {
|
|
|
if (dto.getRoleId() == null) {
|
|
|
throw new BaseException("角色id不能为空");
|
|
|
}
|
|
|
List<Map> maps = baseService.ipDetailList(dto);
|
|
|
if (CollectionUtils.isEmpty(maps)) {
|
|
|
- return null;
|
|
|
+ return new ArrayList<>();
|
|
|
}
|
|
|
Map map = maps.get(0);
|
|
|
- String userCountGroup = String.valueOf(map.get("user_count_group"));
|
|
|
- if (StringUtils.isEmpty(userCountGroup)) {
|
|
|
- return null;
|
|
|
+ String filedRoleId = "role_count_group";
|
|
|
+ if (dto.getExcludeUserType() == 1) {
|
|
|
+ filedRoleId = "role_count_group_filters";
|
|
|
}
|
|
|
- return baseService.userDetailList(Arrays.stream(userCountGroup.split(",")).map(String::trim).map(Long::valueOf).collect(Collectors.toList()), dto);
|
|
|
+ String roleIdStr = String.valueOf(map.get(filedRoleId));
|
|
|
+ if (StringUtils.isEmpty(roleIdStr) || roleIdStr.equals("[]")) {
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ if (dto.getExcludeUserType() == 1) {
|
|
|
+ roleIdStr = roleIdStr.replaceAll("[\\[\\]\"]", "");
|
|
|
+ }
|
|
|
+ return baseService.roleDetailList(Arrays.stream(roleIdStr.split(",")).map(String::trim).map(Long::valueOf).collect(Collectors.toList()), dto);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map> userDetailList(List<Long> userIds, RoleIpInfoParamDTO dto) {
|
|
|
+ public List<Map> roleDetailList(List<Long> roleId, RoleIpInfoParamDTO roleIpInfoParamDTO) {
|
|
|
Criteria criteria = Cnd.cri();
|
|
|
- criteria.where().andInList("user_id", userIds);
|
|
|
- Criteria orderCriteria = getUserDetailOrderSql(dto);
|
|
|
- String userDetailListSql = getUserDetailListSql(criteria, orderCriteria);
|
|
|
- Sql sql = Sqls.create(userDetailListSql);
|
|
|
+ criteria.where().andInList("role_id", roleId);
|
|
|
+ String roleDetailListSql = getRoleDetailList(criteria);
|
|
|
+ Sql sql = Sqls.create(roleDetailListSql);
|
|
|
sql.setCallback(Sqls.callback.maps());
|
|
|
dao.execute(sql);
|
|
|
//查询结果
|
|
|
- return sql.getList(Map.class);
|
|
|
+ List<Map> list = sql.getList(Map.class);
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
private Criteria getUserDetailOrderSql(RoleIpInfoParamDTO dto) {
|
|
@@ -1253,75 +1264,6 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
""" + orderCriteria;
|
|
|
}
|
|
|
|
|
|
- private String getUserDetailCountSql(Criteria criteria) {
|
|
|
- return """
|
|
|
- select count(1) 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
|
|
|
- """;
|
|
|
- }
|
|
|
-
|
|
|
- private Criteria getUserDetailSqlByQuery(RoleIpInfoParamDTO dto) {
|
|
|
- Criteria criteria = Cnd.cri();
|
|
|
- if (dto.getRegIp() != null) {
|
|
|
- criteria.where().andEquals("a.ip", dto.getRegIp());
|
|
|
- }
|
|
|
- return criteria;
|
|
|
- }
|
|
|
-
|
|
|
- private String getRoleDetailCountSql(Criteria criteria) {
|
|
|
- return """
|
|
|
- select count(1) from ( select role_id roleId ,any_value(role_name) roleNmae,game_id gameId,any_value(game_name) gameName,ip,server_id serverId,any_value(server_name) serverName,user_id userId,any_value(user_name) userName from game_ads.role_ip_monitor
|
|
|
- """ + criteria + """
|
|
|
- group by role_id,game_id,ip,server_id,user_id)a
|
|
|
- """;
|
|
|
- }
|
|
|
-
|
|
|
private String getRoleDetailList(Criteria criteria) {
|
|
|
return """
|
|
|
select role_id roleId ,any_value(role_name) roleName,game_id gameId,any_value(game_name) gameName,ip,server_id serverId,any_value(server_name) serverName,user_id userId,any_value(user_name) userName from game_ads.role_ip_monitor
|
|
@@ -1330,25 +1272,15 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
""";
|
|
|
}
|
|
|
|
|
|
- private Criteria getRoleDetailSqlByQuery(RoleIpInfoParamDTO dto) {
|
|
|
- Criteria criteria = Cnd.cri();
|
|
|
- if (StringUtils.isNotEmpty(dto.getRegIp())) {
|
|
|
- criteria.where().andEquals("ip", dto.getRegIp());
|
|
|
- }
|
|
|
- if (dto.getExcludeUserId() != null) {
|
|
|
- criteria.where().andNotEquals("user_id", dto.getExcludeUserId());
|
|
|
- }
|
|
|
- return criteria;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* ipRoleCount 同ip的角色数量
|
|
|
*/
|
|
|
private String getIpDetailListSql(Criteria criteria) {
|
|
|
return """
|
|
|
select * from game_ads.role_ip_monitor
|
|
|
- """ + criteria;
|
|
|
+ """ + criteria + """
|
|
|
+ order by role_level desc
|
|
|
+ """;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -1360,19 +1292,19 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
|
|
|
private String getGameCountryRoleListSql(Criteria criA) {
|
|
|
return """
|
|
|
- select a.country as country,a.role_id as roleId,user_id as userId ,role_name as roleName ,role_level as roleLevel ,combat_num as combatNum,
|
|
|
- server_id as serverId ,server_name as serverName ,create_time as createTime,IFNULL(b.role_total_amount,0) as roleTotalAmount
|
|
|
- from dm_game_order.t_game_user_role a
|
|
|
- left join game_ads.ads_role_amount b on a.role_id = b.role_id
|
|
|
+ select a.country as country,a.role_id as roleId,a.user_id as userId ,a.role_name as roleName ,a.role_level as roleLevel ,combat_num as combatNum,
|
|
|
+ a.server_id as serverId ,a.server_name as serverName ,create_time as createTime,IFNULL(b.amount,0) as roleTotalAmount
|
|
|
+ from dm_game_order.t_game_user_role a
|
|
|
+ left join game_dw.dw_order_day_amount b on a.role_id = b.role_id
|
|
|
""" + criA;
|
|
|
}
|
|
|
|
|
|
private String getGameCountryRoleCountSql(Criteria criA) {
|
|
|
return """
|
|
|
- select count(1) from ( select a.country as country,a.role_id as roleId,user_id as userId ,role_name as roleName ,role_level as roleLevel ,combat_num as combatNum,
|
|
|
- server_id as serverId ,server_name as serverName ,create_time as createTime,IFNULL(b.role_total_amount,0) as roleTotalAmount
|
|
|
+ select count(1) from ( select a.country as country,a.role_id as roleId,a.user_id as userId ,a.role_name as roleName ,a.role_level as roleLevel ,a.combat_num as combatNum,
|
|
|
+ a.server_id as serverId ,a.server_name as serverName ,a.create_time as createTime,IFNULL(b.amount,0) as roleTotalAmount
|
|
|
from dm_game_order.t_game_user_role a
|
|
|
- left join game_ads.ads_role_amount b on a.role_id = b.role_id
|
|
|
+ left join game_dw.dw_order_day_amount b on a.role_id = b.role_id
|
|
|
""" + criA + """
|
|
|
) a
|
|
|
""";
|
|
@@ -1381,17 +1313,17 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
private Criteria getSqlByQuery(RoleGameCountryParamDTO dto) {
|
|
|
Criteria cri = Cnd.cri();
|
|
|
if (StringUtils.isNotEmpty(dto.getCountry())) {
|
|
|
- cri.where().andEquals("country", dto.getCountry());
|
|
|
+ cri.where().andEquals("a.country", dto.getCountry());
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(dto.getServerId())) {
|
|
|
- cri.where().andEquals("server_id", dto.getServerId());
|
|
|
+ cri.where().andEquals("a.server_id", dto.getServerId());
|
|
|
}
|
|
|
- cri.where().andInList("game_id", Arrays.asList(35L, 36L, 10035L));
|
|
|
+ cri.where().andInList("a.game_id", Arrays.asList(35L, 36L, 10035L));
|
|
|
if (dto.getCountryLevel() != null && dto.getCountryLevel() == 0) {
|
|
|
- cri.where().andLTE("role_level", 13);
|
|
|
+ cri.where().andLTE("a.role_level", 13);
|
|
|
}
|
|
|
if (dto.getCountryLevel() != null && dto.getCountryLevel() == 1) {
|
|
|
- cri.where().andGT("role_level", 13);
|
|
|
+ cri.where().andGT("a.role_level", 13);
|
|
|
}
|
|
|
return cri;
|
|
|
}
|
|
@@ -1434,14 +1366,14 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
from (select a.country,
|
|
|
a.game_id,
|
|
|
a.server_name,
|
|
|
- IFNULL(c.role_total_amount, 0) as role_total_amount,
|
|
|
+ IFNULL(c.amount, 0) as role_total_amount,
|
|
|
if(b.role_level <= 13, 0, 1) as country_level,
|
|
|
if(d.role_id is not null, 1, 0) as active,
|
|
|
a.server_id,
|
|
|
concat(a.country,',',a.server_id) as cs
|
|
|
from dm_game_order.t_server_country a
|
|
|
left join dm_game_order.t_game_user_role b on a.country = b.country and a.server_id = b.server_id
|
|
|
- left join game_ads.ads_role_amount c on c.role_id = b.role_id
|
|
|
+ left join game_dw.dw_order_day_amount c on c.role_id = b.role_id
|
|
|
left join (
|
|
|
select role_id,ROW_NUMBER()over(partition by role_id) as num from game_dw.dw_active_log
|
|
|
where game_id in (35,36,10035)
|
|
@@ -1474,57 +1406,13 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
|
|
|
private String getIpInfoListSql(Criteria criA) {
|
|
|
return """
|
|
|
- WITH
|
|
|
- login_data AS (
|
|
|
- SELECT
|
|
|
- role_id, game_id, user_id, ip
|
|
|
- FROM dm_game_order.t_user_login_log
|
|
|
- WHERE
|
|
|
- game_id IN (35,36,10035)
|
|
|
- AND role_id != 'null'
|
|
|
- AND ip IS NOT NULL AND ip != 'null' AND ip != ''
|
|
|
- ),
|
|
|
- user_role_counts AS (
|
|
|
- SELECT user_id, COUNT(DISTINCT role_id) AS user_role_count
|
|
|
- FROM login_data
|
|
|
- GROUP BY user_id
|
|
|
- ),
|
|
|
- ip_relationships AS (
|
|
|
- SELECT
|
|
|
- a.role_id,
|
|
|
- COUNT(DISTINCT b.user_id) AS user_count,
|
|
|
- COUNT(DISTINCT b.role_id) AS role_count
|
|
|
- FROM login_data a
|
|
|
- LEFT JOIN login_data b ON a.ip = b.ip
|
|
|
- GROUP BY a.role_id
|
|
|
- ),
|
|
|
- role_ip_roles AS (
|
|
|
- SELECT
|
|
|
- r.role_id,
|
|
|
- COUNT(DISTINCT all_roles.role_id) AS role_count
|
|
|
- FROM login_data r
|
|
|
- JOIN login_data all_roles ON r.ip = all_roles.ip
|
|
|
- GROUP BY r.role_id
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- SELECT
|
|
|
- a.*,
|
|
|
- GREATEST(e.role_count - urc.user_role_count, 0) AS ip_role_count_filter,
|
|
|
- GREATEST(f.role_count - urc.user_role_count, 0) AS role_user_ip_count_filter,
|
|
|
- game.game_name
|
|
|
- FROM game_ads.role_ip_monitor a
|
|
|
- LEFT JOIN (
|
|
|
- SELECT role_id, game_id, user_id, COUNT(DISTINCT ip) AS ip_count
|
|
|
- FROM login_data
|
|
|
- GROUP BY role_id, game_id, user_id
|
|
|
- ) c ON a.role_id = c.role_id AND a.game_id = c.game_id AND a.user_id = c.user_id
|
|
|
- LEFT JOIN ip_relationships d ON a.role_id = d.role_id
|
|
|
- LEFT JOIN ip_relationships e ON a.role_id = e.role_id
|
|
|
- LEFT JOIN role_ip_roles f ON a.role_id = f.role_id
|
|
|
- LEFT JOIN user_role_counts urc ON a.user_id = urc.user_id
|
|
|
- LEFT JOIN dm_game_order.t_game game ON a.game_id = game.id AND game.source_system = 'ZX_ONE'
|
|
|
+ SELECT
|
|
|
+ a.*,
|
|
|
+ a.role_count_group_filters_count as ip_role_count_filter,
|
|
|
+ a.role_user_group_filters_count as role_user_ip_count_filter,
|
|
|
+ game.game_name
|
|
|
+ FROM game_ads.role_ip_monitor a
|
|
|
+ LEFT JOIN dm_game_order.t_game game ON a.game_id = game.id AND game.source_system = 'ZX_ONE'
|
|
|
""" + criA;
|
|
|
}
|
|
|
|
|
@@ -1585,62 +1473,15 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
|
|
|
private String getIpInfoListCountSql(Criteria criA) {
|
|
|
return """
|
|
|
- SELECT COUNT(1) FROM (
|
|
|
- WITH
|
|
|
- login_data AS (
|
|
|
- SELECT
|
|
|
- role_id, game_id, user_id, ip
|
|
|
- FROM dm_game_order.t_user_login_log
|
|
|
- WHERE
|
|
|
- game_id IN (35,36,10035)
|
|
|
- AND role_id != 'null'
|
|
|
- AND ip IS NOT NULL AND ip != 'null' AND ip != ''
|
|
|
- ),
|
|
|
- user_role_counts AS (
|
|
|
- SELECT user_id, COUNT(DISTINCT role_id) AS user_role_count
|
|
|
- FROM login_data
|
|
|
- GROUP BY user_id
|
|
|
- ),
|
|
|
- ip_relationships AS (
|
|
|
- SELECT
|
|
|
- a.role_id,
|
|
|
- COUNT(DISTINCT b.user_id) AS user_count,
|
|
|
- COUNT(DISTINCT b.role_id) AS role_count
|
|
|
- FROM login_data a
|
|
|
- LEFT JOIN login_data b ON a.ip = b.ip
|
|
|
- GROUP BY a.role_id
|
|
|
- ),
|
|
|
- role_ip_roles AS (
|
|
|
- SELECT
|
|
|
- r.role_id,
|
|
|
- COUNT(DISTINCT all_roles.role_id) AS role_count
|
|
|
- FROM login_data r
|
|
|
- JOIN login_data all_roles ON r.ip = all_roles.ip
|
|
|
- GROUP BY r.role_id
|
|
|
- )
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- SELECT
|
|
|
+ select count(1) from ( SELECT
|
|
|
a.*,
|
|
|
- GREATEST(e.role_count - urc.user_role_count, 0) AS ip_role_count_filter,
|
|
|
- GREATEST(f.role_count - urc.user_role_count, 0) AS role_user_ip_count_filter,
|
|
|
+ a.role_count_group_filters_count as ip_role_count_filter,
|
|
|
+ a.role_user_group_filters_count as role_user_ip_count_filter,
|
|
|
game.game_name
|
|
|
FROM game_ads.role_ip_monitor a
|
|
|
- LEFT JOIN (
|
|
|
- SELECT role_id, game_id, user_id, COUNT(DISTINCT ip) AS ip_count
|
|
|
- FROM login_data
|
|
|
- GROUP BY role_id, game_id, user_id
|
|
|
- ) c ON a.role_id = c.role_id AND a.game_id = c.game_id AND a.user_id = c.user_id
|
|
|
- LEFT JOIN ip_relationships d ON a.role_id = d.role_id
|
|
|
- LEFT JOIN ip_relationships e ON a.role_id = e.role_id
|
|
|
- LEFT JOIN role_ip_roles f ON a.role_id = f.role_id
|
|
|
- LEFT JOIN user_role_counts urc ON a.user_id = urc.user_id
|
|
|
LEFT JOIN dm_game_order.t_game game ON a.game_id = game.id AND game.source_system = 'ZX_ONE'
|
|
|
- """ +
|
|
|
- criA
|
|
|
- + """
|
|
|
- ) a
|
|
|
+ """ + criA + """
|
|
|
+ ) a
|
|
|
""";
|
|
|
}
|
|
|
|