|
@@ -0,0 +1,180 @@
|
|
|
|
+package com.zanxiang.game.data.serve.service.impl;
|
|
|
|
+
|
|
|
|
+import com.zanxiang.game.data.serve.pojo.entity.AdsOverallSummary;
|
|
|
|
+import com.zanxiang.game.data.serve.pojo.param.AdsOverallSummaryParam;
|
|
|
|
+import com.zanxiang.game.data.serve.pojo.vo.AdsOverallSummaryLineDataVO;
|
|
|
|
+import com.zanxiang.game.data.serve.pojo.vo.AdsOverallSummaryVO;
|
|
|
|
+import com.zanxiang.game.data.serve.service.IAdsOverallSummaryService;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.nutz.dao.Cnd;
|
|
|
|
+import org.nutz.dao.Condition;
|
|
|
|
+import org.nutz.dao.Dao;
|
|
|
|
+import org.nutz.dao.Sqls;
|
|
|
|
+import org.nutz.dao.sql.Criteria;
|
|
|
|
+import org.nutz.dao.sql.Sql;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.math.BigInteger;
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
+import java.util.List;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @author tianhua
|
|
|
|
+ * @time 2023/7/4
|
|
|
|
+ * @Description 整体概况逻辑处理
|
|
|
|
+ **/
|
|
|
|
+@Service
|
|
|
|
+@Slf4j
|
|
|
|
+public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private Dao dao;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public AdsOverallSummaryVO getOverallSummaryData(AdsOverallSummaryParam param) {
|
|
|
|
+
|
|
|
|
+ //前端展示数据的实体对象
|
|
|
|
+ AdsOverallSummaryVO adsOverallSummaryVO = new AdsOverallSummaryVO();
|
|
|
|
+ //获取查询条件 整体数据查询 不需要日期
|
|
|
|
+ Condition totalDataCon = myCondition(param, false, false);
|
|
|
|
+ //获取查询条件 查询今日数据 需要按当前日期查询
|
|
|
|
+ Condition todayDataCon = myCondition(param, false, true);
|
|
|
|
+
|
|
|
|
+ //查询数据 设置到实体类中
|
|
|
|
+ //总玩家数
|
|
|
|
+ adsOverallSummaryVO.setTotalPlayers(BigInteger.valueOf(dao.func(AdsOverallSummary.class, "sum", "todayPlayerCount", totalDataCon)));
|
|
|
|
+ //今日新增玩家数
|
|
|
|
+ adsOverallSummaryVO.setTodayPlayerCount(BigInteger.valueOf(dao.func(AdsOverallSummary.class, "sum", "todayPlayerCount", todayDataCon)));
|
|
|
|
+ //昨日新增玩家数
|
|
|
|
+ adsOverallSummaryVO.setYesterdayPlayerCount(BigInteger.valueOf(dao.func(AdsOverallSummary.class, "sum", "yesterdayPlayerCount", todayDataCon)));
|
|
|
|
+
|
|
|
|
+ //累计消耗
|
|
|
|
+ adsOverallSummaryVO.setTotalCost(BigDecimal.valueOf(dao.func(AdsOverallSummary.class, "sum", "todayTotalCost", totalDataCon)));
|
|
|
|
+ //今日消耗
|
|
|
|
+ adsOverallSummaryVO.setTodayTotalCost(BigDecimal.valueOf(dao.func(AdsOverallSummary.class, "sum", "todayTotalCost", todayDataCon)));
|
|
|
|
+ //昨日消耗
|
|
|
|
+ adsOverallSummaryVO.setYesterdayTotalCost(BigDecimal.valueOf(dao.func(AdsOverallSummary.class, "sum", "yesterdayTotalCost", todayDataCon)));
|
|
|
|
+
|
|
|
|
+ //累计充值
|
|
|
|
+ adsOverallSummaryVO.setTotalAmount(BigDecimal.valueOf(dao.func(AdsOverallSummary.class, "sum", "todayAmount", totalDataCon)));
|
|
|
|
+ //今日新用户充值
|
|
|
|
+ adsOverallSummaryVO.setTodayNewPlayerAmount(BigDecimal.valueOf(dao.func(AdsOverallSummary.class, "sum", "todayNewPlayerAmount", todayDataCon)));
|
|
|
|
+ //今日账面充值
|
|
|
|
+ adsOverallSummaryVO.setTodayAmount(BigDecimal.valueOf(dao.func(AdsOverallSummary.class, "sum", "todayAmount", todayDataCon)));
|
|
|
|
+ //昨日新用户充值
|
|
|
|
+ adsOverallSummaryVO.setYesterdayNewPlayerAmount(BigDecimal.valueOf(dao.func(AdsOverallSummary.class, "sum", "yesterdayNewPlayerAmount", todayDataCon)));
|
|
|
|
+ //昨日账面充值
|
|
|
|
+ adsOverallSummaryVO.setYesterdayAmount(BigDecimal.valueOf(dao.func(AdsOverallSummary.class, "sum", "yesterdayAmount", todayDataCon)));
|
|
|
|
+
|
|
|
|
+ //总渠道数量
|
|
|
|
+ adsOverallSummaryVO.setTotalAgentCount(BigInteger.valueOf(dao.func(AdsOverallSummary.class, "sum", "todayAgentCount", totalDataCon)));
|
|
|
|
+ //今日新增渠道数量
|
|
|
|
+ adsOverallSummaryVO.setTodayAgentCount(BigInteger.valueOf(dao.func(AdsOverallSummary.class, "sum", "todayAgentCount", todayDataCon)));
|
|
|
|
+ //昨日新增渠道数量
|
|
|
|
+ adsOverallSummaryVO.setYesterdayAgentCount(BigInteger.valueOf(dao.func(AdsOverallSummary.class, "sum", "yesterdayAgentCount", todayDataCon)));
|
|
|
|
+
|
|
|
|
+ //游戏总计数量
|
|
|
|
+ adsOverallSummaryVO.setTotalGameCount(BigInteger.valueOf(dao.func(AdsOverallSummary.class, "sum", "todayGameCount", totalDataCon)));
|
|
|
|
+ //今日新增游戏数量
|
|
|
|
+ adsOverallSummaryVO.setTodayGameCount(BigInteger.valueOf(dao.func(AdsOverallSummary.class, "sum", "todayGameCount", todayDataCon)));
|
|
|
|
+ //昨日新增游戏数量
|
|
|
|
+ adsOverallSummaryVO.setYesterdayGameCount(BigInteger.valueOf(dao.func(AdsOverallSummary.class, "sum", "yesterdayGameCount", todayDataCon)));
|
|
|
|
+
|
|
|
|
+ //总回本率
|
|
|
|
+ adsOverallSummaryVO.setTotalRoi(BigDecimal.valueOf(dao.func(AdsOverallSummary.class, "sum", "totalRoi", totalDataCon)));
|
|
|
|
+ //首日回本率
|
|
|
|
+ adsOverallSummaryVO.setFirstRoi(BigDecimal.valueOf(dao.func(AdsOverallSummary.class, "sum", "firstRoi", totalDataCon)));
|
|
|
|
+ //7天回本率
|
|
|
|
+ adsOverallSummaryVO.setD7TotalRoi(BigDecimal.valueOf(dao.func(AdsOverallSummary.class, "sum", "d7TotalRoi", totalDataCon)));
|
|
|
|
+ //30天回本率
|
|
|
|
+ adsOverallSummaryVO.setD30TotalRoi(BigDecimal.valueOf(dao.func(AdsOverallSummary.class, "sum", "d30TotalRoi", totalDataCon)));
|
|
|
|
+
|
|
|
|
+ return adsOverallSummaryVO;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<AdsOverallSummaryLineDataVO> getOverallSummaryLineData(AdsOverallSummaryParam param) {
|
|
|
|
+
|
|
|
|
+ //前端展示的折线数据对象实体
|
|
|
|
+ AdsOverallSummaryLineDataVO adsOverallSummaryLineDataVO = new AdsOverallSummaryLineDataVO();
|
|
|
|
+
|
|
|
|
+ //自定义sql语句
|
|
|
|
+ Sql sql = Sqls.create("Select dt," +
|
|
|
|
+ "SUM(x.today_total_cost) cost, " +
|
|
|
|
+ "SUM(x.today_buy_amount)+SUM(x.today_nature_amount) amount," +
|
|
|
|
+ "SUM(x.today_buy_amount) buy_amount," +
|
|
|
|
+ "SUM(x.today_nature_amount) nature_amount, " +
|
|
|
|
+ "SUM(x.first_roi) first_roi," +
|
|
|
|
+ "SUM(x.today_player_count) player_account " +
|
|
|
|
+ "from ads_overall_summary x $condition");
|
|
|
|
+ //根据条件获取数据
|
|
|
|
+ Condition lineCon = myCondition(param, true, false);
|
|
|
|
+ //拼接查询条件
|
|
|
|
+ sql.setCondition(lineCon);
|
|
|
|
+
|
|
|
|
+ //自定义回显对象
|
|
|
|
+ sql.setCallback(Sqls.callback.entities());
|
|
|
|
+ sql.setEntity(dao.getEntity(AdsOverallSummaryLineDataVO.class));
|
|
|
|
+
|
|
|
|
+ //执行自定义sql语句
|
|
|
|
+ dao.execute(sql);
|
|
|
|
+
|
|
|
|
+ return sql.getList(AdsOverallSummaryLineDataVO.class);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 自定义查询条件
|
|
|
|
+ *
|
|
|
|
+ * @param param 前端传递的查询参数实体
|
|
|
|
+ * @param needLocalDate 是否拼接日期查询条件
|
|
|
|
+ * @param isQueryTodayData 是否是查询今日数据
|
|
|
|
+ * @return Condition
|
|
|
|
+ */
|
|
|
|
+ private Condition myCondition(AdsOverallSummaryParam param, Boolean needLocalDate, Boolean isQueryTodayData) {
|
|
|
|
+
|
|
|
|
+ Criteria cri = Cnd.cri();
|
|
|
|
+ //默认查询条件
|
|
|
|
+ if (param.getGameId() != null) {
|
|
|
|
+ //拼接游戏查询条件
|
|
|
|
+ cri.where().andEquals("gameId", param.getGameId());
|
|
|
|
+ }
|
|
|
|
+ if (param.getPithcerId() != null) {
|
|
|
|
+ //拼接投手查询条件
|
|
|
|
+ cri.where().andEquals("pithcerId", param.getPithcerId());
|
|
|
|
+ }
|
|
|
|
+ if (param.getAgentId() != null) {
|
|
|
|
+ //拼接渠道查询条件
|
|
|
|
+ cri.where().andEquals("agentId", param.getAgentId());
|
|
|
|
+ }
|
|
|
|
+ if (param.getAccountId() != null) {
|
|
|
|
+ //拼接广告账户查询条件
|
|
|
|
+ cri.where().andEquals("accountId", param.getAccountId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //如果需要查询今日及昨日数据 就指定查询日期条件为当天日期
|
|
|
|
+ if (isQueryTodayData) {
|
|
|
|
+ cri.where().andEquals("dt", LocalDate.now());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //折线数据需要拼接时间查询条件
|
|
|
|
+ if (needLocalDate) {
|
|
|
|
+ if (param.getBeginDate() != null && param.getEndDate() != null) {
|
|
|
|
+ //如果是折线则需要给定时间内的数据
|
|
|
|
+ cri.where().andBetween("dt", param.getBeginDate(), param.getEndDate());
|
|
|
|
+ //日期排序
|
|
|
|
+ } else {
|
|
|
|
+ //没有具体时间默认查询今天数据
|
|
|
|
+ cri.where().andBetween("dt", LocalDate.now().minusDays(30), LocalDate.now());
|
|
|
|
+ }
|
|
|
|
+ //按日期分组
|
|
|
|
+ cri.getGroupBy().groupBy("dt").asc("dt");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return cri;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|