ソースを参照

Merge remote-tracking branch 'origin/package' into package

bilingfeng 1 年間 前
コミット
421e8342fe

+ 1 - 1
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/AccountAgentDayServiceImpl.java

@@ -1313,7 +1313,7 @@ public class AccountAgentDayServiceImpl implements IAccountAgentDayService {
                          CONCAT(SUM(CAST(SPLIT_PART(amount_sum , '/', 1) AS DECIMAL(10, 2))),'/',SUM(CAST(SPLIT_PART(amount_sum, '/', 6) AS DECIMAL(10, 2))),'/',SUM(CAST(SPLIT_PART(amount_sum, '/', 2) AS BIGINT))) AS trend_total,
                     round(if(sum(register_num) > 0, sum(first_new_user_amount_num) / sum(register_num), 0), 4) as first_recharge_rate,
                     round(if(sum(register_num) > 0, sum(buy_new_user_total_amount_num) / sum(register_num), 0), 4) as buy_user_recharge_rate,
-                    round(if(sum(register_num) > 0, sum(first_new_user_amount_num) / sum(amount_num), 0), 4) as new_user_recharge_rate,
+                    round(if(sum(amount_num) > 0, sum(first_new_user_amount_num) / sum(amount_num), 0), 4) as new_user_recharge_rate,
                     round(if(sum(first_new_user_amount_count) > 0, sum(first_new_user_amount) / sum(first_new_user_amount_count), 0), 4) as avg_first_user_recharge,
                     round(if(sum(buy_new_user_total_amount_count) > 0, sum(buy_new_user_total_amount) / sum(buy_new_user_total_amount_count), 0), 4) as avg_buy_user_recharge,
                     round(if(sum(amount_count) > 0, sum(amount) / sum(amount_count), 0), 4) as avg_show_user_recharge,

+ 31 - 15
game-data/game-data-serve/src/main/java/com/zanxiang/game/data/serve/service/impl/GameDataServiceImpl.java

@@ -3185,13 +3185,6 @@ public class GameDataServiceImpl implements IGameDataService {
             dto.setRegisteredBeginDate(LocalDate.now());
             dto.setRegisteredEndDate(LocalDate.now());
         }
-        //如果没有排序条件给默认值
-        if (StringUtils.isBlank(dto.getSortFiled())) {
-            dto.setSortFiled("cost_date");
-        }
-        if (StringUtils.isBlank(dto.getSortType())) {
-            dto.setSortType(OrderByEnum.DESC.getOrderType());
-        }
         //默认查询总数据
         if (StringUtils.isBlank(dto.getTableTypes())) {
             dto.setTableTypes("total");
@@ -3216,7 +3209,16 @@ public class GameDataServiceImpl implements IGameDataService {
         }
         //拼接排序条件
         Criteria orderByCri = Cnd.cri();
-        orderByCri.getOrderBy().orderBy(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()), dto.getSortType());
+        //如果没有排序条件给默认值
+        if (StringUtils.isBlank(dto.getSortType())) {
+            dto.setSortType(OrderByEnum.DESC.getOrderType());
+        }
+        if (StringUtils.isBlank(dto.getSortFiled())) {
+            orderByCri.getOrderBy().orderBy("cost_date", dto.getSortType());
+            orderByCri.getOrderBy().orderBy("cost", dto.getSortType());
+        } else {
+            orderByCri.getOrderBy().orderBy(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()), dto.getSortType());
+        }
         //创建sql查询数据
         Sql sql = Sqls.create(getFirstNewUserAgainByTableTypesSql(dto.getTableTypes(), cri) + orderByCri);
         //设置自定义回传类型
@@ -3364,6 +3366,19 @@ public class GameDataServiceImpl implements IGameDataService {
                     .append(dto.getSourceSystem())
                     .append("'");
         }
+        //拼接排序条件
+        //如果没有排序条件给默认值
+        if (StringUtils.isBlank(dto.getSortType())) {
+            dto.setSortType(OrderByEnum.DESC.getOrderType());
+        }
+        if (StringUtils.isBlank(dto.getSortFiled())) {
+            queryStr.append(" ORDER BY today_total_amount DESC, player_id DESC");
+        } else {
+            queryStr.append("""
+                     ORDER BY %s %s, player_id DESC
+                    """.formatted(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()),
+                    dto.getSortType()));
+        }
         //得到用户id数组
         Long[] usersId = againTrendVO.getUsersId();
         //查询具体的数据
@@ -3379,8 +3394,9 @@ public class GameDataServiceImpl implements IGameDataService {
                 FROM
                     game_ads.ads_player_recharge_ranking
                 WHERE player_id IN (@usersId)
-                and dt = DATE_ADD(reg_user_time,
-                """ + queryStr);
+                and dt = DATE_ADD(DATE(reg_user_time),
+                """ + queryStr
+                );
         //设置参数
         if ("total".equals(timeType)) {
             userDetilsSql.vars().set("amount", "total_amount");
@@ -3430,7 +3446,7 @@ public class GameDataServiceImpl implements IGameDataService {
         }
         //拼接查询时间
         if (dto.getRegisteredBeginDate() != null && dto.getRegisteredEndDate() != null) {
-            findUsersCri.where().andBetween("reg_user_time", dto.getRegisteredBeginDate(), dto.getRegisteredEndDate());
+            findUsersCri.where().andBetween("DATE(reg_user_time)", dto.getRegisteredBeginDate(), dto.getRegisteredEndDate());
         }
         //不同数据类型 查询条件不同 buy、nature、total
         if ("buy".equals(dto.getTableTypes())) {
@@ -3476,7 +3492,7 @@ public class GameDataServiceImpl implements IGameDataService {
         }
         //拼接查询时间
         if (dto.getRegisteredBeginDate() != null && dto.getRegisteredEndDate() != null) {
-            findUsersCri.where().andBetween("reg_user_time", dto.getRegisteredBeginDate(), dto.getRegisteredEndDate());
+            findUsersCri.where().andBetween("DATE(reg_user_time)", dto.getRegisteredBeginDate(), dto.getRegisteredEndDate());
         }
         //不同数据类型 查询条件不同 buy、nature、total
         if ("buy".equals(dto.getTableTypes())) {
@@ -6122,8 +6138,8 @@ public class GameDataServiceImpl implements IGameDataService {
                     game_ads.ads_player_recharge_ranking
                 """ + cri +
                 """
-                    AND dt = reg_user_time
-                GROUP BY reg_game_id, reg_user_time
+                    AND dt = DATE(reg_user_time)
+                GROUP BY reg_game_id, DATE(reg_user_time)
                         """;
     }
 
@@ -6140,7 +6156,7 @@ public class GameDataServiceImpl implements IGameDataService {
                     game_ads.ads_player_recharge_ranking
                 """ + cri +
                 """
-                    AND dt = reg_user_time
+                    AND dt = DATE(reg_user_time)
                 """;
     }
 

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

@@ -1089,7 +1089,7 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
                 		MAX(classify) as classify,
                 		SUM(today_cost) as today_cost,
                 		SUM(show_count) as show_count,
-                		round(if(SUM(show_count) > 0, SUM(today_cost) / SUM(show_count), 0), 2) as thousand_display_price,
+                		round(if(SUM(show_count) > 0, SUM(today_cost) * 1000 / SUM(show_count), 0), 2) as thousand_display_price,
                 		SUM(click_count) as click_count,
                 		round(if(SUM(click_count) > 0, SUM(today_cost) / SUM(click_count), 0), 2) as avg_click_cost,
                 		round(if(SUM(show_count) > 0, SUM(click_count) / SUM(show_count), 0), 4) as ctr,
@@ -1216,7 +1216,7 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
                 SELECT
                     IFNULL(SUM(today_cost), 0) as today_cost,
                 	IFNULL(SUM(show_count), 0) as show_count,
-                	round(if(SUM(show_count) > 0, SUM(today_cost) / SUM(show_count), 0), 2) as thousand_display_price,
+                	round(if(SUM(show_count) > 0, SUM(today_cost) * 1000 / SUM(show_count), 0), 2) as thousand_display_price,
                 	IFNULL(SUM(click_count), 0) as click_count,
                 	round(if(SUM(click_count) > 0, SUM(today_cost) / SUM(click_count), 0), 2) as avg_click_cost,
                 	round(if(SUM(show_count) > 0, SUM(click_count) / SUM(show_count), 0), 4) as ctr,
@@ -1487,7 +1487,7 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
                 		MAX(classify) as classify,
                 		SUM(today_cost) as today_cost,
                 		SUM(show_count) as show_count,
-                		round(if(SUM(show_count) > 0, SUM(today_cost) / SUM(show_count), 0), 2) as thousand_display_price,
+                		round(if(SUM(show_count) > 0, SUM(today_cost) * 1000 / SUM(show_count), 0), 2) as thousand_display_price,
                 		SUM(click_count) as click_count,
                 		round(if(SUM(click_count) > 0, SUM(today_cost) / SUM(click_count), 0), 2) as avg_click_cost,
                 		round(if(SUM(show_count) > 0, SUM(click_count) / SUM(show_count), 0), 4) as ctr,
@@ -1614,7 +1614,7 @@ public class PromotionDayServiceImpl implements IAdsPromotionDayService {
                 SELECT
                     IFNULL(SUM(today_cost), 0) as today_cost,
                 	IFNULL(SUM(show_count), 0) as show_count,
-                	round(if(SUM(show_count) > 0, SUM(today_cost) / SUM(show_count), 0), 2) as thousand_display_price,
+                	round(if(SUM(show_count) > 0, SUM(today_cost) * 1000 / SUM(show_count), 0), 2) as thousand_display_price,
                 	IFNULL(SUM(click_count), 0) as click_count,
                 	round(if(SUM(click_count) > 0, SUM(today_cost) / SUM(click_count), 0), 2) as avg_click_cost,
                 	round(if(SUM(show_count) > 0, SUM(click_count) / SUM(show_count), 0), 4) as ctr,