|
@@ -2,6 +2,7 @@ package com.zanxiang.game.data.serve.service.impl;
|
|
|
|
|
|
import com.google.common.base.CaseFormat;
|
|
|
import com.google.gson.Gson;
|
|
|
+import com.zanxiang.game.data.serve.component.DataPowerComponent;
|
|
|
import com.zanxiang.game.data.serve.pojo.dto.*;
|
|
|
import com.zanxiang.game.data.serve.pojo.entity.*;
|
|
|
import com.zanxiang.game.data.serve.pojo.enums.OrderByEnum;
|
|
@@ -183,6 +184,8 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
|
|
|
@Autowired
|
|
|
private Dao dao;
|
|
|
+ @Autowired
|
|
|
+ private DataPowerComponent dataPowerComponent;
|
|
|
|
|
|
/**
|
|
|
* 游戏每日数据
|
|
@@ -192,6 +195,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Page<GameDataDayVO> getGameDataDay(GameDataDayDTO dto) {
|
|
|
+ long[] gameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
|
|
|
//传入的注册时间为空时,给一个默认值 当天数据
|
|
|
if (dto.getRegisteredBeginDate() == null || dto.getRegisteredEndDate() == null) {
|
|
@@ -204,9 +208,9 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
//拼接游戏名称查询条件
|
|
|
cri.where().andEquals("game_name", dto.getGameName());
|
|
|
}
|
|
|
- if (dto.getGameId() != null) {
|
|
|
+ if (gameIds != null) {
|
|
|
//拼接游戏id查询条件
|
|
|
- cri.where().andEquals("game_id", dto.getGameId());
|
|
|
+ cri.where().andIn("game_id", gameIds);
|
|
|
}
|
|
|
if (dto.getGameClassify() != null) {
|
|
|
//拼接游戏类型查询条件
|
|
@@ -260,6 +264,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
* @return 返回给前端的总计数据实体
|
|
|
*/
|
|
|
public GameDataDayTotalVO getGameDataDayTotal(GameDataDayTotalDTO dto) {
|
|
|
+ long[] gameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
|
|
|
//如果没有传入查询时间默认查询当天
|
|
|
if (dto.getRegisteredBeginDate() == null || dto.getRegisteredEndDate() == null) {
|
|
@@ -268,9 +273,9 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
}
|
|
|
//新增查询条件
|
|
|
Criteria cri = Cnd.cri();
|
|
|
- if (dto.getGameId() != null) {
|
|
|
+ if (gameIds != null) {
|
|
|
//拼接游戏id
|
|
|
- cri.where().andEquals("game_id", dto.getGameId());
|
|
|
+ cri.where().andIn("game_id", gameIds);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getGameName())) {
|
|
|
//拼接游戏名称
|
|
@@ -311,6 +316,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Page<GameDataTotalVO> getGameDataTotal(GameDataTotalDTO dto) {
|
|
|
+ long[] gameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
//如果注册时间参数为空,默认设置查询当天数据
|
|
|
if (dto.getRegisteredBeginDate() == null || dto.getRegisteredEndDate() == null) {
|
|
|
dto.setRegisteredBeginDate(LocalDate.now());
|
|
@@ -323,15 +329,15 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
}
|
|
|
|
|
|
//主表查询条件
|
|
|
- Criteria criA = myCri(dto, "criA", true);
|
|
|
+ Criteria criA = myCri(gameIds, dto, "criA", true);
|
|
|
//账面相关查询条件 时间条件只和充值时间相关
|
|
|
- Criteria criB = myCri(dto, "criB", true);
|
|
|
+ Criteria criB = myCri(gameIds, dto, "criB", true);
|
|
|
//账面人数相关 时间只需要充值时间条件,不需要注册时间条件
|
|
|
- Criteria criAmount = myCriRecharge(dto, false);
|
|
|
+ Criteria criAmount = myCriRecharge(gameIds, dto, false);
|
|
|
//新用户充值人数和新用户复充人数 时间条件需要注册时间和充值时间
|
|
|
- Criteria criNewUser = myCriRecharge(dto, true);
|
|
|
+ Criteria criNewUser = myCriRecharge(gameIds, dto, true);
|
|
|
//创角人数查询条件
|
|
|
- Criteria criRoleNum = myCriRole(dto);
|
|
|
+ Criteria criRoleNum = myCriRole(gameIds, dto);
|
|
|
//拼接排序条件
|
|
|
Criteria orderByCri = Cnd.cri();
|
|
|
//如果没有排序条件给默认值
|
|
@@ -528,6 +534,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
* @return 返回给前端额数据
|
|
|
*/
|
|
|
public GameDataTotalTotalVO getGameDataTotalTotal(GameDataTotalTotalDTO dto) {
|
|
|
+ long[] gameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
//如果注册时间参数为空,默认设置查询当天数据
|
|
|
if (dto.getRegisteredBeginDate() == null || dto.getRegisteredEndDate() == null) {
|
|
|
dto.setRegisteredBeginDate(LocalDate.now());
|
|
@@ -542,15 +549,15 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
GameDataTotalDTO totalDTO = new GameDataTotalDTO();
|
|
|
copyNullProperties(dto, totalDTO);
|
|
|
//主表查询条件
|
|
|
- Criteria criA = myCri(totalDTO, "criA", false);
|
|
|
+ Criteria criA = myCri(gameIds, totalDTO, "criA", false);
|
|
|
//账面相关查询条件 时间条件只和充值时间相关
|
|
|
- Criteria criB = myCri(totalDTO, "criB", false);
|
|
|
+ Criteria criB = myCri(gameIds, totalDTO, "criB", false);
|
|
|
//账面人数相关 时间只需要充值时间条件,不需要注册时间条件
|
|
|
- Criteria criAmount = myCriRecharge(totalDTO, false);
|
|
|
+ Criteria criAmount = myCriRecharge(gameIds, totalDTO, false);
|
|
|
//新用户充值人数和新用户复充人数 时间条件需要注册时间和充值时间
|
|
|
- Criteria criNewUser = myCriRecharge(totalDTO, true);
|
|
|
+ Criteria criNewUser = myCriRecharge(gameIds, totalDTO, true);
|
|
|
//创角人数查询条件
|
|
|
- Criteria criRoleNum = myCriRole(totalDTO);
|
|
|
+ Criteria criRoleNum = myCriRole(gameIds, totalDTO);
|
|
|
//创建sql语句 执行sql
|
|
|
Sql sql = Sqls.create(gameDataTotalTotalSql() + criA);
|
|
|
//设置自定义回显对象
|
|
@@ -969,6 +976,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Page<GameDataWaterVO> getGameDataWater(GameDataWaterDTO dto) {
|
|
|
+ long[] userGameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
if (null == dto.getRechargeDate()) {
|
|
|
dto.setRechargeDate(LocalDate.now());
|
|
|
}
|
|
@@ -993,8 +1001,8 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
cri.where().andEquals("source_system", dto.getSourceSystem());
|
|
|
}
|
|
|
- if (null != dto.getGameId()) {
|
|
|
- cri.where().andEquals("game_id", dto.getGameId());
|
|
|
+ if (null != userGameIds) {
|
|
|
+ cri.where().andIn("game_id", userGameIds);
|
|
|
}
|
|
|
cri.where().and("dt", "=", dto.getRechargeDate());
|
|
|
cri.groupBy("source_system,game_id");
|
|
@@ -1076,6 +1084,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Map<LocalDate, List<GameDataAgainDayVO>> getGameDataAgainDay(GameDataAgainDayDTO dto) {
|
|
|
+ long[] userGameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
|
|
|
//如果查询时间不传递默认从今天开始查询
|
|
|
if (dto.getBeginDate() == null) {
|
|
@@ -1094,8 +1103,8 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
if (StringUtils.isNotBlank(dto.getGameName())) {
|
|
|
cri.where().andEquals("game_name", dto.getGameName());
|
|
|
}
|
|
|
- if (dto.getGameId() != null) {
|
|
|
- cri.where().andEquals("game_id", dto.getGameId());
|
|
|
+ if (userGameIds != null) {
|
|
|
+ cri.where().andIn("game_id", userGameIds);
|
|
|
}
|
|
|
if (dto.getBeginDate() != null) {
|
|
|
cri.where().andEquals("dt", dto.getBeginDate());
|
|
@@ -1340,16 +1349,16 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
* @param needGroupBy 是否需要分组条件
|
|
|
* @return 查询条件
|
|
|
*/
|
|
|
- private Criteria myCri(GameDataTotalDTO dto, String type, Boolean needGroupBy) {
|
|
|
+ private Criteria myCri(long[] gameIds, GameDataTotalDTO dto, String type, Boolean needGroupBy) {
|
|
|
//根据传入的dto拼接查询参数
|
|
|
Criteria cri = Cnd.cri();
|
|
|
if (StringUtils.isNotBlank(dto.getGameName())) {
|
|
|
//拼接游戏名称查询条件
|
|
|
cri.where().andEquals("game_name", dto.getGameName());
|
|
|
}
|
|
|
- if (dto.getGameId() != null) {
|
|
|
+ if (gameIds != null) {
|
|
|
//拼接游戏id查询条件
|
|
|
- cri.where().andEquals("game_id", dto.getGameId());
|
|
|
+ cri.where().andIn("game_id", gameIds);
|
|
|
}
|
|
|
if (dto.getGameClassify() != null) {
|
|
|
//拼接游戏类型查询条件
|
|
@@ -1386,12 +1395,12 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
* @param needRegTime 是否需要拼接注册时间
|
|
|
* @return 查询条件
|
|
|
*/
|
|
|
- private Criteria myCriRecharge(GameDataTotalDTO dto, Boolean needRegTime) {
|
|
|
+ private Criteria myCriRecharge(long[] gameIds, GameDataTotalDTO dto, Boolean needRegTime) {
|
|
|
//根据传入的dto拼接查询参数
|
|
|
Criteria cri = Cnd.cri();
|
|
|
- if (dto.getGameId() != null) {
|
|
|
+ if (gameIds != null) {
|
|
|
//拼接游戏id查询条件
|
|
|
- cri.where().andEquals("game_id", dto.getGameId());
|
|
|
+ cri.where().andIn("game_id", gameIds);
|
|
|
}
|
|
|
if (dto.getGameClassify() != null) {
|
|
|
//拼接游戏类型查询条件
|
|
@@ -1420,12 +1429,12 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
* @param dto 前端传递的查询条件
|
|
|
* @return 查询条件
|
|
|
*/
|
|
|
- private Criteria myCriRole(GameDataTotalDTO dto) {
|
|
|
+ private Criteria myCriRole(long[] gameIds, GameDataTotalDTO dto) {
|
|
|
//根据传入的dto拼接查询参数
|
|
|
Criteria cri = Cnd.cri();
|
|
|
- if (dto.getGameId() != null) {
|
|
|
+ if (gameIds != null) {
|
|
|
//拼接游戏id查询条件
|
|
|
- cri.where().andEquals("user_game_id", dto.getGameId());
|
|
|
+ cri.where().andIn("user_game_id", gameIds);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
//拼接SDK来源
|
|
@@ -3058,6 +3067,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
|
|
|
@Override
|
|
|
public Page<GameDataH5VO> getH5Recharge(GameDataH5DTO dto) {
|
|
|
+ long[] gameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
if (null == dto.getCostBeginDate() || null == dto.getCostEndDate()) {
|
|
|
dto.setCostEndDate(LocalDate.now());
|
|
|
dto.setCostBeginDate(LocalDate.now());
|
|
@@ -3081,8 +3091,8 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
cri.where().andEquals("a.source_system", dto.getSourceSystem());
|
|
|
}
|
|
|
- if (null != dto.getGameId()) {
|
|
|
- cri.where().andEquals("a.game_id", dto.getGameId());
|
|
|
+ if (null != gameIds) {
|
|
|
+ cri.where().andIn("a.game_id", gameIds);
|
|
|
}
|
|
|
cri.where().and("a.dt", ">=", dto.getCostBeginDate()).and("a.dt", "<=", dto.getCostEndDate());
|
|
|
cri.where().andEquals("a.id", 1);
|
|
@@ -3098,9 +3108,8 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
Sql sqlCount = Sqls.queryEntity("select count(*) from ads_h5_game_day a " + "$condition");
|
|
|
sqlCount.setCondition(cri);
|
|
|
pager.setRecordCount((int) Daos.queryCount(dao, sqlCount));
|
|
|
- List<Long> gameIds = sql.getList(GameDataH5VO.class).stream()
|
|
|
- .map(GameDataH5VO::getGameId).collect(Collectors.toList());
|
|
|
- if (CollectionUtils.isEmpty(gameIds)) {
|
|
|
+ if (pager.getRecordCount() < 1) {
|
|
|
+ // 没数据,直接返回
|
|
|
return new Page<>();
|
|
|
}
|
|
|
|
|
@@ -3217,6 +3226,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Page<LtvDataVO> getLtvData(LtvDataDTO dto) {
|
|
|
+ long[] userGameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
if (dto.getRegisteredBeginDate() == null || dto.getRegisteredEndDate() == null) {
|
|
|
//查询时间不传递默认传递当天
|
|
|
dto.setRegisteredBeginDate(LocalDate.now());
|
|
@@ -3229,8 +3239,8 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
//创建查询条件
|
|
|
Criteria cri = Cnd.cri();
|
|
|
//拼接游戏ID
|
|
|
- if (dto.getGameId() != null) {
|
|
|
- cri.where().andEquals("game_id", dto.getGameId());
|
|
|
+ if (userGameIds != null) {
|
|
|
+ cri.where().andIn("game_id", userGameIds);
|
|
|
}
|
|
|
//拼接游戏应用类型
|
|
|
if (dto.getClassify() != null) {
|
|
@@ -3282,6 +3292,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
*/
|
|
|
@Override
|
|
|
public LtvDataTotalVO getLtvTotalData(LtvDataTotalDTO dto) {
|
|
|
+ long[] userGameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
//如果没有传入查询时间默认查询当天
|
|
|
if (dto.getRegisteredBeginDate() == null || dto.getRegisteredEndDate() == null) {
|
|
|
dto.setRegisteredBeginDate(LocalDate.now());
|
|
@@ -3293,9 +3304,9 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
}
|
|
|
//新增查询条件
|
|
|
Criteria cri = Cnd.cri();
|
|
|
- if (dto.getGameId() != null) {
|
|
|
+ if (userGameIds != null) {
|
|
|
//拼接游戏id
|
|
|
- cri.where().andEquals("game_id", dto.getGameId());
|
|
|
+ cri.where().andIn("game_id", userGameIds);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
//拼接SDK来源
|
|
@@ -3342,6 +3353,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Page<GameDataFirstNewUserAgainVO> getFirstNewUserAgain(GameDataFirstNewUserAgainDTO dto) {
|
|
|
+ long[] userGameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
if (dto.getRegisteredBeginDate() == null || dto.getRegisteredEndDate() == null) {
|
|
|
//查询时间不传递默认传递当天
|
|
|
dto.setRegisteredBeginDate(LocalDate.now());
|
|
@@ -3354,8 +3366,8 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
//创建查询条件
|
|
|
Criteria cri = Cnd.cri();
|
|
|
//拼接游戏ID
|
|
|
- if (dto.getGameId() != null) {
|
|
|
- cri.where().andEquals("game_id", dto.getGameId());
|
|
|
+ if (userGameIds != null) {
|
|
|
+ cri.where().andIn("game_id", userGameIds);
|
|
|
}
|
|
|
//拼接游戏应用类型
|
|
|
if (dto.getClassify() != null) {
|
|
@@ -3425,6 +3437,7 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
*/
|
|
|
@Override
|
|
|
public GameDataFirstNewUserAgainTotalVO getFirstNewUserAgainTotal(GameDataFirstNewUserAgainTotalDTO dto) {
|
|
|
+ long[] userGameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : new long[]{dto.getGameId()};
|
|
|
//如果没有传入查询时间默认查询当天
|
|
|
if (dto.getRegisteredBeginDate() == null || dto.getRegisteredEndDate() == null) {
|
|
|
dto.setRegisteredBeginDate(LocalDate.now());
|
|
@@ -3436,9 +3449,9 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
}
|
|
|
//新增查询条件
|
|
|
Criteria cri = Cnd.cri();
|
|
|
- if (dto.getGameId() != null) {
|
|
|
+ if (userGameIds != null) {
|
|
|
//拼接游戏id
|
|
|
- cri.where().andEquals("game_id", dto.getGameId());
|
|
|
+ cri.where().andIn("game_id", userGameIds);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
//拼接SDK来源
|