|
@@ -1,13 +1,12 @@
|
|
|
package com.zanxiang.game.data.serve.service.impl;
|
|
|
|
|
|
-import java.time.LocalDateTime;
|
|
|
-
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.zanxiang.erp.base.ErpServer;
|
|
|
import com.zanxiang.erp.base.rpc.ISysUserRpc;
|
|
|
import com.zanxiang.erp.security.util.SecurityUtil;
|
|
|
import com.zanxiang.game.data.serve.pojo.dto.*;
|
|
|
import com.zanxiang.game.data.serve.pojo.enums.OrderByEnum;
|
|
|
+import com.zanxiang.game.data.serve.pojo.vo.RoleGameCountryVO;
|
|
|
import com.zanxiang.game.data.serve.service.IRoleManageService;
|
|
|
import com.zanxiang.game.data.serve.utils.Page;
|
|
|
import com.zanxiang.game.module.base.ServerInfo;
|
|
@@ -18,7 +17,6 @@ import com.zanxiang.game.module.base.pojo.vo.SendMsgResultVO;
|
|
|
import com.zanxiang.game.module.base.pojo.vo.SendMsgVO;
|
|
|
import com.zanxiang.game.module.base.rpc.ICPSendMsgRpc;
|
|
|
import com.zanxiang.game.module.base.util.PageUtil;
|
|
|
-import com.zanxiang.module.util.JsonUtil;
|
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
|
import com.zanxiang.module.util.pojo.ResultVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -31,6 +29,7 @@ import org.nutz.dao.Sqls;
|
|
|
import org.nutz.dao.pager.Pager;
|
|
|
import org.nutz.dao.sql.Criteria;
|
|
|
import org.nutz.dao.sql.Sql;
|
|
|
+import org.nutz.dao.util.cri.SimpleCriteria;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StopWatch;
|
|
@@ -999,10 +998,137 @@ public class RoleManageServiceImpl implements IRoleManageService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Page<Map> gameCountryListOfPage(RoleGameCountryParamDTO dto) {
|
|
|
+ public Map<String, List<RoleGameCountryVO>> gameCountryList(GameCountryParamDTO dto) {
|
|
|
+ //创建查询条件
|
|
|
+ Criteria criA = getSqlByQuery(dto);
|
|
|
+ String gameCountryListSql = getGameCountryListSql(criA);
|
|
|
+ Sql sql1 = Sqls.create(gameCountryListSql);
|
|
|
+ dao.execute(sql1);
|
|
|
+ sql1.setCallback(Sqls.callback.entities());
|
|
|
+ sql1.setEntity(dao.getEntity(RoleGameCountryVO.class));
|
|
|
+ dao.execute(sql1);
|
|
|
+ //查询结果
|
|
|
+ List<RoleGameCountryVO> list = sql1.getList(RoleGameCountryVO.class);
|
|
|
+ if(CollectionUtils.isNotEmpty(list)){
|
|
|
+ //以country为key,value是list分组
|
|
|
+ Map<String, List<RoleGameCountryVO>> map = list.stream().collect(Collectors.groupingBy(RoleGameCountryVO::getCs));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Page<Map> gameCountryRoleList(RoleGameCountryParamDTO dto) {
|
|
|
+ Criteria criA = getSqlByQuery(dto);
|
|
|
+ //分页对象
|
|
|
+ Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
|
|
|
+ //查询总记录数
|
|
|
+ Sql countSql = Sqls.create(getGameCountryRoleCountSql(criA));
|
|
|
+ countSql.setCallback(Sqls.callback.integer());
|
|
|
+ dao.execute(countSql);
|
|
|
+ pager.setRecordCount(countSql.getInt());
|
|
|
+ //主表添加排序条件
|
|
|
+ if (StringUtils.isBlank(dto.getSortType())) {
|
|
|
+ dto.setSortType(OrderByEnum.DESC.getOrderType());
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(dto.getSortFiled())) {
|
|
|
+ criA.getOrderBy().orderBy("role_total_amount", dto.getSortType());
|
|
|
+ } else {
|
|
|
+ criA.getOrderBy().orderBy(dto.getSortFiled(), dto.getSortType());
|
|
|
+ }
|
|
|
+ //列表sql
|
|
|
+ String gameCountryRoleListSql = getGameCountryRoleListSql(criA);
|
|
|
+ Sql sql = Sqls.create(gameCountryRoleListSql);
|
|
|
+ sql.setCallback(Sqls.callback.maps());
|
|
|
+ sql.setPager(pager);
|
|
|
+ dao.execute(sql);
|
|
|
+ //查询结果
|
|
|
+ List<Map> list = sql.getList(Map.class);
|
|
|
+ return new Page<>(list, pager);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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
|
|
|
+ """ + 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
|
|
|
+ from dm_game_order.t_game_user_role a
|
|
|
+ left join game_ads.ads_role_amount b on a.role_id = b.role_id) a
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Criteria getSqlByQuery(RoleGameCountryParamDTO dto) {
|
|
|
+ Criteria cri = Cnd.cri();
|
|
|
+ if(StringUtils.isNotEmpty(dto.getCountry())){
|
|
|
+ cri.where().andEquals("country",dto.getCountry());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(dto.getServerId())){
|
|
|
+ cri.where().andEquals("server_id",dto.getServerId());
|
|
|
+ }
|
|
|
+ cri.where().andInList("game_id", Arrays.asList(35L,36L,10035L));
|
|
|
+ return cri;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Criteria getSqlByQuery(GameCountryParamDTO dto) {
|
|
|
+ Criteria criA = Cnd.cri();
|
|
|
+ //如果帮派为空就取4个帮派
|
|
|
+ if(CollectionUtils.isEmpty(dto.getGameCountryList())){
|
|
|
+ String countryListSql = getCountryListSql();
|
|
|
+ Sql sql = Sqls.create(countryListSql);
|
|
|
+ sql.setCallback(Sqls.callback.strList());
|
|
|
+ dao.execute(sql);
|
|
|
+ List<String> list = sql.getList(String.class);
|
|
|
+ if(CollectionUtils.isNotEmpty(list)){
|
|
|
+ criA.where().andInStrList("cs", list);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ criA.where().andInStrList("country", dto.getGameCountryList());
|
|
|
+ }
|
|
|
+ return criA;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getGameCountryListSql(Criteria criA) {
|
|
|
+ return """
|
|
|
+ select country,
|
|
|
+ country_level,
|
|
|
+ sum(role_total_amount) as role_total_amount,
|
|
|
+ count(1) as role_count,
|
|
|
+ sum(active) as active_count,
|
|
|
+ server_id,
|
|
|
+ ANY_VALUE(cs) cs
|
|
|
+ from (select a.country,
|
|
|
+ IFNULL(c.role_total_amount, 0) as role_total_amount,
|
|
|
+ if(b.role_level <= 13, 1, 0) 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 (
|
|
|
+ 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)
|
|
|
+ and dt = Date(NOW()) ) d on b.role_id = d.role_id and d.num = 1
|
|
|
+ ) a
|
|
|
+ """+criA+"""
|
|
|
+ group by country_level,country,server_id order by role_count desc
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getCountryListSql() {
|
|
|
+ return """
|
|
|
+ select concat(country,',',server_id) from dm_game_order.t_game_user_role where country is not null and country != '' and country !='null' and game_id in(35,36,1003) group by country,server_id order by count(role_id) desc limit 4;
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
private String getIpInfoListSql(Criteria criA) {
|
|
|
return """
|
|
|
WITH
|