|
@@ -1,12 +1,19 @@
|
|
package cn.com.ctop.toutiao.modules.report.service.impl;
|
|
package cn.com.ctop.toutiao.modules.report.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
|
+import cn.com.ctop.common.module.entity.RuleDataPlan;
|
|
|
|
+import cn.com.ctop.common.module.entity.RuleDataTarget;
|
|
|
|
+import cn.com.ctop.common.module.entity.UserAllocation;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
|
+import cn.com.ctop.common.module.service.IRuleDataPlanService;
|
|
|
|
+import cn.com.ctop.common.module.service.IRuleDataTargetService;
|
|
|
|
+import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
import cn.com.ctop.common.module.vo.ByteDanceAdvertiserReportDTO;
|
|
import cn.com.ctop.common.module.vo.ByteDanceAdvertiserReportDTO;
|
|
|
|
+import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
|
|
import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
|
|
import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertiserDataService;
|
|
import cn.com.ctop.toutiao.modules.report.entity.*;
|
|
import cn.com.ctop.toutiao.modules.report.entity.*;
|
|
import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
|
|
import cn.com.ctop.toutiao.modules.report.mapper.BytedanceReportMaterialDailyMapper;
|
|
@@ -146,12 +153,66 @@ public class ReportServiceImpl implements IReportService {
|
|
getCampaignReportByPage(token, conditions, page + 1);
|
|
getCampaignReportByPage(token, conditions, page + 1);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void getAdvertiserPlanReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl) {
|
|
public void getAdvertiserPlanReport(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl) {
|
|
var conditions = getReportDTO(token, startDate, endDate, bytedanceReportTypePl);
|
|
var conditions = getReportDTO(token, startDate, endDate, bytedanceReportTypePl);
|
|
getPlanReportByPage(token, conditions, 1);
|
|
getPlanReportByPage(token, conditions, 1);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public void getAdvertiserPlanRuleData(CtopOauthToken token, Date startDate, Date endDate, String bytedanceReportTypePl) {
|
|
|
|
+ var conditions = getReportDTO(token, startDate, endDate, bytedanceReportTypePl);
|
|
|
|
+ getPlanRuleDataByPage(token, conditions, 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void getPlanRuleDataByPage(CtopOauthToken token, ByteDanceAdvertiserReportDTO conditions, int page) {
|
|
|
|
+ conditions.setPage(page);
|
|
|
|
+ var config = new SerializeConfig();
|
|
|
|
+ config.propertyNamingStrategy = PropertyNamingStrategy.SnakeCase;
|
|
|
|
+ var jsonObject = JSONObject.parseObject(JSON.toJSONString(conditions, config));
|
|
|
|
+
|
|
|
|
+ JSONObject getObject = getAdStat(token, jsonObject);
|
|
|
|
+ if (null == getObject) {
|
|
|
|
+ log.error("广告计划报表数据获取异常=》account:{};message:{}", token.getAccountId(), "返回数据异常");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ Integer code = getObject.getInteger("code");
|
|
|
|
+ var message = getObject.getString("message");
|
|
|
|
+ if (null == code || code != 0) {
|
|
|
|
+ log.error("广告计划报表数据获取异常=》account:{};message:{}", token.getAccountId(), message);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ var dataArray = getObject.getJSONObject("data").getJSONArray("list");
|
|
|
|
+ if (null == dataArray || dataArray.size() <= 0) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ UserAllocation allocation = userAllocationService.getByAccountId(token.getAccountId());
|
|
|
|
+ for (var i = 0; i < dataArray.size(); i++) {
|
|
|
|
+ var data = dataArray.getJSONObject(i);
|
|
|
|
+ var dailyReport = new RuleDataPlan(data, token.getAccountId());
|
|
|
|
+ dailyReport.setAccountName(allocation.getAuthName());
|
|
|
|
+ ByteDanceAdvertisePlan plan = advertiserDataService.getSinglePlanById(token,dailyReport.getId()+"");
|
|
|
|
+ if(null!=plan){
|
|
|
|
+ dailyReport.setBudget(plan.getBudget());
|
|
|
|
+ dailyReport.setDownloadUrl(plan.getDownloadUrl());
|
|
|
|
+ dailyReport.setExternalUrl(plan.getExternalUrl());
|
|
|
|
+ dailyReport.setPricing(plan.getPricing());
|
|
|
|
+ RuleDataTarget target = new RuleDataTarget(token,dailyReport.getId(),data,allocation.getAuthName());
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ ruleDataPlanService.saveOrUpdate(dailyReport);
|
|
|
|
+ }
|
|
|
|
+ getPlanRuleDataByPage(token, conditions, page + 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IUserAllocationService userAllocationService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IRuleDataPlanService ruleDataPlanService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IRuleDataTargetService ruleDataTargetService;
|
|
|
|
+
|
|
private void getPlanReportByPage(CtopOauthToken token, ByteDanceAdvertiserReportDTO conditions, int page) {
|
|
private void getPlanReportByPage(CtopOauthToken token, ByteDanceAdvertiserReportDTO conditions, int page) {
|
|
conditions.setPage(page);
|
|
conditions.setPage(page);
|
|
var config = new SerializeConfig();
|
|
var config = new SerializeConfig();
|
|
@@ -185,6 +246,7 @@ public class ReportServiceImpl implements IReportService {
|
|
hourlyReports.add(hourlyReport);
|
|
hourlyReports.add(hourlyReport);
|
|
} else {
|
|
} else {
|
|
var dailyReport = new BytedancePlanDailyReport(data, token.getAccountId());
|
|
var dailyReport = new BytedancePlanDailyReport(data, token.getAccountId());
|
|
|
|
+ //获取计划详情
|
|
dailyReports.add(dailyReport);
|
|
dailyReports.add(dailyReport);
|
|
}
|
|
}
|
|
}
|
|
}
|