|
@@ -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);
|
|
|
|
|
|
String totalDataConString = totalDataCon.toSql(dao.getEntity(AdsOverallSummary.class));
|
|
|
|
|
@@ -60,14 +60,14 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
|
|
|
|
|
|
totalDataSql.setCallback(Sqls.callback.entity());
|
|
|
- totalDataSql.setEntity(dao.getEntity(AdsOverallSummaryVO.class));
|
|
|
+ totalDataSql.setEntity(dao.getEntity(OverallSummaryVO.class));
|
|
|
|
|
|
dao.execute(totalDataSql);
|
|
|
-
|
|
|
- AdsOverallSummaryVO totalDataVO = totalDataSql.getObject(AdsOverallSummaryVO.class);
|
|
|
+
|
|
|
+ OverallSummaryVO totalDataVO = totalDataSql.getObject(OverallSummaryVO.class);
|
|
|
|
|
|
|
|
|
- Condition todayDataCon = myCondition(param, false, 1);
|
|
|
+ Condition todayDataCon = myCondition(dto, false, 1);
|
|
|
|
|
|
String todayDataConString = todayDataCon.toSql(dao.getEntity(AdsOverallSummary.class));
|
|
|
Sql todayDataSql = Sqls.create("""
|
|
@@ -90,39 +90,39 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
|
|
|
|
|
|
todayDataSql.setCallback(Sqls.callback.entity());
|
|
|
- todayDataSql.setEntity(dao.getEntity(AdsOverallSummaryVO.class));
|
|
|
+ todayDataSql.setEntity(dao.getEntity(OverallSummaryVO.class));
|
|
|
|
|
|
dao.execute(todayDataSql);
|
|
|
-
|
|
|
- AdsOverallSummaryVO adsOverallSummaryVO = todayDataSql.getObject(AdsOverallSummaryVO.class);
|
|
|
+
|
|
|
+ OverallSummaryVO overallSummaryVO = todayDataSql.getObject(OverallSummaryVO.class);
|
|
|
|
|
|
|
|
|
- copyNullProperties(totalDataVO, adsOverallSummaryVO);
|
|
|
+ copyNullProperties(totalDataVO, overallSummaryVO);
|
|
|
|
|
|
|
|
|
|
|
|
- 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));
|
|
|
|
|
|
- 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));
|
|
|
|
|
|
- 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));
|
|
|
|
|
|
|
|
|
- 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));
|
|
|
|
|
|
- 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));
|
|
|
|
|
|
|
|
|
- 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));
|
|
|
|
|
@@ -140,43 +140,43 @@ public class AdsOverallSummaryServiceImpl implements IAdsOverallSummaryService {
|
|
|
|
|
|
|
|
|
sql.setCallback(Sqls.callback.entities());
|
|
|
- sql.setEntity(dao.getEntity(AdsOverallSummaryLineDataVO.class));
|
|
|
+ sql.setEntity(dao.getEntity(OverallSummaryLineDataVO.class));
|
|
|
|
|
|
|
|
|
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());
|
|
|
}
|
|
|
|
|
|
- if (param.getPitcherId() != null) {
|
|
|
+ if (dto.getPitcherId() != null) {
|
|
|
|
|
|
- cri.where().andEquals("pitcherId", param.getPitcherId());
|
|
|
+ cri.where().andEquals("pitcherId", dto.getPitcherId());
|
|
|
} else if (SecurityUtil.isManager()){
|
|
|
|
|
|
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<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);
|
|
|
}
|
|
|
|
|
|
- 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.add(AdsOverallSummaryLineDataVO.builder()
|
|
|
+ list.add(OverallSummaryLineDataVO.builder()
|
|
|
.dt(entry.getKey())
|
|
|
.amount(BigDecimal.ZERO)
|
|
|
.buyAmount(BigDecimal.ZERO)
|