Parcourir la source

:feat:1、游戏每月留存 2、游戏每月留存总计

zhangxianyu il y a 3 mois
Parent
commit
8bbae8230f

+ 1 - 1
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/controller/GameDataController.java

@@ -140,7 +140,7 @@ public class GameDataController {
     }
 
     @ApiOperation(value = "留存数据-月")
-//    @PreAuthorize(permissionKey = "gameData:activeDay:activeMonth")
+    @PreAuthorize(permissionKey = "gameData:activeDay:activeMonth")
     @PostMapping("/activeData/month")
     public ResultVO<Page<ActiveDataMonthVO>> getActiveDataMonth(@RequestBody ActiveDataDayDTO dto) {
         return ResultVO.ok(activeDataService.getActiveDataMonth(dto));

+ 20 - 11
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/IActiveDataServiceImpl.java

@@ -222,7 +222,7 @@ public class IActiveDataServiceImpl implements IActiveDataService {
         //解析ActiveDataTotalVO的映射
         Map<String, Field> fieldTotalMap = new HashMap<>();
         List<Field> dayNTotalFieldList = new ArrayList<>();
-        Class<?> tempTotalClazz = ActiveDataTotalVO.class;
+        Class<?> tempTotalClazz = ActiveDataMonthTotalVO.class;
         while (tempTotalClazz != null) {
             Field[] fields = tempTotalClazz.getDeclaredFields();
             for (Field field : fields) {
@@ -1049,9 +1049,9 @@ public class IActiveDataServiceImpl implements IActiveDataService {
 
     @Override
     public Page<ActiveDataMonthVO> getActiveDataMonth(ActiveDataDayDTO dto) {
-//        com.github.sd4324530.jtuple.Tuple2<List<Long>, List<Long>> poerInfo = dataPowerComponent.getPowerInfo();
-//        List<Long> userGameIds = dto.getGameId() == null ? poerInfo.second : dto.getGameId();
-        List<Long> userGameIds = new ArrayList<>();
+        com.github.sd4324530.jtuple.Tuple2<List<Long>, List<Long>> poerInfo = dataPowerComponent.getPowerInfo();
+        List<Long> userGameIds = dto.getGameId() == null ? poerInfo.second : dto.getGameId();
+//        List<Long> userGameIds = dto.getGameId();
 
         //默认查询的字段及表名
         String gameColumn = "game_id";
@@ -1262,7 +1262,7 @@ public class IActiveDataServiceImpl implements IActiveDataService {
     public ActiveDataMonthTotalVO getActiveMonthDataTotal(ActiveDataTotalDTO dto) {
         com.github.sd4324530.jtuple.Tuple2<List<Long>, List<Long>> poerInfo = dataPowerComponent.getPowerInfo();
         List<Long> gameIds = dto.getGameId() == null ? poerInfo.second : dto.getGameId();
-
+//        List<Long> gameIds = dto.getGameId();
         //默认查询字段
         String gameColumn = "game_id";
         String classifyColumn = "game_classify";
@@ -1382,38 +1382,47 @@ public class IActiveDataServiceImpl implements IActiveDataService {
      * @return String : 查询出来的结果 第n月的 充值金额/充值人数
      */
     private String activeDataMonthTotalSql(String type, String tableName) {
+        String regType = new String(type);
+        if ("buy".equals(type)) {
+            regType = regType + "_";
+        } else if ("nature".equals(type)) {
+            regType = regType + "_";
+        } else {
+            regType = "";
+        }
         //修改类型,与数据库字段名相匹配
         if ("buy".equals(type)) {
             type = type + "_";
         } else if ("nature".equals(type)) {
             type = type + "_";
         } else {
-            type = "";
+            type = "total"+"_";
         }
+
         //拼接查询条件
         StringBuilder trendDay = new StringBuilder(StringUtils.EMPTY);
         trendDay.append("SELECT ");
         if ("ads_game_active_reg_month".equals(tableName) ||
                 "game_ads_parent.ads_game_active_reg_month_parent".equals(tableName)) {
             //m1-m23数据
-            for (int month = 1; month < 23; month++) {
+            for (int month = 1; month < 24; month++) {
                 trendDay.append("""
                         CONCAT( SUM(CAST(SPLIT_PART(%sm%s, '/', 1) AS BIGINT(20))), '/',
                                 SUM(IF(DATE_ADD(dt, INTERVAL %s month) <= Local.now(), %sreg_num, 0))
                         ) AS m%s,
-                           """.formatted(type, month, month, type, month));
+                           """.formatted(type, month, month, regType, month));
             }
             //m24数据
             trendDay.append("""
                     CONCAT( SUM(CAST(SPLIT_PART(%sm24, '/', 1) AS BIGINT(20))), '/',
                             SUM(IF(DATE_ADD(dt, INTERVAL 24 month) <= Local.now(), %sreg_num, 0))
                     ) AS m24
-                       """.formatted(type, type));
+                       """.formatted(type, regType));
         } else if ("ads_game_active_order_month".equals(tableName) ||
                 "game_ads_parent.ads_game_active_role_month_parent".equals(tableName)) {
 
             //m1-m23数据
-            for (int month = 1; month < 23; month++) {
+            for (int month = 1; month < 24; month++) {
                 trendDay.append("""
                         CONCAT( SUM(CAST(SPLIT_PART(%sm%s, '/', 1) AS BIGINT(20))), '/',
                                 SUM(CAST(SPLIT_PART(%sm%s, '/', 2) AS BIGINT(20))), '/',
@@ -1432,7 +1441,7 @@ public class IActiveDataServiceImpl implements IActiveDataService {
                        """.formatted(type, type, type, type));
         } else {
             //m1-m23数据
-            for (int month = 1; month < 23; month++) {
+            for (int month = 1; month < 24; month++) {
                 trendDay.append("""
                         CONCAT( SUM(CAST(SPLIT_PART(%sm%s, '/', 1) AS BIGINT(20))), '/',
                                 SUM(CAST(SPLIT_PART(%sm%s, '/', 2) AS BIGINT(20))), '/',