|
@@ -74,8 +74,24 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
List<ReportCostVo> nowCostList = new ArrayList<>();
|
|
|
List<ReportCostVo> lastCostList = new ArrayList<>();
|
|
|
|
|
|
- //当前时间段数据
|
|
|
- nowCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfo(accountId,startTime,endTime);
|
|
|
+
|
|
|
+ //根据本阶段时间 获取 上阶段 开始-截至 时间
|
|
|
+ Map<String,String> lastTimeMap = TimeStartAndEndUtil.getStartEndTime(startTime,endTime);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 日期相差不为 0 则 展示 日报(每天数据总和)数据
|
|
|
+ * 日期相差天数为0 则 展示 24小时 数据
|
|
|
+ */
|
|
|
+ if (!lastTimeMap.get("daysBetween").equals("0")){
|
|
|
+ // 账户 日报 阶段 数据
|
|
|
+ nowCostList = bytedanceAdvertiserHourlyReportMapper.selectPlanCostInfoCount(accountId,null,startTime,endTime);
|
|
|
+ lastCostList = bytedanceAdvertiserHourlyReportMapper.selectPlanCostInfoCount(accountId,null,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
|
|
|
+ }else{
|
|
|
+ // 账户 当前时间段数据
|
|
|
+ nowCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,startTime,endTime);
|
|
|
+ //上阶段数据
|
|
|
+ lastCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
|
|
|
+ }
|
|
|
|
|
|
//更新时间
|
|
|
List<ReportCostVo> updTimeList = nowCostList.stream().sorted(Comparator.comparing(ReportCostVo::getCreateTime)).collect(Collectors.toList());
|
|
@@ -85,10 +101,6 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
double nowCost = nowCostList.stream().mapToDouble(ReportCostVo::getCost).sum();
|
|
|
resultMap.put("nowCost", String.format("%.2f", nowCost));
|
|
|
|
|
|
- //根据本阶段时间 获取 上阶段 开始-截至 时间
|
|
|
- Map<String,String> lastTimeMap = TimeStartAndEndUtil.getStartEndTime(startTime,endTime);
|
|
|
- //上阶段数据
|
|
|
- lastCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfo(accountId,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
|
|
|
//上阶段花费
|
|
|
double lastCost = lastCostList.stream().mapToDouble(ReportCostVo::getCost).sum();
|
|
|
resultMap.put("lastCost", String.format("%.2f", lastCost));
|
|
@@ -116,15 +128,6 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
// 上阶段数据
|
|
|
Map lastMap = getCost(lastCostList);
|
|
|
|
|
|
- /**
|
|
|
- * 日期相差不为 0 则 展示 时间段(每天数据总和)数据
|
|
|
- * 日期相差天数为0 则 展示 24小时 数据
|
|
|
- */
|
|
|
- if (!lastTimeMap.get("daysBetween").equals("0")){
|
|
|
- //阶段 数据
|
|
|
- nowCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,startTime,endTime);
|
|
|
- lastCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStage(accountId,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
|
|
|
- }
|
|
|
//当前阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
|
|
|
nowMap.put("costList", getCostList(nowCostList,startTime,endTime,lastTimeMap.get("daysBetween")));
|
|
|
//上个阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
|
|
@@ -133,7 +136,6 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
resultMap.put("nowMap", nowMap);
|
|
|
resultMap.put("lastMap", lastMap);
|
|
|
|
|
|
-
|
|
|
return Result.successMsg("成功。",resultMap);
|
|
|
}
|
|
|
|
|
@@ -288,11 +290,19 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
@Override
|
|
|
public Result getReportPlanCost(String accountId, String startTime, String endTime,Integer pageNum,Integer pageSize) throws Exception {
|
|
|
DecimalFormat df = new DecimalFormat("0.00%");
|
|
|
+ List<ReportCostVo> reportCostVoList = null;
|
|
|
//根据本阶段时间 获取 上阶段 开始-截至 时间
|
|
|
Map<String,String> lastTimeMap = TimeStartAndEndUtil.getStartEndTime(startTime,endTime);
|
|
|
- PageHelper.startPage(pageNum,pageSize);
|
|
|
- //查询计划数据时报
|
|
|
- List<ReportCostVo> reportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfo(accountId, null, startTime,endTime);
|
|
|
+ if (!lastTimeMap.get("daysBetween").equals("0")){
|
|
|
+ //日报
|
|
|
+ PageHelper.startPage(pageNum,pageSize);
|
|
|
+ reportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfoDay(accountId, null, startTime,endTime);
|
|
|
+ }else {
|
|
|
+ PageHelper.startPage(pageNum,pageSize);
|
|
|
+ //时报
|
|
|
+ reportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfo(accountId, null, startTime,endTime);
|
|
|
+ }
|
|
|
+
|
|
|
reportCostVoList.forEach(reportCostVo -> {
|
|
|
//出价
|
|
|
QueryWrapper<ByteDanceAdvertisePlan> planQueryWrapper = new QueryWrapper<>();
|
|
@@ -333,7 +343,7 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
reportCostVo.setConver(String.format("%.2f", conver));
|
|
|
|
|
|
// 计划id 和 上阶段 时间 查询 上阶段数据
|
|
|
- List<ReportCostVo> lastReportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfo(accountId, reportCostVo.getAdId(), lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
|
|
|
+ List<ReportCostVo> lastReportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfoDay(accountId, reportCostVo.getAdId(), lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
|
|
|
double compare = 0;
|
|
|
if (lastReportCostVoList.size() > 0){
|
|
|
if (lastReportCostVoList.get(0).getCost() !=0){
|