|
@@ -52,10 +52,16 @@ import java.util.stream.Collectors;
|
|
|
@Slf4j
|
|
|
public class GameDataServiceImpl implements IGameDataService {
|
|
|
private static final List<Tuple2<Field, Field>> dayNFieldMapList;
|
|
|
- static {
|
|
|
+ private static final List<Tuple2<Field, Field>> dayNTotalFieldMapList;
|
|
|
+
|
|
|
+ static {
|
|
|
Map<String, Field> fieldMap = new HashMap<>();
|
|
|
+ Map<String, Field> fieldTotalMap = new HashMap<>();
|
|
|
List<Field> dayNFieldList = new ArrayList<>();
|
|
|
+ List<Field> dayNTotalFieldList = new ArrayList<>();
|
|
|
Class<?> tempClazz = GameDataDayVO.class;
|
|
|
+ Class<?> tempTotalClazz = GameDataDayTotalVO.class;
|
|
|
+
|
|
|
while (tempClazz != null) {
|
|
|
Field[] fields = tempClazz.getDeclaredFields();
|
|
|
for (Field field : fields) {
|
|
@@ -69,19 +75,48 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
}
|
|
|
tempClazz = tempClazz.getSuperclass();
|
|
|
}
|
|
|
- if(dayNFieldList.isEmpty()) {
|
|
|
- dayNFieldMapList = Collections.emptyList();
|
|
|
+
|
|
|
+ while (tempTotalClazz != null) {
|
|
|
+ Field[] fields = tempTotalClazz.getDeclaredFields();
|
|
|
+ for (Field field : fields) {
|
|
|
+ if (Modifier.isFinal(field.getModifiers()) || Modifier.isStatic(field.getModifiers())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ fieldTotalMap.put(field.getName(), field);
|
|
|
+ if (field.getType() == RechargeTrendVO.class) {
|
|
|
+ dayNTotalFieldList.add(field);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tempTotalClazz = tempTotalClazz.getSuperclass();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dayNFieldList.isEmpty()) {
|
|
|
+ dayNFieldMapList = Collections.emptyList();
|
|
|
} else {
|
|
|
dayNFieldMapList = new ArrayList<>(dayNFieldList.size());
|
|
|
- for(Field dayNField : dayNFieldList) {
|
|
|
+ for (Field dayNField : dayNFieldList) {
|
|
|
dayNField.setAccessible(true);
|
|
|
Field sourceField = fieldMap.get(dayNField.getName().replace("Trend", ""));
|
|
|
sourceField.setAccessible(true);
|
|
|
- if(sourceField != null) {
|
|
|
+ if (sourceField != null) {
|
|
|
dayNFieldMapList.add(Tuples.of(sourceField, dayNField));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (dayNTotalFieldList.isEmpty()) {
|
|
|
+ dayNTotalFieldMapList = Collections.emptyList();
|
|
|
+ } else {
|
|
|
+ dayNTotalFieldMapList = new ArrayList<>(dayNTotalFieldList.size());
|
|
|
+ for (Field dayNTotalField : dayNTotalFieldList) {
|
|
|
+ dayNTotalField.setAccessible(true);
|
|
|
+ Field sourceField = fieldTotalMap.get(dayNTotalField.getName().replace("Trend", ""));
|
|
|
+ sourceField.setAccessible(true);
|
|
|
+ if (sourceField != null) {
|
|
|
+ dayNTotalFieldMapList.add(Tuples.of(sourceField, dayNTotalField));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Autowired
|
|
@@ -183,6 +218,9 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
//拼接SDK来源
|
|
|
cri.where().andEquals("source_system", dto.getSourceSystem());
|
|
|
}
|
|
|
+ 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());
|
|
@@ -195,8 +233,12 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
gameDataDayTotalsql.setEntity(dao.getEntity(GameDataDayTotalVO.class));
|
|
|
//执行sql
|
|
|
dao.execute(gameDataDayTotalsql);
|
|
|
-
|
|
|
- return gameDataDayTotalsql.getObject(GameDataDayTotalVO.class);
|
|
|
+ //得到每日总计对象
|
|
|
+ GameDataDayTotalVO vo = gameDataDayTotalsql.getObject(GameDataDayTotalVO.class);
|
|
|
+ if (vo.getAmountD1() != null) {
|
|
|
+ formatDayNTotal(vo);
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -328,6 +370,13 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
vo.setBuyNewUserAmountArpu(vo.getBuyNewUserAmountNum().compareTo(0L) == 0 ? BigDecimal.ZERO :
|
|
|
BigDecimal.valueOf(vo.getBuyNewUserAmount().doubleValue() / vo.getBuyNewUserAmountNum().doubleValue()).setScale(4, RoundingMode.HALF_UP));
|
|
|
|
|
|
+ //新用户回收率
|
|
|
+ vo.setBuyNewUserRechargeRate(vo.getCost().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
|
|
|
+ vo.getBuyNewUserAmount().divide(vo.getCost(), 4, RoundingMode.HALF_UP));
|
|
|
+ //新用户充值成本
|
|
|
+ vo.setBuyNewUserRechargeCost(vo.getBuyNewUserAmountNum() == 0 ? BigDecimal.ZERO :
|
|
|
+ vo.getCost().divide(BigDecimal.valueOf(vo.getBuyNewUserAmountNum()), 4, RoundingMode.HALF_UP));
|
|
|
+
|
|
|
//设置自然量数据
|
|
|
//新用户充值次数、金额、人数
|
|
|
vo.setNatureNewUserAmount(natureDayN == null ? BigDecimal.ZERO : natureDayN.getRechargeMoney());
|
|
@@ -363,6 +412,13 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
vo.setNatureNewUserAmountArpu(vo.getNatureNewUserAmountNum().compareTo(0L) == 0 ? BigDecimal.ZERO :
|
|
|
BigDecimal.valueOf(vo.getNatureNewUserAmount().doubleValue() / vo.getNatureNewUserAmountNum().doubleValue()).setScale(4, RoundingMode.HALF_UP));
|
|
|
|
|
|
+ //新用户回收率
|
|
|
+ vo.setNatureNewUserRechargeRate(vo.getCost().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
|
|
|
+ vo.getNatureNewUserAmount().divide(vo.getCost(), 4, RoundingMode.HALF_UP));
|
|
|
+ //新用户充值成本
|
|
|
+ vo.setNatureNewUserRechargeCost(vo.getNatureNewUserAmountNum() == 0 ? BigDecimal.ZERO :
|
|
|
+ vo.getCost().divide(BigDecimal.valueOf(vo.getNatureNewUserAmountNum()), 4, RoundingMode.HALF_UP));
|
|
|
+
|
|
|
//设置总量数据
|
|
|
//新用户充值次数、金额、人数
|
|
|
vo.setNewUserAmount(dayN == null ? BigDecimal.ZERO : dayN.getRechargeMoney());
|
|
@@ -398,6 +454,13 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
vo.setNewUserAmountArpu(vo.getNewUserAmountNum().compareTo(0L) == 0 ? BigDecimal.ZERO :
|
|
|
BigDecimal.valueOf(vo.getNewUserAmount().doubleValue() / vo.getNewUserAmountNum().doubleValue()).setScale(4, RoundingMode.HALF_UP));
|
|
|
|
|
|
+ //新用户回收率
|
|
|
+ vo.setNewUserRechargeRate(vo.getCost().compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ZERO :
|
|
|
+ vo.getNewUserAmount().divide(vo.getCost(), 4, RoundingMode.HALF_UP));
|
|
|
+ //新用户充值成本
|
|
|
+ vo.setNewUserRechargeCost(vo.getNewUserAmountNum() == 0 ? BigDecimal.ZERO :
|
|
|
+ vo.getCost().divide(BigDecimal.valueOf(vo.getNewUserAmountNum()), 4, RoundingMode.HALF_UP));
|
|
|
+
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
@@ -412,7 +475,82 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
* @return 返回给前端额数据
|
|
|
*/
|
|
|
public GameDataTotalTotalVO getGameDataTotalTotal(GameDataTotalTotalDTO dto) {
|
|
|
- return null;
|
|
|
+ //如果注册时间参数为空,默认设置查询当天数据
|
|
|
+ if (dto.getRegisteredBeginDate() == null || dto.getRegisteredEndDate() == null) {
|
|
|
+ dto.setRegisteredBeginDate(LocalDate.now());
|
|
|
+ dto.setRegisteredEndDate(LocalDate.now());
|
|
|
+ }
|
|
|
+ //如果充值时间参数为空,默认设置查询当天数据
|
|
|
+ if (dto.getRechargeBeginDate() == null || dto.getRechargeEndDate() == null) {
|
|
|
+ dto.setRechargeBeginDate(LocalDate.now());
|
|
|
+ dto.setRechargeEndDate(LocalDate.now());
|
|
|
+ }
|
|
|
+ //根据传入的dto拼接查询参数
|
|
|
+ Criteria cri = Cnd.cri();
|
|
|
+ if (StringUtils.isNotBlank(dto.getGameName())) {
|
|
|
+ //拼接游戏名称查询条件
|
|
|
+ cri.where().andEquals("game_name", dto.getGameName());
|
|
|
+ }
|
|
|
+ if (dto.getGameId() != null) {
|
|
|
+ //拼接游戏id查询条件
|
|
|
+ cri.where().andEquals("game_id", dto.getGameId());
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+
|
|
|
+ Sql gameDataTotalTotalSql = Sqls.create(gameDataTotalTotalSql() + cri);
|
|
|
+ //设置回传对象
|
|
|
+ gameDataTotalTotalSql.setCallback(Sqls.callback.entity());
|
|
|
+ gameDataTotalTotalSql.setEntity(dao.getEntity(GameDataTotalTotalVO.class));
|
|
|
+ //执行sql
|
|
|
+ dao.execute(gameDataTotalTotalSql);
|
|
|
+ //得到查询出的结果
|
|
|
+ GameDataTotalTotalVO vo = gameDataTotalTotalSql.getObject(GameDataTotalTotalVO.class);
|
|
|
+
|
|
|
+ //查询充值时间相关数据
|
|
|
+ //查询条件
|
|
|
+ Criteria criRc = Cnd.cri();
|
|
|
+ if (StringUtils.isNotBlank(dto.getGameName())) {
|
|
|
+ //拼接游戏名称查询条件
|
|
|
+ criRc.where().andEquals("game_name", dto.getGameName());
|
|
|
+ }
|
|
|
+ if (dto.getGameClassify() != null) {
|
|
|
+ //拼接游戏类型查询条件
|
|
|
+ criRc.where().andEquals("game_classify", dto.getGameClassify());
|
|
|
+ }
|
|
|
+ if (dto.getGameId() != null) {
|
|
|
+ //拼接游戏id查询条件
|
|
|
+ criRc.where().andEquals("game_id", dto.getGameId());
|
|
|
+ }
|
|
|
+ if (dto.getRechargeBeginDate() != null && dto.getRechargeEndDate() != null) {
|
|
|
+ //拼接充值日期查询条件
|
|
|
+ criRc.where().andBetween("dt", dto.getRechargeBeginDate(), dto.getRechargeEndDate());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
+ //拼接SDK来源
|
|
|
+ criRc.where().andEquals("source_system", dto.getSourceSystem());
|
|
|
+ }
|
|
|
+ //创建sql语句
|
|
|
+ Sql sqlWithRechargeDate = Sqls.create(gameDataTotalSqlRecharge() + criRc);
|
|
|
+ //设置回传对象
|
|
|
+ sqlWithRechargeDate.setCallback(Sqls.callback.entity());
|
|
|
+ sqlWithRechargeDate.setEntity(dao.getEntity(GameDataTotalTotalVO.class));
|
|
|
+ dao.execute(sqlWithRechargeDate);
|
|
|
+ GameDataTotalTotalVO tempVO = sqlWithRechargeDate.getObject(GameDataTotalTotalVO.class);
|
|
|
+ //将两个对象内的数据合并
|
|
|
+ copyNullProperties(tempVO, vo);
|
|
|
+
|
|
|
+ return vo;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -874,8 +1012,13 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 通过反射赋值每日趋势
|
|
|
+ *
|
|
|
+ * @param vo
|
|
|
+ */
|
|
|
private void formatDayN(GameDataDayVO vo) {
|
|
|
- if(CollectionUtils.isEmpty(dayNFieldMapList)) {
|
|
|
+ if (CollectionUtils.isEmpty(dayNFieldMapList)) {
|
|
|
return;
|
|
|
}
|
|
|
dayNFieldMapList.forEach(dayNFieldMap -> {
|
|
@@ -895,46 +1038,42 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 通过反射使用set方法 得到复充趋势的值
|
|
|
+ * 通过反射赋值每日总计趋势
|
|
|
*
|
|
|
- * @param vo 需要操作的对象
|
|
|
- * @param timeType D1-D30 , M1-M6
|
|
|
- * @param tableType buy、nature 总
|
|
|
+ * @param vo
|
|
|
*/
|
|
|
- private void setAgainContentByNum(GameDataDayVO vo, String timeType, String tableType) {
|
|
|
- try {
|
|
|
- //反射得到复充趋势数据字符串
|
|
|
- Field f;
|
|
|
- if (StringUtils.isNotBlank(tableType)) {
|
|
|
- f = vo.getClass().getDeclaredField(tableType + "Amount" + timeType);
|
|
|
- } else {
|
|
|
- f = vo.getClass().getDeclaredField("amount" + timeType);
|
|
|
- }
|
|
|
- f.setAccessible(true);
|
|
|
- //分割数据
|
|
|
- String[] strs = f.get(vo).toString().split("/");
|
|
|
-
|
|
|
- //反射得到set方法
|
|
|
- Field field;
|
|
|
- if (StringUtils.isNotBlank(tableType)) {
|
|
|
- field = vo.getClass().getDeclaredField(tableType + "Amount" + timeType + "Trend");
|
|
|
- } else {
|
|
|
- field = vo.getClass().getDeclaredField("amount" + timeType + "Trend");
|
|
|
- }
|
|
|
-
|
|
|
- field.setAccessible(true);
|
|
|
- //赋值
|
|
|
- field.set(vo, RechargeTrendVO.builder()
|
|
|
- .rechargeMoney(new BigDecimal(strs[0]))
|
|
|
- .rechargeUserCount(Long.valueOf(strs[1]))
|
|
|
- .increase(new BigDecimal(strs[2]))
|
|
|
- .back(new BigDecimal(strs[3]))
|
|
|
- .multiples(new BigDecimal(strs[4]))
|
|
|
- .build());
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- throw new BaseException("get/set 方法出错,映射出错");
|
|
|
+ private void formatDayNTotal(GameDataDayTotalVO vo) {
|
|
|
+ if (CollectionUtils.isEmpty(dayNTotalFieldMapList)) {
|
|
|
+ return;
|
|
|
}
|
|
|
+ dayNTotalFieldMapList.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);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1127,6 +1266,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
buy_new_user_total_amount_count,
|
|
|
buy_new_user_total_amount_num,
|
|
|
buy_new_user_total_amount,
|
|
|
+ buy_total_roi,
|
|
|
buy_first_roi,
|
|
|
buy_first_amount_rate,
|
|
|
buy_today_amount_rate,
|
|
@@ -1174,6 +1314,20 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
buy_amount_m6,
|
|
|
buy_amount_y1,
|
|
|
buy_amount_sum,
|
|
|
+ buy_reg_cost,
|
|
|
+ buy_first_amount_cost as buy_first_new_user_recharge_cost,
|
|
|
+ buy_total_amount_cost as buy_total_recharge_cost,
|
|
|
+ buy_hundred_user_num,
|
|
|
+ buy_hundred_user_num_cost,
|
|
|
+ buy_first_role_num,
|
|
|
+ buy_role_num,
|
|
|
+ buy_new_user_total_role_num,
|
|
|
+ round(IF(buy_first_role_num > 0, cost / buy_first_role_num, 0), 2) buy_first_role_num_cost,
|
|
|
+ round(IF(buy_role_num > 0, cost / buy_role_num, 0), 2) buy_role_num_cost,
|
|
|
+ round(IF(buy_new_user_total_role_num >0, cost / buy_new_user_total_role_num, 0), 2) buy_new_user_total_role_num_cost,
|
|
|
+ round(IF(buy_reg_num >0, buy_first_role_num / buy_reg_num, 0), 4) buy_first_role_num_rate,
|
|
|
+ round(IF(buy_reg_num >0, buy_role_num / buy_reg_num, 0), 4) buy_role_num_rate,
|
|
|
+ round(IF(buy_reg_num >0, buy_new_user_total_role_num / buy_reg_num, 0), 4) buy_new_user_total_role_num_rate,
|
|
|
|
|
|
nature_first_new_user_amount_count,
|
|
|
nature_first_new_user_amount_num,
|
|
@@ -1187,6 +1341,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
nature_new_user_total_amount_count,
|
|
|
nature_new_user_total_amount_num,
|
|
|
nature_new_user_total_amount,
|
|
|
+ nature_total_roi,
|
|
|
nature_first_roi,
|
|
|
nature_first_amount_rate,
|
|
|
nature_today_amount_rate,
|
|
@@ -1234,6 +1389,20 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
nature_amount_m6,
|
|
|
nature_amount_y1,
|
|
|
nature_amount_sum,
|
|
|
+ nature_reg_cost,
|
|
|
+ nature_first_amount_cost as nature_first_new_user_recharge_cost,
|
|
|
+ nature_total_amount_cost as nature_total_recharge_cost,
|
|
|
+ nature_hundred_user_num,
|
|
|
+ nature_hundred_user_num_cost,
|
|
|
+ nature_first_role_num,
|
|
|
+ nature_role_num,
|
|
|
+ nature_new_user_total_role_num,
|
|
|
+ round(IF(nature_first_role_num > 0, cost / nature_first_role_num, 0), 2) nature_first_role_num_cost,
|
|
|
+ round(IF(nature_role_num > 0, cost / nature_role_num, 0), 2) nature_role_num_cost,
|
|
|
+ round(IF(nature_new_user_total_role_num >0, cost / nature_new_user_total_role_num, 0), 2) nature_new_user_total_role_num_cost,
|
|
|
+ round(IF(nature_reg_num >0, nature_first_role_num / nature_reg_num, 0), 4) nature_first_role_num_rate,
|
|
|
+ round(IF(nature_reg_num >0, nature_role_num / nature_reg_num, 0), 4) nature_role_num_rate,
|
|
|
+ round(IF(nature_reg_num >0, nature_new_user_total_role_num / nature_reg_num, 0), 4) nature_new_user_total_role_num_rate,
|
|
|
|
|
|
first_new_user_amount_count,
|
|
|
first_new_user_amount_num,
|
|
@@ -1247,6 +1416,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
new_user_total_amount_count,
|
|
|
new_user_total_amount_num,
|
|
|
new_user_total_amount,
|
|
|
+ total_roi,
|
|
|
first_roi,
|
|
|
first_amount_rate,
|
|
|
today_amount_rate,
|
|
@@ -1293,7 +1463,21 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
amount_m3,
|
|
|
amount_m6,
|
|
|
amount_y1,
|
|
|
- amount_sum
|
|
|
+ amount_sum,
|
|
|
+ reg_cost,
|
|
|
+ first_amount_cost as first_new_user_recharge_cost,
|
|
|
+ total_amount_cost as total_recharge_cost,
|
|
|
+ hundred_user_num,
|
|
|
+ hundred_user_num_cost,
|
|
|
+ first_role_num,
|
|
|
+ role_num,
|
|
|
+ new_user_total_role_num,
|
|
|
+ round(IF(first_role_num > 0, cost / first_role_num, 0), 2) first_role_num_cost,
|
|
|
+ round(IF(role_num > 0, cost / role_num, 0), 2) role_num_cost,
|
|
|
+ round(IF(new_user_total_role_num >0, cost / new_user_total_role_num, 0), 2) new_user_total_role_num_cost,
|
|
|
+ round(IF(reg_num >0, first_role_num / reg_num, 0), 4) first_role_num_rate,
|
|
|
+ round(IF(reg_num >0, role_num / reg_num, 0), 4) role_num_rate,
|
|
|
+ round(IF(reg_num >0, new_user_total_role_num / reg_num, 0), 4) new_user_total_role_num_rate
|
|
|
|
|
|
FROM
|
|
|
ads_game_day
|
|
@@ -1308,92 +1492,296 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
private String gameDataDayTotalSql() {
|
|
|
return """
|
|
|
SELECT
|
|
|
- SUM(cost) cost,
|
|
|
-
|
|
|
- SUM(buy_reg_num) buy_reg_num,
|
|
|
- SUM(nature_reg_num) nature_reg_num,
|
|
|
- SUM(reg_num) reg_num,
|
|
|
+ IFNULL(SUM(cost), 0) cost,
|
|
|
|
|
|
- SUM(buy_first_new_user_amount_count) buy_first_new_user_amount_count,
|
|
|
- SUM(buy_first_new_user_amount_num) buy_first_new_user_amount_num,
|
|
|
- SUM(buy_first_new_user_amount) buy_first_new_user_amount,
|
|
|
- SUM(buy_old_user_count) buy_old_user_count,
|
|
|
- SUM(buy_old_user_num) buy_old_user_num,
|
|
|
- SUM(buy_old_user_amount) buy_old_user_amount,
|
|
|
- SUM(buy_amount_count) buy_amount_count,
|
|
|
- SUM(buy_amount_num) buy_amount_num,
|
|
|
- SUM(buy_amount) buy_amount,
|
|
|
- SUM(buy_new_user_total_amount_count) buy_new_user_total_amount_count,
|
|
|
- SUM(buy_new_user_total_amount_num) buy_new_user_total_amount_num,
|
|
|
- SUM(buy_new_user_total_amount) buy_new_user_total_amount,
|
|
|
- round(if(SUM(cost) > 0 , SUM(buy_first_new_user_amount) / SUM(cost) ,0), 4) buy_first_roi,
|
|
|
- round(if(SUM(buy_reg_num) > 0 , SUM(buy_first_new_user_amount_num) / SUM(buy_reg_num) ,0), 4) buy_first_amount_rate,
|
|
|
- round(if(SUM(buy_reg_num) > 0, SUM(buy_new_user_total_amount_num) / SUM(buy_reg_num), 0) ,4) buy_today_amount_rate,
|
|
|
- round(if(SUM(buy_amount_num) > 0 , SUM(buy_first_new_user_amount_num) / SUM(buy_amount_num) ,0), 4) buy_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) buy_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) buy_today_avg_amount,
|
|
|
- round(if(SUM(buy_amount_count) > 0, SUM(buy_amount) / SUM(buy_amount_count), 0), 2) buy_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) buy_user_again_rate,
|
|
|
- round(if(SUM(buy_reg_num) > 0, SUM(buy_new_user_total_amount) / SUM(buy_reg_num), 0), 2) buy_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) buy_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) buy_today_amount_arpu,
|
|
|
- round(if(SUM(buy_amount_num) > 0, SUM(buy_amount) / SUM(buy_amount_num), 0), 2) buy_amount_arpu,
|
|
|
-
|
|
|
- SUM(nature_first_new_user_amount_count) nature_first_new_user_amount_count,
|
|
|
- SUM(nature_first_new_user_amount_num) nature_first_new_user_amount_num,
|
|
|
- SUM(nature_first_new_user_amount) nature_first_new_user_amount,
|
|
|
- SUM(nature_old_user_count) nature_old_user_count,
|
|
|
- SUM(nature_old_user_num) nature_old_user_num,
|
|
|
- SUM(nature_old_user_amount) nature_old_user_amount,
|
|
|
- SUM(nature_amount_count) nature_amount_count,
|
|
|
- SUM(nature_amount_num) nature_amount_num,
|
|
|
- SUM(nature_amount) nature_amount,
|
|
|
- SUM(nature_new_user_total_amount_count) nature_new_user_total_amount_count,
|
|
|
- SUM(nature_new_user_total_amount_num) nature_new_user_total_amount_num,
|
|
|
- SUM(nature_new_user_total_amount) nature_new_user_total_amount,
|
|
|
- round(if(SUM(cost) > 0 , SUM(nature_first_new_user_amount) / SUM(cost) ,0), 4) nature_first_roi,
|
|
|
- round(if(SUM(nature_reg_num) > 0 , SUM(nature_first_new_user_amount_num) / SUM(nature_reg_num) ,0), 4) nature_first_amount_rate,
|
|
|
- round(if(SUM(nature_reg_num) > 0, SUM(nature_new_user_total_amount_num) / SUM(nature_reg_num), 0) ,4) nature_today_amount_rate,
|
|
|
- round(if(SUM(nature_amount_num) > 0 , SUM(nature_first_new_user_amount_num) / SUM(nature_amount_num) ,0), 4) nature_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) nature_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) nature_today_avg_amount,
|
|
|
- round(if(SUM(nature_amount_count) > 0, SUM(nature_amount) / SUM(nature_amount_count), 0), 2) nature_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) nature_user_again_rate,
|
|
|
- round(if(SUM(nature_reg_num) > 0, SUM(nature_new_user_total_amount) / SUM(nature_reg_num), 0), 2) nature_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) nature_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) nature_today_amount_arpu,
|
|
|
- round(if(SUM(nature_amount_num) > 0, SUM(nature_amount) / SUM(nature_amount_num), 0), 2) nature_amount_arpu,
|
|
|
+ IFNULL(SUM(buy_reg_num), 0) buy_reg_num,
|
|
|
+ IFNULL(SUM(nature_reg_num), 0) nature_reg_num,
|
|
|
+ IFNULL(SUM(reg_num), 0) reg_num,
|
|
|
|
|
|
- SUM(first_new_user_amount_count) first_new_user_amount_count,
|
|
|
- SUM(first_new_user_amount_num) first_new_user_amount_num,
|
|
|
- SUM(first_new_user_amount) first_new_user_amount,
|
|
|
- SUM(old_user_count) old_user_count,
|
|
|
- SUM(old_user_num) old_user_num,
|
|
|
- SUM(old_user_amount) old_user_amount,
|
|
|
- SUM(amount_count) amount_count,
|
|
|
- SUM(amount_num) amount_num,
|
|
|
- SUM(amount) amount,
|
|
|
- SUM(new_user_total_amount_count) new_user_total_amount_count,
|
|
|
- SUM(new_user_total_amount_num) new_user_total_amount_num,
|
|
|
- SUM(new_user_total_amount) 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
|
|
|
-
|
|
|
- FROM
|
|
|
- ads_game_day
|
|
|
-
|
|
|
-
|
|
|
- """;
|
|
|
+ """
|
|
|
+ + amountDay("buy_") +
|
|
|
+ """
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 29 day) <= LocalDate.now() , CAST(SPLIT_PART(buy_amount_m1 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(buy_amount_m1, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(buy_amount_m1, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 29 day) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 29 day) <= LocalDate.now(), CAST(SPLIT_PART(buy_amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS buy_amount_m1,
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 59 day) <= LocalDate.now() , CAST(SPLIT_PART(buy_amount_m2 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(buy_amount_m2, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(buy_amount_m2, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 59 day) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 59 day) <= LocalDate.now(), CAST(SPLIT_PART(buy_amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS buy_amount_m2,
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 89 day) <= LocalDate.now() , CAST(SPLIT_PART(buy_amount_m3 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(buy_amount_m3, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(buy_amount_m3, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 89 day) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 89 day) <= LocalDate.now(), CAST(SPLIT_PART(buy_amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS buy_amount_m3,
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 179 day) <= LocalDate.now() , CAST(SPLIT_PART(buy_amount_m6 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(buy_amount_m6, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(buy_amount_m6, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 179 day) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 179 day) <= LocalDate.now(), CAST(SPLIT_PART(buy_amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS buy_amount_m6,
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 1 year) <= LocalDate.now() , CAST(SPLIT_PART(buy_amount_y1 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(buy_amount_y1, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(buy_amount_y1, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 1 year) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 1 year) <= LocalDate.now(), CAST(SPLIT_PART(buy_amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS buy_amount_y1,
|
|
|
+ CONCAT(
|
|
|
+ SUM(CAST(SPLIT_PART(buy_amount_sum , '/', 1) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(buy_amount_sum, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(buy_amount_sum, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(cost), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(buy_amount_d1 , '/', 1) AS DECIMAL(10, 2)))
|
|
|
+ ) AS buy_amount_sum,
|
|
|
+ IFNULL(SUM(buy_first_new_user_amount_count), 0) buy_first_new_user_amount_count,
|
|
|
+ IFNULL(SUM(buy_first_new_user_amount_num), 0) buy_first_new_user_amount_num,
|
|
|
+ IFNULL(SUM(buy_first_new_user_amount), 0) buy_first_new_user_amount,
|
|
|
+ IFNULL(SUM(buy_old_user_count), 0) buy_old_user_count,
|
|
|
+ IFNULL(SUM(buy_old_user_num), 0) buy_old_user_num,
|
|
|
+ IFNULL(SUM(buy_old_user_amount), 0) buy_old_user_amount,
|
|
|
+ IFNULL(SUM(buy_amount_count), 0) buy_amount_count,
|
|
|
+ IFNULL(SUM(buy_amount_num), 0) buy_amount_num,
|
|
|
+ IFNULL(SUM(buy_amount), 0) buy_amount,
|
|
|
+ IFNULL(SUM(buy_new_user_total_amount_count), 0) buy_new_user_total_amount_count,
|
|
|
+ IFNULL(SUM(buy_new_user_total_amount_num), 0) buy_new_user_total_amount_num,
|
|
|
+ IFNULL(SUM(buy_new_user_total_amount), 0) buy_new_user_total_amount,
|
|
|
+ round(if(SUM(cost) > 0 , SUM(buy_first_new_user_amount) / SUM(cost) ,0), 4) buy_first_roi,
|
|
|
+ round(if(SUM(buy_reg_num) > 0 , SUM(buy_first_new_user_amount_num) / SUM(buy_reg_num) ,0), 4) buy_first_amount_rate,
|
|
|
+ round(if(SUM(buy_reg_num) > 0, SUM(buy_new_user_total_amount_num) / SUM(buy_reg_num), 0) ,4) buy_today_amount_rate,
|
|
|
+ round(if(SUM(buy_amount_num) > 0 , SUM(buy_first_new_user_amount_num) / SUM(buy_amount_num) ,0), 4) buy_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) buy_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) buy_today_avg_amount,
|
|
|
+ round(if(SUM(buy_amount_count) > 0, SUM(buy_amount) / SUM(buy_amount_count), 0), 2) buy_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) buy_user_again_rate,
|
|
|
+ round(if(SUM(buy_reg_num) > 0, SUM(buy_new_user_total_amount) / SUM(buy_reg_num), 0), 2) buy_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) buy_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) buy_today_amount_arpu,
|
|
|
+ round(if(SUM(buy_amount_num) > 0, SUM(buy_amount) / SUM(buy_amount_num), 0), 2) buy_amount_arpu,
|
|
|
+ round(if(SUM(buy_reg_num) > 0, SUM(cost) / SUM(buy_reg_num), 0), 2) buy_reg_cost,
|
|
|
+ round(if(SUM(buy_first_new_user_amount_num) > 0, SUM(cost) / SUM(buy_first_new_user_amount_num), 0), 2) buy_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) buy_total_recharge_cost,
|
|
|
+ round(if(SUM(cost) > 0, SUM(buy_new_user_total_amount) / SUM(cost), 0), 4) buy_total_roi,
|
|
|
+ SUM(buy_hundred_user_num) buy_hundred_user_num,
|
|
|
+ round(IF(SUM(buy_hundred_user_num) > 0, SUM(cost) / SUM(buy_hundred_user_num), 0), 2) buy_hundred_user_num_cost,
|
|
|
+ SUM(buy_first_role_num) buy_first_role_num,
|
|
|
+ SUM(buy_role_num) buy_role_num,
|
|
|
+ SUM(buy_new_user_total_role_num) buy_new_user_total_role_num,
|
|
|
+ round(IF(SUM(buy_first_role_num) > 0, SUM(cost) / SUM(buy_first_role_num), 0), 2) buy_first_role_num_cost,
|
|
|
+ round(IF(SUM(buy_role_num) > 0, SUM(cost) / SUM(buy_role_num), 0), 2) buy_role_num_cost,
|
|
|
+ round(IF(SUM(buy_new_user_total_role_num) >0, SUM(cost) / SUM(buy_new_user_total_role_num), 0), 2) buy_new_user_total_role_num_cost,
|
|
|
+ round(IF(SUM(buy_reg_num) >0, SUM(buy_first_role_num) / SUM(buy_reg_num), 0), 4) buy_first_role_num_rate,
|
|
|
+ round(IF(SUM(buy_reg_num) >0, SUM(buy_role_num) / SUM(buy_reg_num), 0), 4) buy_role_num_rate,
|
|
|
+ round(IF(SUM(buy_reg_num) >0, SUM(buy_new_user_total_role_num) / SUM(buy_reg_num), 0), 4) buy_new_user_total_role_num_rate,
|
|
|
+
|
|
|
+ """
|
|
|
+ + amountDay("nature_") +
|
|
|
+ """
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 29 day) <= LocalDate.now() , CAST(SPLIT_PART(nature_amount_m1 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(nature_amount_m1, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(nature_amount_m1, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 29 day) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 29 day) <= LocalDate.now(), CAST(SPLIT_PART(nature_amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS nature_amount_m1,
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 59 day) <= LocalDate.now() , CAST(SPLIT_PART(nature_amount_m2 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(nature_amount_m2, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(nature_amount_m2, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 59 day) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 59 day) <= LocalDate.now(), CAST(SPLIT_PART(nature_amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS nature_amount_m2,
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 89 day) <= LocalDate.now() , CAST(SPLIT_PART(nature_amount_m3 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(nature_amount_m3, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(nature_amount_m3, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 89 day) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 89 day) <= LocalDate.now(), CAST(SPLIT_PART(nature_amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS nature_amount_m3,
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 179 day) <= LocalDate.now() , CAST(SPLIT_PART(nature_amount_m6 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(nature_amount_m6, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(nature_amount_m6, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 179 day) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 179 day) <= LocalDate.now(), CAST(SPLIT_PART(nature_amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS nature_amount_m6,
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 1 year) <= LocalDate.now() , CAST(SPLIT_PART(nature_amount_y1 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(nature_amount_y1, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(nature_amount_y1, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 1 year) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 1 year) <= LocalDate.now(), CAST(SPLIT_PART(nature_amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS nature_amount_y1,
|
|
|
+ CONCAT(
|
|
|
+ SUM(CAST(SPLIT_PART(nature_amount_sum , '/', 1) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(nature_amount_sum, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(nature_amount_sum, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(cost), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(nature_amount_d1 , '/', 1) AS DECIMAL(10, 2)))
|
|
|
+ ) AS nature_amount_sum,
|
|
|
+ IFNULL(SUM(nature_first_new_user_amount_count), 0) nature_first_new_user_amount_count,
|
|
|
+ IFNULL(SUM(nature_first_new_user_amount_num), 0) nature_first_new_user_amount_num,
|
|
|
+ IFNULL(SUM(nature_first_new_user_amount), 0) nature_first_new_user_amount,
|
|
|
+ IFNULL(SUM(nature_old_user_count), 0) nature_old_user_count,
|
|
|
+ IFNULL(SUM(nature_old_user_num), 0) nature_old_user_num,
|
|
|
+ IFNULL(SUM(nature_old_user_amount), 0) nature_old_user_amount,
|
|
|
+ IFNULL(SUM(nature_amount_count), 0) nature_amount_count,
|
|
|
+ IFNULL(SUM(nature_amount_num), 0) nature_amount_num,
|
|
|
+ IFNULL(SUM(nature_amount), 0) nature_amount,
|
|
|
+ IFNULL(SUM(nature_new_user_total_amount_count), 0) nature_new_user_total_amount_count,
|
|
|
+ IFNULL(SUM(nature_new_user_total_amount_num), 0) nature_new_user_total_amount_num,
|
|
|
+ IFNULL(SUM(nature_new_user_total_amount), 0) nature_new_user_total_amount,
|
|
|
+ round(if(SUM(cost) > 0 , SUM(nature_first_new_user_amount) / SUM(cost) ,0), 4) nature_first_roi,
|
|
|
+ round(if(SUM(nature_reg_num) > 0 , SUM(nature_first_new_user_amount_num) / SUM(nature_reg_num) ,0), 4) nature_first_amount_rate,
|
|
|
+ round(if(SUM(nature_reg_num) > 0, SUM(nature_new_user_total_amount_num) / SUM(nature_reg_num), 0) ,4) nature_today_amount_rate,
|
|
|
+ round(if(SUM(nature_amount_num) > 0 , SUM(nature_first_new_user_amount_num) / SUM(nature_amount_num) ,0), 4) nature_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) nature_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) nature_today_avg_amount,
|
|
|
+ round(if(SUM(nature_amount_count) > 0, SUM(nature_amount) / SUM(nature_amount_count), 0), 2) nature_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) nature_user_again_rate,
|
|
|
+ round(if(SUM(nature_reg_num) > 0, SUM(nature_new_user_total_amount) / SUM(nature_reg_num), 0), 2) nature_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) nature_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) nature_today_amount_arpu,
|
|
|
+ round(if(SUM(nature_amount_num) > 0, SUM(nature_amount) / SUM(nature_amount_num), 0), 2) nature_amount_arpu,
|
|
|
+ round(if(SUM(nature_reg_num) > 0, SUM(cost) / SUM(nature_reg_num), 0), 2) nature_reg_cost,
|
|
|
+ round(if(SUM(nature_first_new_user_amount_num) > 0, SUM(cost) / SUM(nature_first_new_user_amount_num), 0), 2) nature_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) nature_total_recharge_cost,
|
|
|
+ round(if(SUM(cost) > 0, SUM(nature_new_user_total_amount) / SUM(cost), 0), 4) nature_total_roi,
|
|
|
+ SUM(nature_hundred_user_num) nature_hundred_user_num,
|
|
|
+ round(IF(SUM(nature_hundred_user_num) > 0, SUM(cost) / SUM(nature_hundred_user_num), 0), 2) nature_hundred_user_num_cost,
|
|
|
+ SUM(nature_first_role_num) nature_first_role_num,
|
|
|
+ SUM(nature_role_num) nature_role_num,
|
|
|
+ SUM(nature_new_user_total_role_num) nature_new_user_total_role_num,
|
|
|
+ round(IF(SUM(nature_first_role_num) > 0, SUM(cost) / SUM(nature_first_role_num), 0), 2) nature_first_role_num_cost,
|
|
|
+ round(IF(SUM(nature_role_num) > 0, SUM(cost) / SUM(nature_role_num), 0), 2) nature_role_num_cost,
|
|
|
+ round(IF(SUM(nature_new_user_total_role_num) >0, SUM(cost) / SUM(nature_new_user_total_role_num), 0), 2) nature_new_user_total_role_num_cost,
|
|
|
+ round(IF(SUM(nature_reg_num) >0, SUM(nature_first_role_num) / SUM(nature_reg_num), 0), 4) nature_first_role_num_rate,
|
|
|
+ round(IF(SUM(nature_reg_num) >0, SUM(nature_role_num) / SUM(nature_reg_num), 0), 4) nature_role_num_rate,
|
|
|
+ round(IF(SUM(nature_reg_num) >0, SUM(nature_new_user_total_role_num) / SUM(nature_reg_num), 0), 4) nature_new_user_total_role_num_rate,
|
|
|
+
|
|
|
+ """
|
|
|
+ + amountDay("") +
|
|
|
+ """
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 29 day) <= LocalDate.now() , CAST(SPLIT_PART(amount_m1 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(amount_m1, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(amount_m1, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 29 day) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 29 day) <= LocalDate.now(), CAST(SPLIT_PART(amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS amount_m1,
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 59 day) <= LocalDate.now() , CAST(SPLIT_PART(amount_m2 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(amount_m2, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(amount_m2, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 59 day) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 59 day) <= LocalDate.now(), CAST(SPLIT_PART(amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS amount_m2,
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 89 day) <= LocalDate.now() , CAST(SPLIT_PART(amount_m3 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(amount_m3, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(amount_m3, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 89 day) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 89 day) <= LocalDate.now(), CAST(SPLIT_PART(amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS amount_m3,
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 179 day) <= LocalDate.now() , CAST(SPLIT_PART(amount_m6 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(amount_m6, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(amount_m6, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 179 day) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 179 day) <= LocalDate.now(), CAST(SPLIT_PART(amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS amount_m6,
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 1 year) <= LocalDate.now() , CAST(SPLIT_PART(amount_y1 , '/', 1) AS DECIMAL(10, 2)), 0 )), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(amount_y1, '/', 6) AS DECIMAL(10, 2))), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(amount_y1, '/', 2) AS BIGINT)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 1 year) <= LocalDate.now(), cost, 0)), '/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL 1 year) <= LocalDate.now(), CAST(SPLIT_PART(amount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS amount_y1,
|
|
|
+ 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)), '/',
|
|
|
+ SUM(cost), '/',
|
|
|
+ SUM(CAST(SPLIT_PART(amount_d1 , '/', 1) AS DECIMAL(10, 2)))
|
|
|
+ ) AS amount_sum,
|
|
|
+ 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
|
|
|
+ *
|
|
|
+ * @param type 输入的参数表示选择表的类型
|
|
|
+ * @return String : Dn的充值金额 / D1-Dn的充值总金额 / Dn的充值人数 /当前消耗(剔除不存在的天数数据) /D1充值金额总和(剔除不存在的天数数据)/type
|
|
|
+ */
|
|
|
+ private String amountDay(String type) {
|
|
|
+ //拼接查询条件
|
|
|
+ StringBuilder trendDay = new StringBuilder(StringUtils.EMPTY);
|
|
|
+ for (int day = 1; day <= 29; day++) {
|
|
|
+ trendDay.append("""
|
|
|
+ CONCAT(
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL %s day) <= LocalDate.now() , CAST(SPLIT_PART(%samount_d%s , '/', 1) AS DECIMAL(10, 2)), 0 )),'/',
|
|
|
+ SUM(CAST(SPLIT_PART( %samount_d%s, '/', 6) AS DECIMAL(10, 2))),'/',
|
|
|
+ SUM(CAST(SPLIT_PART(%samount_d%s, '/', 2) AS BIGINT)),'/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL %s day) <= LocalDate.now(), cost, 0)),'/',
|
|
|
+ SUM(IF( DATE_ADD(dt, INTERVAL %s day) <= LocalDate.now(), CAST(SPLIT_PART(%samount_d1 , '/', 1) AS DECIMAL(10, 2)) , 0))
|
|
|
+ ) AS %samount_d%s ,
|
|
|
+ """.formatted(day - 1, type, day, type, day, type, day, day - 1, day - 1, type, type, day));
|
|
|
+ }
|
|
|
+
|
|
|
+ return trendDay.toString();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1433,12 +1821,15 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
sum(a.new_user_total_amount_num) new_user_total_amount_num,
|
|
|
sum(a.new_user_total_amount) new_user_total_amount,
|
|
|
|
|
|
- round(if(sum(a.buy_reg_num) > 0 ,sum(a.buy_first_new_user_amount_num) / sum(a.buy_reg_num), 0), 4) buy_first_roi,
|
|
|
- round(if(sum(a.buy_reg_num) > 0, sum(a.buy_new_user_total_amount_num) / sum(a.buy_reg_num), 0), 4) buy_today_roi,
|
|
|
- round(if(sum(a.nature_reg_num) > 0 ,sum(a.nature_first_new_user_amount_num) / sum(a.nature_reg_num), 0), 4) nature_first_roi,
|
|
|
- round(if(sum(a.nature_reg_num) > 0, sum(a.nature_new_user_total_amount_num) / sum(a.nature_reg_num), 0), 4) nature_today_roi,
|
|
|
- round(if(sum(a.reg_num) > 0 ,sum(a.first_new_user_amount_num) / sum(a.reg_num), 0), 4) first_roi,
|
|
|
- round(if(sum(a.reg_num) > 0, sum(a.new_user_total_amount_num) / sum(a.reg_num), 0), 4) today_roi,
|
|
|
+ round(if(SUM(a.cost) > 0 , SUM(buy_first_new_user_amount) / SUM(a.cost) ,0), 4) buy_first_roi,
|
|
|
+ round(if(sum(a.buy_reg_num) > 0 ,sum(a.buy_first_new_user_amount_num) / sum(a.buy_reg_num), 0), 4) buy_first_amount_rate,
|
|
|
+ round(if(sum(a.buy_reg_num) > 0, sum(a.buy_new_user_total_amount_num) / sum(a.buy_reg_num), 0), 4) buy_today_amount_rate,
|
|
|
+ round(if(SUM(a.cost) > 0 , SUM(a.nature_first_new_user_amount) / SUM(a.cost) ,0), 4) nature_first_roi,
|
|
|
+ round(if(sum(a.nature_reg_num) > 0 ,sum(a.nature_first_new_user_amount_num) / sum(a.nature_reg_num), 0), 4) nature_first_amount_rate,
|
|
|
+ round(if(sum(a.nature_reg_num) > 0, sum(a.nature_new_user_total_amount_num) / sum(a.nature_reg_num), 0), 4) nature_today_amount_rate,
|
|
|
+ round(if(SUM(a.cost) > 0 , SUM(first_new_user_amount) / SUM(a.cost) ,0), 4) first_roi,
|
|
|
+ round(if(sum(a.reg_num) > 0 ,sum(a.first_new_user_amount_num) / sum(a.reg_num), 0), 4) first_amount_rate,
|
|
|
+ round(if(sum(a.reg_num) > 0, sum(a.new_user_total_amount_num) / sum(a.reg_num), 0), 4) today_amount_rate,
|
|
|
|
|
|
round(if(sum(a.buy_first_new_user_amount_count) > 0, sum(a.buy_first_new_user_amount) / sum(a.buy_first_new_user_amount_count), 0), 2) buy_first_avg_amount,
|
|
|
round(if(sum(a.buy_new_user_total_amount_count) > 0, sum(a.buy_new_user_total_amount) / sum(a.buy_new_user_total_amount_count), 0), 2) buy_today_avg_amount,
|
|
@@ -1464,13 +1855,155 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
|
|
|
round(if(sum(a.reg_num) > 0 , sum(a.new_user_total_amount) / sum(a.reg_num), 0), 2) reg_user_arpu,
|
|
|
round(if(sum(a.first_new_user_amount_num) > 0 , sum(a.first_new_user_amount) / sum(a.first_new_user_amount_num), 0), 2) first_amount_arpu,
|
|
|
- round(if(sum(a.new_user_total_amount_num) > 0 , sum(a.new_user_total_amount) / sum(a.new_user_total_amount_num), 0), 2) today_amount_arpu
|
|
|
+ round(if(sum(a.new_user_total_amount_num) > 0 , sum(a.new_user_total_amount) / sum(a.new_user_total_amount_num), 0), 2) today_amount_arpu,
|
|
|
+
|
|
|
+ round(if(SUM(buy_reg_num) > 0, SUM(cost) / SUM(buy_reg_num), 0), 2) buy_reg_cost,
|
|
|
+ round(if(SUM(nature_reg_num) > 0, SUM(cost) / SUM(nature_reg_num), 0), 2) nature_reg_cost,
|
|
|
+ round(if(SUM(reg_num) > 0, SUM(cost) / SUM(reg_num), 0), 2) reg_cost,
|
|
|
+
|
|
|
+ round(if(SUM(cost) > 0 , SUM(buy_new_user_total_amount) / SUM(cost), 0), 4) buy_total_roi,
|
|
|
+ round(if(SUM(cost) > 0 , SUM(nature_new_user_total_amount) / SUM(cost), 0), 4) nature_total_roi,
|
|
|
+ round(if(SUM(cost) > 0 , SUM(new_user_total_amount) / SUM(cost), 0), 4) total_roi,
|
|
|
+
|
|
|
+ round(if(SUM(buy_first_new_user_amount_num) > 0, SUM(cost) / SUM(buy_first_new_user_amount_num), 0), 2) buy_first_new_user_recharge_cost,
|
|
|
+ round(if(SUM(nature_first_new_user_amount_num) > 0, SUM(cost) / SUM(nature_first_new_user_amount_num), 0), 2) nature_first_new_user_recharge_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(buy_new_user_total_amount_num) > 0, SUM(cost) / SUM(buy_new_user_total_amount_num), 0), 2) buy_total_recharge_cost,
|
|
|
+ round(if(SUM(nature_new_user_total_amount_num) > 0, SUM(cost) / SUM(nature_new_user_total_amount_num), 0), 2) nature_total_recharge_cost,
|
|
|
+ round(if(SUM(new_user_total_amount_num) > 0, SUM(cost) / SUM(new_user_total_amount_num), 0), 2) total_recharge_cost,
|
|
|
+
|
|
|
+ SUM(buy_hundred_user_num) buy_hundred_user_num,
|
|
|
+ round(IF(SUM(buy_hundred_user_num) > 0, SUM(cost) / SUM(buy_hundred_user_num), 0), 2) buy_hundred_user_num_cost,
|
|
|
+ SUM(buy_first_role_num) buy_first_role_num,
|
|
|
+ SUM(buy_role_num) buy_role_num,
|
|
|
+ SUM(buy_new_user_total_role_num) buy_new_user_total_role_num,
|
|
|
+ round(IF(SUM(buy_first_role_num) > 0, SUM(cost) / SUM(buy_first_role_num), 0), 2) buy_first_role_num_cost,
|
|
|
+ round(IF(SUM(buy_role_num) > 0, SUM(cost) / SUM(buy_role_num), 0), 2) buy_role_num_cost,
|
|
|
+ round(IF(SUM(buy_new_user_total_role_num) >0, SUM(cost) / SUM(buy_new_user_total_role_num), 0), 2) buy_new_user_total_role_num_cost,
|
|
|
+ round(IF(SUM(buy_reg_num) >0, SUM(buy_first_role_num) / SUM(buy_reg_num), 0), 4) buy_first_role_num_rate,
|
|
|
+ round(IF(SUM(buy_reg_num) >0, SUM(buy_role_num) / SUM(buy_reg_num), 0), 4) buy_role_num_rate,
|
|
|
+ round(IF(SUM(buy_reg_num) >0, SUM(buy_new_user_total_role_num) / SUM(buy_reg_num), 0), 4) buy_new_user_total_role_num_rate,
|
|
|
+
|
|
|
+ SUM(nature_hundred_user_num) nature_hundred_user_num,
|
|
|
+ round(IF(SUM(nature_hundred_user_num) > 0, SUM(cost) / SUM(nature_hundred_user_num), 0), 2) nature_hundred_user_num_cost,
|
|
|
+ SUM(nature_first_role_num) nature_first_role_num,
|
|
|
+ SUM(nature_role_num) nature_role_num,
|
|
|
+ SUM(nature_new_user_total_role_num) nature_new_user_total_role_num,
|
|
|
+ round(IF(SUM(nature_first_role_num) > 0, SUM(cost) / SUM(nature_first_role_num), 0), 2) nature_first_role_num_cost,
|
|
|
+ round(IF(SUM(nature_role_num) > 0, SUM(cost) / SUM(nature_role_num), 0), 2) nature_role_num_cost,
|
|
|
+ round(IF(SUM(nature_new_user_total_role_num) >0, SUM(cost) / SUM(nature_new_user_total_role_num), 0), 2) nature_new_user_total_role_num_cost,
|
|
|
+ round(IF(SUM(nature_reg_num) >0, SUM(nature_first_role_num) / SUM(nature_reg_num), 0), 4) nature_first_role_num_rate,
|
|
|
+ round(IF(SUM(nature_reg_num) >0, SUM(nature_role_num) / SUM(nature_reg_num), 0), 4) nature_role_num_rate,
|
|
|
+ round(IF(SUM(nature_reg_num) >0, SUM(nature_new_user_total_role_num) / SUM(nature_reg_num), 0), 4) nature_new_user_total_role_num_rate,
|
|
|
+
|
|
|
+ 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 a
|
|
|
""";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 游戏总数据总计一栏sql
|
|
|
+ *
|
|
|
+ * @return String
|
|
|
+ */
|
|
|
+ private String gameDataTotalTotalSql() {
|
|
|
+ return """
|
|
|
+ SELECT
|
|
|
+ IFNULL(sum(buy_reg_num), 0) buy_reg_num,
|
|
|
+ IFNULL(sum(nature_reg_num), 0) nature_reg_num,
|
|
|
+ IFNULL(sum(reg_num), 0) reg_num,
|
|
|
+ IFNULL(sum(cost), 0) cost,
|
|
|
+
|
|
|
+ IFNULL(sum(buy_first_new_user_amount_count), 0) buy_first_new_user_amount_count,
|
|
|
+ IFNULL(sum(buy_first_new_user_amount_num), 0) buy_first_new_user_amount_num,
|
|
|
+ IFNULL(sum(buy_first_new_user_amount), 0) buy_first_new_user_amount,
|
|
|
+ IFNULL(sum(nature_first_new_user_amount_count), 0) nature_first_new_user_amount_count,
|
|
|
+ IFNULL(sum(nature_first_new_user_amount_num), 0) nature_first_new_user_amount_num,
|
|
|
+ IFNULL(sum(nature_first_new_user_amount), 0) nature_first_new_user_amount,
|
|
|
+ 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(buy_new_user_total_amount_count), 0) buy_new_user_total_amount_count,
|
|
|
+ IFNULL(sum(buy_new_user_total_amount_num), 0) buy_new_user_total_amount_num,
|
|
|
+ IFNULL(sum(buy_new_user_total_amount), 0) buy_new_user_total_amount,
|
|
|
+ IFNULL(sum(nature_new_user_total_amount_count), 0) nature_new_user_total_amount_count,
|
|
|
+ IFNULL(sum(nature_new_user_total_amount_num), 0) nature_new_user_total_amount_num,
|
|
|
+ IFNULL(sum(nature_new_user_total_amount), 0) nature_new_user_total_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(buy_first_new_user_amount) / SUM(cost) ,0), 4) buy_first_roi,
|
|
|
+ round(if(sum(buy_reg_num) > 0 ,sum(buy_first_new_user_amount_num) / sum(buy_reg_num), 0), 4) buy_first_amount_rate,
|
|
|
+ round(if(sum(buy_reg_num) > 0, sum(buy_new_user_total_amount_num) / sum(buy_reg_num), 0), 4) buy_today_amount_rate,
|
|
|
+ round(if(SUM(cost) > 0 , SUM(nature_first_new_user_amount) / SUM(cost) ,0), 4) nature_first_roi,
|
|
|
+ round(if(sum(nature_reg_num) > 0 ,sum(nature_first_new_user_amount_num) / sum(nature_reg_num), 0), 4) nature_first_amount_rate,
|
|
|
+ round(if(sum(nature_reg_num) > 0, sum(nature_new_user_total_amount_num) / sum(nature_reg_num), 0), 4) nature_today_amount_rate,
|
|
|
+ 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(buy_first_new_user_amount_count) > 0, sum(buy_first_new_user_amount) / sum(buy_first_new_user_amount_count), 0), 2) buy_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) buy_today_avg_amount,
|
|
|
+
|
|
|
+ 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) nature_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) nature_today_avg_amount,
|
|
|
+
|
|
|
+ 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(buy_new_user_total_amount_num) > 0 , sum(buy_reg_order_user_again) / sum(buy_new_user_total_amount_num), 0), 4) buy_today_again_rate,
|
|
|
+ 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) nature_today_again_rate,
|
|
|
+ round(if(sum(new_user_total_amount_num) > 0 , sum(reg_order_user_again) / sum(new_user_total_amount_num), 0), 4) today_again_rate,
|
|
|
+
|
|
|
+ round(if(sum(buy_reg_num) > 0 , sum(buy_new_user_total_amount) / sum(buy_reg_num), 0), 2) buy_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) buy_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) buy_today_amount_arpu,
|
|
|
+
|
|
|
+ round(if(sum(nature_reg_num) > 0 , sum(nature_new_user_total_amount) / sum(nature_reg_num), 0), 2) nature_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) nature_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) nature_today_amount_arpu,
|
|
|
+
|
|
|
+ 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(buy_reg_num) > 0, SUM(cost) / SUM(buy_reg_num), 0), 2) buy_reg_cost,
|
|
|
+ round(if(SUM(nature_reg_num) > 0, SUM(cost) / SUM(nature_reg_num), 0), 2) nature_reg_cost,
|
|
|
+ round(if(SUM(reg_num) > 0, SUM(cost) / SUM(reg_num), 0), 2) reg_cost,
|
|
|
+
|
|
|
+ round(if(SUM(cost) > 0 , SUM(buy_new_user_total_amount) / SUM(cost), 0), 4) buy_total_roi,
|
|
|
+ round(if(SUM(cost) > 0 , SUM(nature_new_user_total_amount) / SUM(cost), 0), 4) nature_total_roi,
|
|
|
+ round(if(SUM(cost) > 0 , SUM(new_user_total_amount) / SUM(cost), 0), 4) total_roi,
|
|
|
+
|
|
|
+ round(if(SUM(buy_first_new_user_amount_num) > 0, SUM(cost) / SUM(buy_first_new_user_amount_num), 0), 2) buy_first_new_user_recharge_cost,
|
|
|
+ round(if(SUM(nature_first_new_user_amount_num) > 0, SUM(cost) / SUM(nature_first_new_user_amount_num), 0), 2) nature_first_new_user_recharge_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(buy_new_user_total_amount_num) > 0, SUM(cost) / SUM(buy_new_user_total_amount_num), 0), 2) buy_total_recharge_cost,
|
|
|
+ round(if(SUM(nature_new_user_total_amount_num) > 0, SUM(cost) / SUM(nature_new_user_total_amount_num), 0), 2) nature_total_recharge_cost,
|
|
|
+ round(if(SUM(new_user_total_amount_num) > 0, SUM(cost) / SUM(new_user_total_amount_num), 0), 2) total_recharge_cost
|
|
|
+
|
|
|
+ FROM
|
|
|
+ game_ads.ads_game_day
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 和充值时间有关的sql
|
|
|
*
|