|
@@ -5,7 +5,6 @@ import cn.com.ctop.bytedance.mapper.BytedanceAdvertiserDailyReportMapper;
|
|
import cn.com.ctop.bytedance.mapper.BytedanceCampaignDailyReportMapper;
|
|
import cn.com.ctop.bytedance.mapper.BytedanceCampaignDailyReportMapper;
|
|
import cn.com.ctop.bytedance.mapper.BytedanceReportMapper;
|
|
import cn.com.ctop.bytedance.mapper.BytedanceReportMapper;
|
|
import cn.com.ctop.bytedance.service.IBytedanceReportService;
|
|
import cn.com.ctop.bytedance.service.IBytedanceReportService;
|
|
-import cn.com.ctop.bytedance.vo.ReportVO;
|
|
|
|
import cn.com.ctop.common.module.entity.UserAllocation;
|
|
import cn.com.ctop.common.module.entity.UserAllocation;
|
|
import cn.com.ctop.common.module.mapper.UserAllocationMapper;
|
|
import cn.com.ctop.common.module.mapper.UserAllocationMapper;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
@@ -208,53 +207,51 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
String nowDate = DateUtils.getNowDate("yyyy-MM-dd"); // 当前日期
|
|
String nowDate = DateUtils.getNowDate("yyyy-MM-dd"); // 当前日期
|
|
String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1); // 当前日期-1
|
|
String anotherDay = DateUtils.getAnotherDay("yyyy-MM-dd", nowDate, -1); // 当前日期-1
|
|
if (type == 1) { // 今日总消耗
|
|
if (type == 1) { // 今日总消耗
|
|
- ReportVO reportVO = campaignDailyReportMapper.selectDayReport(nowDate);
|
|
|
|
- System.err.println("12312312313131313131313131313131");
|
|
|
|
- System.err.println(reportVO.toString());
|
|
|
|
- System.err.println("----------------------------------------------");
|
|
|
|
- JSONObject yesterJson = reportMapper.selectYesterday(anotherDay);
|
|
|
|
- if (!Check.isNull(yesterJson)) {
|
|
|
|
- BigDecimal cost = accountJson.getBigDecimal("cost"); // 今日消耗
|
|
|
|
- BigDecimal yesterCost = yesterJson.getBigDecimal("cost");// 昨日消耗
|
|
|
|
- BigDecimal compareBigDecima = new BigDecimal(0);
|
|
|
|
- if (yesterCost.compareTo(compareBigDecima) != 0) {
|
|
|
|
- BigDecimal costProportion = (cost.subtract(yesterCost)).divide(yesterCost, BigDecimal.ROUND_HALF_UP);
|
|
|
|
- accountJson.put("costProportion", costProportion); // 较昨日增加比例
|
|
|
|
- } else {
|
|
|
|
- accountJson.put("costProportion", 0); // 较昨日增加比例
|
|
|
|
- }
|
|
|
|
|
|
+ accountJson = reportMapper.selectDayReport(nowDate);
|
|
|
|
+ if (!Check.isNull(accountJson)) {
|
|
|
|
+ JSONObject yesterJson = reportMapper.selectDayReport(anotherDay);
|
|
|
|
+ if (!Check.isNull(yesterJson)) {
|
|
|
|
+ BigDecimal cost = accountJson.getBigDecimal("cost"); // 今日消耗
|
|
|
|
+ BigDecimal yesterCost = yesterJson.getBigDecimal("cost");// 昨日消耗
|
|
|
|
+ BigDecimal compareBigDecima = new BigDecimal(0);
|
|
|
|
+ if (yesterCost.compareTo(compareBigDecima) != 0) {
|
|
|
|
+ BigDecimal costProportion = (cost.subtract(yesterCost)).divide(yesterCost, BigDecimal.ROUND_HALF_UP);
|
|
|
|
+ accountJson.put("costProportion", costProportion); // 较昨日增加比例
|
|
|
|
+ } else {
|
|
|
|
+ accountJson.put("costProportion", 0); // 较昨日增加比例
|
|
|
|
+ }
|
|
|
|
|
|
- Long photoShow = accountJson.getLong("photoShow");// 今日封面展示
|
|
|
|
- Long yesterPhotoShow = yesterJson.getLong("photoShow");// 昨日封面展示
|
|
|
|
- if (yesterPhotoShow != 0L) {
|
|
|
|
- double showProportion = (photoShow.doubleValue() - yesterPhotoShow.doubleValue()) / yesterPhotoShow.doubleValue();
|
|
|
|
- accountJson.put("showProportion", showProportion); // 较昨日增加比例
|
|
|
|
- } else {
|
|
|
|
- accountJson.put("showProportion", 0); // 较昨日增加比例
|
|
|
|
- }
|
|
|
|
|
|
+ Long photoShow = accountJson.getLong("photoShow");// 今日封面展示
|
|
|
|
+ Long yesterPhotoShow = yesterJson.getLong("photoShow");// 昨日封面展示
|
|
|
|
+ if (yesterPhotoShow != 0L) {
|
|
|
|
+ double showProportion = (photoShow.doubleValue() - yesterPhotoShow.doubleValue()) / yesterPhotoShow.doubleValue();
|
|
|
|
+ accountJson.put("showProportion", showProportion); // 较昨日增加比例
|
|
|
|
+ } else {
|
|
|
|
+ accountJson.put("showProportion", 0); // 较昨日增加比例
|
|
|
|
+ }
|
|
|
|
|
|
- Long photoClick = accountJson.getLong("photoClick");// 今日封面展示
|
|
|
|
- Long yesterphotoClick = yesterJson.getLong("photoShow");// 昨日封面展示
|
|
|
|
- if (yesterPhotoShow != 0L) {
|
|
|
|
- double photoClickProportion = (photoClick.doubleValue() - yesterphotoClick.doubleValue()) / yesterphotoClick.doubleValue();
|
|
|
|
- accountJson.put("photoClickProportion", photoClickProportion); // 较昨日增加比例
|
|
|
|
- } else {
|
|
|
|
- accountJson.put("photoClickProportion", 0); // 较昨日增加比例
|
|
|
|
- }
|
|
|
|
|
|
+ Long photoClick = accountJson.getLong("photoClick");// 今日封面展示
|
|
|
|
+ Long yesterphotoClick = yesterJson.getLong("photoShow");// 昨日封面展示
|
|
|
|
+ if (yesterPhotoShow != 0L) {
|
|
|
|
+ double photoClickProportion = (photoClick.doubleValue() - yesterphotoClick.doubleValue()) / yesterphotoClick.doubleValue();
|
|
|
|
+ accountJson.put("photoClickProportion", photoClickProportion); // 较昨日增加比例
|
|
|
|
+ } else {
|
|
|
|
+ accountJson.put("photoClickProportion", 0); // 较昨日增加比例
|
|
|
|
+ }
|
|
|
|
|
|
- Long aclick = accountJson.getLong("aclick");// 今日封面展示
|
|
|
|
- Long yesterAclick = yesterJson.getLong("photoShow");// 昨日封面展示
|
|
|
|
- if (yesterPhotoShow != 0L) {
|
|
|
|
- double aClickProportion = (aclick.doubleValue() - yesterAclick.doubleValue()) / yesterAclick.doubleValue();
|
|
|
|
- accountJson.put("aClickProportion", aClickProportion); // 较昨日增加比例
|
|
|
|
- } else {
|
|
|
|
- accountJson.put("aClickProportion", 0); // 较昨日增加比例
|
|
|
|
- }
|
|
|
|
|
|
+ Long aclick = accountJson.getLong("aclick");// 今日封面展示
|
|
|
|
+ Long yesterAclick = yesterJson.getLong("photoShow");// 昨日封面展示
|
|
|
|
+ if (yesterPhotoShow != 0L) {
|
|
|
|
+ double aClickProportion = (aclick.doubleValue() - yesterAclick.doubleValue()) / yesterAclick.doubleValue();
|
|
|
|
+ accountJson.put("aClickProportion", aClickProportion); // 较昨日增加比例
|
|
|
|
+ } else {
|
|
|
|
+ accountJson.put("aClickProportion", 0); // 较昨日增加比例
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-
|
|
|
|
} else if (type == 2) { // 昨日总消耗
|
|
} else if (type == 2) { // 昨日总消耗
|
|
- accountJson = reportMapper.selectYesterday(anotherDay);
|
|
|
|
|
|
+ accountJson = reportMapper.selectDayReport(anotherDay);
|
|
|
|
|
|
} else if (type == 3) { // 近七天
|
|
} else if (type == 3) { // 近七天
|
|
String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
|
|
String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
|
|
@@ -334,6 +331,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ System.err.println(accountJson);
|
|
return accountJson;
|
|
return accountJson;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -349,7 +347,6 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
for (int i = 0; i < dayDetail.size(); i++) {
|
|
for (int i = 0; i < dayDetail.size(); i++) {
|
|
JSONObject detailJson = dayDetail.get(i);
|
|
JSONObject detailJson = dayDetail.get(i);
|
|
String statHour = detailJson.getString("statHour");
|
|
String statHour = detailJson.getString("statHour");
|
|
-
|
|
|
|
JSONObject yesterDayJson = reportMapper.selectYesterdayByHourAndDate(anotherDay, statHour);
|
|
JSONObject yesterDayJson = reportMapper.selectYesterdayByHourAndDate(anotherDay, statHour);
|
|
if (!Check.isNull(yesterDayJson)) {
|
|
if (!Check.isNull(yesterDayJson)) {
|
|
BigDecimal cost = detailJson.getBigDecimal("cost"); // 今日消耗
|
|
BigDecimal cost = detailJson.getBigDecimal("cost"); // 今日消耗
|
|
@@ -386,14 +383,13 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
} else {
|
|
} else {
|
|
detailJson.put("proportion", 0); // 较昨日增加比例
|
|
detailJson.put("proportion", 0); // 较昨日增加比例
|
|
}
|
|
}
|
|
- detail.add(detailJson);
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+ detail.add(detailJson);
|
|
|
|
|
|
}
|
|
}
|
|
- System.err.println(detail);
|
|
|
|
} else if (type == 2) { // 昨日明细
|
|
} else if (type == 2) { // 昨日明细
|
|
detail = reportMapper.selectReportDetail(anotherDay);
|
|
detail = reportMapper.selectReportDetail(anotherDay);
|
|
- System.err.println(detail);
|
|
|
|
} else if (type == 3) { // 近七天明细
|
|
} else if (type == 3) { // 近七天明细
|
|
String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
|
|
String endDate = DateUtils.getAnotherDay("yyyy-MM-dd", anotherDay, -7);
|
|
detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
|
|
detail = reportMapper.selectDayDetailByDate(anotherDay, endDate);
|
|
@@ -423,7 +419,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
if ("month".equals(sign)) {
|
|
if ("month".equals(sign)) {
|
|
Map<String, Object> dateMap = DateUtils.compare_date("yyyy-MM", bigDate, smallDate);
|
|
Map<String, Object> dateMap = DateUtils.compare_date("yyyy-MM", bigDate, smallDate);
|
|
List<JSONObject> comparedArr = reportMapper.selectDayDetailsByMonth((String) dateMap.get("bigDate")); // 除数数据
|
|
List<JSONObject> comparedArr = reportMapper.selectDayDetailsByMonth((String) dateMap.get("bigDate")); // 除数数据
|
|
- String comparedDate = (String) dateMap.get("bigDate");
|
|
|
|
|
|
+ String comparedDate = (String) dateMap.get("smallDate");
|
|
for (int i = 0; i < comparedArr.size(); i++) {
|
|
for (int i = 0; i < comparedArr.size(); i++) {
|
|
JSONObject comparedJson = comparedArr.get(i);
|
|
JSONObject comparedJson = comparedArr.get(i);
|
|
if (!Check.isNull(comparedJson)) {
|
|
if (!Check.isNull(comparedJson)) {
|
|
@@ -497,6 +493,7 @@ public class BytedanceReportServiceImpl implements IBytedanceReportService {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ System.err.println(detail);
|
|
|
|
|
|
return detail;
|
|
return detail;
|
|
}
|
|
}
|