|
@@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.type.TypeFactory;
|
|
import com.fasterxml.jackson.databind.type.TypeFactory;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.var;
|
|
import lombok.var;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.http.ParseException;
|
|
import org.apache.http.ParseException;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.jeecg.common.util.DateUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -203,11 +204,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void getVideoList(CtopOauthToken token) {
|
|
|
|
- getVideoListByPage(token, 1);
|
|
|
|
|
|
+ public void getVideoList(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
|
+ getVideoListByPage(token, startDate, endDate, 1);
|
|
}
|
|
}
|
|
|
|
|
|
- private void getVideoListByPage(CtopOauthToken token, int page) {
|
|
|
|
|
|
+ private void getVideoListByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put("Content-Type", "application/json");
|
|
headers.put("Content-Type", "application/json");
|
|
@@ -216,6 +217,10 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
param.put("advertiser_id", token.getAccountId());
|
|
param.put("advertiser_id", token.getAccountId());
|
|
param.put("page_size", 500);
|
|
param.put("page_size", 500);
|
|
param.put("page", page);
|
|
param.put("page", page);
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
+ }
|
|
String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
Integer code = resultJson.getInteger("code");
|
|
Integer code = resultJson.getInteger("code");
|
|
@@ -240,7 +245,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
videoGets.add(kuaiShouVideoGet);
|
|
videoGets.add(kuaiShouVideoGet);
|
|
}
|
|
}
|
|
kuaiShouVideoGetService.replaceBatch(videoGets);
|
|
kuaiShouVideoGetService.replaceBatch(videoGets);
|
|
- getVideoListByPage(token, page + 1);
|
|
|
|
|
|
+ getVideoListByPage(token, startDate, endDate, page + 1);
|
|
}
|
|
}
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -939,6 +944,17 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
getAdvertiserGroupReportDaily(token, getStartDate, getEndDate);
|
|
getAdvertiserGroupReportDaily(token, getStartDate, getEndDate);
|
|
//4: 获取广告创意信息数据
|
|
//4: 获取广告创意信息数据
|
|
getAdvertiserCreativeReportDaily(token, getStartDate, getEndDate);
|
|
getAdvertiserCreativeReportDaily(token, getStartDate, getEndDate);
|
|
|
|
+
|
|
|
|
+ //获取全量广告计划数据
|
|
|
|
+ getCampaignList(token, null, null);
|
|
|
|
+ //获取全量广告主数据
|
|
|
|
+ getGroupList(token, null, null);
|
|
|
|
+ //获取全量创意数据
|
|
|
|
+ getCreativeList(token, null, null);
|
|
|
|
+ //获取全量视频素材数据
|
|
|
|
+ getVideoList(token, null, null);
|
|
|
|
+ //获取图片信息数据
|
|
|
|
+ getImageList(token, null, null);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -1066,17 +1082,21 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void getCampaignList(CtopOauthToken token) {
|
|
|
|
- getCampaignListByPage(token.getAccessToken(), token.getAccountId(), 1);
|
|
|
|
|
|
+ public void getCampaignList(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
|
+ getCampaignListByPage(token.getAccessToken(), token.getAccountId(), startDate, endDate, 1);
|
|
}
|
|
}
|
|
|
|
|
|
- private void getCampaignListByPage(String accessToken, Long accountId, int page) {
|
|
|
|
|
|
+ private void getCampaignListByPage(String accessToken, Long accountId, Date startDate, Date endDate, int page) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_LIST;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_LIST;
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put("Access-Token", accessToken);
|
|
headers.put("Access-Token", accessToken);
|
|
headers.put("Content-Type", " application/json");
|
|
headers.put("Content-Type", " application/json");
|
|
JSONObject param = new JSONObject();
|
|
JSONObject param = new JSONObject();
|
|
param.put("advertiser_id", accountId);
|
|
param.put("advertiser_id", accountId);
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
+ }
|
|
param.put("page", page);
|
|
param.put("page", page);
|
|
param.put("page_size", 200);
|
|
param.put("page_size", 200);
|
|
|
|
|
|
@@ -1098,7 +1118,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
addCampaign(accountId, details);
|
|
addCampaign(accountId, details);
|
|
- getCampaignListByPage(accessToken, accountId, page + 1);
|
|
|
|
|
|
+ getCampaignListByPage(accessToken, accountId, startDate, endDate, page + 1);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1109,13 +1129,17 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public void getCampaignList(String accessToken, Long advertiserId, Integer page) {
|
|
|
|
|
|
+ public void getCampaignList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_LIST;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CAMPAIGN_LIST;
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put("Access-Token", accessToken);
|
|
headers.put("Access-Token", accessToken);
|
|
headers.put("Content-Type", " application/json");
|
|
headers.put("Content-Type", " application/json");
|
|
JSONObject param = new JSONObject();
|
|
JSONObject param = new JSONObject();
|
|
param.put("advertiser_id", advertiserId);
|
|
param.put("advertiser_id", advertiserId);
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
+ }
|
|
param.put("page", page);
|
|
param.put("page", page);
|
|
param.put("page_size", 200);
|
|
param.put("page_size", 200);
|
|
try {
|
|
try {
|
|
@@ -1128,7 +1152,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
JSONArray details = dataJson.getJSONArray("details");
|
|
JSONArray details = dataJson.getJSONArray("details");
|
|
if (!Check.isNull(details)) {
|
|
if (!Check.isNull(details)) {
|
|
addCampaign(advertiserId, details);
|
|
addCampaign(advertiserId, details);
|
|
- getCampaignList(accessToken, advertiserId, page + 1);
|
|
|
|
|
|
+ getCampaignList(accessToken, advertiserId, startDate, endDate, page + 1);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
log.error("获取广告计划信息返回结果异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
|
|
log.error("获取广告计划信息返回结果异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
|
|
@@ -1191,6 +1215,13 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
campaign.setCampaignName(detail.getString("campaign_name"));
|
|
campaign.setCampaignName(detail.getString("campaign_name"));
|
|
campaign.setDayBudget(detail.getLong("day_budget"));
|
|
campaign.setDayBudget(detail.getLong("day_budget"));
|
|
campaign.setStatus(detail.getInteger("status"));
|
|
campaign.setStatus(detail.getInteger("status"));
|
|
|
|
+
|
|
|
|
+ campaign.setPutStatus(detail.getInteger("put_status"));
|
|
|
|
+ campaign.setCampaignType(detail.getInteger("campaign_type"));
|
|
|
|
+ campaign.setCreateChannel(detail.getInteger("create_channel"));
|
|
|
|
+ campaign.setPutCreateTime(detail.getString("create_time"));
|
|
|
|
+ campaign.setPutUpdateTime(detail.getString("update_time"));
|
|
|
|
+
|
|
campaigns.add(campaign);
|
|
campaigns.add(campaign);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1198,8 +1229,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void getGroupList(CtopOauthToken token) {
|
|
|
|
- getGroupListByPage(token, 1);
|
|
|
|
|
|
+ public void getGroupList(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
|
+ getGroupListByPage(token, startDate, endDate, 1);
|
|
}
|
|
}
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -1224,13 +1255,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
//1:获取全量广告计划数据
|
|
//1:获取全量广告计划数据
|
|
- getCampaignList(token);
|
|
|
|
|
|
+ getCampaignList(token, null, null);
|
|
//1:获取全量广告组数据
|
|
//1:获取全量广告组数据
|
|
- getGroupList(token);
|
|
|
|
|
|
+ getGroupList(token, null, null);
|
|
//1:获取全量创意数据
|
|
//1:获取全量创意数据
|
|
- getCreativeList(token);
|
|
|
|
|
|
+ getCreativeList(token, null, null);
|
|
//2:获取全量视频素材数据
|
|
//2:获取全量视频素材数据
|
|
- getVideoList(token);
|
|
|
|
|
|
+ getVideoList(token, null, null);
|
|
|
|
+ //获取图片信息数据
|
|
|
|
+ getImageList(token, null, null);
|
|
countDownLatch.countDown();
|
|
countDownLatch.countDown();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -1265,12 +1298,16 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
hourlyCreativeStatisticService.deleteHourlyReport(deleteDate);
|
|
hourlyCreativeStatisticService.deleteHourlyReport(deleteDate);
|
|
}
|
|
}
|
|
|
|
|
|
- private void getGroupListByPage(CtopOauthToken token, int page) {
|
|
|
|
|
|
+ private void getGroupListByPage(CtopOauthToken token, Date startDate, Date endDate, int page) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
|
|
JSONObject param = new JSONObject();
|
|
JSONObject param = new JSONObject();
|
|
param.put("advertiser_id", token.getAccountId());
|
|
param.put("advertiser_id", token.getAccountId());
|
|
param.put("page_size", 200);
|
|
param.put("page_size", 200);
|
|
param.put("page", page);
|
|
param.put("page", page);
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
+ }
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
headers.put("Content-Type", " application/json");
|
|
headers.put("Content-Type", " application/json");
|
|
@@ -1292,7 +1329,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
addGroup(token.getAccountId(), details);
|
|
addGroup(token.getAccountId(), details);
|
|
- getGroupListByPage(token, page + 1);
|
|
|
|
|
|
+ getGroupListByPage(token, startDate, endDate, page + 1);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1303,12 +1340,16 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public void getGroupList(String accessToken, Long advertiserId, Integer page) {
|
|
|
|
|
|
+ public void getGroupList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GROUP_LIST;
|
|
JSONObject param = new JSONObject();
|
|
JSONObject param = new JSONObject();
|
|
param.put("advertiser_id", advertiserId);
|
|
param.put("advertiser_id", advertiserId);
|
|
param.put("page_size", 200);
|
|
param.put("page_size", 200);
|
|
param.put("page", page);
|
|
param.put("page", page);
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
+ }
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put("Access-Token", accessToken);
|
|
headers.put("Access-Token", accessToken);
|
|
headers.put("Content-Type", " application/json");
|
|
headers.put("Content-Type", " application/json");
|
|
@@ -1323,7 +1364,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
JSONArray details = dataJson.getJSONArray("details");
|
|
JSONArray details = dataJson.getJSONArray("details");
|
|
if (!Check.isNull(details)) {
|
|
if (!Check.isNull(details)) {
|
|
addGroup(advertiserId, details);
|
|
addGroup(advertiserId, details);
|
|
- getGroupList(accessToken, advertiserId, page + 1);
|
|
|
|
|
|
+ getGroupList(accessToken, advertiserId, startDate, endDate, page + 1);
|
|
}
|
|
}
|
|
|
|
|
|
} else {
|
|
} else {
|
|
@@ -1463,17 +1504,21 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void getCreativeList(CtopOauthToken token) {
|
|
|
|
- getCreativeListByPage(token.getAccessToken(), token.getAccountId(), 1);
|
|
|
|
|
|
+ public void getCreativeList(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
|
+ getCreativeListByPage(token.getAccessToken(), token.getAccountId(), startDate, endDate, 1);
|
|
}
|
|
}
|
|
|
|
|
|
- public void getCreativeListByPage(String accessToken, Long advertiserId, Integer page) {
|
|
|
|
|
|
+ public void getCreativeListByPage(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
|
|
Map<String, String> headers = new HashMap<>();
|
|
Map<String, String> headers = new HashMap<>();
|
|
headers.put("Content-Type", " application/json");
|
|
headers.put("Content-Type", " application/json");
|
|
headers.put("Access-Token", accessToken);
|
|
headers.put("Access-Token", accessToken);
|
|
JSONObject param = new JSONObject();
|
|
JSONObject param = new JSONObject();
|
|
param.put("advertiser_id", advertiserId);
|
|
param.put("advertiser_id", advertiserId);
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
+ }
|
|
param.put("page_size", 200);
|
|
param.put("page_size", 200);
|
|
param.put("page", page);
|
|
param.put("page", page);
|
|
|
|
|
|
@@ -1523,7 +1568,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
creativeService.replaceBatch(creatives);
|
|
creativeService.replaceBatch(creatives);
|
|
- getCreativeListByPage(accessToken, advertiserId, page + 1);
|
|
|
|
|
|
+ getCreativeListByPage(accessToken, advertiserId, startDate, endDate, page + 1);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1586,13 +1631,17 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
* @param advertiserId
|
|
* @param advertiserId
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public void getCreativeList(String accessToken, Long advertiserId, Integer page) {
|
|
|
|
|
|
+ public void getCreativeList(String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
|
|
Map<String, String> headers = new HashMap<String, String>();
|
|
Map<String, String> headers = new HashMap<String, String>();
|
|
headers.put("Content-Type", " application/json");
|
|
headers.put("Content-Type", " application/json");
|
|
headers.put("Access-Token", accessToken);
|
|
headers.put("Access-Token", accessToken);
|
|
JSONObject param = new JSONObject();
|
|
JSONObject param = new JSONObject();
|
|
param.put("advertiser_id", advertiserId);
|
|
param.put("advertiser_id", advertiserId);
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
+ }
|
|
param.put("page_size", 200);
|
|
param.put("page_size", 200);
|
|
param.put("page", page);
|
|
param.put("page", page);
|
|
try {
|
|
try {
|
|
@@ -1631,7 +1680,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
- getCreativeList(accessToken, advertiserId, page + 1);
|
|
|
|
|
|
+ getCreativeList(accessToken, advertiserId, startDate, endDate, page + 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -2542,4 +2591,300 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
}
|
|
}
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ IKuaiShouImageGetService kuaiShouImageGetService;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询图片列表
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void getImageList(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
|
+ getImageList(token, startDate, endDate, 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询图片列表
|
|
|
|
+ */
|
|
|
|
+ private void getImageList(CtopOauthToken token, Date startDate, Date endDate, int page) {
|
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_LIST;
|
|
|
|
+ Map<String, String> headers = new HashMap<String, String>();
|
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
|
+
|
|
|
|
+ //传参
|
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
|
+ param.put("advertiser_id", token.getAccountId());
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
|
|
+ param.put("startDate", DateUtils.formatDate(startDate));
|
|
|
|
+ param.put("endDate", DateUtils.formatDate(endDate));
|
|
|
|
+ }
|
|
|
|
+ param.put("page_size", 500);
|
|
|
|
+ param.put("page", page);
|
|
|
|
+ //
|
|
|
|
+ String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
|
+
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
|
+ String message = resultJson.getString("message");
|
|
|
|
+ if (null == code || code != 0) {
|
|
|
|
+ log.error("获取快手图片列表数据异常:{},accountId:{}", message, token.getAccountId());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
|
|
|
|
+ if (null == details || details.size() <= 0) {
|
|
|
|
+ log.info("快手图片列表信息为空=》accountId:{}", token.getAccountId());
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ List<KuaiShouImageGet> imageGets = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
|
+ var detailJson = details.getJSONObject(i);
|
|
|
|
+ var kuaiShouImageGet = JSONObject.toJavaObject(detailJson, KuaiShouImageGet.class);
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ kuaiShouImageGet.setAccountId(token.getAccountId());
|
|
|
|
+ kuaiShouImageGet.setCreateTime(new Date());
|
|
|
|
+ kuaiShouImageGet.setUpdateTime(new Date());
|
|
|
|
+ imageGets.add(kuaiShouImageGet);
|
|
|
|
+ }
|
|
|
|
+ kuaiShouImageGetService.replaceBatch(imageGets);
|
|
|
|
+ getImageList(token, startDate, endDate, page + 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询图片列表---测试使用
|
|
|
|
+ */
|
|
|
|
+ public void getImageList(String token, Long accountId, Date startDate, Date endDate, int page) {
|
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_LIST;
|
|
|
|
+ Map<String, String> headers = new HashMap<String, String>();
|
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
|
+ headers.put("Access-Token", token);
|
|
|
|
+
|
|
|
|
+ //传参
|
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
|
+ param.put("advertiser_id", accountId);
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
|
|
+ param.put("startDate", DateUtils.formatDate(startDate));
|
|
|
|
+ param.put("endDate", DateUtils.formatDate(endDate));
|
|
|
|
+ }
|
|
|
|
+ param.put("page_size", 500);
|
|
|
|
+ param.put("page", page);
|
|
|
|
+ //
|
|
|
|
+
|
|
|
|
+ //String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
|
+
|
|
|
|
+ //test start
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ List<KuaiShouImageGet> list = new ArrayList<>();
|
|
|
|
+ KuaiShouImageGet kuaiShouImageGet1 = new KuaiShouImageGet();
|
|
|
|
+ kuaiShouImageGet1.setUrl("http://static.yximgs.com/udata/pkg/markb21f94845c4350.jpg");
|
|
|
|
+ kuaiShouImageGet1.setWidth(720L);
|
|
|
|
+ kuaiShouImageGet1.setHeight(1280L);
|
|
|
|
+ kuaiShouImageGet1.setSize(441029L);
|
|
|
|
+ kuaiShouImageGet1.setFormat("jpg");
|
|
|
|
+ kuaiShouImageGet1.setImageToken("market0a8a3104ee6b4f148ab21f94845c4350.jpg");
|
|
|
|
+ kuaiShouImageGet1.setSignature("44a20b91b0727fa2abb68b19c0456422");
|
|
|
|
+ list.add(kuaiShouImageGet1);
|
|
|
|
+
|
|
|
|
+ map1.put("details", list);
|
|
|
|
+ map1.put("total_count", 4);
|
|
|
|
+ map.put("data", map1);
|
|
|
|
+ map.put("message", "OK");
|
|
|
|
+ map.put("code", 0);
|
|
|
|
+ String result = JSONObject.toJSONString(map);
|
|
|
|
+ //test end
|
|
|
|
+
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
|
+ String message = resultJson.getString("message");
|
|
|
|
+ if (null == code || code != 0) {
|
|
|
|
+ log.error("获取快手图片列表数据异常:{},accountId:{}", message, accountId);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
|
|
|
|
+ if (null == details || details.size() <= 0) {
|
|
|
|
+ log.info("快手图片列表信息为空=》accountId:{}", accountId);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ List<KuaiShouImageGet> imageGets = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
|
+ var detailJson = details.getJSONObject(i);
|
|
|
|
+ var kuaiShouImageGet = JSONObject.toJavaObject(detailJson, KuaiShouImageGet.class);
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ kuaiShouImageGet.setAccountId(accountId);
|
|
|
|
+ kuaiShouImageGet.setCreateTime(new Date());
|
|
|
|
+ kuaiShouImageGet.setUpdateTime(new Date());
|
|
|
|
+ imageGets.add(kuaiShouImageGet);
|
|
|
|
+ }
|
|
|
|
+ kuaiShouImageGetService.replaceBatch(imageGets);
|
|
|
|
+ getImageList(token, accountId, startDate, endDate, page + 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取全量视频素材数据--测试使用
|
|
|
|
+ *
|
|
|
|
+ * @param token
|
|
|
|
+ * @param startDate
|
|
|
|
+ * @param endDate
|
|
|
|
+ * @param page
|
|
|
|
+ */
|
|
|
|
+ public void getVideoList(String token, Long accountId, Date startDate, Date endDate, int page) {
|
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
|
+ headers.put("Access-Token", token);
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
+ param.put("advertiser_id", accountId);
|
|
|
|
+ param.put("page_size", 500);
|
|
|
|
+ param.put("page", page);
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
+ }
|
|
|
|
+ String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
|
+ String message = resultJson.getString("message");
|
|
|
|
+ if (null == code || code != 0) {
|
|
|
|
+ log.error("获取快手视频列表数据异常:{},accountId:{}", message, accountId);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
|
|
|
|
+ if (null == details || details.size() <= 0) {
|
|
|
|
+ log.info("快手视频列表信息为空=》accountId:{}", accountId);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ List<KuaiShouVideoGet> videoGets = new ArrayList<>();
|
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
|
+ var detailJson = details.getJSONObject(i);
|
|
|
|
+ var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
|
|
|
|
+ kuaiShouVideoGet.setAccountId(accountId);
|
|
|
|
+ kuaiShouVideoGet.setId("" + accountId + kuaiShouVideoGet.getPhotoId());
|
|
|
|
+ kuaiShouVideoGet.setCreateTime(new Date());
|
|
|
|
+ kuaiShouVideoGet.setUpdateTime(new Date());
|
|
|
|
+ videoGets.add(kuaiShouVideoGet);
|
|
|
|
+ }
|
|
|
|
+ kuaiShouVideoGetService.replaceBatch(videoGets);
|
|
|
|
+ getVideoList(token, accountId, startDate, endDate, page + 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取账户余额
|
|
|
|
+ *
|
|
|
|
+ * @param oauthToken
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public JSONObject fundGet(CtopOauthToken oauthToken) {
|
|
|
|
+ try {
|
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.FUND_GET;
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
+ headers.put("Access-Token", oauthToken.getAccessToken());
|
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
+ json.put("advertiser_id", oauthToken.getAccountId());
|
|
|
|
+ String result = HttpUtils.kuaiShouhttpPostRequest(url, json.toJSONString(), headers);
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
+ if (!Check.isNull(resultJson)) {
|
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
|
+ if (code == 0) {
|
|
|
|
+ JSONObject dataJson = resultJson.getJSONObject("data");
|
|
|
|
+ if (!Check.isNull(dataJson)) {
|
|
|
|
+ return dataJson;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ log.error("获取账户余额失败");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.error("获取账户余额返回为空");
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取账户流水数据
|
|
|
|
+ *
|
|
|
|
+ * @param token
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouDailyFlowsService kuaiShouDailyFlowsService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void getDailyFlows(CtopOauthToken token) {
|
|
|
|
+ try {
|
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.DAILY_FLOWS;
|
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
|
+ headers.put("Access-Token", token.getAccessToken());
|
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
|
+ json.put("advertiser_id", token.getAccountId());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String endDate = DateUtils.getNowDate("yyyy-MM-dd");
|
|
|
|
+ String startDate = DateUtils.getAnotherDay("yyyy-MM-dd", endDate, -1);
|
|
|
|
+ json.put("start_date", startDate);
|
|
|
|
+ json.put("end_date", endDate);
|
|
|
|
+ String result = HttpUtils.kuaiShouhttpPostRequest(url, json.toJSONString(), headers);
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
+ if (!Check.isNull(resultJson)) {
|
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
|
+ if (code == 0) {
|
|
|
|
+ JSONObject dataJson = resultJson.getJSONObject("data");
|
|
|
|
+ if (!Check.isNull(dataJson)) {
|
|
|
|
+ JSONArray details = dataJson.getJSONArray("details");
|
|
|
|
+ if (!Check.isNull(details)) {
|
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
|
+ JSONObject detailJson = details.getJSONObject(i);
|
|
|
|
+ if (!Check.isNull(detailJson)) {
|
|
|
|
+ String date = detailJson.getString("date");
|
|
|
|
+ Map<String, Object> deleteMap = new HashMap<>();
|
|
|
|
+ deleteMap.put("date", date);
|
|
|
|
+ deleteMap.put("account_id", token.getAccountId());
|
|
|
|
+ kuaiShouDailyFlowsService.removeByMap(deleteMap);
|
|
|
|
+ KuaiShouDailyFlows dailyFlows = new KuaiShouDailyFlows();
|
|
|
|
+ dailyFlows.setAccountId(token.getAccountId());
|
|
|
|
+ dailyFlows.setDate(date);
|
|
|
|
+ dailyFlows.setBalance(detailJson.getBigDecimal("balance"));
|
|
|
|
+ dailyFlows.setDailyCharge(detailJson.getBigDecimal("daily_charge"));
|
|
|
|
+ dailyFlows.setRealCharged(detailJson.getBigDecimal("real_charged"));
|
|
|
|
+ dailyFlows.setContractRebateRealCharged(detailJson.getBigDecimal("contract_rebate_real_charged"));
|
|
|
|
+ dailyFlows.setDirectRebateRealCharged(detailJson.getBigDecimal("direct_rebate_real_charged"));
|
|
|
|
+ dailyFlows.setDailyTransferIn(detailJson.getBigDecimal("daily_transfer_in"));
|
|
|
|
+ dailyFlows.setContractRebateRealRecharged(detailJson.getBigDecimal("contract_rebate_real_recharged"));
|
|
|
|
+ dailyFlows.setDirectRebateRealRecharged(detailJson.getBigDecimal("direct_rebate_real_recharged"));
|
|
|
|
+ dailyFlows.setDailyTransferOut(detailJson.getBigDecimal("daily_transfer_out"));
|
|
|
|
+ dailyFlows.setRealRecharged(detailJson.getBigDecimal("real_recharged"));
|
|
|
|
+ kuaiShouDailyFlowsService.save(dailyFlows);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ log.error("获取账户余额失败");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.error("获取账户余额返回为空");
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|