|
@@ -648,39 +648,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
* @return 返回给前端的总计数据实体
|
|
* @return 返回给前端的总计数据实体
|
|
*/
|
|
*/
|
|
public GameDataDayTotalVO getGameDataDayTotal(GameDataDayTotalDTO dto) {
|
|
public GameDataDayTotalVO getGameDataDayTotal(GameDataDayTotalDTO dto) {
|
|
- com.github.sd4324530.jtuple.Tuple2<List<Long>, List<Long>> poerInfo = dataPowerComponent.getPowerInfo(dto.getSourceSystem());
|
|
|
|
- List<Long> gameIds = CollectionUtils.isEmpty(dto.getGameId()) ? poerInfo.second : dto.getGameId();
|
|
|
|
-
|
|
|
|
- //默认查询 total 总量数据
|
|
|
|
- if (StringUtils.isBlank(dto.getTableTypes())) {
|
|
|
|
- dto.setTableTypes("total");
|
|
|
|
- }
|
|
|
|
- //默认查询 子游戏维度 数据
|
|
|
|
- if (dto.getGameDimension() == null) {
|
|
|
|
- dto.setGameDimension(1L);
|
|
|
|
- }
|
|
|
|
- //新增查询条件
|
|
|
|
- Criteria cri = Cnd.cri();
|
|
|
|
- if (CollectionUtils.isNotEmpty(gameIds)) {
|
|
|
|
- if (dto.getGameDimension() == 1L) {
|
|
|
|
- //拼接游戏id
|
|
|
|
- cri.where().andInList("game_id", gameIds);
|
|
|
|
- } else if (dto.getGameDimension() == 2L) {
|
|
|
|
- //拼接游戏id
|
|
|
|
- cri.where().andInList("parent_game_id", gameIds);
|
|
|
|
- } else {
|
|
|
|
- //拼接游戏id
|
|
|
|
- cri.where().andInList("super_game_id", gameIds);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
|
- //拼接SDK来源
|
|
|
|
- cri.where().andEquals("source_system", dto.getSourceSystem());
|
|
|
|
- }
|
|
|
|
- if (dto.getRegisteredBeginDate() != null && dto.getRegisteredEndDate() != null) {
|
|
|
|
- //拼接查询时间
|
|
|
|
- cri.where().andBetween("dt", dto.getRegisteredBeginDate(), dto.getRegisteredEndDate());
|
|
|
|
- }
|
|
|
|
|
|
+ Criteria cri = getGameDataDayTotalCriteria(dto);
|
|
//创建sql
|
|
//创建sql
|
|
Sql gameDataDayTotalsql;
|
|
Sql gameDataDayTotalsql;
|
|
//判断查询的维度
|
|
//判断查询的维度
|
|
@@ -726,6 +694,49 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
return vo;
|
|
return vo;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取游戏每日数据总计条件str
|
|
|
|
+ */
|
|
|
|
+ private Criteria getGameDataDayTotalCriteria(GameDataDayTotalDTO dto) {
|
|
|
|
+ com.github.sd4324530.jtuple.Tuple2<List<Long>, List<Long>> poerInfo = dataPowerComponent.getPowerInfo(dto.getSourceSystem());
|
|
|
|
+// List<Long> gameIds = dto.getGameId();
|
|
|
|
+ List<Long> gameIds = CollectionUtils.isEmpty(dto.getGameId()) ? poerInfo.second : dto.getGameId();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //默认查询 total 总量数据
|
|
|
|
+ if (StringUtils.isBlank(dto.getTableTypes())) {
|
|
|
|
+ dto.setTableTypes("total");
|
|
|
|
+ }
|
|
|
|
+ //默认查询 子游戏维度 数据
|
|
|
|
+ if (dto.getGameDimension() == null) {
|
|
|
|
+ dto.setGameDimension(1L);
|
|
|
|
+ }
|
|
|
|
+ Criteria cri = Cnd.cri();
|
|
|
|
+ if (CollectionUtils.isNotEmpty(gameIds)) {
|
|
|
|
+ if (dto.getGameDimension() == 1L) {
|
|
|
|
+ //拼接游戏id
|
|
|
|
+ cri.where().andInList("game_id", gameIds);
|
|
|
|
+ } else if (dto.getGameDimension() == 2L) {
|
|
|
|
+ //拼接游戏id
|
|
|
|
+ cri.where().andInList("parent_game_id", gameIds);
|
|
|
|
+ } else {
|
|
|
|
+ //拼接游戏id
|
|
|
|
+ cri.where().andInList("super_game_id", gameIds);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
|
+ //拼接SDK来源
|
|
|
|
+ cri.where().andEquals("source_system", dto.getSourceSystem());
|
|
|
|
+ }
|
|
|
|
+ if (dto.getRegisteredBeginDate() != null && dto.getRegisteredEndDate() != null) {
|
|
|
|
+ //拼接查询时间
|
|
|
|
+ cri.where().andBetween("dt", dto.getRegisteredBeginDate(), dto.getRegisteredEndDate());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return cri;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 游戏总数据
|
|
* 游戏总数据
|
|
*
|
|
*
|
|
@@ -1891,7 +1902,8 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
if (CollectionUtils.isEmpty(dayNTotalFieldMapList)) {
|
|
if (CollectionUtils.isEmpty(dayNTotalFieldMapList)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- dayNTotalFieldMapList.forEach(dayNTotalFieldMap -> {
|
|
|
|
|
|
+
|
|
|
|
+ for (Tuple2<Field, Field> dayNTotalFieldMap : dayNTotalFieldMapList) {
|
|
try {
|
|
try {
|
|
//得到需要计算的值
|
|
//得到需要计算的值
|
|
String[] temps = ((String) dayNTotalFieldMap.getT1().get(vo)).split("/");
|
|
String[] temps = ((String) dayNTotalFieldMap.getT1().get(vo)).split("/");
|
|
@@ -1918,7 +1930,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
} catch (IllegalAccessException e) {
|
|
} catch (IllegalAccessException e) {
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
- });
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -3322,6 +3334,164 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
""" + tableName;
|
|
""" + tableName;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 游戏每日数据总计sql-子游戏、父游戏维度 (新)
|
|
|
|
+ *
|
|
|
|
+ * @param tableType 查询的类型
|
|
|
|
+ * @return String
|
|
|
|
+ */
|
|
|
|
+ private String gameDataDayTotalSql2(String tableType, String tableName) {
|
|
|
|
+ if ("buy".equals(tableType)) {
|
|
|
|
+ return """
|
|
|
|
+ SELECT
|
|
|
|
+ IFNULL(SUM(cost), 0) cost,
|
|
|
|
+ IFNULL(SUM(buy_reg_num), 0) reg_num,
|
|
|
|
+ """
|
|
|
|
+ + amountDay("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
|
|
|
|
+ """ + tableName;
|
|
|
|
+ } else if ("nature".equals(tableType)) {
|
|
|
|
+ return """
|
|
|
|
+ SELECT
|
|
|
|
+ IFNULL(SUM(cost), 0) cost,
|
|
|
|
+ IFNULL(SUM(nature_reg_num), 0) reg_num,
|
|
|
|
+ """
|
|
|
|
+ + amountDay("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
|
|
|
|
+ """ + tableName;
|
|
|
|
+ }
|
|
|
|
+ //总量数据
|
|
|
|
+ return """
|
|
|
|
+ SELECT
|
|
|
|
+ IFNULL(SUM(cost), 0) cost,
|
|
|
|
+ IFNULL(SUM(reg_num), 0) reg_num,
|
|
|
|
+ """
|
|
|
|
+ + amountDay("") +
|
|
|
|
+ """
|
|
|
|
+ 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
|
|
|
|
+ """ + tableName;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 游戏每日数据总计sql-超父游戏维度
|
|
* 游戏每日数据总计sql-超父游戏维度
|
|
*
|
|
*
|
|
@@ -3575,6 +3745,66 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
return trendDay.toString();
|
|
return trendDay.toString();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ String s = amountDay2("buy_");
|
|
|
|
+ System.out.println(s);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Dn的充值金额 / D1-Dn的充值总金额 / Dn的充值人数 /当前消耗(剔除不存在的天数数据) /D1充值金额总和(剔除不存在的天数数据)
|
|
|
|
+ * 游戏每日总计趋势sql
|
|
|
|
+ */
|
|
|
|
+ private static String amountDay2(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),'/',
|
|
|
|
+ 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++) {
|
|
|
|
+ trendDay.append("""
|
|
|
|
+ CONCAT(
|
|
|
|
+ SUM(IF(DATE_ADD(a.dt, INTERVAL %d day) <= DATE(NOW()), %sda%d - %sda%d, 0)),'/',
|
|
|
|
+ sum(%sda%d),'/',
|
|
|
|
+ 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));
|
|
|
|
+ }
|
|
|
|
+ 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),'/',
|
|
|
|
+ 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))
|
|
|
|
+ ) AS amount_m%s ,
|
|
|
|
+ """.formatted(month -1 , type,month,type,month - 1,type, month, type, month, month - 1,month - 1, type,month));
|
|
|
|
+ }
|
|
|
|
+// //拼接sum数据
|
|
|
|
+ trendDay.append("""
|
|
|
|
+ CONCAT(
|
|
|
|
+ SUM(%stotal), '/',
|
|
|
|
+ SUM(%stotal), '/',
|
|
|
|
+ SUM(ifnull(%stotal_num,0)), '/',
|
|
|
|
+ SUM(cost), '/',
|
|
|
|
+ SUM(%sda1))
|
|
|
|
+ ) AS amount_sum ,
|
|
|
|
+ """.formatted(type, type, type, type));
|
|
|
|
+
|
|
|
|
+ return trendDay.toString();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 游戏总数据SQL
|
|
* 游戏总数据SQL
|
|
*
|
|
*
|