|
@@ -1,7 +1,6 @@
|
|
|
package cn.com.ctop.kuaishou.modules.report.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
|
-
|
|
|
import cn.com.ctop.kuaishou.modules.report.mapper.KuaiShouAccountReportMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.report.service.IKuaiShouAccountReportService;
|
|
|
import cn.com.ctop.kuaishou.modules.utils.LinkUtils;
|
|
@@ -31,7 +30,7 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
|
|
|
@Autowired
|
|
|
KuaiShouAccountReportMapper kuaiShouAccountReportMapper;
|
|
|
|
|
|
- private static final BigDecimal zero=BigDecimal.ZERO;
|
|
|
+ private static final BigDecimal zero = BigDecimal.ZERO;
|
|
|
|
|
|
@Override
|
|
|
public Map<String, Object> getSumDataBy(String mediaId, BigDecimal discount, JSONArray accounts, String startDate, String endDate) {
|
|
@@ -44,12 +43,12 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
|
|
|
return result;
|
|
|
}
|
|
|
before = kuaiShouAccountReportMapper.queryTodaySumByHour(DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), after.getInteger("maxHour"), accounts);
|
|
|
- if(before==null){
|
|
|
+ if (before == null) {
|
|
|
before = after;
|
|
|
}
|
|
|
} else {
|
|
|
after = kuaiShouAccountReportMapper.querySumByStartEndDate(endDate, startDate, accounts);
|
|
|
- if(after==null){
|
|
|
+ if (after == null) {
|
|
|
return result;
|
|
|
}
|
|
|
before = after;
|
|
@@ -60,16 +59,16 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
|
|
|
|
|
|
@Override
|
|
|
public List<JSONObject> getChartDataBy(String mediaId, BigDecimal discount, JSONArray accounts, String startDate, String endDate) throws ParseException {
|
|
|
- List<JSONObject> result=new ArrayList<>();
|
|
|
+ List<JSONObject> result = new ArrayList<>();
|
|
|
String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.dicMapKs);
|
|
|
if (startDate.equals(endDate)) {
|
|
|
List<JSONObject> after = kuaiShouAccountReportMapper.queryTodayDetailReportBy(filedAll, startDate, accounts);
|
|
|
List<JSONObject> before = kuaiShouAccountReportMapper.queryTodayDetailReportBy(filedAll, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), accounts);
|
|
|
- if(after.size()==0){
|
|
|
+ if (after.size() == 0) {
|
|
|
return result;
|
|
|
}
|
|
|
- if(before.size()==0){
|
|
|
- before=nullDataHandle();
|
|
|
+ if (before.size() == 0) {
|
|
|
+ before = nullDataHandle();
|
|
|
}
|
|
|
List<JSONObject> afterDis = this.countDiscountCost(mediaId, discount, after);
|
|
|
List<JSONObject> beforeDis = this.countDiscountCost(mediaId, discount, before);
|
|
@@ -77,13 +76,12 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
|
|
|
} else {
|
|
|
List<JSONObject> after;
|
|
|
//判断是不是日期间隔大于半年
|
|
|
- if(DateUtils.isMoreSixMonth(startDate,endDate)){
|
|
|
+ if (DateUtils.isMoreSixMonth(startDate, endDate)) {
|
|
|
after = kuaiShouAccountReportMapper.queryDetailGroupMonthByDate(endDate, startDate, accounts);
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
after = kuaiShouAccountReportMapper.queryDetailByStartEndDate(endDate, startDate, accounts);
|
|
|
}
|
|
|
- if(after==null){
|
|
|
+ if (after == null) {
|
|
|
return result;
|
|
|
}
|
|
|
result = this.countDiscountCost(mediaId, discount, after);
|
|
@@ -96,16 +94,25 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
|
|
|
List<JSONObject> result;
|
|
|
String filedAll = JsonResourceUtil.joinAllFiled(AccountReportConstants.dicMapKs);
|
|
|
if (startDate.equals(endDate)) {
|
|
|
- result = kuaiShouAccountReportMapper.queryTodaySumByHourGroupAccount(filedAll, startDate, hour, accounts, target, order);
|
|
|
- JSONObject afterSum = kuaiShouAccountReportMapper.querySumByHour(filedAll, startDate, hour, accounts);
|
|
|
- JSONObject beforeSum = kuaiShouAccountReportMapper.querySumByHour(filedAll, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), hour, accounts);
|
|
|
- result.add(afterSum);
|
|
|
- result.add(beforeSum);
|
|
|
- result.add(countTotal(afterSum, beforeSum));
|
|
|
+ if (startDate.equals(DateUtils.date2Str())) {
|
|
|
+ result = kuaiShouAccountReportMapper.queryTodaySumByHourGroupAccount(filedAll, startDate, hour, accounts, target, order);
|
|
|
+ JSONObject afterSum = kuaiShouAccountReportMapper.querySumByHour(filedAll, startDate, hour, accounts);
|
|
|
+ JSONObject beforeSum = kuaiShouAccountReportMapper.querySumByHour(filedAll, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), hour, accounts);
|
|
|
+ result.add(afterSum);
|
|
|
+ result.add(beforeSum);
|
|
|
+ result.add(countTotal(afterSum, beforeSum));
|
|
|
+ } else {
|
|
|
+ result = kuaiShouAccountReportMapper.querySumByDateGroupAccount(filedAll, endDate, startDate, accounts, target, order);
|
|
|
+ JSONObject afterSum = kuaiShouAccountReportMapper.queryAllSumByStartEndDate(filedAll, endDate, startDate, accounts);
|
|
|
+ JSONObject beforeSum = kuaiShouAccountReportMapper.queryAllSumByStartEndDate(filedAll, DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, endDate, -1), DateUtils.getAnotherDay(SystemDateConstant.yyyy_MM_dd, startDate, -1), accounts);
|
|
|
+ result.add(afterSum);
|
|
|
+ result.add(beforeSum);
|
|
|
+ result.add(countTotal(afterSum, beforeSum));
|
|
|
+ }
|
|
|
} else {
|
|
|
- if(accounts.size()>1){
|
|
|
+ if (accounts.size() > 1) {
|
|
|
result = kuaiShouAccountReportMapper.querySumByDateGroupAccount(filedAll, endDate, startDate, accounts, target, order);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
result = kuaiShouAccountReportMapper.querySumByDateGroupAccountAndDate(filedAll, endDate, startDate, accounts, target, order);
|
|
|
}
|
|
|
result.add(kuaiShouAccountReportMapper.queryAllSumByStartEndDate(filedAll, endDate, startDate, accounts));
|
|
@@ -117,7 +124,11 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
|
|
|
public List<JSONObject> getExcelDataBy(String filed, String mediaId, JSONArray accounts, String startDate, String endDate, int hour, String target, String order) {
|
|
|
List<JSONObject> result;
|
|
|
if (startDate.equals(endDate)) {
|
|
|
- result = kuaiShouAccountReportMapper.queryTodaySumByHourGroupAccount(filed, startDate, hour, accounts, target, order);
|
|
|
+ if (startDate.equals(DateUtils.date2Str())) {
|
|
|
+ result = kuaiShouAccountReportMapper.queryTodaySumByHourGroupAccount(filed, startDate, hour, accounts, target, order);
|
|
|
+ } else {
|
|
|
+ result = kuaiShouAccountReportMapper.querySumByDateGroupAccount(filed, endDate, startDate, accounts, target, order);
|
|
|
+ }
|
|
|
} else {
|
|
|
result = kuaiShouAccountReportMapper.querySumByDateGroupAccount(filed, endDate, startDate, accounts, target, order);
|
|
|
}
|
|
@@ -180,25 +191,25 @@ public class KuaiShouAccountReportServiceImpl implements IKuaiShouAccountReportS
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
after.forEach((k, v) -> {
|
|
|
//去除没法计算的字段
|
|
|
- if ("accountId".equals(k) || "authName".equals(k) || v.toString().contains("%")||before.getString(k).contains("%")) {
|
|
|
+ if ("accountId".equals(k) || "authName".equals(k) || v.toString().contains("%") || before.getString(k).contains("%")) {
|
|
|
jsonObject.put(k, "-");
|
|
|
- }else {
|
|
|
- jsonObject.put(k, LinkUtils.countLink(after.getBigDecimal(k)==null?zero:after.getBigDecimal(k), before.getBigDecimal(k)==null?zero:before.getBigDecimal(k)));
|
|
|
+ } else {
|
|
|
+ jsonObject.put(k, LinkUtils.countLink(after.getBigDecimal(k) == null ? zero : after.getBigDecimal(k), before.getBigDecimal(k) == null ? zero : before.getBigDecimal(k)));
|
|
|
}
|
|
|
});
|
|
|
return jsonObject;
|
|
|
}
|
|
|
|
|
|
- private List<JSONObject> nullDataHandle(){
|
|
|
- List<JSONObject> objectList= new ArrayList<>();
|
|
|
+ private List<JSONObject> nullDataHandle() {
|
|
|
+ List<JSONObject> objectList = new ArrayList<>();
|
|
|
JSONObject jsonObject;
|
|
|
- for(int i=0;i<24;i++){
|
|
|
- jsonObject=new JSONObject();
|
|
|
- jsonObject.put("cost",0);
|
|
|
- jsonObject.put("photoShow",0);
|
|
|
- jsonObject.put("photoClick",0);
|
|
|
- jsonObject.put("aClick",0);
|
|
|
- jsonObject.put("statHour",i);
|
|
|
+ for (int i = 0; i < 24; i++) {
|
|
|
+ jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("cost", 0);
|
|
|
+ jsonObject.put("photoShow", 0);
|
|
|
+ jsonObject.put("photoClick", 0);
|
|
|
+ jsonObject.put("aClick", 0);
|
|
|
+ jsonObject.put("statHour", i);
|
|
|
objectList.add(jsonObject);
|
|
|
}
|
|
|
return objectList;
|