|
@@ -112,39 +112,35 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
nowCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,startTime,endTime);
|
|
|
lastCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
|
|
|
}
|
|
|
-
|
|
|
- nowMap.put("costList", nowCostList);
|
|
|
- lastMap.put("costList", lastCostList);
|
|
|
+ //当前阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
|
|
|
+ nowMap.put("costList", getCostList(nowCostList));
|
|
|
+ //上个阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
|
|
|
+ lastMap.put("costList", getCostList(lastCostList));
|
|
|
|
|
|
resultMap.put("nowMap", nowMap);
|
|
|
resultMap.put("lastMap", lastMap);
|
|
|
-
|
|
|
return Result.successMsg("成功。",resultMap);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 获取 数据
|
|
|
+ * 获取 数据 (总)
|
|
|
* @param list
|
|
|
* @return
|
|
|
*/
|
|
|
public Map<String,Object> getCost(List<ReportCostVo> list){
|
|
|
Map<String,Object> map = new HashMap<>();
|
|
|
-
|
|
|
//花费
|
|
|
double cost = list.stream().mapToDouble(ReportCostVo::getCost).sum();
|
|
|
-
|
|
|
//转化成本 = 总花费 / 转化数
|
|
|
int converNum = list.stream().mapToInt(ReportCostVo::getConvertNum).sum();
|
|
|
double conver = cost / converNum;
|
|
|
map.put("conver", String.format("%.2f", conver));
|
|
|
map.put("converNum", converNum);
|
|
|
-
|
|
|
//转化率 = 转化数 / 点击数 * 100
|
|
|
int clickNum = list.stream().mapToInt(ReportCostVo::getClick).sum();
|
|
|
double click = Double.valueOf(converNum) / Double.valueOf(clickNum) * 100;
|
|
|
map.put("converRate", String.format("%.2f", click));
|
|
|
-
|
|
|
// 平均千次展显费用 = 总花费/展示数 * 1000
|
|
|
int showNum = list.stream().mapToInt(ReportCostVo::getShowNum).sum();
|
|
|
double show = (cost / showNum) * 1000 ;
|
|
@@ -152,6 +148,30 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ //获取 数据 (时间段)
|
|
|
+ public List<ReportCostVo> getCostList(List<ReportCostVo> list){
|
|
|
+ list.forEach(reportCostVo -> {
|
|
|
+ //花费
|
|
|
+ double cost = reportCostVo.getCost();
|
|
|
+ //转化成本 = 总花费 / 转化数
|
|
|
+ int converNum = reportCostVo.getConvertNum();
|
|
|
+ double conver = cost / converNum;
|
|
|
+ reportCostVo.setConver(String.format("%.2f", conver));
|
|
|
+ reportCostVo.setConvertNum(converNum);
|
|
|
+
|
|
|
+ //转化率 = 转化数 / 点击数 * 100
|
|
|
+ int clickNum = reportCostVo.getClick();
|
|
|
+ double click = Double.valueOf(converNum) / Double.valueOf(clickNum) * 100;
|
|
|
+ reportCostVo.setConverRate(String.format("%.2f", click));
|
|
|
+
|
|
|
+ // 平均千次展显费用 = 总花费/展示数 * 1000
|
|
|
+ int showNum = reportCostVo.getShowNum();
|
|
|
+ double show = (cost / showNum) * 1000 ;
|
|
|
+ reportCostVo.setAverageShow(String.format("%.2f", show));
|
|
|
+ });
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
/**
|