|
@@ -16,6 +16,7 @@ import lombok.Builder;
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
import lombok.NoArgsConstructor;
|
|
import lombok.NoArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.nutz.dao.Cnd;
|
|
import org.nutz.dao.Cnd;
|
|
@@ -32,7 +33,6 @@ import org.springframework.beans.BeanWrapper;
|
|
import org.springframework.beans.BeanWrapperImpl;
|
|
import org.springframework.beans.BeanWrapperImpl;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
|
import reactor.util.function.Tuple2;
|
|
import reactor.util.function.Tuple2;
|
|
import reactor.util.function.Tuples;
|
|
import reactor.util.function.Tuples;
|
|
|
|
|
|
@@ -195,8 +195,12 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Page<GameDataDayVO> getGameDataDay(GameDataDayDTO dto) {
|
|
public Page<GameDataDayVO> getGameDataDay(GameDataDayDTO dto) {
|
|
|
|
+ //如果不传游戏id,按照老的游戏每日数据查询数据
|
|
|
|
+ if (CollectionUtils.isEmpty(dto.getGameId())) {
|
|
|
|
+ return getGameDataDayForOld(dto);
|
|
|
|
+ }
|
|
com.github.sd4324530.jtuple.Tuple2<List<Long>, List<Long>> poerInfo = dataPowerComponent.getPowerInfo(dto.getSourceSystem());
|
|
com.github.sd4324530.jtuple.Tuple2<List<Long>, List<Long>> poerInfo = dataPowerComponent.getPowerInfo(dto.getSourceSystem());
|
|
- List<Long> gameIds = dto.getGameId() == null ? poerInfo.second : Collections.singletonList(dto.getGameId());
|
|
|
|
|
|
+ List<Long> gameIds = CollectionUtils.isEmpty(dto.getGameId()) ? poerInfo.second : dto.getGameId();
|
|
|
|
|
|
//默认查询 total 总量数据
|
|
//默认查询 total 总量数据
|
|
if (StringUtils.isBlank(dto.getTableTypes())) {
|
|
if (StringUtils.isBlank(dto.getTableTypes())) {
|
|
@@ -208,7 +212,92 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
//拼接游戏名称查询条件
|
|
//拼接游戏名称查询条件
|
|
cri.where().andEquals("game_name", dto.getGameName());
|
|
cri.where().andEquals("game_name", dto.getGameName());
|
|
}
|
|
}
|
|
- if (gameIds != null) {
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(gameIds)) {
|
|
|
|
+ //拼接游戏id查询条件
|
|
|
|
+ cri.where().andInList("game_id", gameIds);
|
|
|
|
+ }
|
|
|
|
+ if (dto.getGameClassify() != null) {
|
|
|
|
+ //拼接游戏类型查询条件
|
|
|
|
+ cri.where().andEquals("game_classify", dto.getGameClassify());
|
|
|
|
+ }
|
|
|
|
+ if (dto.getRegisteredBeginDate() != null && dto.getRegisteredEndDate() != null) {
|
|
|
|
+ cri.where().andBetween("dt", dto.getRegisteredBeginDate(), dto.getRegisteredEndDate());
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
|
+ //拼接SDK来源
|
|
|
|
+ cri.where().andEquals("source_system", dto.getSourceSystem());
|
|
|
|
+ }
|
|
|
|
+ //按时间分组
|
|
|
|
+ cri.getGroupBy().groupBy("dt", "source_system");
|
|
|
|
+ //拼接排序条件
|
|
|
|
+ if (StringUtils.isBlank(dto.getSortType())) {
|
|
|
|
+ dto.setSortType(OrderByEnum.DESC.getOrderType());
|
|
|
|
+ }
|
|
|
|
+ if (StringUtils.isBlank(dto.getSortFiled())) {
|
|
|
|
+ cri.getOrderBy().orderBy("cost_date", dto.getSortFiled());
|
|
|
|
+ cri.getOrderBy().orderBy("cost", dto.getSortFiled());
|
|
|
|
+ } else {
|
|
|
|
+ cri.getOrderBy().orderBy(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()), dto.getSortType());
|
|
|
|
+ }
|
|
|
|
+ //编写sql语句 拼接查询条件
|
|
|
|
+ Sql sql = Sqls.create(gameDataDayGroupByDtSql(dto.getTableTypes()) + cri);
|
|
|
|
+ //设置自定义回显对象
|
|
|
|
+ sql.setCallback(Sqls.callback.entities());
|
|
|
|
+ sql.setEntity(dao.getEntity(GameDataDayVO.class));
|
|
|
|
+ //设置pager对象
|
|
|
|
+ Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
|
|
|
|
+ sql.setPager(pager);
|
|
|
|
+ //执行sql
|
|
|
|
+ dao.execute(sql);
|
|
|
|
+ //得到结果集list
|
|
|
|
+ List<GameDataDayVO> list = sql.getList(GameDataDayVO.class);
|
|
|
|
+ //设置查询总数
|
|
|
|
+ Sql sqlCount = Sqls.create(
|
|
|
|
+ """
|
|
|
|
+ SELECT
|
|
|
|
+ COUNT(1)
|
|
|
|
+ FROM (
|
|
|
|
+ SELECT
|
|
|
|
+ COUNT(1)
|
|
|
|
+ FROM game_ads.ads_game_day
|
|
|
|
+ """ + cri +
|
|
|
|
+ """
|
|
|
|
+ ) a;
|
|
|
|
+ """);
|
|
|
|
+ sqlCount.setCallback(Sqls.callback.integer());
|
|
|
|
+ dao.execute(sqlCount);
|
|
|
|
+ pager.setRecordCount(sqlCount.getInt());
|
|
|
|
+
|
|
|
|
+ List<GameDataDayVO> gameDataDayVOList = list.stream().map(vo -> {
|
|
|
|
+ formatDayNGroupByDt(vo);
|
|
|
|
+ return vo;
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ //返回list结果 封装到page对象里
|
|
|
|
+ return new Page<>(gameDataDayVOList, pager);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 游戏每日数据
|
|
|
|
+ *
|
|
|
|
+ * @param dto 前端传递查询参数
|
|
|
|
+ * @return 返回给前端的数据
|
|
|
|
+ */
|
|
|
|
+ private Page<GameDataDayVO> getGameDataDayForOld(GameDataDayDTO 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");
|
|
|
|
+ }
|
|
|
|
+ //根据dto拼接查询条件
|
|
|
|
+ Criteria cri = Cnd.cri();
|
|
|
|
+ if (StringUtils.isNotBlank(dto.getGameName())) {
|
|
|
|
+ //拼接游戏名称查询条件
|
|
|
|
+ cri.where().andEquals("game_name", dto.getGameName());
|
|
|
|
+ }
|
|
|
|
+ if (CollectionUtils.isNotEmpty(gameIds)) {
|
|
//拼接游戏id查询条件
|
|
//拼接游戏id查询条件
|
|
cri.where().andInList("game_id", gameIds);
|
|
cri.where().andInList("game_id", gameIds);
|
|
}
|
|
}
|
|
@@ -247,7 +336,6 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
List<GameDataDayVO> list = sql.getList(GameDataDayVO.class);
|
|
List<GameDataDayVO> list = sql.getList(GameDataDayVO.class);
|
|
//设置查询总数
|
|
//设置查询总数
|
|
pager.setRecordCount(dao.count(AdsGameDay.class, cri));
|
|
pager.setRecordCount(dao.count(AdsGameDay.class, cri));
|
|
-
|
|
|
|
List<GameDataDayVO> gameDataDayVOList = list.stream().map(vo -> {
|
|
List<GameDataDayVO> gameDataDayVOList = list.stream().map(vo -> {
|
|
formatDayN(vo);
|
|
formatDayN(vo);
|
|
return vo;
|
|
return vo;
|
|
@@ -265,7 +353,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
*/
|
|
*/
|
|
public GameDataDayTotalVO getGameDataDayTotal(GameDataDayTotalDTO dto) {
|
|
public GameDataDayTotalVO getGameDataDayTotal(GameDataDayTotalDTO dto) {
|
|
com.github.sd4324530.jtuple.Tuple2<List<Long>, List<Long>> poerInfo = dataPowerComponent.getPowerInfo(dto.getSourceSystem());
|
|
com.github.sd4324530.jtuple.Tuple2<List<Long>, List<Long>> poerInfo = dataPowerComponent.getPowerInfo(dto.getSourceSystem());
|
|
- List<Long> gameIds = dto.getGameId() == null ? poerInfo.second : Collections.singletonList(dto.getGameId());
|
|
|
|
|
|
+ List<Long> gameIds = CollectionUtils.isEmpty(dto.getGameId()) ? poerInfo.second : dto.getGameId();
|
|
|
|
|
|
//默认查询 total 总量数据
|
|
//默认查询 total 总量数据
|
|
if (StringUtils.isBlank(dto.getTableTypes())) {
|
|
if (StringUtils.isBlank(dto.getTableTypes())) {
|
|
@@ -273,7 +361,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
}
|
|
}
|
|
//新增查询条件
|
|
//新增查询条件
|
|
Criteria cri = Cnd.cri();
|
|
Criteria cri = Cnd.cri();
|
|
- if (gameIds != null) {
|
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(gameIds)) {
|
|
//拼接游戏id
|
|
//拼接游戏id
|
|
cri.where().andInList("game_id", gameIds);
|
|
cri.where().andInList("game_id", gameIds);
|
|
}
|
|
}
|
|
@@ -1314,6 +1402,44 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 通过反射赋值每日总计趋势(游戏每日按日期聚合数据)
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ private void formatDayNGroupByDt(GameDataDayVO vo) {
|
|
|
|
+ if (CollectionUtils.isEmpty(dayNFieldMapList)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ dayNFieldMapList.forEach(dayNTotalFieldMap -> {
|
|
|
|
+ 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());
|
|
|
|
+
|
|
|
|
+ } catch (IllegalAccessException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 通过反射赋值每日总计趋势
|
|
* 通过反射赋值每日总计趋势
|
|
*
|
|
*
|
|
@@ -2034,6 +2160,175 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
""";
|
|
""";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 游戏每日数据总计sql
|
|
|
|
+ *
|
|
|
|
+ * @param tableType 查询的类型
|
|
|
|
+ * @return String
|
|
|
|
+ */
|
|
|
|
+ private String gameDataDayGroupByDtSql(String tableType) {
|
|
|
|
+ if ("buy".equals(tableType)) {
|
|
|
|
+ return """
|
|
|
|
+ SELECT
|
|
|
|
+ dt as cost_date,
|
|
|
|
+ source_system,
|
|
|
|
+ GROUP_CONCAT(game_name) as game_name,
|
|
|
|
+ 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
|
|
|
|
+ ads_game_day
|
|
|
|
+ """;
|
|
|
|
+ } else if ("nature".equals(tableType)) {
|
|
|
|
+ return """
|
|
|
|
+ SELECT
|
|
|
|
+ dt as cost_date,
|
|
|
|
+ source_system,
|
|
|
|
+ GROUP_CONCAT(game_name) as game_name,
|
|
|
|
+ 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
|
|
|
|
+ ads_game_day
|
|
|
|
+ """;
|
|
|
|
+ }
|
|
|
|
+ //总量数据
|
|
|
|
+ return """
|
|
|
|
+ SELECT
|
|
|
|
+ dt as cost_date,
|
|
|
|
+ source_system,
|
|
|
|
+ GROUP_CONCAT(game_name) as game_name,
|
|
|
|
+ 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
|
|
|
|
+ ads_game_day
|
|
|
|
+ """;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 游戏每日数据总计sql
|
|
* 游戏每日数据总计sql
|
|
*
|
|
*
|