|
@@ -657,10 +657,10 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
gameDataDayTotalsql = Sqls.create(gameDataDayTotalSqlForSuper(dto.getTableTypes()) + cri);
|
|
|
} else if (dto.getGameDimension() == 2) {
|
|
|
//父游戏维度
|
|
|
- gameDataDayTotalsql = Sqls.create(gameDataDayTotalSql(dto.getTableTypes(), "game_ads_parent.ads_game_day_parent") + cri);
|
|
|
+ gameDataDayTotalsql = Sqls.create(gameDataDayTotalSqlParent(dto.getTableTypes()) + cri);
|
|
|
} else {
|
|
|
//子游戏维度
|
|
|
- gameDataDayTotalsql = Sqls.create(gameDataDayTotalSql(dto.getTableTypes(), "ads_game_day") + cri);
|
|
|
+ gameDataDayTotalsql = Sqls.create(gameDataDayTotalSqlSubgame(dto.getTableTypes()) + cri);
|
|
|
}
|
|
|
//设置自定义回传对象
|
|
|
gameDataDayTotalsql.setCallback(Sqls.callback.entity());
|
|
@@ -716,22 +716,22 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
if (CollectionUtils.isNotEmpty(gameIds)) {
|
|
|
if (dto.getGameDimension() == 1L) {
|
|
|
//拼接游戏id
|
|
|
- cri.where().andInList("game_id", gameIds);
|
|
|
+ cri.where().andInList("a.game_id", gameIds);
|
|
|
} else if (dto.getGameDimension() == 2L) {
|
|
|
//拼接游戏id
|
|
|
- cri.where().andInList("parent_game_id", gameIds);
|
|
|
+ cri.where().andInList("a.parent_game_id", gameIds);
|
|
|
} else {
|
|
|
//拼接游戏id
|
|
|
- cri.where().andInList("super_game_id", gameIds);
|
|
|
+ cri.where().andInList("a.super_game_id", gameIds);
|
|
|
}
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
//拼接SDK来源
|
|
|
- cri.where().andEquals("source_system", dto.getSourceSystem());
|
|
|
+ cri.where().andEquals("a.source_system", dto.getSourceSystem());
|
|
|
}
|
|
|
if (dto.getRegisteredBeginDate() != null && dto.getRegisteredEndDate() != null) {
|
|
|
//拼接查询时间
|
|
|
- cri.where().andBetween("dt", dto.getRegisteredBeginDate(), dto.getRegisteredEndDate());
|
|
|
+ cri.where().andBetween("a.dt", dto.getRegisteredBeginDate(), dto.getRegisteredEndDate());
|
|
|
}
|
|
|
|
|
|
return cri;
|
|
@@ -1905,28 +1905,30 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
|
|
|
for (Tuple2<Field, Field> dayNTotalFieldMap : dayNTotalFieldMapList) {
|
|
|
try {
|
|
|
- //得到需要计算的值
|
|
|
- String[] temps = ((String) dayNTotalFieldMap.getT1().get(vo)).split("/");
|
|
|
- //dn的金额总计
|
|
|
- BigDecimal dNAmount = new BigDecimal(temps[0]);
|
|
|
- //d1-dn的金额总计
|
|
|
- BigDecimal d1ToDNTotalAmount = new BigDecimal(temps[1]);
|
|
|
- //d1-dn的消耗总计(排除了未到时间的cost)
|
|
|
- BigDecimal d1ToDNTotalCost = new BigDecimal(temps[3]);
|
|
|
- //d1的金额总计(排除了未到时间的d1)
|
|
|
- BigDecimal d1Amount = new BigDecimal(temps[4]);
|
|
|
- //赋值
|
|
|
- dayNTotalFieldMap.getT2().set(vo, RechargeTrendVO.builder()
|
|
|
- .rechargeMoney(dNAmount)
|
|
|
- .rechargeUserCount(Long.valueOf(temps[2]))
|
|
|
- .increase(d1ToDNTotalCost.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
|
|
|
- dNAmount.divide(d1ToDNTotalCost, 4, RoundingMode.HALF_UP))
|
|
|
- .back(d1ToDNTotalCost.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
|
|
|
- d1ToDNTotalAmount.divide(d1ToDNTotalCost, 4, RoundingMode.HALF_UP))
|
|
|
- .multiples(d1Amount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
|
|
|
- d1ToDNTotalAmount.divide(d1Amount, 4, RoundingMode.HALF_UP))
|
|
|
- .build());
|
|
|
-
|
|
|
+ String str = (String) dayNTotalFieldMap.getT1().get(vo);
|
|
|
+ if(StringUtils.isNotEmpty(str)){
|
|
|
+ //得到需要计算的值
|
|
|
+ String[] temps = str.split("/");
|
|
|
+ //dn的金额总计
|
|
|
+ BigDecimal dNAmount = new BigDecimal(temps[0]);
|
|
|
+ //d1-dn的金额总计
|
|
|
+ BigDecimal d1ToDNTotalAmount = new BigDecimal(temps[1]);
|
|
|
+ //d1-dn的消耗总计(排除了未到时间的cost)
|
|
|
+ BigDecimal d1ToDNTotalCost = new BigDecimal(temps[3]);
|
|
|
+ //d1的金额总计(排除了未到时间的d1)
|
|
|
+ BigDecimal d1Amount = new BigDecimal(temps[4]);
|
|
|
+ //赋值
|
|
|
+ dayNTotalFieldMap.getT2().set(vo, RechargeTrendVO.builder()
|
|
|
+ .rechargeMoney(dNAmount)
|
|
|
+ .rechargeUserCount(Long.valueOf(temps[2]))
|
|
|
+ .increase(d1ToDNTotalCost.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
|
|
|
+ dNAmount.divide(d1ToDNTotalCost, 4, RoundingMode.HALF_UP))
|
|
|
+ .back(d1ToDNTotalCost.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
|
|
|
+ d1ToDNTotalAmount.divide(d1ToDNTotalCost, 4, RoundingMode.HALF_UP))
|
|
|
+ .multiples(d1Amount.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
|
|
|
+ d1ToDNTotalAmount.divide(d1Amount, 4, RoundingMode.HALF_UP))
|
|
|
+ .build());
|
|
|
+ }
|
|
|
} catch (IllegalAccessException e) {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
@@ -3232,7 +3234,9 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
round(IF(SUM(buy_reg_num) >0, SUM(buy_role_num) / SUM(buy_reg_num), 0), 4) role_num_rate,
|
|
|
round(IF(SUM(buy_reg_num) >0, SUM(buy_new_user_total_role_num) / SUM(buy_reg_num), 0), 4) new_user_total_role_num_rate
|
|
|
FROM
|
|
|
- """ + tableName;
|
|
|
+ """ + tableName + """
|
|
|
+ as a
|
|
|
+ """;
|
|
|
} else if ("nature".equals(tableType)) {
|
|
|
return """
|
|
|
SELECT
|
|
@@ -3336,19 +3340,19 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 游戏每日数据总计sql-子游戏、父游戏维度 (新)
|
|
|
+ * 游戏每日数据总计sql-子游戏 (新)
|
|
|
*
|
|
|
- * @param tableType 查询的类型
|
|
|
+ * @param tableType 查询类型
|
|
|
* @return String
|
|
|
*/
|
|
|
- private String gameDataDayTotalSql2(String tableType, String tableName) {
|
|
|
+ private String gameDataDayTotalSqlSubgame(String tableType) {
|
|
|
if ("buy".equals(tableType)) {
|
|
|
return """
|
|
|
SELECT
|
|
|
IFNULL(SUM(cost), 0) cost,
|
|
|
IFNULL(SUM(buy_reg_num), 0) reg_num,
|
|
|
"""
|
|
|
- + amountDay("buy_") +
|
|
|
+ + amountDayStr("buy_") +
|
|
|
"""
|
|
|
IFNULL(SUM(buy_first_new_user_amount_count), 0) first_new_user_amount_count,
|
|
|
IFNULL(SUM(buy_first_new_user_amount_num), 0) first_new_user_amount_num,
|
|
@@ -3389,15 +3393,18 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
round(IF(SUM(buy_reg_num) >0, SUM(buy_first_role_num) / SUM(buy_reg_num), 0), 4) first_role_num_rate,
|
|
|
round(IF(SUM(buy_reg_num) >0, SUM(buy_role_num) / SUM(buy_reg_num), 0), 4) role_num_rate,
|
|
|
round(IF(SUM(buy_reg_num) >0, SUM(buy_new_user_total_role_num) / SUM(buy_reg_num), 0), 4) new_user_total_role_num_rate
|
|
|
- FROM
|
|
|
- """ + tableName;
|
|
|
+ FROM game_ads.ads_game_day as a
|
|
|
+ LEFT JOIN game_dw.dw_game_amount_day_buy
|
|
|
+ b on a.source_system = b.source_system
|
|
|
+ and a.dt = b.dt and a.game_id = b.buy_game_id
|
|
|
+ """;
|
|
|
} else if ("nature".equals(tableType)) {
|
|
|
return """
|
|
|
SELECT
|
|
|
IFNULL(SUM(cost), 0) cost,
|
|
|
IFNULL(SUM(nature_reg_num), 0) reg_num,
|
|
|
"""
|
|
|
- + amountDay("nature_") +
|
|
|
+ + amountDayStr("nature_") +
|
|
|
"""
|
|
|
IFNULL(SUM(nature_first_new_user_amount_count), 0) first_new_user_amount_count,
|
|
|
IFNULL(SUM(nature_first_new_user_amount_num), 0) first_new_user_amount_num,
|
|
@@ -3438,8 +3445,10 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
round(IF(SUM(nature_reg_num) >0, SUM(nature_first_role_num) / SUM(nature_reg_num), 0), 4) first_role_num_rate,
|
|
|
round(IF(SUM(nature_reg_num) >0, SUM(nature_role_num) / SUM(nature_reg_num), 0), 4) role_num_rate,
|
|
|
round(IF(SUM(nature_reg_num) >0, SUM(nature_new_user_total_role_num) / SUM(nature_reg_num), 0), 4) new_user_total_role_num_rate
|
|
|
- FROM
|
|
|
- """ + tableName;
|
|
|
+ FROM game_ads.ads_game_day as a
|
|
|
+ left join game_dw.dw_game_amount_day_nature d
|
|
|
+ on a.dt=d.dt and a.game_id = d.nature_game_id
|
|
|
+ """;
|
|
|
}
|
|
|
//总量数据
|
|
|
return """
|
|
@@ -3447,7 +3456,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
IFNULL(SUM(cost), 0) cost,
|
|
|
IFNULL(SUM(reg_num), 0) reg_num,
|
|
|
"""
|
|
|
- + amountDay("") +
|
|
|
+ + amountDayStr("") +
|
|
|
"""
|
|
|
IFNULL(SUM(first_new_user_amount_count), 0) first_new_user_amount_count,
|
|
|
IFNULL(SUM(first_new_user_amount_num), 0) first_new_user_amount_num,
|
|
@@ -3488,8 +3497,173 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
round(IF(SUM(reg_num) >0, SUM(first_role_num) / SUM(reg_num), 0), 4) first_role_num_rate,
|
|
|
round(IF(SUM(reg_num) >0, SUM(role_num) / SUM(reg_num), 0), 4) role_num_rate,
|
|
|
round(IF(SUM(reg_num) >0, SUM(new_user_total_role_num) / SUM(reg_num), 0), 4) new_user_total_role_num_rate
|
|
|
- FROM
|
|
|
- """ + tableName;
|
|
|
+ FROM game_ads.ads_game_day as a
|
|
|
+ left join game_dw.dw_game_amount_day
|
|
|
+ b on a.dt=b.dt and a.game_id = b.game_id
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 游戏每日数据总计sql - 父游戏维度 (新)
|
|
|
+ * @param tableType 查询类型
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private String gameDataDayTotalSqlParent(String tableType) {
|
|
|
+ if ("buy".equals(tableType)) {
|
|
|
+ return """
|
|
|
+ SELECT
|
|
|
+ IFNULL(SUM(cost), 0) cost,
|
|
|
+ IFNULL(SUM(buy_reg_num), 0) reg_num,
|
|
|
+ """
|
|
|
+ + amountDayStr("buy_") +
|
|
|
+ """
|
|
|
+ IFNULL(SUM(buy_first_new_user_amount_count), 0) first_new_user_amount_count,
|
|
|
+ IFNULL(SUM(buy_first_new_user_amount_num), 0) first_new_user_amount_num,
|
|
|
+ IFNULL(SUM(buy_first_new_user_amount), 0) first_new_user_amount,
|
|
|
+ IFNULL(SUM(buy_old_user_count), 0) old_user_count,
|
|
|
+ IFNULL(SUM(buy_old_user_num), 0) old_user_num,
|
|
|
+ IFNULL(SUM(buy_old_user_amount), 0) old_user_amount,
|
|
|
+ IFNULL(SUM(buy_amount_count), 0) amount_count,
|
|
|
+ IFNULL(SUM(buy_amount_num), 0) amount_num,
|
|
|
+ IFNULL(SUM(buy_amount), 0) amount,
|
|
|
+ IFNULL(SUM(buy_new_user_total_amount_count), 0) new_user_total_amount_count,
|
|
|
+ IFNULL(SUM(buy_new_user_total_amount_num), 0) new_user_total_amount_num,
|
|
|
+ IFNULL(SUM(buy_new_user_total_amount), 0) new_user_total_amount,
|
|
|
+ round(if(SUM(cost) > 0 , SUM(buy_first_new_user_amount) / SUM(cost) ,0), 4) first_roi,
|
|
|
+ round(if(SUM(buy_reg_num) > 0 , SUM(buy_first_new_user_amount_num) / SUM(buy_reg_num) ,0), 4) first_amount_rate,
|
|
|
+ round(if(SUM(buy_reg_num) > 0, SUM(buy_new_user_total_amount_num) / SUM(buy_reg_num), 0) ,4) today_amount_rate,
|
|
|
+ round(if(SUM(buy_amount_num) > 0 , SUM(buy_first_new_user_amount_num) / SUM(buy_amount_num) ,0), 4) new_user_rate,
|
|
|
+ round(if(SUM(buy_first_new_user_amount_count) > 0, SUM(buy_first_new_user_amount) / SUM(buy_first_new_user_amount_count), 0), 2) first_avg_amount,
|
|
|
+ round(if(SUM(buy_new_user_total_amount_count) > 0, SUM(buy_new_user_total_amount) / SUM(buy_new_user_total_amount_count), 0), 2) today_avg_amount,
|
|
|
+ round(if(SUM(buy_amount_count) > 0, SUM(buy_amount) / SUM(buy_amount_count), 0), 2) avg_amount,
|
|
|
+ round(if(SUM(buy_new_user_total_amount_num) > 0, SUM(buy_reg_order_user_again) / SUM(buy_new_user_total_amount_num), 0), 4) user_again_rate,
|
|
|
+ round(if(SUM(buy_reg_num) > 0, SUM(buy_new_user_total_amount) / SUM(buy_reg_num), 0), 2) reg_user_arpu,
|
|
|
+ round(if(SUM(buy_first_new_user_amount_num) > 0 , SUM(buy_first_new_user_amount) / SUM(buy_first_new_user_amount_num), 0), 2) first_amount_arpu,
|
|
|
+ round(if(SUM(buy_new_user_total_amount_num) > 0 , SUM(buy_new_user_total_amount) / SUM(buy_new_user_total_amount_num), 0), 2) today_amount_arpu,
|
|
|
+ round(if(SUM(buy_amount_num) > 0, SUM(buy_amount) / SUM(buy_amount_num), 0), 2) amount_arpu,
|
|
|
+ round(if(SUM(buy_reg_num) > 0, SUM(cost) / SUM(buy_reg_num), 0), 2) reg_cost,
|
|
|
+ round(if(SUM(buy_first_new_user_amount_num) > 0, SUM(cost) / SUM(buy_first_new_user_amount_num), 0), 2) first_new_user_recharge_cost,
|
|
|
+ round(if(SUM(buy_new_user_total_amount_num) > 0, SUM(cost) / SUM(buy_new_user_total_amount_num), 0), 2) total_recharge_cost,
|
|
|
+ round(if(SUM(cost) > 0, SUM(buy_new_user_total_amount) / SUM(cost), 0), 4) total_roi,
|
|
|
+ IFNULL(SUM(buy_hundred_user_num), 0) hundred_user_num,
|
|
|
+ round(IF(SUM(buy_hundred_user_num) > 0, SUM(cost) / SUM(buy_hundred_user_num), 0), 2) hundred_user_num_cost,
|
|
|
+ IFNULL(SUM(buy_first_role_num), 0) first_role_num,
|
|
|
+ IFNULL(SUM(buy_role_num), 0) role_num,
|
|
|
+ IFNULL(SUM(buy_new_user_total_role_num), 0) new_user_total_role_num,
|
|
|
+ round(IF(SUM(buy_first_role_num) > 0, SUM(cost) / SUM(buy_first_role_num), 0), 2) first_role_num_cost,
|
|
|
+ round(IF(SUM(buy_role_num) > 0, SUM(cost) / SUM(buy_role_num), 0), 2) role_num_cost,
|
|
|
+ round(IF(SUM(buy_new_user_total_role_num) >0, SUM(cost) / SUM(buy_new_user_total_role_num), 0), 2) new_user_total_role_num_cost,
|
|
|
+ round(IF(SUM(buy_reg_num) >0, SUM(buy_first_role_num) / SUM(buy_reg_num), 0), 4) first_role_num_rate,
|
|
|
+ round(IF(SUM(buy_reg_num) >0, SUM(buy_role_num) / SUM(buy_reg_num), 0), 4) role_num_rate,
|
|
|
+ round(IF(SUM(buy_reg_num) >0, SUM(buy_new_user_total_role_num) / SUM(buy_reg_num), 0), 4) new_user_total_role_num_rate
|
|
|
+ FROM game_ads_parent.ads_game_day_parent as a
|
|
|
+ LEFT JOIN game_dw_parent.dw_game_amount_day_buy_parent b
|
|
|
+ on a.source_system = b.source_system
|
|
|
+ and a.dt = b.dt and a.parent_game_id = b.buy_parent_game_id
|
|
|
+ """;
|
|
|
+ } else if ("nature".equals(tableType)) {
|
|
|
+ return """
|
|
|
+ SELECT
|
|
|
+ IFNULL(SUM(cost), 0) cost,
|
|
|
+ IFNULL(SUM(nature_reg_num), 0) reg_num,
|
|
|
+ """
|
|
|
+ + amountDayStr("nature_") +
|
|
|
+ """
|
|
|
+ IFNULL(SUM(nature_first_new_user_amount_count), 0) first_new_user_amount_count,
|
|
|
+ IFNULL(SUM(nature_first_new_user_amount_num), 0) first_new_user_amount_num,
|
|
|
+ IFNULL(SUM(nature_first_new_user_amount), 0) first_new_user_amount,
|
|
|
+ IFNULL(SUM(nature_old_user_count), 0) old_user_count,
|
|
|
+ IFNULL(SUM(nature_old_user_num), 0) old_user_num,
|
|
|
+ IFNULL(SUM(nature_old_user_amount), 0) old_user_amount,
|
|
|
+ IFNULL(SUM(nature_amount_count), 0) amount_count,
|
|
|
+ IFNULL(SUM(nature_amount_num), 0) amount_num,
|
|
|
+ IFNULL(SUM(nature_amount), 0) amount,
|
|
|
+ IFNULL(SUM(nature_new_user_total_amount_count), 0) new_user_total_amount_count,
|
|
|
+ IFNULL(SUM(nature_new_user_total_amount_num), 0) new_user_total_amount_num,
|
|
|
+ IFNULL(SUM(nature_new_user_total_amount), 0) new_user_total_amount,
|
|
|
+ round(if(SUM(cost) > 0 , SUM(nature_first_new_user_amount) / SUM(cost) ,0), 4) first_roi,
|
|
|
+ round(if(SUM(nature_reg_num) > 0 , SUM(nature_first_new_user_amount_num) / SUM(nature_reg_num) ,0), 4) first_amount_rate,
|
|
|
+ round(if(SUM(nature_reg_num) > 0, SUM(nature_new_user_total_amount_num) / SUM(nature_reg_num), 0) ,4) today_amount_rate,
|
|
|
+ round(if(SUM(nature_amount_num) > 0 , SUM(nature_first_new_user_amount_num) / SUM(nature_amount_num) ,0), 4) new_user_rate,
|
|
|
+ round(if(SUM(nature_first_new_user_amount_count) > 0, SUM(nature_first_new_user_amount) / SUM(nature_first_new_user_amount_count), 0), 2) first_avg_amount,
|
|
|
+ round(if(SUM(nature_new_user_total_amount_count) > 0, SUM(nature_new_user_total_amount) / SUM(nature_new_user_total_amount_count), 0), 2) today_avg_amount,
|
|
|
+ round(if(SUM(nature_amount_count) > 0, SUM(nature_amount) / SUM(nature_amount_count), 0), 2) avg_amount,
|
|
|
+ round(if(SUM(nature_new_user_total_amount_num) > 0, SUM(nature_reg_order_user_again) / SUM(nature_new_user_total_amount_num), 0), 4) user_again_rate,
|
|
|
+ round(if(SUM(nature_reg_num) > 0, SUM(nature_new_user_total_amount) / SUM(nature_reg_num), 0), 2) reg_user_arpu,
|
|
|
+ round(if(SUM(nature_first_new_user_amount_num) > 0 , SUM(nature_first_new_user_amount) / SUM(nature_first_new_user_amount_num), 0), 2) first_amount_arpu,
|
|
|
+ round(if(SUM(nature_new_user_total_amount_num) > 0 , SUM(nature_new_user_total_amount) / SUM(nature_new_user_total_amount_num), 0), 2) today_amount_arpu,
|
|
|
+ round(if(SUM(nature_amount_num) > 0, SUM(nature_amount) / SUM(nature_amount_num), 0), 2) amount_arpu,
|
|
|
+ round(if(SUM(nature_reg_num) > 0, SUM(cost) / SUM(nature_reg_num), 0), 2) reg_cost,
|
|
|
+ round(if(SUM(nature_first_new_user_amount_num) > 0, SUM(cost) / SUM(nature_first_new_user_amount_num), 0), 2) first_new_user_recharge_cost,
|
|
|
+ round(if(SUM(nature_new_user_total_amount_num) > 0, SUM(cost) / SUM(nature_new_user_total_amount_num), 0), 2) total_recharge_cost,
|
|
|
+ round(if(SUM(cost) > 0, SUM(nature_new_user_total_amount) / SUM(cost), 0), 4) total_roi,
|
|
|
+ SUM(nature_hundred_user_num) hundred_user_num,
|
|
|
+ round(IF(SUM(nature_hundred_user_num) > 0, SUM(cost) / SUM(nature_hundred_user_num), 0), 2) hundred_user_num_cost,
|
|
|
+ SUM(nature_first_role_num) first_role_num,
|
|
|
+ SUM(nature_role_num) role_num,
|
|
|
+ SUM(nature_new_user_total_role_num) new_user_total_role_num,
|
|
|
+ round(IF(SUM(nature_first_role_num) > 0, SUM(cost) / SUM(nature_first_role_num), 0), 2) first_role_num_cost,
|
|
|
+ round(IF(SUM(nature_role_num) > 0, SUM(cost) / SUM(nature_role_num), 0), 2) role_num_cost,
|
|
|
+ round(IF(SUM(nature_new_user_total_role_num) >0, SUM(cost) / SUM(nature_new_user_total_role_num), 0), 2) new_user_total_role_num_cost,
|
|
|
+ round(IF(SUM(nature_reg_num) >0, SUM(nature_first_role_num) / SUM(nature_reg_num), 0), 4) first_role_num_rate,
|
|
|
+ round(IF(SUM(nature_reg_num) >0, SUM(nature_role_num) / SUM(nature_reg_num), 0), 4) role_num_rate,
|
|
|
+ round(IF(SUM(nature_reg_num) >0, SUM(nature_new_user_total_role_num) / SUM(nature_reg_num), 0), 4) new_user_total_role_num_rate
|
|
|
+ FROM game_ads_parent.ads_game_day_parent as a
|
|
|
+ left join game_dw_parent.dw_game_amount_day_nature_parent d
|
|
|
+ on a.dt=d.dt and a.parent_game_id = d.nature_parent_game_id
|
|
|
+ """;
|
|
|
+ }
|
|
|
+ //总量数据
|
|
|
+ return """
|
|
|
+ SELECT
|
|
|
+ IFNULL(SUM(cost), 0) cost,
|
|
|
+ IFNULL(SUM(reg_num), 0) reg_num,
|
|
|
+ """
|
|
|
+ + amountDayStr("") +
|
|
|
+ """
|
|
|
+ IFNULL(SUM(first_new_user_amount_count), 0) first_new_user_amount_count,
|
|
|
+ IFNULL(SUM(first_new_user_amount_num), 0) first_new_user_amount_num,
|
|
|
+ IFNULL(SUM(first_new_user_amount), 0) first_new_user_amount,
|
|
|
+ IFNULL(SUM(old_user_count), 0) old_user_count,
|
|
|
+ IFNULL(SUM(old_user_num), 0) old_user_num,
|
|
|
+ IFNULL(SUM(old_user_amount), 0) old_user_amount,
|
|
|
+ IFNULL(SUM(amount_count), 0) amount_count,
|
|
|
+ IFNULL(SUM(amount_num), 0) amount_num,
|
|
|
+ IFNULL(SUM(amount), 0) amount,
|
|
|
+ IFNULL(SUM(new_user_total_amount_count), 0) new_user_total_amount_count,
|
|
|
+ IFNULL(SUM(new_user_total_amount_num), 0) new_user_total_amount_num,
|
|
|
+ IFNULL(SUM(new_user_total_amount), 0) new_user_total_amount,
|
|
|
+ round(if(SUM(cost) > 0 , SUM(first_new_user_amount) / SUM(cost) ,0), 4) first_roi,
|
|
|
+ round(if(SUM(reg_num) > 0 , SUM(first_new_user_amount_num) / SUM(reg_num) ,0), 4) first_amount_rate,
|
|
|
+ round(if(SUM(reg_num) > 0, SUM(new_user_total_amount_num) / SUM(reg_num), 0) ,4) today_amount_rate,
|
|
|
+ round(if(SUM(amount_num) > 0 , SUM(first_new_user_amount_num) / SUM(amount_num) ,0), 4) new_user_rate,
|
|
|
+ round(if(SUM(first_new_user_amount_count) > 0, SUM(first_new_user_amount) / SUM(first_new_user_amount_count), 0), 2) first_avg_amount,
|
|
|
+ round(if(SUM(new_user_total_amount_count) > 0, SUM(new_user_total_amount) / SUM(new_user_total_amount_count), 0), 2) today_avg_amount,
|
|
|
+ round(if(SUM(amount_count) > 0, SUM(amount) / SUM(amount_count), 0), 2) avg_amount,
|
|
|
+ round(if(SUM(new_user_total_amount_num) > 0, SUM(reg_order_user_again) / SUM(new_user_total_amount_num), 0), 4) user_again_rate,
|
|
|
+ round(if(SUM(reg_num) > 0, SUM(new_user_total_amount) / SUM(reg_num), 0), 2) reg_user_arpu,
|
|
|
+ round(if(SUM(first_new_user_amount_num) > 0 , SUM(first_new_user_amount) / SUM(first_new_user_amount_num), 0), 2) first_amount_arpu,
|
|
|
+ round(if(SUM(new_user_total_amount_num) > 0 , SUM(new_user_total_amount) / SUM(new_user_total_amount_num), 0), 2) today_amount_arpu,
|
|
|
+ round(if(SUM(amount_num) > 0, SUM(amount) / SUM(amount_num), 0), 2) amount_arpu,
|
|
|
+ round(if(SUM(reg_num) > 0, SUM(cost) / SUM(reg_num), 0), 2) reg_cost,
|
|
|
+ round(if(SUM(first_new_user_amount_num) > 0, SUM(cost) / SUM(first_new_user_amount_num), 0), 2) first_new_user_recharge_cost,
|
|
|
+ round(if(SUM(new_user_total_amount_num) > 0, SUM(cost) / SUM(new_user_total_amount_num), 0), 2) total_recharge_cost,
|
|
|
+ round(if(SUM(cost) > 0, SUM(new_user_total_amount) / SUM(cost), 0), 4) total_roi,
|
|
|
+ SUM(hundred_user_num) hundred_user_num,
|
|
|
+ round(IF(SUM(hundred_user_num) > 0, SUM(cost) / SUM(hundred_user_num), 0), 2) hundred_user_num_cost,
|
|
|
+ SUM(first_role_num) first_role_num,
|
|
|
+ SUM(role_num) role_num,
|
|
|
+ SUM(new_user_total_role_num) new_user_total_role_num,
|
|
|
+ round(IF(SUM(first_role_num) > 0, SUM(cost) / SUM(first_role_num), 0), 2) first_role_num_cost,
|
|
|
+ round(IF(SUM(role_num) > 0, SUM(cost) / SUM(role_num), 0), 2) role_num_cost,
|
|
|
+ round(IF(SUM(new_user_total_role_num) >0, SUM(cost) / SUM(new_user_total_role_num), 0), 2) new_user_total_role_num_cost,
|
|
|
+ round(IF(SUM(reg_num) >0, SUM(first_role_num) / SUM(reg_num), 0), 4) first_role_num_rate,
|
|
|
+ round(IF(SUM(reg_num) >0, SUM(role_num) / SUM(reg_num), 0), 4) role_num_rate,
|
|
|
+ round(IF(SUM(reg_num) >0, SUM(new_user_total_role_num) / SUM(reg_num), 0), 4) new_user_total_role_num_rate
|
|
|
+ FROM game_ads_parent.ads_game_day_parent as a
|
|
|
+ left join game_dw_parent.dw_game_amount_day_parent as b
|
|
|
+ on a.dt = b.dt and a.parent_game_id = b.parent_game_id
|
|
|
+ """;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -3746,8 +3920,8 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- String s = amountDay2("buy_");
|
|
|
- System.out.println(s);
|
|
|
+// String s = amountDay2("buy_");
|
|
|
+// System.out.println(s);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -3755,35 +3929,46 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
* Dn的充值金额 / D1-Dn的充值总金额 / Dn的充值人数 /当前消耗(剔除不存在的天数数据) /D1充值金额总和(剔除不存在的天数数据)
|
|
|
* 游戏每日总计趋势sql
|
|
|
*/
|
|
|
- private static String amountDay2(String type){
|
|
|
+ private static String amountDayStr(String type){
|
|
|
//拼接查询条件
|
|
|
StringBuilder trendDay = new StringBuilder(StringUtils.EMPTY);
|
|
|
trendDay.append("""
|
|
|
CONCAT(
|
|
|
SUM(IF(DATE_ADD(a.dt, INTERVAL 0 day) <= DATE(NOW()), %sda1, 0)),'/',
|
|
|
- sum(%sda1),'/',
|
|
|
+ IFNULL(sum(%sda1),0),'/',
|
|
|
sum(ifnull(%sda1_num,0)),'/',
|
|
|
SUM(IF(DATE_ADD(a.dt, INTERVAL 0 day) <= DATE(NOW()), cost, 0)),'/',
|
|
|
SUM(IF(DATE_ADD(a.dt, INTERVAL 0 day) <= DATE(NOW()), %sda1, 0))
|
|
|
) AS amount_d1 ,
|
|
|
""".formatted(type, type, type, type));
|
|
|
|
|
|
- for (int day = 2; day <= 90; day++) {
|
|
|
+ for (int day = 2; day < 90; day++) {
|
|
|
trendDay.append("""
|
|
|
CONCAT(
|
|
|
SUM(IF(DATE_ADD(a.dt, INTERVAL %d day) <= DATE(NOW()), %sda%d - %sda%d, 0)),'/',
|
|
|
- sum(%sda%d),'/',
|
|
|
+ IFNULL(sum(%sda%d),0),'/',
|
|
|
sum(ifnull(%sda%d_num,0)),'/',
|
|
|
SUM(IF(DATE_ADD(a.dt, INTERVAL %d day) <= DATE(NOW()), cost, 0)),'/',
|
|
|
SUM(IF(DATE_ADD(a.dt, INTERVAL %d day) <= DATE(NOW()), %sda1, 0))
|
|
|
) AS amount_d%s ,
|
|
|
""".formatted( day - 1,type,day,type,day - 1,type, day, type, day, day - 1, day - 1, type, day));
|
|
|
}
|
|
|
+
|
|
|
+ //三月
|
|
|
+ trendDay.append("""
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF(DATE_ADD(a.dt, INTERVAL 2 month) <= DATE(NOW()), %sda3, 0)),'/',
|
|
|
+ IFNULL(sum(%sda3),0),'/',
|
|
|
+ sum(ifnull(%sda3_num,0)),'/',
|
|
|
+ SUM(IF(DATE_ADD(a.dt, INTERVAL 2 month) <= DATE(NOW()), cost, 0)),'/',
|
|
|
+ SUM(IF(DATE_ADD(a.dt, INTERVAL 2 month) <= DATE(NOW()), %sda1, 0))
|
|
|
+ ) AS amount_m3 ,
|
|
|
+ """.formatted(type, type, type, type));
|
|
|
for (int month = 4; month <= 12; month++) {
|
|
|
trendDay.append("""
|
|
|
CONCAT(
|
|
|
SUM(IF(DATE_ADD(a.dt, INTERVAL %d month) <= DATE(NOW()), %sm%d - %sm%d, 0)),'/',
|
|
|
- sum(%sm%d),'/',
|
|
|
+ IFNULL(sum(%sm%d),0),'/',
|
|
|
sum(ifnull(%sm%d_num,0)),'/',
|
|
|
SUM(IF(DATE_ADD(a.dt, INTERVAL %d month) <= DATE(NOW()), cost, 0)),'/',
|
|
|
SUM(IF(DATE_ADD(a.dt, INTERVAL %d month) <= DATE(NOW()), %sda1, 0))
|
|
@@ -3797,7 +3982,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
SUM(%stotal), '/',
|
|
|
SUM(ifnull(%stotal_num,0)), '/',
|
|
|
SUM(cost), '/',
|
|
|
- SUM(%sda1))
|
|
|
+ SUM(%sda1)
|
|
|
) AS amount_sum ,
|
|
|
""".formatted(type, type, type, type));
|
|
|
|