|
@@ -4,6 +4,7 @@ import com.google.common.base.CaseFormat;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.zanxiang.game.data.serve.pojo.dto.GameDataAgainDayDTO;
|
|
|
import com.zanxiang.game.data.serve.pojo.dto.GameDataDayDTO;
|
|
|
+import com.zanxiang.game.data.serve.pojo.dto.GameDataH5DTO;
|
|
|
import com.zanxiang.game.data.serve.pojo.dto.GameDataTotalDTO;
|
|
|
import com.zanxiang.game.data.serve.pojo.dto.GameDataWaterDTO;
|
|
|
import com.zanxiang.game.data.serve.pojo.entity.AdsEverydayWater;
|
|
@@ -16,8 +17,10 @@ import com.zanxiang.game.data.serve.service.IGameDataService;
|
|
|
import com.zanxiang.game.data.serve.utils.Page;
|
|
|
import com.zanxiang.module.util.DateUtil;
|
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
import lombok.Builder;
|
|
|
import lombok.Data;
|
|
|
+import lombok.NoArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.nutz.dao.Cnd;
|
|
@@ -611,8 +614,14 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
if (StringUtils.isNotBlank(dto.getGameClassify())) {
|
|
|
cri.where().andEquals("game_classify", dto.getGameClassify());
|
|
|
}
|
|
|
+ if (StringUtils.isNotBlank(dto.getGameClassify())) {
|
|
|
+ cri.where().andEquals("game_classify", dto.getGameClassify());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
+ cri.where().andEquals("source_system", dto.getSourceSystem());
|
|
|
+ }
|
|
|
cri.where().and("dt", "=", dto.getRechargeDate());
|
|
|
- cri.groupBy("game_id");
|
|
|
+ cri.groupBy("source_system,game_id");
|
|
|
cri.orderBy(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()), dto.getSortType());
|
|
|
Sql sql = Sqls.queryEntity(waterSql() + "$condition");
|
|
|
sql.setPager(pager);
|
|
@@ -1371,14 +1380,485 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
""";
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 流水sql
|
|
|
- * @return String
|
|
|
- */
|
|
|
+ @Override
|
|
|
+ public Page<GameDataH5VO> getH5Recharge(GameDataH5DTO dto) {
|
|
|
+ if (null == dto.getCostBeginDate() || null == dto.getCostEndDate()) {
|
|
|
+ dto.setCostEndDate(LocalDate.now());
|
|
|
+ dto.setCostBeginDate(LocalDate.now());
|
|
|
+ }
|
|
|
+ if (null == dto.getRechargeBeginDate() || null == dto.getRechargeEndDate()) {
|
|
|
+ dto.setRechargeEndDate(LocalDate.now());
|
|
|
+ dto.setRechargeBeginDate(LocalDate.now());
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(dto.getSortFiled())) {
|
|
|
+ dto.setSortFiled("h5_nature_new_user_total_amount");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(dto.getSortType())) {
|
|
|
+ dto.setSortType(OrderByEnum.DESC.getOrderType());
|
|
|
+ }
|
|
|
+ Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
|
|
|
+ // 创建一个 Criteria 接口实例
|
|
|
+ SimpleCriteria cri = Cnd.cri();
|
|
|
+ if (StringUtils.isNotBlank(dto.getGameName())) {
|
|
|
+ cri.where().andLike("a.game_name", dto.getGameName());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
+ cri.where().andLike("a.source_system", dto.getSourceSystem());
|
|
|
+ }
|
|
|
+ cri.where().and("a.dt", ">=", dto.getCostBeginDate()).and("a.dt", "<=", dto.getCostEndDate());
|
|
|
+ cri.where().andEquals("a.id",1);
|
|
|
+ cri.groupBy("a.source_system,a.game_id");
|
|
|
+ cri.orderBy(CaseFormat.LOWER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, dto.getSortFiled()), dto.getSortType());
|
|
|
+ Sql sql = Sqls.queryEntity(h5RechargeSql() + "$condition");
|
|
|
+ sql.setPager(pager);
|
|
|
+ Entity<GameDataH5VO> entity = dao.getEntity(GameDataH5VO.class);
|
|
|
+ sql.setEntity(entity).setCondition(cri);
|
|
|
+ sql.setParam("rechargeBeginDay", dto.getRechargeBeginDate());
|
|
|
+ sql.setParam("rechargeEndDay", dto.getRechargeEndDate());
|
|
|
+ dao.execute(sql);
|
|
|
+ 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)) {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ //h5注册时间内的dayn充值数据,dayn的json数据
|
|
|
+ Map<String, Object> dayNMap = new HashMap<>(4);
|
|
|
+ dayNMap.put("beginDay", dto.getCostBeginDate());
|
|
|
+ dayNMap.put("endDay", dto.getCostEndDate());
|
|
|
+
|
|
|
+ //h5导量注册时间内的dayn充值数据,dayn的json数据
|
|
|
+ Map<String, Object> importDayNMap = new HashMap<>(4);
|
|
|
+ importDayNMap.put("beginDay", dto.getCostBeginDate());
|
|
|
+ importDayNMap.put("endDay", dto.getCostEndDate());
|
|
|
+
|
|
|
+ //h5账面
|
|
|
+ String show = """
|
|
|
+ select
|
|
|
+ sum(h5_buy_amount) as h5_buy_amount,
|
|
|
+ sum(h5_buy_amount_num) as h5_buy_amount_num,
|
|
|
+ sum(h5_nature_amount) as h5_nature_amount,
|
|
|
+ sum(h5_nature_amount_num) as h5_nature_amount_num
|
|
|
+ from ads_h5_game_day
|
|
|
+ """;
|
|
|
+ Sql showSql = Sqls.queryEntity(show + "$condition");
|
|
|
+ Entity<ShowRecharge> showEntity = dao.getEntity(ShowRecharge.class);
|
|
|
+ List<GameDataH5VO> gameDataH5VOList = sql.getList(GameDataH5VO.class).stream().map(item -> {
|
|
|
+ {
|
|
|
+ SimpleCriteria showCri = Cnd.cri();
|
|
|
+ if (StringUtils.isNotBlank(dto.getGameName())) {
|
|
|
+ showCri.where().andLike("game_name", dto.getGameName());
|
|
|
+ }
|
|
|
+ showCri.where().and("dt", ">=", dto.getRechargeBeginDate()).and("dt", "<=", dto.getRechargeEndDate());
|
|
|
+ showCri.groupBy("source_system,game_id");
|
|
|
+ showCri.where().andEquals("game_id",item.getGameId());
|
|
|
+ showCri.where().andEquals("id",1);
|
|
|
+ showCri.where().andEquals("source_system",item.getSourceSystem());
|
|
|
+ showSql.setEntity(showEntity).setCondition(showCri);
|
|
|
+ dao.execute(showSql);
|
|
|
+ ShowRecharge showRecharge = showSql.getObject(ShowRecharge.class);
|
|
|
+ if (null != showRecharge){
|
|
|
+ item.setH5NatureAmount(showRecharge.getH5NatureAmount());
|
|
|
+ item.setH5NatureAmountNum(showRecharge.getH5NatureAmountNum());
|
|
|
+ item.setH5BuyAmount(showRecharge.getH5BuyAmount());
|
|
|
+ item.setH5BuyAmountNum(showRecharge.getH5BuyAmountNum());
|
|
|
+ }else {
|
|
|
+ item.setH5NatureAmount(BigDecimal.ZERO);
|
|
|
+ item.setH5NatureAmountNum(0L);
|
|
|
+ item.setH5BuyAmount(BigDecimal.ZERO);
|
|
|
+ item.setH5BuyAmountNum(0L);
|
|
|
+ }
|
|
|
+
|
|
|
+ dayNMap.put("sourceSystem", item.getSourceSystem());
|
|
|
+ dayNMap.put("h5GameId", item.getGameId());
|
|
|
+
|
|
|
+ H5DayN h5PayDayN = getH5PayDayN(dto, dayNMap);
|
|
|
+ //h5充值时间范围内存在买量充值数据
|
|
|
+ if (null != h5PayDayN) {
|
|
|
+ item.setH5NewUserRechargeMoney(h5PayDayN.getRechargeMoney());
|
|
|
+ item.setH5NewUserRechargeNum(h5PayDayN.getRechargeNum());
|
|
|
+ } else {
|
|
|
+ item.setH5NewUserRechargeMoney(BigDecimal.ZERO);
|
|
|
+ item.setH5NewUserRechargeNum(0L);
|
|
|
+ }
|
|
|
+ H5DayN h5NatureDayN = getNatureH5DayN(dto, dayNMap);
|
|
|
+ //h5充值时间范围内存在自然量充值数据
|
|
|
+ if (null != h5NatureDayN) {
|
|
|
+ item.setH5NewUserNatureRechargeMoney(h5NatureDayN.getRechargeMoney());
|
|
|
+ item.setH5NewUserNatureRechargeNum(h5NatureDayN.getRechargeNum());
|
|
|
+ } else {
|
|
|
+ item.setH5NewUserNatureRechargeMoney(BigDecimal.ZERO);
|
|
|
+ item.setH5NewUserNatureRechargeNum(0L);
|
|
|
+ }
|
|
|
+ item.setH5NewUserNatureRechargeRate(null == item.getH5NewUserNatureRechargeMoney() || null == item.getH5NewUserRechargeMoney() || item.getH5NewUserRechargeMoney().compareTo(BigDecimal.ZERO) == 0 ?
|
|
|
+ BigDecimal.ZERO : item.getH5NewUserNatureRechargeMoney().divide(item.getH5NewUserRechargeMoney(), 4, RoundingMode.DOWN));
|
|
|
+ item.setH5NewUserNatureNewUserRate(null == item.getH5NewUserRechargeNum() || null == item.getH5NewUserNatureRechargeNum() || item.getH5NewUserRechargeNum() == 0 ?
|
|
|
+ BigDecimal.ZERO : BigDecimal.valueOf(item.getH5NewUserNatureRechargeNum()).divide(BigDecimal.valueOf(item.getH5NewUserRechargeNum()), 4, RoundingMode.DOWN));
|
|
|
+
|
|
|
+ //买量导入用户数据
|
|
|
+ List<H5BuyUserVO> buyGameList = getH5BuyUserVOList(dto, importDayNMap, item);
|
|
|
+ //官方导入用户数据
|
|
|
+ List<H5NatureUserVO> natureGameList = getH5NatureUserVOList(dto, importDayNMap, item);
|
|
|
+
|
|
|
+ item.setH5BuyUserVOList(buyGameList);
|
|
|
+ item.setH5NatureUserVOList(natureGameList);
|
|
|
+ return item;
|
|
|
+ }
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ return new Page<>(gameDataH5VOList, pager);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<H5NatureUserVO> getH5NatureUserVOList(GameDataH5DTO dto, Map<String, Object> importDayNMap, GameDataH5VO item) {
|
|
|
+ Sql natureGameSql = Sqls.queryEntity("""
|
|
|
+ select
|
|
|
+ nature_source_system,
|
|
|
+ nature_game_id,
|
|
|
+ max(nature_game_name) as nature_game_name,
|
|
|
+ max(nature_classify) as nature_classify,
|
|
|
+ sum(h5_lead_nature_new_user_total_amount) as h5_lead_nature_new_user_total_amount,
|
|
|
+ sum(h5_lead_nature_new_user_total_amount_num) as h5_lead_nature_new_user_total_amount_num
|
|
|
+ from ads_h5_game_day
|
|
|
+ where
|
|
|
+ game_id = @gameId
|
|
|
+ and
|
|
|
+ dt>=@beginDay and dt<=@endDay
|
|
|
+ group by nature_source_system,nature_game_id
|
|
|
+ """);
|
|
|
+ natureGameSql.setParam("gameId", item.getGameId());
|
|
|
+ natureGameSql.setParam("beginDay", dto.getCostBeginDate());
|
|
|
+ natureGameSql.setParam("endDay", dto.getCostEndDate());
|
|
|
+ Entity<H5NatureUserVO> natureGameEntity = dao.getEntity(H5NatureUserVO.class);
|
|
|
+ natureGameSql.setEntity(natureGameEntity);
|
|
|
+ dao.execute(natureGameSql);
|
|
|
+
|
|
|
+ Sql natureShowGameSql = Sqls.queryEntity("""
|
|
|
+ select
|
|
|
+ nature_source_system,
|
|
|
+ nature_game_id,
|
|
|
+ sum(h5_lead_nature_amount) as h5_lead_nature_amount,
|
|
|
+ sum(h5_lead_nature_amount_num) as h5_lead_nature_amount_num
|
|
|
+ from ads_h5_game_day
|
|
|
+ where
|
|
|
+ game_id = @gameId
|
|
|
+ and
|
|
|
+ dt>=@beginDay and dt<=@endDay
|
|
|
+ group by nature_source_system,nature_game_id
|
|
|
+ """);
|
|
|
+ natureShowGameSql.setParam("gameId", item.getGameId());
|
|
|
+ natureShowGameSql.setParam("beginDay", dto.getRechargeBeginDate());
|
|
|
+ natureShowGameSql.setParam("endDay", dto.getRechargeEndDate());
|
|
|
+ Entity<H5NatureUserVO> buyShowGameEntity = dao.getEntity(H5NatureUserVO.class);
|
|
|
+ natureShowGameSql.setEntity(buyShowGameEntity);
|
|
|
+ dao.execute(natureShowGameSql);
|
|
|
+ Map<Long, List<H5NatureUserVO>> showBuyGameMap = natureShowGameSql.getList(H5NatureUserVO.class).stream()
|
|
|
+ .filter(tt->null!=tt.getNatureGameId())
|
|
|
+ .collect(Collectors.groupingBy(H5NatureUserVO::getNatureGameId));
|
|
|
+
|
|
|
+ List<H5NatureUserVO> natureGameList = natureGameSql.getList(H5NatureUserVO.class).stream()
|
|
|
+ .filter(tt->null!=tt.getNatureGameId())
|
|
|
+ .map(natureGame -> {
|
|
|
+ importDayNMap.put("sourceSystem", natureGame.getNatureSourceSystem());
|
|
|
+ importDayNMap.put("gameId", natureGame.getNatureGameId());
|
|
|
+ H5DayN importNatureH5DayN = getImportNatureH5DayN(dto, importDayNMap);
|
|
|
+ if (null != showBuyGameMap&& null!=showBuyGameMap.get(natureGame.getNatureGameId()) && !showBuyGameMap.get(natureGame.getNatureGameId()).isEmpty()) {
|
|
|
+ natureGame.setH5LeadNatureAmount(showBuyGameMap.get(natureGame.getNatureGameId()).get(0).getH5LeadNatureAmount());
|
|
|
+ natureGame.setH5LeadNatureAmountNum(showBuyGameMap.get(natureGame.getNatureGameId()).get(0).getH5LeadNatureAmountNum());
|
|
|
+ }else {
|
|
|
+ natureGame.setH5LeadNatureAmount(BigDecimal.ZERO);
|
|
|
+ natureGame.setH5LeadNatureAmountNum(0L);
|
|
|
+ }
|
|
|
+ //充值时间范围内存在官方导量充值数据
|
|
|
+ if (null != importNatureH5DayN) {
|
|
|
+ natureGame.setNewUserRechargeMoney(importNatureH5DayN.getRechargeMoney());
|
|
|
+ natureGame.setNewUserRechargeNum(importNatureH5DayN.getRechargeNum());
|
|
|
+ } else {
|
|
|
+ natureGame.setNewUserRechargeMoney(BigDecimal.ZERO);
|
|
|
+ natureGame.setNewUserRechargeNum(0L);
|
|
|
+ }
|
|
|
+ return natureGame;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return natureGameList;
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<H5BuyUserVO> getH5BuyUserVOList(GameDataH5DTO dto, Map<String, Object> importDayNMap, GameDataH5VO item) {
|
|
|
+ //买量导入游戏
|
|
|
+ Sql buyGameSql = Sqls.queryEntity("""
|
|
|
+ select
|
|
|
+ buy_source_system,
|
|
|
+ buy_game_id,
|
|
|
+ max(buy_game_name) as buy_game_name,
|
|
|
+ max(buy_classify) as buy_classify,
|
|
|
+ sum(h5_lead_buy_new_user_total_amount) as h5_lead_buy_new_user_total_amount,
|
|
|
+ sum(h5_lead_buy_new_user_total_amount_num) as h5_lead_buy_new_user_total_amount_num
|
|
|
+ from ads_h5_game_day
|
|
|
+ where
|
|
|
+ game_id = @gameId
|
|
|
+ and
|
|
|
+ dt>=@beginDay and dt<=@endDay
|
|
|
+ group by buy_source_system,buy_game_id
|
|
|
+ """);
|
|
|
+ buyGameSql.setParam("gameId", item.getGameId());
|
|
|
+ buyGameSql.setParam("beginDay", dto.getCostBeginDate());
|
|
|
+ buyGameSql.setParam("endDay", dto.getCostEndDate());
|
|
|
+ Entity<H5BuyUserVO> buyGameEntity = dao.getEntity(H5BuyUserVO.class);
|
|
|
+ buyGameSql.setEntity(buyGameEntity);
|
|
|
+ dao.execute(buyGameSql);
|
|
|
+
|
|
|
+ //买量导入游戏账面
|
|
|
+ Sql buyShowGameSql = Sqls.queryEntity("""
|
|
|
+ select
|
|
|
+ buy_source_system,
|
|
|
+ buy_game_id,
|
|
|
+ sum(h5_lead_buy_amount) as h5_lead_buy_amount,
|
|
|
+ sum(h5_lead_buy_amount_num) as h5_lead_buy_amount_num
|
|
|
+ from ads_h5_game_day
|
|
|
+ where
|
|
|
+ game_id = @gameId
|
|
|
+ and
|
|
|
+ dt>=@beginDay and dt<=@endDay
|
|
|
+ group by buy_source_system,buy_game_id
|
|
|
+ """);
|
|
|
+ buyShowGameSql.setParam("gameId", item.getGameId());
|
|
|
+ buyShowGameSql.setParam("beginDay", dto.getRechargeBeginDate());
|
|
|
+ buyShowGameSql.setParam("endDay", dto.getRechargeEndDate());
|
|
|
+ Entity<H5BuyUserVO> buyShowGameEntity = dao.getEntity(H5BuyUserVO.class);
|
|
|
+ buyShowGameSql.setEntity(buyShowGameEntity);
|
|
|
+ dao.execute(buyShowGameSql);
|
|
|
+ Map<Long, List<H5BuyUserVO>> showBuyGameMap = buyShowGameSql.getList(H5BuyUserVO.class).stream()
|
|
|
+ .filter(tt -> null != tt.getBuyGameId())
|
|
|
+ .collect(Collectors.groupingBy(H5BuyUserVO::getBuyGameId));
|
|
|
+
|
|
|
+ List<H5BuyUserVO> buyGameList = buyGameSql.getList(H5BuyUserVO.class).stream()
|
|
|
+ .filter(tt->null!=tt.getBuyGameId())
|
|
|
+ .map(buyGame -> {
|
|
|
+ importDayNMap.put("sourceSystem", buyGame.getBuySourceSystem());
|
|
|
+ importDayNMap.put("gameId", buyGame.getBuyGameId());
|
|
|
+ H5DayN importBuyH5DayN = getImportBuyH5DayN(dto, importDayNMap);
|
|
|
+ if (null != showBuyGameMap && null!=showBuyGameMap.get(buyGame.getBuyGameId()) && !showBuyGameMap.get(buyGame.getBuyGameId()).isEmpty()) {
|
|
|
+ buyGame.setH5LeadBuyAmount(showBuyGameMap.get(buyGame.getBuyGameId()).get(0).getH5LeadBuyAmount());
|
|
|
+ buyGame.setH5LeadBuyAmountNum(showBuyGameMap.get(buyGame.getBuyGameId()).get(0).getH5LeadBuyAmountNum());
|
|
|
+ }else {
|
|
|
+ buyGame.setH5LeadBuyAmount(BigDecimal.ZERO);
|
|
|
+ buyGame.setH5LeadBuyAmountNum(0L);
|
|
|
+ }
|
|
|
+ //买量导入游戏充值时间范围内存在新用户充值数据
|
|
|
+ if (null != importBuyH5DayN) {
|
|
|
+ buyGame.setNewUserRechargeMoney(importBuyH5DayN.getRechargeMoney());
|
|
|
+ buyGame.setNewUserRechargeNum(importBuyH5DayN.getRechargeNum());
|
|
|
+ } else {
|
|
|
+ buyGame.setNewUserRechargeMoney(BigDecimal.ZERO);
|
|
|
+ buyGame.setNewUserRechargeNum(0L);
|
|
|
+ }
|
|
|
+ return buyGame;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return buyGameList;
|
|
|
+ }
|
|
|
+ private H5DayN getImportNatureH5DayN(GameDataH5DTO dto, Map<String, Object> dayNMap) {
|
|
|
+ Sql importNatureSqlDayN = Sqls.queryString("""
|
|
|
+ select dayN from ads_dayn_h5_lead_nature_game
|
|
|
+ where
|
|
|
+ dt>=@beginDay and dt<=@endDay
|
|
|
+ and source_system = @sourceSystem
|
|
|
+ and h5_lead_nature_game_id = @gameId
|
|
|
+ """);
|
|
|
+ importNatureSqlDayN.setParams(dayNMap);
|
|
|
+ dao.execute(importNatureSqlDayN);
|
|
|
+ List<String> importNatureDayNList = importNatureSqlDayN.getList(String.class);
|
|
|
+ H5DayN importNatureDayN = null;
|
|
|
+ //ads_dayn_h5_nature_game 存在充值数据
|
|
|
+ if (!CollectionUtils.isEmpty(importNatureDayNList)) {
|
|
|
+ Gson gson = new Gson();
|
|
|
+ List<Map<String, String>> jsonList = gson.fromJson(importNatureDayNList.toString(), ArrayList.class);
|
|
|
+
|
|
|
+ Map<String, String> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("dayN", "0.00-0");
|
|
|
+ for (Map<String, String> jsonMap : jsonList) {
|
|
|
+ for (Map.Entry<String, String> entry : jsonMap.entrySet()) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ String value = entry.getValue();
|
|
|
+ String[] parts = value.split("-");
|
|
|
+ if (DateUtil.parseLocalDate(key).compareTo(dto.getRechargeBeginDate()) >= 0
|
|
|
+ && DateUtil.parseLocalDate(key).compareTo(dto.getRechargeEndDate()) <= 0) {
|
|
|
+ String[] existingParts = resultMap.get("dayN").split("-");
|
|
|
+ BigDecimal money = new BigDecimal(existingParts[0]).add(new BigDecimal(parts[0]));
|
|
|
+ int num = Integer.parseInt(existingParts[1]) + Integer.parseInt(parts[1]);
|
|
|
+ String newValue = money + "-" + num;
|
|
|
+ resultMap.put("dayN", newValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!resultMap.isEmpty() && !resultMap.get("dayN").isEmpty()) {
|
|
|
+ String[] parts = resultMap.get("dayN").split("-");
|
|
|
+ importNatureDayN = H5DayN.builder()
|
|
|
+ .rechargeMoney(new BigDecimal(parts[0]))
|
|
|
+ .rechargeNum(Long.valueOf(parts[1]))
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return importNatureDayN;
|
|
|
+ }
|
|
|
+
|
|
|
+ private H5DayN getImportBuyH5DayN(GameDataH5DTO dto, Map<String, Object> dayNMap) {
|
|
|
+ Sql importBuySqlDayN = Sqls.queryString("""
|
|
|
+ select dayN from ads_dayn_h5_lead_buy_game
|
|
|
+ where
|
|
|
+ dt>=@beginDay and dt<=@endDay
|
|
|
+ and source_system = @sourceSystem
|
|
|
+ and h5_lead_buy_game_id = @gameId
|
|
|
+ """);
|
|
|
+ importBuySqlDayN.setParams(dayNMap);
|
|
|
+ dao.execute(importBuySqlDayN);
|
|
|
+ List<String> importBuyDayNList = importBuySqlDayN.getList(String.class);
|
|
|
+ H5DayN importBuyDayN = null;
|
|
|
+ //ads_dayn_h5_nature_game 存在充值数据
|
|
|
+ if (!CollectionUtils.isEmpty(importBuyDayNList)) {
|
|
|
+ Gson gson = new Gson();
|
|
|
+ List<Map<String, String>> jsonList = gson.fromJson(importBuyDayNList.toString(), ArrayList.class);
|
|
|
+
|
|
|
+ Map<String, String> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("dayN", "0.00-0");
|
|
|
+ for (Map<String, String> jsonMap : jsonList) {
|
|
|
+ for (Map.Entry<String, String> entry : jsonMap.entrySet()) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ String value = entry.getValue();
|
|
|
+ String[] parts = value.split("-");
|
|
|
+ if (DateUtil.parseLocalDate(key).compareTo(dto.getRechargeBeginDate()) >= 0
|
|
|
+ && DateUtil.parseLocalDate(key).compareTo(dto.getRechargeEndDate()) <= 0) {
|
|
|
+ String[] existingParts = resultMap.get("dayN").split("-");
|
|
|
+ BigDecimal money = new BigDecimal(existingParts[0]).add(new BigDecimal(parts[0]));
|
|
|
+ int num = Integer.parseInt(existingParts[1]) + Integer.parseInt(parts[1]);
|
|
|
+ String newValue = money + "-" + num;
|
|
|
+ resultMap.put("dayN", newValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!resultMap.isEmpty() && !resultMap.get("dayN").isEmpty()) {
|
|
|
+ String[] parts = resultMap.get("dayN").split("-");
|
|
|
+ importBuyDayN = H5DayN.builder()
|
|
|
+ .rechargeMoney(new BigDecimal(parts[0]))
|
|
|
+ .rechargeNum(Long.valueOf(parts[1]))
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return importBuyDayN;
|
|
|
+ }
|
|
|
+
|
|
|
+ private H5DayN getNatureH5DayN(GameDataH5DTO dto, Map<String, Object> dayNMap) {
|
|
|
+ Sql natureSqlDayN = Sqls.queryString("""
|
|
|
+ select dayN from ads_dayn_h5_nature_game
|
|
|
+ where
|
|
|
+ dt>=@beginDay and dt<=@endDay
|
|
|
+ and source_system = @sourceSystem
|
|
|
+ and h5_nature_game_id = @h5GameId
|
|
|
+ """);
|
|
|
+ natureSqlDayN.setParams(dayNMap);
|
|
|
+ dao.execute(natureSqlDayN);
|
|
|
+ List<String> natureDayNList = natureSqlDayN.getList(String.class);
|
|
|
+ H5DayN h5NatureDayN = null;
|
|
|
+ //ads_dayn_h5_nature_game 存在充值数据
|
|
|
+ if (!CollectionUtils.isEmpty(natureDayNList)) {
|
|
|
+ Gson gson = new Gson();
|
|
|
+ List<Map<String, String>> jsonList = gson.fromJson(natureDayNList.toString(), ArrayList.class);
|
|
|
+
|
|
|
+ Map<String, String> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("dayN", "0.00-0");
|
|
|
+ for (Map<String, String> jsonMap : jsonList) {
|
|
|
+ for (Map.Entry<String, String> entry : jsonMap.entrySet()) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ String value = entry.getValue();
|
|
|
+ String[] parts = value.split("-");
|
|
|
+ if (DateUtil.parseLocalDate(key).compareTo(dto.getRechargeBeginDate()) >= 0
|
|
|
+ && DateUtil.parseLocalDate(key).compareTo(dto.getRechargeEndDate()) <= 0) {
|
|
|
+ String[] existingParts = resultMap.get("dayN").split("-");
|
|
|
+ BigDecimal money = new BigDecimal(existingParts[0]).add(new BigDecimal(parts[0]));
|
|
|
+ int num = Integer.parseInt(existingParts[1]) + Integer.parseInt(parts[1]);
|
|
|
+ String newValue = money + "-" + num;
|
|
|
+ resultMap.put("dayN", newValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!resultMap.isEmpty() && !resultMap.get("dayN").isEmpty()) {
|
|
|
+ String[] parts = resultMap.get("dayN").split("-");
|
|
|
+ h5NatureDayN = H5DayN.builder()
|
|
|
+ .rechargeMoney(new BigDecimal(parts[0]))
|
|
|
+ .rechargeNum(Long.valueOf(parts[1]))
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return h5NatureDayN;
|
|
|
+ }
|
|
|
+
|
|
|
+ private H5DayN getH5PayDayN(GameDataH5DTO dto, Map<String, Object> dayNMap) {
|
|
|
+ H5DayN h5PayDayN = null;
|
|
|
+ Sql paySqlDayN = Sqls.queryString("""
|
|
|
+ select dayN from ads_dayn_h5_pay_game
|
|
|
+ where
|
|
|
+ dt>=@beginDay and dt<=@endDay
|
|
|
+ and source_system = @sourceSystem
|
|
|
+ and h5_game_id = @h5GameId
|
|
|
+ """);
|
|
|
+ paySqlDayN.setParams(dayNMap);
|
|
|
+ dao.execute(paySqlDayN);
|
|
|
+ List<String> payDayNList = paySqlDayN.getList(String.class);
|
|
|
+
|
|
|
+ //ads_dayn_h5_pay_game存在充值数据
|
|
|
+ if (!CollectionUtils.isEmpty(payDayNList)) {
|
|
|
+ Gson gson = new Gson();
|
|
|
+ List<Map<String, String>> jsonList = gson.fromJson(payDayNList.toString(), ArrayList.class);
|
|
|
+
|
|
|
+ Map<String, String> resultMap = new HashMap<>();
|
|
|
+ resultMap.put("dayN", "0.00-0");
|
|
|
+ for (Map<String, String> jsonMap : jsonList) {
|
|
|
+ for (Map.Entry<String, String> entry : jsonMap.entrySet()) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ String value = entry.getValue();
|
|
|
+ String[] parts = value.split("-");
|
|
|
+ if (DateUtil.parseLocalDate(key).compareTo(dto.getRechargeBeginDate()) >= 0
|
|
|
+ && DateUtil.parseLocalDate(key).compareTo(dto.getRechargeEndDate()) <= 0) {
|
|
|
+ String[] existingParts = resultMap.get("dayN").split("-");
|
|
|
+ BigDecimal money = new BigDecimal(existingParts[0]).add(new BigDecimal(parts[0]));
|
|
|
+ int num = Integer.parseInt(existingParts[1]) + Integer.parseInt(parts[1]);
|
|
|
+ String newValue = money + "-" + num;
|
|
|
+ resultMap.put("dayN", newValue);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!resultMap.isEmpty() && !resultMap.get("dayN").isEmpty()) {
|
|
|
+ String[] parts = resultMap.get("dayN").split("-");
|
|
|
+ h5PayDayN = H5DayN.builder()
|
|
|
+ .rechargeMoney(new BigDecimal(parts[0]))
|
|
|
+ .rechargeNum(Long.valueOf(parts[1]))
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return h5PayDayN;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String h5RechargeSql() {
|
|
|
+ return """
|
|
|
+ select
|
|
|
+ a.game_id as id,
|
|
|
+ a.game_id as game_id,
|
|
|
+ max(a.game_name) as game_name,
|
|
|
+ max(a.source_system) as source_system,
|
|
|
+ sum(a.h5_buy_new_user_total_amount) as h5_buy_new_user_total_amount,
|
|
|
+ sum(a.h5_buy_new_user_total_amount_num) as h5_buy_new_user_total_amount_num,
|
|
|
+ round(if(sum(a.h5_buy_new_user_total_amount) > 0, sum(a.h5_nature_new_user_total_amount) / sum(a.h5_buy_new_user_total_amount), 0), 4) as h5_nature_new_user_total_amount_rate,
|
|
|
+ sum(a.h5_nature_new_user_total_amount) as h5_nature_new_user_total_amount,
|
|
|
+ sum(a.h5_nature_new_user_total_amount_num) as h5_nature_new_user_total_amount_num
|
|
|
+ from ads_h5_game_day a
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
private String waterSql() {
|
|
|
return """
|
|
|
select
|
|
|
game_id as id,
|
|
|
+ source_system,
|
|
|
game_id,
|
|
|
max(game_name) as game_name,
|
|
|
max(game_classify) as game_classify,
|
|
@@ -1436,4 +1916,25 @@ public class GameDataServiceImpl implements IGameDataService {
|
|
|
private BigInteger rechargeAgainNum;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Data
|
|
|
+ @Builder
|
|
|
+ public static class H5DayN{
|
|
|
+ private BigDecimal rechargeMoney;
|
|
|
+ private Long rechargeNum;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Data
|
|
|
+ @NoArgsConstructor
|
|
|
+ @AllArgsConstructor
|
|
|
+ @Builder
|
|
|
+ public static class ShowRecharge{
|
|
|
+ private BigDecimal h5NatureAmount;
|
|
|
+
|
|
|
+ private Long h5NatureAmountNum;
|
|
|
+
|
|
|
+ private BigDecimal h5BuyAmount;
|
|
|
+
|
|
|
+ private Long h5BuyAmountNum;
|
|
|
+ }
|
|
|
}
|