|
@@ -2,8 +2,11 @@ package cn.com.ctop.kuaishou.modules.report.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.module.utils.HttpUtils2;
|
|
import cn.com.ctop.common.module.utils.HttpUtils2;
|
|
import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent;
|
|
import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgent;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.report.entity.KuaishouReportDailyAgentSum;
|
|
import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAgentMapper;
|
|
import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAgentMapper;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.report.mapper.KuaishouReportDailyAgentSumMapper;
|
|
import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
|
|
import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import org.apache.http.client.CookieStore;
|
|
import org.apache.http.client.CookieStore;
|
|
@@ -35,6 +38,8 @@ import java.util.*;
|
|
public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouReportDailyAgentMapper, KuaishouReportDailyAgent> implements IKuaishouReportDailyAgentService {
|
|
public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouReportDailyAgentMapper, KuaishouReportDailyAgent> implements IKuaishouReportDailyAgentService {
|
|
@Autowired
|
|
@Autowired
|
|
private KuaishouReportDailyAgentMapper kuaishouReportDailyAgentMapper;
|
|
private KuaishouReportDailyAgentMapper kuaishouReportDailyAgentMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private KuaishouReportDailyAgentSumMapper kuaishouReportDailyAgentSumMapper;
|
|
@Value("${jeecg.path.chrome-driver}")
|
|
@Value("${jeecg.path.chrome-driver}")
|
|
private String chromeDriver;
|
|
private String chromeDriver;
|
|
@Override
|
|
@Override
|
|
@@ -102,7 +107,7 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
|
|
|
|
|
|
while(DateUtils.compareDate(currentDate,endDate)<=0){
|
|
while(DateUtils.compareDate(currentDate,endDate)<=0){
|
|
String listUrl = "https://agent.e.kuaishou.com/rest/dsp/agent/account/data/list";
|
|
String listUrl = "https://agent.e.kuaishou.com/rest/dsp/agent/account/data/list";
|
|
- String postData = "{\"agentId\":403756224,\"date\":\"2019-12-13\",\"sortKey\":\"totalCharge\",\"isAscending\":false,\"pageInfo\":{\"totalCount\":1616,\"currentPage\":1,\"pageSize\":999999}}";
|
|
|
|
|
|
+ String postData = "{\"agentId\":403756224,\"date\":\""+currentDate+"\",\"sortKey\":\"totalCharge\",\"isAscending\":false,\"pageInfo\":{\"totalCount\":1616,\"currentPage\":1,\"pageSize\":999999}}";
|
|
String result = HttpUtils2.httpPostRequestTest(listUrl,postData,headerMap);
|
|
String result = HttpUtils2.httpPostRequestTest(listUrl,postData,headerMap);
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
JsonNode resultNode = mapper.readTree(result);
|
|
JsonNode resultNode = mapper.readTree(result);
|
|
@@ -113,10 +118,29 @@ public class KuaishouReportDailyAgentServiceImpl extends ServiceImpl<KuaishouRep
|
|
List<KuaishouReportDailyAgent> reportList = new ArrayList<>();
|
|
List<KuaishouReportDailyAgent> reportList = new ArrayList<>();
|
|
while (iterator1.hasNext()){
|
|
while (iterator1.hasNext()){
|
|
JsonNode dataNode = iterator1.next();
|
|
JsonNode dataNode = iterator1.next();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
if(i == 0){
|
|
if(i == 0){
|
|
-
|
|
|
|
|
|
+ KuaishouReportDailyAgentSum kuaishouReportDailyAgentSum = new KuaishouReportDailyAgentSum();
|
|
|
|
+ kuaishouReportDailyAgentSum.setBalance(dataNode.get("totalBalanceDouble").decimalValue());
|
|
|
|
+ kuaishouReportDailyAgentSum.setConvertClickRate(dataNode.get("actionbarClickRatio").decimalValue());
|
|
|
|
+ kuaishouReportDailyAgentSum.setConvertCount(dataNode.get("actionbarClick").asInt());
|
|
|
|
+ kuaishouReportDailyAgentSum.setCost(dataNode.get("totalChargedInYuan").decimalValue());
|
|
|
|
+ kuaishouReportDailyAgentSum.setCostCampaignCount(dataNode.get("chargedCampaignCount").asInt());
|
|
|
|
+ kuaishouReportDailyAgentSum.setDate(sdf.parse(currentDate));
|
|
|
|
+ kuaishouReportDailyAgentSum.setFengmianClickCount(dataNode.get("adPhotoClick").asInt());
|
|
|
|
+ kuaishouReportDailyAgentSum.setFengmianClickRate(dataNode.get("clickRatio").decimalValue());
|
|
|
|
+ kuaishouReportDailyAgentSum.setFengmianShowCount(dataNode.get("impression").asInt());
|
|
|
|
+ kuaishouReportDailyAgentSum.setFandianCost(dataNode.get("rebateRealChargedInYuan").decimalValue());
|
|
|
|
+ kuaishouReportDailyAgentSum.setJiliCost(dataNode.get("directRebateRealChargedInYuan").decimalValue());
|
|
|
|
+ kuaishouReportDailyAgentSum.setKuangfanCost(dataNode.get("contractRebateRealChargedInYuan").decimalValue());
|
|
|
|
+ kuaishouReportDailyAgentSum.setSucaiShowCount(dataNode.get("click").asInt());
|
|
|
|
+ kuaishouReportDailyAgentSum.setXianjinCost(dataNode.get("realChargedInYuan").decimalValue());
|
|
|
|
+ kuaishouReportDailyAgentSum.setXinyongCost(dataNode.get("creditRealChargedInYuan").decimalValue());
|
|
|
|
+ QueryWrapper<KuaishouReportDailyAgentSum> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.eq("date",currentDate);
|
|
|
|
+ kuaishouReportDailyAgentSumMapper.delete(queryWrapper);
|
|
|
|
+ kuaishouReportDailyAgentSumMapper.insert(kuaishouReportDailyAgentSum);
|
|
}else {
|
|
}else {
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
KuaishouReportDailyAgent kuaishouReportDailyAgent = new KuaishouReportDailyAgent();
|
|
KuaishouReportDailyAgent kuaishouReportDailyAgent = new KuaishouReportDailyAgent();
|
|
kuaishouReportDailyAgent.setAccountId(dataNode.get("accountId").asInt());
|
|
kuaishouReportDailyAgent.setAccountId(dataNode.get("accountId").asInt());
|
|
kuaishouReportDailyAgent.setAdvertiserCreateTime(new Date(dataNode.get("createTime").asLong()));
|
|
kuaishouReportDailyAgent.setAdvertiserCreateTime(new Date(dataNode.get("createTime").asLong()));
|