|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
+import com.sun.xml.bind.v2.TODO;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAdvertiserStrategy;
|
|
import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAdvertiserStrategy;
|
|
import org.jeecg.modules.bytedance.advertise.entity.ByteDanceAdvertisePlan;
|
|
import org.jeecg.modules.bytedance.advertise.entity.ByteDanceAdvertisePlan;
|
|
@@ -43,6 +44,7 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
|
|
|
|
//时段数组
|
|
//时段数组
|
|
private final static List<String> TIMES = Arrays.asList("0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23");
|
|
private final static List<String> TIMES = Arrays.asList("0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23");
|
|
|
|
+ public static final String PATTEN_DEFAULT_YMD = "yyyy-MM-dd";
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
@@ -74,8 +76,28 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
List<ReportCostVo> nowCostList = new ArrayList<>();
|
|
List<ReportCostVo> nowCostList = new ArrayList<>();
|
|
List<ReportCostVo> lastCostList = 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);
|
|
|
|
+ ReportCostVo statHourVo = new ReportCostVo();
|
|
|
|
+ if (nowCostList.size() > 0){
|
|
|
|
+ statHourVo = nowCostList.get(nowCostList.size()-1);
|
|
|
|
+ }
|
|
|
|
+ //上阶段数据
|
|
|
|
+ lastCostList = bytedanceAdvertiserHourlyReportMapper.getReportCostInfoStageLast(accountId,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"),statHourVo.getTime());
|
|
|
|
+ }
|
|
|
|
|
|
//更新时间
|
|
//更新时间
|
|
List<ReportCostVo> updTimeList = nowCostList.stream().sorted(Comparator.comparing(ReportCostVo::getCreateTime)).collect(Collectors.toList());
|
|
List<ReportCostVo> updTimeList = nowCostList.stream().sorted(Comparator.comparing(ReportCostVo::getCreateTime)).collect(Collectors.toList());
|
|
@@ -85,10 +107,6 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
double nowCost = nowCostList.stream().mapToDouble(ReportCostVo::getCost).sum();
|
|
double nowCost = nowCostList.stream().mapToDouble(ReportCostVo::getCost).sum();
|
|
resultMap.put("nowCost", String.format("%.2f", nowCost));
|
|
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();
|
|
double lastCost = lastCostList.stream().mapToDouble(ReportCostVo::getCost).sum();
|
|
resultMap.put("lastCost", String.format("%.2f", lastCost));
|
|
resultMap.put("lastCost", String.format("%.2f", lastCost));
|
|
@@ -96,7 +114,7 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
//环比 =(当前花费 - 上阶段花费 )/ 上阶段花费
|
|
//环比 =(当前花费 - 上阶段花费 )/ 上阶段花费
|
|
compare = (nowCost - lastCost) / lastCost;
|
|
compare = (nowCost - lastCost) / lastCost;
|
|
//resultMap.put("compare", Double.isNaN(compare) ? "0" : df.format(compare));
|
|
//resultMap.put("compare", Double.isNaN(compare) ? "0" : df.format(compare));
|
|
- resultMap.put("compare", Double.isNaN(compare) ? "0" : String.format("%.2f", compare*100));
|
|
|
|
|
|
+ resultMap.put("compare", new Double(lastCost).intValue() == 0 ? "0" : String.format("%.2f", compare*100));
|
|
|
|
|
|
//花费占比 = 花费 / 账户预算
|
|
//花费占比 = 花费 / 账户预算
|
|
//获取账户预算
|
|
//获取账户预算
|
|
@@ -106,34 +124,34 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
strategyQueryWrapper.last("limit 1");
|
|
strategyQueryWrapper.last("limit 1");
|
|
AiBytedanceAdvertiserStrategy strategy = aiBytedanceAdvertiserStrategyMapper.selectOne(strategyQueryWrapper);
|
|
AiBytedanceAdvertiserStrategy strategy = aiBytedanceAdvertiserStrategyMapper.selectOne(strategyQueryWrapper);
|
|
//没有预算则使用上阶段花费
|
|
//没有预算则使用上阶段花费
|
|
- double accountBudget = Check.isNull(strategy) ? lastCost : strategy.getAccountBudget().doubleValue();
|
|
|
|
|
|
+ double accountBudget = Check.isNull(strategy) || strategy.getAccountBudget().intValue() == 0 ? lastCost : strategy.getAccountBudget().doubleValue();
|
|
//花费占比
|
|
//花费占比
|
|
double costShare = nowCost / accountBudget;
|
|
double costShare = nowCost / accountBudget;
|
|
- resultMap.put("costShare", Double.isNaN(costShare) ? "0" : df.format(costShare));
|
|
|
|
|
|
+ resultMap.put("costShare",new Double(accountBudget).intValue() == 0 ? "0" : df.format(costShare));
|
|
|
|
|
|
//获取 本阶段 转化成本;转化数;转化率;平均千次展现费用。数据展示
|
|
//获取 本阶段 转化成本;转化数;转化率;平均千次展现费用。数据展示
|
|
Map nowMap = getCost(nowCostList);
|
|
Map nowMap = getCost(nowCostList);
|
|
// 上阶段数据
|
|
// 上阶段数据
|
|
Map lastMap = getCost(lastCostList);
|
|
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"));
|
|
|
|
|
|
+ if (nowCostList.size() > 0){
|
|
|
|
+ //当前阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
|
|
|
|
+ nowMap.put("costList", getCostList(nowCostList,startTime,endTime,lastTimeMap.get("daysBetween")));
|
|
|
|
+ }else {
|
|
|
|
+ nowMap.put("costList",Arrays.asList());
|
|
}
|
|
}
|
|
- //当前阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
|
|
|
|
- nowMap.put("costList", getCostList(nowCostList,startTime,endTime,lastTimeMap.get("daysBetween")));
|
|
|
|
- //上个阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
|
|
|
|
- lastMap.put("costList", getCostList(lastCostList,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"),lastTimeMap.get("daysBetween")));
|
|
|
|
|
|
+
|
|
|
|
+ if (lastCostList.size() > 0){
|
|
|
|
+ //上个阶段 每个时间 的 转化成本;转化数;转化率;平均千次展现费用。数据展示
|
|
|
|
+ lastMap.put("costList", getCostList(lastCostList,lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"),lastTimeMap.get("daysBetween")));
|
|
|
|
+ }else {
|
|
|
|
+ lastMap.put("costList",Arrays.asList());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
resultMap.put("nowMap", nowMap);
|
|
resultMap.put("nowMap", nowMap);
|
|
resultMap.put("lastMap", lastMap);
|
|
resultMap.put("lastMap", lastMap);
|
|
|
|
|
|
-
|
|
|
|
return Result.successMsg("成功。",resultMap);
|
|
return Result.successMsg("成功。",resultMap);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -150,16 +168,16 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
//转化成本 = 总花费 / 转化数
|
|
//转化成本 = 总花费 / 转化数
|
|
int converNum = list.stream().mapToInt(ReportCostVo::getConvertNum).sum();
|
|
int converNum = list.stream().mapToInt(ReportCostVo::getConvertNum).sum();
|
|
double conver = cost / new Double(converNum);
|
|
double conver = cost / new Double(converNum);
|
|
- map.put("conver",Double.isNaN(conver) ? "0" : String.format("%.2f", conver));
|
|
|
|
|
|
+ map.put("conver",converNum == 0 ? "0" : String.format("%.2f", conver));
|
|
map.put("converNum", converNum);
|
|
map.put("converNum", converNum);
|
|
//转化率 = 转化数 / 点击数 * 100
|
|
//转化率 = 转化数 / 点击数 * 100
|
|
int clickNum = list.stream().mapToInt(ReportCostVo::getClick).sum();
|
|
int clickNum = list.stream().mapToInt(ReportCostVo::getClick).sum();
|
|
double click = Double.valueOf(converNum) / Double.valueOf(clickNum) * 100;
|
|
double click = Double.valueOf(converNum) / Double.valueOf(clickNum) * 100;
|
|
- map.put("converRate", Double.isNaN(click) ? "0" : String.format("%.2f", click));
|
|
|
|
|
|
+ map.put("converRate", clickNum == 0 ? "0" : String.format("%.2f", click));
|
|
// 平均千次展显费用 = 总花费/展示数 * 1000
|
|
// 平均千次展显费用 = 总花费/展示数 * 1000
|
|
int showNum = list.stream().mapToInt(ReportCostVo::getShowNum).sum();
|
|
int showNum = list.stream().mapToInt(ReportCostVo::getShowNum).sum();
|
|
double show = (cost / showNum) * 1000 ;
|
|
double show = (cost / showNum) * 1000 ;
|
|
- map.put("averageShow", Double.isNaN(show) ? "0" : String.format("%.2f", show));
|
|
|
|
|
|
+ map.put("averageShow", showNum == 0 ? "0" : String.format("%.2f", show));
|
|
return map;
|
|
return map;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -287,70 +305,96 @@ public class BytedanceAdvertiserHourlyReportServiceImpl extends ServiceImpl<Byte
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Result getReportPlanCost(String accountId, String startTime, String endTime,Integer pageNum,Integer pageSize) throws Exception {
|
|
public Result getReportPlanCost(String accountId, String startTime, String endTime,Integer pageNum,Integer pageSize) throws Exception {
|
|
|
|
+ SimpleDateFormat sf = new SimpleDateFormat(PATTEN_DEFAULT_YMD);
|
|
DecimalFormat df = new DecimalFormat("0.00%");
|
|
DecimalFormat df = new DecimalFormat("0.00%");
|
|
|
|
+ DecimalFormat df1 = new DecimalFormat("0.00");
|
|
|
|
+ List<ReportCostVo> reportCostVoList = new ArrayList<ReportCostVo>();
|
|
|
|
+ List<ReportCostVo> lastReportCostVoList = new ArrayList<ReportCostVo>();
|
|
//根据本阶段时间 获取 上阶段 开始-截至 时间
|
|
//根据本阶段时间 获取 上阶段 开始-截至 时间
|
|
Map<String,String> lastTimeMap = TimeStartAndEndUtil.getStartEndTime(startTime,endTime);
|
|
Map<String,String> lastTimeMap = TimeStartAndEndUtil.getStartEndTime(startTime,endTime);
|
|
- PageHelper.startPage(pageNum,pageSize);
|
|
|
|
- //查询计划数据时报
|
|
|
|
- List<ReportCostVo> reportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfo(accountId, null, startTime,endTime);
|
|
|
|
- reportCostVoList.forEach(reportCostVo -> {
|
|
|
|
- //出价
|
|
|
|
- QueryWrapper<ByteDanceAdvertisePlan> planQueryWrapper = new QueryWrapper<>();
|
|
|
|
- planQueryWrapper.eq("account_id",accountId);
|
|
|
|
- planQueryWrapper.last("limit 1");
|
|
|
|
- ByteDanceAdvertisePlan planInfo = byteDanceAdvertisePlanMapper.selectOne(planQueryWrapper);
|
|
|
|
- reportCostVo.setCpaBid(planInfo.getCpaBid());
|
|
|
|
- reportCostVo.setBid(planInfo.getBid());
|
|
|
|
-
|
|
|
|
- // 平均千次展显费用 = 总花费/展示数 * 1000
|
|
|
|
- double show = 0;
|
|
|
|
- if (reportCostVo.getShowNum() != 0){
|
|
|
|
- show = (reportCostVo.getCost() / reportCostVo.getShowNum()) * 1000 ;
|
|
|
|
- }
|
|
|
|
- reportCostVo.setAverageShow(String.format("%.2f", show));
|
|
|
|
-
|
|
|
|
- double avgClick = 0;
|
|
|
|
- double clickRate = 0;
|
|
|
|
- double convetRate = 0;
|
|
|
|
- if (reportCostVo.getClick() != 0){
|
|
|
|
- //平均点击单价 = 花费 / 点击数
|
|
|
|
- avgClick = reportCostVo.getCost() / reportCostVo.getClick().doubleValue();
|
|
|
|
- //点击率 = 点击数 / 展示数
|
|
|
|
- clickRate = reportCostVo.getClick().doubleValue() / reportCostVo.getShowNum().doubleValue();
|
|
|
|
- //转化率 = 转化数 / 点击数 * 100
|
|
|
|
- convetRate = Double.valueOf(reportCostVo.getConvertNum()) / Double.valueOf(reportCostVo.getClick()) * 100;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- reportCostVo.setAverageClick(String.format("%.2f", avgClick));
|
|
|
|
- reportCostVo.setClickRate(df.format(clickRate));
|
|
|
|
- reportCostVo.setConverRate(String.format("%.2f", convetRate));
|
|
|
|
-
|
|
|
|
- //转化成本 = 总花费 / 转化数
|
|
|
|
- double conver = 0;
|
|
|
|
- if (reportCostVo.getConvertNum() != 0){
|
|
|
|
- conver = reportCostVo.getCost() / reportCostVo.getConvertNum();
|
|
|
|
- }
|
|
|
|
- reportCostVo.setConver(String.format("%.2f", conver));
|
|
|
|
-
|
|
|
|
- // 计划id 和 上阶段 时间 查询 上阶段数据
|
|
|
|
- List<ReportCostVo> lastReportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfo(accountId, reportCostVo.getAdId(), lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
|
|
|
|
- double compare = 0;
|
|
|
|
- if (lastReportCostVoList.size() > 0){
|
|
|
|
- if (lastReportCostVoList.get(0).getCost() !=0){
|
|
|
|
- //环比 =(当前花费 - 上阶段花费 )/ 上阶段花费
|
|
|
|
- compare = (reportCostVo.getCost() - lastReportCostVoList.get(0).getCost()) / lastReportCostVoList.get(0).getCost();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- reportCostVo.setCompare(df.format(compare));
|
|
|
|
-
|
|
|
|
- //操作状态
|
|
|
|
- QueryWrapper<ByteDanceAdvertisePlan> advertisePlanQueryWrapper = new QueryWrapper<>();
|
|
|
|
- advertisePlanQueryWrapper.eq("account_id",accountId);
|
|
|
|
- advertisePlanQueryWrapper.eq("id",reportCostVo.getAdId());
|
|
|
|
- advertisePlanQueryWrapper.last("limit 1");
|
|
|
|
- ByteDanceAdvertisePlan advertisePlan = byteDanceAdvertisePlanMapper.selectOne(advertisePlanQueryWrapper);
|
|
|
|
- reportCostVo.setOptStatus(advertisePlan.getOptStatus());
|
|
|
|
- });
|
|
|
|
|
|
+ String nowTime = sf.format(new Date());
|
|
|
|
+
|
|
|
|
+ if (!startTime.equals(nowTime)){
|
|
|
|
+ //日报
|
|
|
|
+ PageHelper.startPage(pageNum,pageSize);
|
|
|
|
+ reportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfoDay(accountId, null, startTime,endTime);
|
|
|
|
+ }else {
|
|
|
|
+ PageHelper.startPage(pageNum,pageSize);
|
|
|
|
+ //时报
|
|
|
|
+ reportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfo(accountId, null, startTime,endTime);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for (ReportCostVo reportCostVo : reportCostVoList) {
|
|
|
|
+ reportCostVo.setCostStr(String.format("%.2f",reportCostVo.getCost()));
|
|
|
|
+ //出价 ctop_bytedance_advertise_plan 广告计划信息表
|
|
|
|
+ QueryWrapper<ByteDanceAdvertisePlan> planQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ planQueryWrapper.eq("account_id",accountId);
|
|
|
|
+ planQueryWrapper.eq("id",reportCostVo.getAdId());
|
|
|
|
+ planQueryWrapper.last("limit 1");
|
|
|
|
+ ByteDanceAdvertisePlan planInfo = byteDanceAdvertisePlanMapper.selectOne(planQueryWrapper);
|
|
|
|
+ reportCostVo.setCpaBid(Check.isNull(planInfo) ? "0" : String.format("%.2f",planInfo.getCpaBid()));
|
|
|
|
+ reportCostVo.setBid(Check.isNull(planInfo) ? "0" : String.format("%.2f",planInfo.getBid()));
|
|
|
|
+ //广告预算 (修改出价不能大于广告计划预算)
|
|
|
|
+ reportCostVo.setAdBudget(Check.isNull(planInfo) ? new BigDecimal(0) : planInfo.getBudget());
|
|
|
|
+
|
|
|
|
+ // 平均千次展显费用 = 总花费/展示数 * 1000
|
|
|
|
+ double show = 0;
|
|
|
|
+ if (reportCostVo.getShowNum() != 0){
|
|
|
|
+ show = (reportCostVo.getCost() / reportCostVo.getShowNum()) * 1000 ;
|
|
|
|
+ }
|
|
|
|
+ reportCostVo.setAverageShow(String.format("%.2f", show));
|
|
|
|
+
|
|
|
|
+ double avgClick = 0;
|
|
|
|
+ double clickRate = 0;
|
|
|
|
+ double convetRate = 0;
|
|
|
|
+ if (reportCostVo.getClick() != 0){
|
|
|
|
+ //平均点击单价 = 花费 / 点击数
|
|
|
|
+ avgClick = reportCostVo.getCost() / reportCostVo.getClick().doubleValue();
|
|
|
|
+ //点击率 = 点击数 / 展示数
|
|
|
|
+ clickRate = reportCostVo.getClick().doubleValue() / reportCostVo.getShowNum().doubleValue();
|
|
|
|
+ //转化率 = 转化数 / 点击数 * 100
|
|
|
|
+ convetRate = Double.valueOf(reportCostVo.getConvertNum()) / Double.valueOf(reportCostVo.getClick()) * 100;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ reportCostVo.setAverageClick(String.format("%.2f", avgClick));
|
|
|
|
+ reportCostVo.setClickRate(df.format(clickRate));
|
|
|
|
+ reportCostVo.setConverRate(String.format("%.2f", convetRate));
|
|
|
|
+
|
|
|
|
+ //转化成本 = 总花费 / 转化数
|
|
|
|
+ double conver = 0;
|
|
|
|
+ if (reportCostVo.getConvertNum() != 0){
|
|
|
|
+ conver = reportCostVo.getCost() / reportCostVo.getConvertNum();
|
|
|
|
+ }
|
|
|
|
+ reportCostVo.setConver(String.format("%.2f", conver));
|
|
|
|
+
|
|
|
|
+ //日报
|
|
|
|
+ if (!startTime.equals(nowTime)){
|
|
|
|
+ // 计划id 和 上阶段 时间 查询 上阶段数据
|
|
|
|
+ lastReportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostInfoDay(accountId, reportCostVo.getAdId(), lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"));
|
|
|
|
+ }else {
|
|
|
|
+ //时报
|
|
|
|
+ //查询上阶段 同时间点 之前的 时报 数据信息
|
|
|
|
+ lastReportCostVoList = bytedanceAdvertiserHourlyReportMapper.selectReportPlanCostHourLast(accountId,reportCostVo.getAdId(),lastTimeMap.get("lastTimeStart"),lastTimeMap.get("lastTimeEnd"),reportCostVo.getStatHour());
|
|
|
|
+ }
|
|
|
|
+ double compare = 0;
|
|
|
|
+ if (lastReportCostVoList.size() > 0){
|
|
|
|
+ if (lastReportCostVoList.get(0).getCost() !=0){
|
|
|
|
+ //环比 =(当前花费 - 上阶段花费 )/ 上阶段花费
|
|
|
|
+ compare = (reportCostVo.getCost() - lastReportCostVoList.get(0).getCost()) / lastReportCostVoList.get(0).getCost();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ reportCostVo.setCompare(df.format(compare));
|
|
|
|
+
|
|
|
|
+ //操作状态
|
|
|
|
+ QueryWrapper<ByteDanceAdvertisePlan> advertisePlanQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ advertisePlanQueryWrapper.eq("account_id",accountId);
|
|
|
|
+ advertisePlanQueryWrapper.eq("id",reportCostVo.getAdId());
|
|
|
|
+ advertisePlanQueryWrapper.last("limit 1");
|
|
|
|
+ ByteDanceAdvertisePlan advertisePlan = byteDanceAdvertisePlanMapper.selectOne(advertisePlanQueryWrapper);
|
|
|
|
+ reportCostVo.setOptStatus(Check.isNull(advertisePlan) ? "0" : advertisePlan.getOptStatus());
|
|
|
|
+ }
|
|
PageInfo<ReportCostVo> pageInfo = new PageInfo<ReportCostVo>(reportCostVoList);
|
|
PageInfo<ReportCostVo> pageInfo = new PageInfo<ReportCostVo>(reportCostVoList);
|
|
return Result.successMsg("成功。", pageInfo);
|
|
return Result.successMsg("成功。", pageInfo);
|
|
}
|
|
}
|