|
@@ -1069,35 +1069,6 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public Page<Map> roleIpDetailListOfPage2(RoleIpInfoParamDTO dto) {
|
|
|
- if (dto.getRoleId() == null) {
|
|
|
- throw new BaseException("角色id不能为空");
|
|
|
- }
|
|
|
-
|
|
|
- Criteria criteria = Cnd.cri();
|
|
|
- criteria.where().andEquals("role_id", dto.getRoleId());
|
|
|
- if (dto.getExcludeUserId() != null) {
|
|
|
- criteria.where().andNotEquals("user_id", dto.getExcludeUserId());
|
|
|
- }
|
|
|
-
|
|
|
- //分页对象
|
|
|
- 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);
|
|
|
- sql.setCallback(Sqls.callback.maps());
|
|
|
- sql.setPager(pager);
|
|
|
- dao.execute(sql);
|
|
|
- //查询结果
|
|
|
- List<Map> list = sql.getList(Map.class);
|
|
|
- return new Page<>(list, pager);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public List<Map> roleIpDetailListOfPage(RoleIpInfoParamDTO dto) {
|
|
|
if (dto.getRoleId() == null) {
|
|
@@ -1130,7 +1101,7 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
public List<Map> ipCountList(List<String> ip) {
|
|
|
Criteria criteria = Cnd.cri();
|
|
|
criteria.where().andInStrList("ip", ip);
|
|
|
- String ipCountList= getIpCountList(criteria);
|
|
|
+ String ipCountList = getIpCountList(criteria);
|
|
|
Sql sql = Sqls.create(ipCountList);
|
|
|
sql.setCallback(Sqls.callback.maps());
|
|
|
dao.execute(sql);
|
|
@@ -1140,7 +1111,7 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
private String getIpCountList(Criteria criteria) {
|
|
|
return """
|
|
|
select ip,count(distinct role_id) as ipRoleCount from dm_game_order.t_user_login_log
|
|
|
- """+criteria+"""
|
|
|
+ """ + criteria + """
|
|
|
group by ip
|
|
|
""";
|
|
|
}
|
|
@@ -1186,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();
|
|
|
//主表添加排序条件
|
|
@@ -1202,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) {
|
|
@@ -1341,24 +1341,6 @@ 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) {
|
|
|
- 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
|
|
|
- """ + criteria;
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* ipRoleCount 同ip的角色数量
|