|
@@ -969,6 +969,20 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
public Page<GameDataWaterVO> getGameDataWater(GameDataWaterDTO dto) {
|
|
|
com.github.sd4324530.jtuple.Tuple2<List<Long>, List<Long>> poerInfo = dataPowerComponent.getPowerInfo();
|
|
|
List<Long> userGameIds = dto.getGameId() == null ? poerInfo.second : Collections.singletonList(dto.getGameId());
|
|
|
+
|
|
|
+ if (dto.getGameDimension() == null) {
|
|
|
+ //默认查询子游戏维度
|
|
|
+ dto.setGameDimension(1L);
|
|
|
+ }
|
|
|
+ //默认查询的字段
|
|
|
+ String gameColumn = "game_id";
|
|
|
+ String classifyColumn = "game_classify";
|
|
|
+ String gameNameColumn = "game_name";
|
|
|
+ if (dto.getGameDimension() == 2L) {
|
|
|
+ gameColumn = "parent_game_id";
|
|
|
+ classifyColumn = "parent_game_classify";
|
|
|
+ gameNameColumn = "parent_game_name";
|
|
|
+ }
|
|
|
if (null == dto.getRechargeDate()) {
|
|
|
dto.setRechargeDate(LocalDate.now());
|
|
|
}
|
|
@@ -982,30 +996,37 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
// 创建一个 Criteria 接口实例
|
|
|
SimpleCriteria cri = Cnd.cri();
|
|
|
if (StringUtils.isNotBlank(dto.getGameName())) {
|
|
|
- cri.where().andLike("game_name", dto.getGameName());
|
|
|
+ cri.where().andLike(gameNameColumn, dto.getGameName());
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getGameClassify())) {
|
|
|
- cri.where().andEquals("game_classify", dto.getGameClassify());
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(dto.getGameClassify())) {
|
|
|
- cri.where().andEquals("game_classify", dto.getGameClassify());
|
|
|
+ cri.where().andEquals(classifyColumn, dto.getGameClassify());
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
cri.where().andEquals("source_system", dto.getSourceSystem());
|
|
|
}
|
|
|
- if (null != userGameIds) {
|
|
|
- cri.where().andInList("game_id", userGameIds);
|
|
|
+ if (CollectionUtils.isNotEmpty(userGameIds)) {
|
|
|
+ cri.where().andInList(gameColumn, userGameIds);
|
|
|
}
|
|
|
cri.where().and("dt", "=", dto.getRechargeDate());
|
|
|
- cri.groupBy("source_system,game_id");
|
|
|
+ cri.groupBy("source_system", gameColumn);
|
|
|
cri.orderBy(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()), dto.getSortType());
|
|
|
- Sql sql = Sqls.queryEntity(waterSql() + "$condition");
|
|
|
+ Sql sql;
|
|
|
+ if (dto.getGameDimension() == 1L) {
|
|
|
+ sql = Sqls.queryEntity(waterSql() + "$condition");
|
|
|
+ } else {
|
|
|
+ sql = Sqls.queryEntity(waterSqlForParent() + "$condition");
|
|
|
+ }
|
|
|
sql.setPager(pager);
|
|
|
Entity<GameDataWaterVO> entity = dao.getEntity(GameDataWaterVO.class);
|
|
|
sql.setEntity(entity).setCondition(cri);
|
|
|
dao.execute(sql);
|
|
|
|
|
|
- Sql sqlCount = Sqls.queryEntity("select count(*) from ads_everyday_water " + "$condition");
|
|
|
+ Sql sqlCount;
|
|
|
+ if (dto.getGameDimension() == 1L) {
|
|
|
+ sqlCount = Sqls.queryEntity("select count(*) from ads_everyday_water " + "$condition");
|
|
|
+ } else {
|
|
|
+ sqlCount = Sqls.queryEntity("select count(*) from game_ads_parent.ads_everyday_water_parent " + "$condition");
|
|
|
+ }
|
|
|
sqlCount.setCondition(cri);
|
|
|
pager.setRecordCount((int) Daos.queryCount(dao, sqlCount));
|
|
|
|
|
@@ -1018,7 +1039,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
|
|
|
SimpleCriteria templateCri = Cnd.cri();
|
|
|
templateCri.where().and("dt", "=", dto.getRechargeDate());
|
|
|
- templateCri.where().andInList("game_id", gameIds);
|
|
|
+ templateCri.where().andInList(gameColumn, gameIds);
|
|
|
Sql templateSql = Sqls.queryEntity(waterTemplateSql() + "$condition");
|
|
|
Entity<AdsEverydayWater> everydayWaterEntity = dao.getEntity(AdsEverydayWater.class);
|
|
|
templateSql.setEntity(everydayWaterEntity).setCondition(templateCri);
|
|
@@ -1703,7 +1724,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
* 通过反射赋值游戏首日复充数据
|
|
|
*
|
|
|
*/
|
|
|
- private void formatFirstNewUserAgain(GameDataFirstNewUserAgainVO vo, Long[] usersId) {
|
|
|
+ private void formatFirstNewUserAgain(GameDataFirstNewUserAgainVO vo, Long[] usersId, GameDataFirstNewUserAgainDTO dto) {
|
|
|
if (CollectionUtils.isEmpty(firstNewUserAgainFieldMapList)) {
|
|
|
return;
|
|
|
}
|
|
@@ -1718,6 +1739,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
.usersId(usersId)
|
|
|
.timeType(name)
|
|
|
.sourceSystem(vo.getSourceSystem())
|
|
|
+ .gameDimension(dto.getGameDimension() == null ? 1L : dto.getGameDimension())
|
|
|
.build());
|
|
|
} catch (IllegalAccessException e) {
|
|
|
throw new RuntimeException(e);
|
|
@@ -1729,7 +1751,8 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
* 通过反射赋值游戏首日复充总计数据
|
|
|
*
|
|
|
*/
|
|
|
- private void formatFirstNewUserAgainTotal(GameDataFirstNewUserAgainTotalVO vo, Long[] usersIdTotal) {
|
|
|
+ private void formatFirstNewUserAgainTotal(GameDataFirstNewUserAgainTotalVO vo,
|
|
|
+ Long[] usersIdTotal, GameDataFirstNewUserAgainTotalDTO dto) {
|
|
|
if (CollectionUtils.isEmpty(firstNewUserAgainTotalFieldMapList)) {
|
|
|
return;
|
|
|
}
|
|
@@ -1749,6 +1772,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
BigDecimal.valueOf(count.doubleValue() / da1Count.doubleValue()).setScale(4, RoundingMode.HALF_UP))
|
|
|
.timeType(name)
|
|
|
.usersId(usersIdTotal)
|
|
|
+ .gameDimension(dto.getGameDimension() == null ? 1L : dto.getGameDimension())
|
|
|
.build());
|
|
|
} catch (IllegalAccessException e) {
|
|
|
throw new RuntimeException(e);
|
|
@@ -4247,7 +4271,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
}
|
|
|
//新增查询条件
|
|
|
Criteria cri = Cnd.cri();
|
|
|
- if (userGameIds != null) {
|
|
|
+ if (CollectionUtils.isNotEmpty(userGameIds)) {
|
|
|
//拼接游戏id
|
|
|
cri.where().andInList(gameColumn, userGameIds);
|
|
|
}
|
|
@@ -4388,7 +4412,8 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
.toArray(Long[]::new);
|
|
|
}
|
|
|
//将string转成 FirstNewUserAgainTrendVO 对象
|
|
|
- formatFirstNewUserAgain(vo, usersID);
|
|
|
+ formatFirstNewUserAgain(vo, usersID, dto);
|
|
|
+
|
|
|
return vo;
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
@@ -4482,7 +4507,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
//voAgainData有值时进行映射的取值处理
|
|
|
if (StringUtils.isNotBlank(voAgainData.getDa1())) {
|
|
|
//计算游戏首日复充总计
|
|
|
- formatFirstNewUserAgainTotal(voAgainData, usersIdTotal);
|
|
|
+ formatFirstNewUserAgainTotal(voAgainData, usersIdTotal, dto);
|
|
|
}
|
|
|
//将两个对象的属性结合
|
|
|
copyNullProperties(voAgainData, voGameData);
|
|
@@ -4501,6 +4526,10 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
|
|
|
//得到需要查询的usersID内容
|
|
|
FirstNewUserAgainTrendVO againTrendVO = dto.getAgainTrendVO();
|
|
|
+ if (againTrendVO.getGameDimension() == null) {
|
|
|
+ //默认子游戏维度
|
|
|
+ againTrendVO.setGameDimension(1L);
|
|
|
+ }
|
|
|
//处理时间条件
|
|
|
String timeType = againTrendVO.getTimeType();
|
|
|
//用来处理日期的字符串
|
|
@@ -4529,35 +4558,41 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
}
|
|
|
//拼接排序条件
|
|
|
//如果没有排序条件给默认值
|
|
|
- if (StringUtils.isBlank(dto.getSortType())) {
|
|
|
- dto.setSortType(OrderByEnum.DESC.getOrderType());
|
|
|
- }
|
|
|
- if (StringUtils.isBlank(dto.getSortFiled())) {
|
|
|
- queryStr.append(" ORDER BY today_total_amount DESC, player_id DESC");
|
|
|
- } else {
|
|
|
- queryStr.append("""
|
|
|
+ if (againTrendVO.getGameDimension() == 1L) {
|
|
|
+ if (StringUtils.isBlank(dto.getSortType())) {
|
|
|
+ dto.setSortType(OrderByEnum.DESC.getOrderType());
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(dto.getSortFiled())) {
|
|
|
+ queryStr.append(" ORDER BY today_total_amount DESC, player_id DESC");
|
|
|
+ } else {
|
|
|
+ queryStr.append("""
|
|
|
ORDER BY %s %s, player_id DESC
|
|
|
""".formatted(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()),
|
|
|
- dto.getSortType()));
|
|
|
+ dto.getSortType()));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //父游戏维度
|
|
|
+ if (StringUtils.isBlank(dto.getSortType())) {
|
|
|
+ dto.setSortType(OrderByEnum.DESC.getOrderType());
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(dto.getSortFiled())) {
|
|
|
+ queryStr.append(" ORDER BY today_total_amount DESC, parent_player_id DESC");
|
|
|
+ } else {
|
|
|
+ queryStr.append("""
|
|
|
+ ORDER BY %s %s, parent_player_id DESC
|
|
|
+ """.formatted(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()),
|
|
|
+ dto.getSortType()));
|
|
|
+ }
|
|
|
}
|
|
|
//得到用户id数组
|
|
|
Long[] usersId = againTrendVO.getUsersId();
|
|
|
//查询具体的数据
|
|
|
- Sql userDetilsSql = Sqls.create("""
|
|
|
- SELECT
|
|
|
- player_id,
|
|
|
- reg_agent_id,
|
|
|
- reg_agent_name,
|
|
|
- server_name,
|
|
|
- role_name,
|
|
|
- $amount as today_total_amount,
|
|
|
- player_os
|
|
|
- FROM
|
|
|
- game_ads.ads_player_recharge_ranking
|
|
|
- WHERE player_id IN (@usersId)
|
|
|
- and dt = DATE_ADD(DATE(reg_user_time),
|
|
|
- """ + queryStr
|
|
|
- );
|
|
|
+ Sql userDetilsSql;
|
|
|
+ if (againTrendVO.getGameDimension() == 1L) {
|
|
|
+ userDetilsSql = Sqls.create(userDetailSql() + queryStr);
|
|
|
+ } else {
|
|
|
+ userDetilsSql = Sqls.create(userDetailSqlForParent() + queryStr);
|
|
|
+ }
|
|
|
//设置参数
|
|
|
if ("total".equals(timeType)) {
|
|
|
userDetilsSql.vars().set("amount", "total_amount");
|
|
@@ -4591,15 +4626,28 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
* @return map
|
|
|
*/
|
|
|
private Map findUsersId(GameDataFirstNewUserAgainDTO dto) {
|
|
|
+
|
|
|
+ //默认查询子游戏维度
|
|
|
+ if (dto.getGameDimension() == null) {
|
|
|
+ dto.setGameDimension(1L);
|
|
|
+ }
|
|
|
+ //默认查询字段
|
|
|
+ String gameColumn = "reg_game_id";
|
|
|
+ String classifyColumn = "classify";
|
|
|
+ if (dto.getGameDimension() == 2L) {
|
|
|
+ gameColumn = "parent_game_id";
|
|
|
+ classifyColumn = "parent_game_classify";
|
|
|
+ }
|
|
|
+
|
|
|
//查询每个游戏的注册首日充值用户id,在玩家充值排行榜里查找
|
|
|
Criteria findUsersCri = Cnd.cri();
|
|
|
//拼接游戏ID
|
|
|
if (dto.getGameId() != null) {
|
|
|
- findUsersCri.where().andInList("reg_game_id", dto.getGameId());
|
|
|
+ findUsersCri.where().andInList(gameColumn, dto.getGameId());
|
|
|
}
|
|
|
//拼接游戏应用类型
|
|
|
if (dto.getClassify() != null) {
|
|
|
- findUsersCri.where().andEquals("classify", dto.getClassify());
|
|
|
+ findUsersCri.where().andEquals(classifyColumn, dto.getClassify());
|
|
|
}
|
|
|
//拼接SDK来源
|
|
|
if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
@@ -4615,7 +4663,12 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
} else if ("nature".equals(dto.getTableTypes())) {
|
|
|
findUsersCri.where().andEquals("reg_agent_id", 0);
|
|
|
}
|
|
|
- Sql findUsersIdSql = Sqls.create(findUsersIdSql(findUsersCri));
|
|
|
+ Sql findUsersIdSql;
|
|
|
+ if (dto.getGameDimension() == 1L) {
|
|
|
+ findUsersIdSql = Sqls.create(findUsersIdSql(findUsersCri));
|
|
|
+ } else {
|
|
|
+ findUsersIdSql = Sqls.create(findUsersIdSqlForParent(findUsersCri));
|
|
|
+ }
|
|
|
//自定义回传
|
|
|
findUsersIdSql.setCallback((connection, resultSet, sql) -> {
|
|
|
Map<String, String> tempMap = new HashMap<>();
|
|
@@ -4637,15 +4690,28 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
* @return map
|
|
|
*/
|
|
|
private String findUsersIdTotal(GameDataFirstNewUserAgainTotalDTO dto) {
|
|
|
+
|
|
|
+ //默认查询子游戏维度
|
|
|
+ if (dto.getGameDimension() == null) {
|
|
|
+ dto.setGameDimension(1L);
|
|
|
+ }
|
|
|
+ //默认查询字段
|
|
|
+ String gameColumn = "reg_game_id";
|
|
|
+ String classifyColumn = "classify";
|
|
|
+ if (dto.getGameDimension() == 2L) {
|
|
|
+ gameColumn = "parent_game_id";
|
|
|
+ classifyColumn = "parent_game_classify";
|
|
|
+ }
|
|
|
+
|
|
|
//查询每个游戏的注册首日充值用户id,在玩家充值排行榜里查找
|
|
|
Criteria findUsersCri = Cnd.cri();
|
|
|
//拼接游戏ID
|
|
|
if (dto.getGameId() != null) {
|
|
|
- findUsersCri.where().andEquals("reg_game_id", dto.getGameId());
|
|
|
+ findUsersCri.where().andInList(gameColumn, dto.getGameId());
|
|
|
}
|
|
|
//拼接游戏应用类型
|
|
|
if (dto.getClassify() != null) {
|
|
|
- findUsersCri.where().andEquals("classify", dto.getClassify());
|
|
|
+ findUsersCri.where().andEquals(classifyColumn, dto.getClassify());
|
|
|
}
|
|
|
//拼接SDK来源
|
|
|
if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
@@ -4661,7 +4727,12 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
} else if ("nature".equals(dto.getTableTypes())) {
|
|
|
findUsersCri.where().andEquals("reg_agent_id", 0);
|
|
|
}
|
|
|
- Sql findUsersIdTotalSql = Sqls.create(findUsersIdTotalSql(findUsersCri));
|
|
|
+ Sql findUsersIdTotalSql;
|
|
|
+ if (dto.getGameDimension() == 1L) {
|
|
|
+ findUsersIdTotalSql = Sqls.create(findUsersIdTotalSql(findUsersCri));
|
|
|
+ } else {
|
|
|
+ findUsersIdTotalSql = Sqls.create(findUsersIdTotalSqlForParent(findUsersCri));
|
|
|
+ }
|
|
|
//自定义回传
|
|
|
findUsersIdTotalSql.setCallback(Sqls.callback.str());
|
|
|
//运行sql
|
|
@@ -8244,6 +8315,25 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
""";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 找出每个游戏注册时间内的注册当天且充值的用户id-父游戏维度
|
|
|
+ *
|
|
|
+ * @return String
|
|
|
+ */
|
|
|
+ private String findUsersIdSqlForParent(Criteria cri) {
|
|
|
+ return """
|
|
|
+ SELECT
|
|
|
+ CONCAT(parent_game_id,'/',DATE(reg_user_time)) as game_id_date,
|
|
|
+ GROUP_CONCAT(CONVERT (parent_player_id, varchar), "/") as amount_users_id
|
|
|
+ FROM
|
|
|
+ game_ads_parent.ads_player_recharge_ranking_parent
|
|
|
+ """ + cri +
|
|
|
+ """
|
|
|
+ AND dt = DATE(reg_user_time)
|
|
|
+ GROUP BY parent_game_id, DATE(reg_user_time)
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 找出每个游戏注册时间内的注册当天且充值的用户id(总计一栏)
|
|
|
*
|
|
@@ -8261,6 +8351,23 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
""";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 找出每个游戏注册时间内的注册当天且充值的用户id(总计一栏)-父游戏维度
|
|
|
+ *
|
|
|
+ * @return String
|
|
|
+ */
|
|
|
+ private String findUsersIdTotalSqlForParent(Criteria cri) {
|
|
|
+ return """
|
|
|
+ SELECT
|
|
|
+ GROUP_CONCAT(CONVERT (parent_player_id, varchar), "/") as amount_users_id
|
|
|
+ FROM
|
|
|
+ game_ads_parent.ads_player_recharge_ranking_parent
|
|
|
+ """ + cri +
|
|
|
+ """
|
|
|
+ AND dt = DATE(reg_user_time)
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
private List<H5NatureUserVO> getH5NatureUserVOList(GameDataH5DTO dto, Map<String, Object> importDayNMap, GameDataH5VO item) {
|
|
|
Sql natureGameSql = Sqls.queryEntity("""
|
|
|
select
|
|
@@ -8736,6 +8843,9 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
""";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 子游戏维度
|
|
|
+ */
|
|
|
private String waterSql() {
|
|
|
return """
|
|
|
select
|
|
@@ -8751,6 +8861,24 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
""";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 父游戏维度
|
|
|
+ */
|
|
|
+ private String waterSqlForParent() {
|
|
|
+ return """
|
|
|
+ select
|
|
|
+ parent_game_id as id,
|
|
|
+ source_system,
|
|
|
+ parent_game_id as game_id,
|
|
|
+ max(parent_game_name) as game_name,
|
|
|
+ max(parent_game_classify) as game_classify,
|
|
|
+ max(amount) as amount,
|
|
|
+ max(buy_amount) as buy_amount,
|
|
|
+ max(nature_amount) as nature_amount
|
|
|
+ from game_ads_parent.ads_everyday_water_parent
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 流水临时sql
|
|
|
*
|
|
@@ -8774,6 +8902,46 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
""";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 用户详情sql-子游戏维度
|
|
|
+ */
|
|
|
+ private String userDetailSql() {
|
|
|
+ return """
|
|
|
+ SELECT
|
|
|
+ player_id,
|
|
|
+ reg_agent_id,
|
|
|
+ reg_agent_name,
|
|
|
+ server_name,
|
|
|
+ role_name,
|
|
|
+ $amount as today_total_amount,
|
|
|
+ player_os
|
|
|
+ FROM
|
|
|
+ game_ads.ads_player_recharge_ranking
|
|
|
+ WHERE player_id IN (@usersId)
|
|
|
+ and dt = DATE_ADD(DATE(reg_user_time),
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户详情sql-子游戏维度
|
|
|
+ */
|
|
|
+ private String userDetailSqlForParent() {
|
|
|
+ return """
|
|
|
+ SELECT
|
|
|
+ parent_player_id as player_id,
|
|
|
+ reg_agent_id,
|
|
|
+ reg_agent_name,
|
|
|
+ server_name,
|
|
|
+ role_name,
|
|
|
+ $amount as today_total_amount,
|
|
|
+ player_os
|
|
|
+ FROM
|
|
|
+ game_ads_parent.ads_player_recharge_ranking_parent
|
|
|
+ WHERE parent_player_id IN (@usersId)
|
|
|
+ and dt = DATE_ADD(DATE(reg_user_time),
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* DayN内部类
|
|
|
*/
|