|
@@ -2,10 +2,10 @@ package com.zanxiang.game.data.serve.service.impl;
|
|
|
|
|
|
import com.zanxiang.erp.security.util.SecurityUtil;
|
|
|
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 com.zanxiang.game.data.serve.pojo.dto.OverallSummaryDTO;
|
|
|
+import com.zanxiang.game.data.serve.pojo.vo.OverallSummaryLineDataVO;
|
|
|
+import com.zanxiang.game.data.serve.pojo.vo.OverallSummaryVO;
|
|
|
+import com.zanxiang.game.data.serve.service.IOverallSummaryService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.nutz.dao.Cnd;
|
|
|
import org.nutz.dao.Condition;
|
|
@@ -34,16 +34,16 @@ import java.util.*;
|
|
|
**/
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
-public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
+public class OverallSummaryServiceImpl implements IOverallSummaryService {
|
|
|
|
|
|
@Autowired
|
|
|
private Dao dao;
|
|
|
|
|
|
@Override
|
|
|
- public AdsOverallSummaryVO getOverallSummaryTotalData(AdsOverallSummaryParam param) {
|
|
|
+ public OverallSummaryVO getOverallSummaryTotalData(OverallSummaryDTO dto) {
|
|
|
|
|
|
//获取查询条件 整体数据查询 不需要日期
|
|
|
- Condition totalDataCon = myCondition(param, false, -1);
|
|
|
+ Condition totalDataCon = myCondition(dto, false, -1);
|
|
|
//查询条件转换为sql语句 设置映射 Entity为 AdsOverallSummary对象
|
|
|
String totalDataConString = totalDataCon.toSql(dao.getEntity(AdsOverallSummary.class));
|
|
|
//自定义sql语句
|
|
@@ -60,14 +60,14 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
|
|
|
//自定义回显对象 结果自动封装到给定的Entity对象中
|
|
|
totalDataSql.setCallback(Sqls.callback.entity());
|
|
|
- totalDataSql.setEntity(dao.getEntity(AdsOverallSummaryVO.class));
|
|
|
+ totalDataSql.setEntity(dao.getEntity(OverallSummaryVO.class));
|
|
|
//执行自定义sql语句
|
|
|
dao.execute(totalDataSql);
|
|
|
- //得到一个包含有总数据的AdsOverallSummaryVO对象
|
|
|
- AdsOverallSummaryVO totalDataVO = totalDataSql.getObject(AdsOverallSummaryVO.class);
|
|
|
+ //得到一个包含有总数据的OverallSummaryVO对象
|
|
|
+ OverallSummaryVO totalDataVO = totalDataSql.getObject(OverallSummaryVO.class);
|
|
|
|
|
|
//获取查询条件 查询今日数据 需要按当前日期查询
|
|
|
- Condition todayDataCon = myCondition(param, false, 1);
|
|
|
+ Condition todayDataCon = myCondition(dto, false, 1);
|
|
|
//查询条件转换为sql语句 设置映射 Entity为 AdsOverallSummary对象
|
|
|
String todayDataConString = todayDataCon.toSql(dao.getEntity(AdsOverallSummary.class));
|
|
|
Sql todayDataSql = Sqls.create("""
|
|
@@ -90,39 +90,39 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
|
|
|
//自定义回显对象 结果自动封装到给定的Entity对象中
|
|
|
todayDataSql.setCallback(Sqls.callback.entity());
|
|
|
- todayDataSql.setEntity(dao.getEntity(AdsOverallSummaryVO.class));
|
|
|
+ todayDataSql.setEntity(dao.getEntity(OverallSummaryVO.class));
|
|
|
//执行自定义sql语句
|
|
|
dao.execute(todayDataSql);
|
|
|
- //得到一个包含有今日和昨日数据的AdsOverallSummaryVO对象
|
|
|
- AdsOverallSummaryVO adsOverallSummaryVO = todayDataSql.getObject(AdsOverallSummaryVO.class);
|
|
|
+ //得到一个包含有今日和昨日数据的OverallSummaryVO对象
|
|
|
+ OverallSummaryVO overallSummaryVO = todayDataSql.getObject(OverallSummaryVO.class);
|
|
|
|
|
|
//拼接参数
|
|
|
- copyNullProperties(totalDataVO, adsOverallSummaryVO);
|
|
|
+ copyNullProperties(totalDataVO, overallSummaryVO);
|
|
|
|
|
|
//7日和30日Roi数据需要手动计算
|
|
|
//7日内新用户累计充值
|
|
|
- BigDecimal d7NewPlayerAmount = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayNewPlayerAmount", myCondition(param, false, 7));
|
|
|
+ BigDecimal d7NewPlayerAmount = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayNewPlayerAmount", myCondition(dto, false, 7));
|
|
|
//7日内总消耗
|
|
|
- BigDecimal d7TotalCost = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayTotalCost", myCondition(param, false, 7));
|
|
|
+ BigDecimal d7TotalCost = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayTotalCost", myCondition(dto, false, 7));
|
|
|
//cost 查询出的结果为null或者为0.00 设置为默认值0
|
|
|
- adsOverallSummaryVO.setD7TotalRoi((d7TotalCost == null || BigDecimal.ZERO.compareTo(d7TotalCost) == 0) ? BigDecimal.ZERO : d7NewPlayerAmount.divide(d7TotalCost, 4, RoundingMode.HALF_UP));
|
|
|
+ overallSummaryVO.setD7TotalRoi((d7TotalCost == null || BigDecimal.ZERO.compareTo(d7TotalCost) == 0) ? BigDecimal.ZERO : d7NewPlayerAmount.divide(d7TotalCost, 4, RoundingMode.HALF_UP));
|
|
|
|
|
|
//30日内新用户累计充值
|
|
|
- BigDecimal d30NewPlayerAmount = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayNewPlayerAmount", myCondition(param, false, 30));
|
|
|
+ BigDecimal d30NewPlayerAmount = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayNewPlayerAmount", myCondition(dto, false, 30));
|
|
|
//30日内总消耗
|
|
|
- BigDecimal d30TotalCost = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayTotalCost", myCondition(param, false, 30));
|
|
|
+ BigDecimal d30TotalCost = (BigDecimal) dao.func2(AdsOverallSummary.class, "sum", "todayTotalCost", myCondition(dto, false, 30));
|
|
|
//计算30日Roi
|
|
|
//cost 查询出的结果为null或者为0.00 设置为默认值0
|
|
|
- adsOverallSummaryVO.setD30TotalRoi((d30TotalCost == null || BigDecimal.ZERO.compareTo(d30TotalCost) == 0) ? BigDecimal.ZERO : d30NewPlayerAmount.divide(d30TotalCost, 4, RoundingMode.HALF_UP));
|
|
|
+ overallSummaryVO.setD30TotalRoi((d30TotalCost == null || BigDecimal.ZERO.compareTo(d30TotalCost) == 0) ? BigDecimal.ZERO : d30NewPlayerAmount.divide(d30TotalCost, 4, RoundingMode.HALF_UP));
|
|
|
|
|
|
- return adsOverallSummaryVO;
|
|
|
+ return overallSummaryVO;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<AdsOverallSummaryLineDataVO> getOverallSummaryLineData(AdsOverallSummaryParam param) {
|
|
|
+ public List<OverallSummaryLineDataVO> getOverallSummaryLineData(OverallSummaryDTO dto) {
|
|
|
|
|
|
//根据条件获取数据
|
|
|
- Condition lineCon = myCondition(param, true, -1);
|
|
|
+ Condition lineCon = myCondition(dto, true, -1);
|
|
|
//查询条件变为字符串
|
|
|
String lineConString = lineCon.toSql(dao.getEntity(AdsOverallSummary.class));
|
|
|
//自定义sql语句 加上条件字符串
|
|
@@ -140,43 +140,43 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
|
|
|
//自定义回显对象 结果自动添加到一个List中 List<Entity>
|
|
|
sql.setCallback(Sqls.callback.entities());
|
|
|
- sql.setEntity(dao.getEntity(AdsOverallSummaryLineDataVO.class));
|
|
|
+ sql.setEntity(dao.getEntity(OverallSummaryLineDataVO.class));
|
|
|
|
|
|
//执行自定义sql语句
|
|
|
dao.execute(sql);
|
|
|
|
|
|
//判断查询日期的数据是否都存在 结果返回
|
|
|
- return checkAllDateData(sql.getList(AdsOverallSummaryLineDataVO.class), param);
|
|
|
+ return checkAllDateData(sql.getList(OverallSummaryLineDataVO.class), dto);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 自定义查询条件
|
|
|
*
|
|
|
- * @param param 前端传递的查询参数实体
|
|
|
+ * @param dto 前端传递的查询参数实体
|
|
|
* @param needLocalDate 是否拼接日期查询条件
|
|
|
* @param queryDays 拼接需要查询数据的天数条件(给今日昨日、首日Roi、7日Roi以及30日Roi使用)
|
|
|
* @return Condition 查询条件
|
|
|
*/
|
|
|
- private Condition myCondition(AdsOverallSummaryParam param, Boolean needLocalDate, Integer queryDays) {
|
|
|
+ private Condition myCondition(OverallSummaryDTO dto, Boolean needLocalDate, Integer queryDays) {
|
|
|
|
|
|
Criteria cri = Cnd.cri();
|
|
|
//默认查询条件
|
|
|
- if (param.getGameId() != null) {
|
|
|
+ if (dto.getGameId() != null) {
|
|
|
//拼接游戏查询条件
|
|
|
- cri.where().andEquals("gameId", param.getGameId());
|
|
|
+ cri.where().andEquals("gameId", dto.getGameId());
|
|
|
}
|
|
|
- if (param.getAgentId() != null) {
|
|
|
+ if (dto.getAgentId() != null) {
|
|
|
//拼接渠道查询条件
|
|
|
- cri.where().andEquals("agentId", param.getAgentId());
|
|
|
+ cri.where().andEquals("agentId", dto.getAgentId());
|
|
|
}
|
|
|
- if (param.getAccountId() != null) {
|
|
|
+ if (dto.getAccountId() != null) {
|
|
|
//拼接广告账户查询条件
|
|
|
- cri.where().andEquals("accountId", param.getAccountId());
|
|
|
+ cri.where().andEquals("accountId", dto.getAccountId());
|
|
|
}
|
|
|
//前端传递 pitcherId 根据 pitcherId 查询
|
|
|
- if (param.getPitcherId() != null) {
|
|
|
+ if (dto.getPitcherId() != null) {
|
|
|
//拼接投手查询条件
|
|
|
- cri.where().andEquals("pitcherId", param.getPitcherId());
|
|
|
+ cri.where().andEquals("pitcherId", dto.getPitcherId());
|
|
|
} else if (SecurityUtil.isManager()){
|
|
|
//前端没有传递 pitcherId 参数并且是管理员 查看所有数据 排除掉 pitcherId = -2 的数据
|
|
|
cri.where().andNotEquals("pitcherId", -2);
|
|
@@ -197,12 +197,12 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
//折线数据需要拼接时间查询条件
|
|
|
if (needLocalDate) {
|
|
|
//如果传入时间区间参数为空 设置默认值
|
|
|
- if (param.getBeginDate() == null || param.getEndDate() == null) {
|
|
|
- param.setBeginDate(LocalDate.now().minusDays(30));
|
|
|
- param.setEndDate(LocalDate.now());
|
|
|
+ if (dto.getBeginDate() == null || dto.getEndDate() == null) {
|
|
|
+ dto.setBeginDate(LocalDate.now().minusDays(30));
|
|
|
+ dto.setEndDate(LocalDate.now());
|
|
|
}
|
|
|
//添加日期条件
|
|
|
- cri.where().andBetween("dt", param.getBeginDate(), param.getEndDate());
|
|
|
+ cri.where().andBetween("dt", dto.getBeginDate(), dto.getEndDate());
|
|
|
//按日期分组
|
|
|
cri.getGroupBy().groupBy("dt");
|
|
|
//按日期排序 升序
|
|
@@ -251,26 +251,26 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
* 不存在要设置默认值 0
|
|
|
*
|
|
|
* @param list 需要判断的list
|
|
|
- * @param param 前端传递的查询参数实体
|
|
|
+ * @param dto 前端传递的查询参数实体
|
|
|
* @return 返回给前端的折线图数据 list
|
|
|
*/
|
|
|
- private List<AdsOverallSummaryLineDataVO> checkAllDateData(List<AdsOverallSummaryLineDataVO> list, AdsOverallSummaryParam param) {
|
|
|
+ private List<OverallSummaryLineDataVO> checkAllDateData(List<OverallSummaryLineDataVO> list, OverallSummaryDTO dto) {
|
|
|
|
|
|
//先判断是否缺少数据 不少数据直接返回
|
|
|
- if ((list.size() - 1) == param.getBeginDate().until(param.getEndDate(), ChronoUnit.DAYS)) {
|
|
|
+ if ((list.size() - 1) == dto.getBeginDate().until(dto.getEndDate(), ChronoUnit.DAYS)) {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
//创建一个Map用来存储日期数据
|
|
|
Map<LocalDate, Integer> map = new HashMap<>();
|
|
|
//添加日期数据
|
|
|
- LocalDate tempDate = param.getBeginDate();
|
|
|
- while (!tempDate.isAfter(param.getEndDate())) {
|
|
|
+ LocalDate tempDate = dto.getBeginDate();
|
|
|
+ while (!tempDate.isAfter(dto.getEndDate())) {
|
|
|
map.put(tempDate, 1);
|
|
|
tempDate = tempDate.plusDays(1);
|
|
|
}
|
|
|
//循环遍历list 查询vo里的日期参数
|
|
|
- for (AdsOverallSummaryLineDataVO vo : list) {
|
|
|
+ for (OverallSummaryLineDataVO vo : list) {
|
|
|
Integer value = map.get(vo.getDt());
|
|
|
if (value != null) {
|
|
|
map.put(vo.getDt(), ++value);
|
|
@@ -280,7 +280,7 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
for (Map.Entry<LocalDate, Integer> entry : map.entrySet()) {
|
|
|
if (entry.getValue() == 1) {
|
|
|
//list数据添加一个默认VO对象
|
|
|
- list.add(AdsOverallSummaryLineDataVO.builder()
|
|
|
+ list.add(OverallSummaryLineDataVO.builder()
|
|
|
.dt(entry.getKey())
|
|
|
.amount(BigDecimal.ZERO)
|
|
|
.buyAmount(BigDecimal.ZERO)
|