Browse Source

:fix:流水监控需求变更,增加聚合,取消部分回显字段

zhangxianyu 1 year ago
parent
commit
75e787a8e3

+ 4 - 15
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/pojo/vo/FlowMonitorVO.java

@@ -20,11 +20,7 @@ public class FlowMonitorVO implements Serializable {
      */
     @ApiModelProperty(value = "SDK类型")
     private String sourceSystem;
-    /**
-     * 投手名称
-     */
-    @ApiModelProperty(value = "投手名称")
-    private String pitcherName;
+
 
     /**
      * 消耗开始时间
@@ -112,15 +108,8 @@ public class FlowMonitorVO implements Serializable {
     private Double costCount = 0.0;
 
     /**
-     * 游戏名称
+     * 昨日充值总数
      */
-    @ApiModelProperty(value = "游戏名称")
-    private String gameName;
-
-    /**
-     * 渠道名称
-     */
-    @ApiModelProperty(value = "渠道名称")
-    private String agentName;
-
+    @ApiModelProperty(value = "yesterday_amount")
+    private Double yesterdayAmount = 0.0;
 }

+ 97 - 100
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/GameDataServiceImpl.java

@@ -5325,112 +5325,109 @@ public class GameDataServiceImpl implements IGameDataService {
      */
     public String flowMonitorSql(FlowMonitorDTO dto, Criteria cri, Criteria criCost, String costTable, String orderTable) {
         String gameColumn = "game_id  ";
-        String gameNameColumn = "game_name ";
         if (dto.getGameDimension() != 1) {
             gameColumn = "parent_game_id ";
-            gameNameColumn = "parent_game_name ";
         }
 
         String sql =
-                """
-                        SELECT 
-                              s.source_system,-- SDK类型
-                              s.minDay cost_begin_date, -- 消耗开始时间
-                              s.maxDay cost_end_date, -- 消耗结束时间
-                              s.day as order_date, -- 订单时间
-                              s.ten_amount, -- 10点充值
-                              s.ten_rate, -- 10点环比
-                              IFNULL(s.ten_recovery,0), -- 10点回报率
-                              s.fourteen_amount,  -- 14点充值
-                              s.fourteen_rate, -- 14点环比
-                              IFNULL(s.fourteen_recovery,0), -- 14点回报率  
-                              s.seventeen_amount, -- 17点充值
-                              s.seventeen_rate, -- 17点环比
-                              IFNULL(s.seventeen_recovery,0), -- 17点回报率
-                              s.twentyfour_amount, -- 24点充值
-                              s.twentyfour_rate, -- 24点环比
-                              IFNULL(s.twentyfour_recovery,0), -- 24点回报率
-                              IFNULL(s.costCount,0) as cost_count , -- 消耗总计
-                              s.pitcher_id, -- 投手id
-                              s.pitcher_name, -- 投手名称
-                              s.agent_id,
-                              s.account_id,
-                              s.agent_name,
-                              s. """ + gameNameColumn +
-                        """
-                              , s. """ + gameColumn +
-                        """
-                                      -- 游戏id
-                                     
-                                from (          
-                                     SELECT
-                                          a.source_system,
-                                          b.minDay,
-                                          b.maxDay,
-                                          a.day,
-                                          a.ten_amount, 
-                                          ROUND(a.ten_rate,2)*100 as ten_rate,  -- 10点环比
-                                          ROUND(IF(ten_amount>0,ten_amount/b.costCount,ten_amount),2)*100 as ten_recovery, -- 10点回报率(充值/消耗)
-                                          a.fourteen_amount, -- 14点充值
-                                          ROUND(a.fourteen_rate,2)*100 as fourteen_rate,  -- 14点环比
-                                          ROUND(IF(fourteen_amount>0,fourteen_amount/b.costCount,fourteen_amount),2)*100 as fourteen_recovery, -- 14点回报率
-                                          a.seventeen_amount, -- 17点充值
-                                          ROUND(a.seventeen_rate,2)*100 as seventeen_rate,  -- 17点环比
-                                          ROUND(IF(seventeen_amount>0,seventeen_amount/b.costCount,seventeen_amount),2)*100 as seventeen_recovery, -- 17点回报率
-                                          a.twentyfour_amount, -- 24点充值
-                                          ROUND(a.twentyfour_rate,2)*100 as twentyfour_rate,  -- 24点环比
-                                          ROUND(IF(twentyfour_amount>0,twentyfour_amount/b.costCount,twentyfour_amount),2)*100 as twentyfour_recovery, -- 24点回报率
-                                          b.costCount,
-                                          a.pitcher_id, -- 投手id
-                                          a.pitcher_name, -- 投手名称
-                                          a.agent_id,
-                                          a.account_id,
-                                          a.agent_name,
-                                          a.
-                                          """ + gameNameColumn + """
-                                          , a. """ + gameColumn + """
+             """
+                 select
+                        cost_begin_date, -- 消耗开始时间
+                        cost_end_date, -- 消耗结束时间
+                        order_date,
+                        source_system,
+                        ten_amount, -- 10点充值金额
+                        ROUND(IF(ten_amount>0,ten_amount/cost_count,cost_count),2)*100 as ten_recovery, -- 10点回报率(充值/消耗)
+                        ROUND(IF(cost_count>0,ten_amount/yesterday_amount,cost_count),2)*100 as ten_rate, -- 10点环比(前一天充值总额/消耗)
+                        fourteen_amount, -- 14点充值金额
+                        ROUND(IF(cost_count>0,fourteen_amount/cost_count,cost_count),2)*100 as fourteen_recovery, -- 14点回报率(充值/消耗)
+                        ROUND(IF(cost_count>0,fourteen_amount/yesterday_amount,cost_count),2)*100 as fourteen_rate, -- 14点环比(前一天充值总额/消耗)
+                        seventeen_amount, -- 17点充值金额
+                        ROUND(IF(cost_count>0,seventeen_amount/cost_count,cost_count),2)*100 as seventeen_recovery, -- 17点回报率(充值/消耗)
+                        ROUND(IF(cost_count>0,seventeen_amount/yesterday_amount,cost_count),2)*100 as seventeen_rate, -- 17点环比(前一天充值总额/消耗)
+                        twentyfour_amount, -- 24点充值金额
+                        ROUND(IF(cost_count>0,twentyfour_amount/cost_count,cost_count),2)*100 as twentyfour_recovery, -- 24点回报率(充值/消耗)
+                        ROUND(IF(cost_count>0,twentyfour_amount/yesterday_amount,cost_count),2)*100 as twentyfour_rate, -- 17点环比(前一天充值总额/消耗)
+                        cost_count, -- 消耗总计
+                        yesterday_amount -- 昨日充值总额
+                  from (
+                               SELECT
+                                      order_date,
+                                      ANY_VALUE(cost_begin_date) cost_begin_date , -- 消耗开始时间
+                                      ANY_VALUE(cost_end_date) cost_end_date, -- 消耗结束时间
+                                      sum(ten_amount) ten_amount,
+                                      sum(fourteen_amount) fourteen_amount ,
+                                      sum(seventeen_amount) seventeen_amount,
+                                      sum(twentyfour_amount) twentyfour_amount,
+                                      any_value(cost_count) cost_count,
+                                      any_value(source_system) source_system,
+                                      sum(yesterday_amount) yesterday_amount
+                                from (
+                                           SELECT
+                                                 s.source_system,-- SDK类型
+                                                 s.minDay cost_begin_date, -- 消耗开始时间
+                                                 s.maxDay cost_end_date, -- 消耗结束时间
+                                                 s.day as order_date, -- 订单时间
+                                                 s.ten_amount, -- 10点充值
+                                                 s.fourteen_amount,  -- 14点充值
+                                                 s.seventeen_amount, -- 17点充值
+                                                 s.twentyfour_amount, -- 24点充值
+                                                 IFNULL(s.costCount,0) as cost_count , -- 消耗总计
+                                                 s.yesterday_amount   -- 昨日充值总额
+                                           from (
+                                                    SELECT
+                                                            a.source_system,
+                                                            b.minDay,
+                                                            b.maxDay,
+                                                            a.day,
+                                                            a.ten_amount,
+                                                            a.fourteen_amount, -- 14点充值
+                                                            a.seventeen_amount, -- 17点充值
+                                                            a.twentyfour_amount, -- 24点充值
+                                                            b.costCount,
+                                                            a.pitcher_id, -- 投手id
+                                                            a.agent_id,
+                                                            a.account_id,
+                                                            a.yesterday_amount,
+                                                            a.""" + gameColumn + """
                                                  
-                        FROM
-                        		(
-                        			SELECT
-                        				day,
-                        				source_system,
-                        				ten_amount,
-                                        fourteen_amount,
-                                        seventeen_amount,
-                                        twentyfour_amount,
-                                        ten_rate,
-                                        fourteen_rate,
-                                        seventeen_rate,
-                                        twentyfour_rate,
-                                        pitcher_id,
-                                        pitcher_name,   
-                                        agent_id,
-                                        account_id,
-                                        agent_name,
-                                        """ + gameNameColumn +"""
-                         , """
-                        + gameColumn +
-                        """
-                                    FROM      
-                                """ + orderTable +
-                        """
-                                	) a
-                                LEFT JOIN (
-                                	SELECT
-                                		source_system,
-                                		sum(cost) costCount,
-                                		max(day) maxDay,
-                                		min(day) minDay
-                                	FROM  
-                                	""" + costTable +
-                        """
-                                """ + criCost +
-                        """
-                                            		GROUP BY source_system
-                                            	) b on a.source_system = b.source_system
-                                )s   
-                                """ + cri;
+                                                       FROM
+                                                      (
+                                                       SELECT
+                                                         day,
+                                                         source_system,
+                                                         ten_amount,
+                                                         fourteen_amount,
+                                                         seventeen_amount,
+                                                         twentyfour_amount,
+                                                         ten_rate,
+                                                         fourteen_rate,
+                                                         seventeen_rate,
+                                                         twentyfour_rate,
+                                                         pitcher_id,
+                                                         agent_id,
+                                                         account_id,
+                                                         yesterday_amount,
+                                                         """ + gameColumn + """
+                                                       FROM
+                                                         """ + orderTable + """
+                                                       ) a
+                                                             LEFT JOIN (
+                                                                    SELECT
+                                                                        source_system,
+                                                                        sum(cost) costCount,
+                                                                        max(day) maxDay,
+                                                                        min(day) minDay
+                                                                     FROM  
+                                                                        """ + costTable + """
+                                                                        """ + criCost + """
+                                                                        GROUP BY source_system
+                                            	                        ) b on a.source_system = b.source_system
+                                           )s""" + cri + """
+                                )a    group by order_date
+                                 
+                  )  aa  ORDER BY order_date DESC
+               """;
         return sql;
     }