|
@@ -119,9 +119,9 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
lastCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
|
|
|
}
|
|
|
//当前阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
|
|
|
- nowMap.put("costList", getCostList(nowCostList,lastTimeMap.get("daysBetween")));
|
|
|
+ nowMap.put("costList", getCostList(nowCostList,startTime,endTime,lastTimeMap.get("daysBetween")));
|
|
|
//上个阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
|
|
|
- lastMap.put("costList", getCostList(lastCostList,lastTimeMap.get("daysBetween")));
|
|
|
+ lastMap.put("costList", getCostList(lastCostList,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"),lastTimeMap.get("daysBetween")));
|
|
|
|
|
|
resultMap.put("nowMap", nowMap);
|
|
|
resultMap.put("lastMap", lastMap);
|
|
@@ -140,7 +140,7 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
double cost = list.stream().mapToDouble(ReportCostVo::getCost).sum();
|
|
|
//转化成本 = 总花费 / 转化数
|
|
|
int converNum = list.stream().mapToInt(ReportCostVo::getConvertNum).sum();
|
|
|
- double conver = cost / converNum;
|
|
|
+ double conver = cost / new Double(converNum);
|
|
|
map.put("conver",Double.isNaN(conver) ? "0" : String.format("%.2f", conver));
|
|
|
map.put("converNum", converNum);
|
|
|
//转化率 = 转化数 / 点击数 * 100
|
|
@@ -155,7 +155,7 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
}
|
|
|
|
|
|
//获取 数据 (时间段)
|
|
|
- public List<ReportCostVo> getCostList(List<ReportCostVo> list,String daysBetween){
|
|
|
+ public List<ReportCostVo> getCostList(List<ReportCostVo> list,String startTime,String endTime,String daysBetween){
|
|
|
list.forEach(reportCostVo -> {
|
|
|
//花费
|
|
|
double cost = reportCostVo.getCost();
|
|
@@ -178,21 +178,35 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
|
|
|
/**
|
|
|
* 时间间隔为0 则表示获取当天数据 0-23时段
|
|
|
+ * 不为0 则表示 获取 开始-截至 时间 阶段数据
|
|
|
*/
|
|
|
- if (daysBetween.equals("0")){
|
|
|
+ List<String> reduceList = new ArrayList<>();
|
|
|
+ if ("0".equals(daysBetween)){
|
|
|
//返回数据中 time 的集合
|
|
|
List<String> voTimes = list.stream().map(ReportCostVo::getTime).collect(Collectors.toList());
|
|
|
// 获取0-23时段 和 已有时段的 差集 (times - voTimes)
|
|
|
- List<String> reduceList = TIMES.stream().filter(item -> !voTimes.contains(item)).collect(Collectors.toList());
|
|
|
- //补充差集时段数据
|
|
|
- if (!Check.isNull(reduceList)){
|
|
|
- reduceList.forEach(reduce ->{
|
|
|
- ReportCostVo vo = new ReportCostVo();
|
|
|
- vo.setTime(reduce);
|
|
|
- list.add(vo);
|
|
|
- });
|
|
|
- }
|
|
|
+ reduceList = TIMES.stream().filter(item -> !voTimes.contains(item)).collect(Collectors.toList());
|
|
|
+ }else {
|
|
|
+ // 获取两个日期之间 所有的 时间 年-月-日
|
|
|
+ List<String> betweenDaysList = TimeStartAndEndUtil.getAllDatesOfTwoTimes(startTime,endTime);
|
|
|
+ ////返回数据中 time 的集合
|
|
|
+ List<String> dayTimes = list.stream().map(ReportCostVo::getTime).collect(Collectors.toList());
|
|
|
+ //差集
|
|
|
+ reduceList = betweenDaysList.stream().filter(item -> !dayTimes.contains(item)).collect(Collectors.toList());
|
|
|
}
|
|
|
+ //补充差集时段数据
|
|
|
+ if (!Check.isNull(reduceList)){
|
|
|
+ reduceList.forEach(reduce ->{
|
|
|
+ ReportCostVo vo = new ReportCostVo();
|
|
|
+ vo.setTime(reduce);
|
|
|
+ vo.setConver("0");//转化成本
|
|
|
+ vo.setConvertNum(0);//转化数
|
|
|
+ vo.setConverRate("0");//转化率
|
|
|
+ vo.setAverageShow("0");//平均前次展现费用
|
|
|
+ list.add(vo);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ Collections.sort(list,Comparator.comparing(ReportCostVo::getTime));
|
|
|
return list;
|
|
|
}
|
|
|
|