瀏覽代碼

feat:1、游戏帮派数据列表 2、游戏帮派角色列表

zhangxianyu 1 月之前
父節點
當前提交
d96bd9c21d

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

@@ -2,6 +2,7 @@ package com.zanxiang.game.data.serve.controller;
 
 
 import com.zanxiang.erp.security.annotation.PreAuthorize;
 import com.zanxiang.erp.security.annotation.PreAuthorize;
 import com.zanxiang.game.data.serve.pojo.dto.*;
 import com.zanxiang.game.data.serve.pojo.dto.*;
+import com.zanxiang.game.data.serve.pojo.vo.RoleGameCountryVO;
 import com.zanxiang.game.data.serve.service.IRoleManageService;
 import com.zanxiang.game.data.serve.service.IRoleManageService;
 import com.zanxiang.game.data.serve.utils.Page;
 import com.zanxiang.game.data.serve.utils.Page;
 import com.zanxiang.game.module.base.ServerInfo;
 import com.zanxiang.game.module.base.ServerInfo;
@@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
 import javax.validation.Valid;
 import javax.validation.Valid;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -65,11 +67,18 @@ public class RoleManageController {
         return ResultVO.ok(roleManageService.ipInfoListOfPage(dto));
         return ResultVO.ok(roleManageService.ipInfoListOfPage(dto));
     }
     }
 
 
+    @ApiOperation(value = "游戏帮派数据列表")
+    @PreAuthorize(permissionKey = "roleManage:gameCountry:list")
+    @PostMapping("/gameCountryList")
+    public ResultVO<Map<String, List<RoleGameCountryVO>>> gameCountryList(@Valid @RequestBody GameCountryParamDTO dto) {
+        return ResultVO.ok(roleManageService.gameCountryList(dto));
+    }
+
     @ApiOperation(value = "游戏帮派角色列表")
     @ApiOperation(value = "游戏帮派角色列表")
-    @PreAuthorize(permissionKey = "roleManage:gameCountry:listOfPage")
-    @PostMapping("/gameCountry/listOfPage")
-    public ResultVO<Page<Map>> gameCountryListOfPage(@RequestBody RoleGameCountryParamDTO dto) {
-        return ResultVO.ok(roleManageService.gameCountryListOfPage(dto));
+    @PreAuthorize(permissionKey = "roleManage:gameCountryRole:list")
+    @PostMapping("/gameCountryRoleList")
+    public ResultVO<Page<Map>> gameCountryRoleList(@Valid @RequestBody RoleGameCountryParamDTO dto) {
+        return ResultVO.ok(roleManageService.gameCountryRoleList(dto));
     }
     }
 
 
 
 

+ 23 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/dto/GameCountryParamDTO.java

@@ -0,0 +1,23 @@
+package com.zanxiang.game.data.serve.pojo.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.Size;
+import java.util.List;
+
+/**
+  * @author ZhangXianyu
+  * @date 2025/2/20
+  * @description 游戏帮派查询参数
+ */
+@Data
+public class GameCountryParamDTO {
+
+   @ApiModelProperty(value = "帮派列表")
+   @Size(max = 4,message = "帮派最多选择4个")
+   private List<String> gameCountryList;
+
+
+
+}

+ 10 - 38
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/dto/RoleGameCountryParamDTO.java

@@ -4,60 +4,32 @@ import com.zanxiang.game.data.serve.pojo.base.BasePage;
 import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.Data;
 
 
-import java.time.LocalDate;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.Size;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
   * @author ZhangXianyu
   * @author ZhangXianyu
   * @date 2025/2/20
   * @date 2025/2/20
-  * @description 角色游戏帮派查询参数
+  * @description 游戏帮派查询参数
  */
  */
 @Data
 @Data
 public class RoleGameCountryParamDTO extends BasePage {
 public class RoleGameCountryParamDTO extends BasePage {
 
 
-   @ApiModelProperty(value = "玩家id")
-   private List<Long> userId;
-
-   @ApiModelProperty(value = "玩家名称")
-   private String userName;
-
-   @ApiModelProperty(value = "游戏角色id")
-   private String roleId;
-
-   @ApiModelProperty(value = "角色名称")
-   private String roleName;
-
-   @ApiModelProperty(value = "游戏id")
-   private List<Long> gameId;
-
-   @ApiModelProperty(value = "游戏名称")
-   private String gameName;
+   @ApiModelProperty(value = "帮派")
+   @NotEmpty(message = "帮派不能为空")
+   private String country;
 
 
    @ApiModelProperty(value = "区服id")
    @ApiModelProperty(value = "区服id")
-   private List<String> serverId;
-
-   @ApiModelProperty(value = "区服名称")
-   private String serverName;
+   @NotEmpty(message = "区服不能为空")
+   private String serverId;
 
 
-   @ApiModelProperty(value = "角色创建时间最小值")
-   private LocalDate createTimeMin;
+   private String sortFiled;
 
 
-   @ApiModelProperty(value = "角色创建时间最大值")
-   private LocalDate createTimeMax;
+   private String sortType;
 
 
-   @ApiModelProperty(value = "角色等级最小值")
-   private Long roleLevelMin;
 
 
-   @ApiModelProperty(value = "角色等级最大值")
-   private Long roleLevelMax;
 
 
-   @ApiModelProperty(value = "角色注册IP")
-   private String regIp;
 
 
-   @ApiModelProperty(notes = "排序字段")
-   private String sortFiled;
-
-   @ApiModelProperty(notes = "排序方式:升序asc;降序desc")
-   private String sortType;
 
 
 }
 }

+ 31 - 0
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/RoleGameCountryVO.java

@@ -0,0 +1,31 @@
+package com.zanxiang.game.data.serve.pojo.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * packageName com.zanxiang.game.data.serve.pojo.vo
+ *
+ * @author ZhangXianyu
+ * @date 2025/2/27
+ * @description TODO
+ */
+@Data
+public class RoleGameCountryVO {
+
+    private String country;
+
+    private Integer countryLevel;
+
+    private BigDecimal roleTotalAmount;
+
+    private Long roleCount;
+
+    private Long active_count;
+
+    private String serverId;
+
+    private String cs;
+
+}

+ 9 - 3
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/IRoleManageService.java

@@ -1,8 +1,7 @@
 package com.zanxiang.game.data.serve.service;
 package com.zanxiang.game.data.serve.service;
 
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.zanxiang.game.data.serve.pojo.dto.*;
 import com.zanxiang.game.data.serve.pojo.dto.*;
-import com.zanxiang.game.data.serve.pojo.vo.GameUserConfigListVO;
+import com.zanxiang.game.data.serve.pojo.vo.RoleGameCountryVO;
 import com.zanxiang.game.module.base.pojo.vo.SendMsgResultVO;
 import com.zanxiang.game.module.base.pojo.vo.SendMsgResultVO;
 import com.zanxiang.game.module.base.pojo.vo.SendMsgVO;
 import com.zanxiang.game.module.base.pojo.vo.SendMsgVO;
 import com.zanxiang.game.data.serve.utils.Page;
 import com.zanxiang.game.data.serve.utils.Page;
@@ -64,5 +63,12 @@ public interface IRoleManageService {
      * @param dto
      * @param dto
      * @return
      * @return
      */
      */
-    Page<Map> gameCountryListOfPage(RoleGameCountryParamDTO dto);
+    Map<String, List<RoleGameCountryVO>> gameCountryList(GameCountryParamDTO dto);
+
+    /**
+     * 游戏帮派角色列表
+     * @param dto
+     * @return
+     */
+    Page<Map> gameCountryRoleList(RoleGameCountryParamDTO dto);
 }
 }

+ 130 - 4
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/RoleManageServiceImpl.java

@@ -1,13 +1,12 @@
 package com.zanxiang.game.data.serve.service.impl;
 package com.zanxiang.game.data.serve.service.impl;
 
 
-import java.time.LocalDateTime;
-
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSON;
 import com.zanxiang.erp.base.ErpServer;
 import com.zanxiang.erp.base.ErpServer;
 import com.zanxiang.erp.base.rpc.ISysUserRpc;
 import com.zanxiang.erp.base.rpc.ISysUserRpc;
 import com.zanxiang.erp.security.util.SecurityUtil;
 import com.zanxiang.erp.security.util.SecurityUtil;
 import com.zanxiang.game.data.serve.pojo.dto.*;
 import com.zanxiang.game.data.serve.pojo.dto.*;
 import com.zanxiang.game.data.serve.pojo.enums.OrderByEnum;
 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.service.IRoleManageService;
 import com.zanxiang.game.data.serve.utils.Page;
 import com.zanxiang.game.data.serve.utils.Page;
 import com.zanxiang.game.module.base.ServerInfo;
 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.pojo.vo.SendMsgVO;
 import com.zanxiang.game.module.base.rpc.ICPSendMsgRpc;
 import com.zanxiang.game.module.base.rpc.ICPSendMsgRpc;
 import com.zanxiang.game.module.base.util.PageUtil;
 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.exception.BaseException;
 import com.zanxiang.module.util.pojo.ResultVO;
 import com.zanxiang.module.util.pojo.ResultVO;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
@@ -31,6 +29,7 @@ import org.nutz.dao.Sqls;
 import org.nutz.dao.pager.Pager;
 import org.nutz.dao.pager.Pager;
 import org.nutz.dao.sql.Criteria;
 import org.nutz.dao.sql.Criteria;
 import org.nutz.dao.sql.Sql;
 import org.nutz.dao.sql.Sql;
+import org.nutz.dao.util.cri.SimpleCriteria;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StopWatch;
 import org.springframework.util.StopWatch;
@@ -999,10 +998,137 @@ public class RoleManageServiceImpl implements IRoleManageService {
     }
     }
 
 
     @Override
     @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;
         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) {
     private String getIpInfoListSql(Criteria criA) {
         return """
         return """
                     WITH
                     WITH