|
@@ -217,9 +217,9 @@ 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(new Date()));
|
|
|
|
- param.put("end_date", DateUtils.formatDate(new Date()));
|
|
|
|
|
|
+ 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);
|
|
@@ -263,8 +263,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
headers.put("Content-Type", "application/json");
|
|
headers.put("Content-Type", "application/json");
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
Map<String, Object> param = new HashMap<>();
|
|
Map<String, Object> param = new HashMap<>();
|
|
- param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
- param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
|
|
+ if (!Check.isNull(startDate)) {
|
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!Check.isNull(endDate)) {
|
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
param.put("advertiser_id", token.getAccountId());
|
|
param.put("advertiser_id", token.getAccountId());
|
|
param.put("temporal_granularity", "DAILY");
|
|
param.put("temporal_granularity", "DAILY");
|
|
param.put("page_size", 500);
|
|
param.put("page_size", 500);
|
|
@@ -350,8 +357,15 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
headers.put("Content-Type", "application/json");
|
|
headers.put("Content-Type", "application/json");
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
Map<String, Object> param = new HashMap<>();
|
|
Map<String, Object> param = new HashMap<>();
|
|
- param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
- param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
|
|
+
|
|
|
|
+ if (!Check.isNull(startDate)) {
|
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
+ }
|
|
|
|
+ if (Check.isNull(endDate)) {
|
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
param.put("advertiser_id", token.getAccountId());
|
|
param.put("advertiser_id", token.getAccountId());
|
|
param.put("temporal_granularity", "DAILY");
|
|
param.put("temporal_granularity", "DAILY");
|
|
param.put("page_size", 500);
|
|
param.put("page_size", 500);
|
|
@@ -523,8 +537,14 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
headers.put("Content-Type", "application/json");
|
|
headers.put("Content-Type", "application/json");
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
Map<String, Object> param = new HashMap<>();
|
|
Map<String, Object> param = new HashMap<>();
|
|
- param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
- param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
|
|
+ if (!Check.isNull(startDate)) {
|
|
|
|
+ param.put("start_date", DateUtils.formatDate(startDate));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!Check.isNull(endDate)) {
|
|
|
|
+ param.put("end_date", DateUtils.formatDate(endDate));
|
|
|
|
+ }
|
|
|
|
+
|
|
param.put("advertiser_id", token.getAccountId());
|
|
param.put("advertiser_id", token.getAccountId());
|
|
param.put("temporal_granularity", "DAILY");
|
|
param.put("temporal_granularity", "DAILY");
|
|
param.put("page_size", 500);
|
|
param.put("page_size", 500);
|
|
@@ -947,7 +967,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
//获取全量广告计划数据
|
|
//获取全量广告计划数据
|
|
getCampaignList(token, null, null);
|
|
getCampaignList(token, null, null);
|
|
- //获取全量广告主数据
|
|
|
|
|
|
+ //获取全量广组主数据
|
|
getGroupList(token, null, null);
|
|
getGroupList(token, null, null);
|
|
//获取全量创意数据
|
|
//获取全量创意数据
|
|
getCreativeList(token, null, null);
|
|
getCreativeList(token, null, null);
|
|
@@ -1093,7 +1113,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
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){
|
|
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
param.put("start_date", DateUtils.formatDate(startDate));
|
|
param.put("start_date", DateUtils.formatDate(startDate));
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
}
|
|
}
|
|
@@ -1136,7 +1156,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
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){
|
|
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
param.put("start_date", DateUtils.formatDate(startDate));
|
|
param.put("start_date", DateUtils.formatDate(startDate));
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
}
|
|
}
|
|
@@ -1215,6 +1235,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);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1229,9 +1256,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
@Autowired
|
|
@Autowired
|
|
private ICtopOauthTokenService tokenService;
|
|
private ICtopOauthTokenService tokenService;
|
|
static ExecutorService executorService = null;
|
|
static ExecutorService executorService = null;
|
|
- /**
|
|
|
|
- * 线程计数器 如果不用执行完后统一走流程,可以不要这个
|
|
|
|
- */
|
|
|
|
|
|
+ //线程计数器 如果不用执行完后统一走流程,可以不要这个
|
|
static CountDownLatch countDownLatch = null;
|
|
static CountDownLatch countDownLatch = null;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -1250,13 +1275,13 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
//1:获取全量广告计划数据
|
|
//1:获取全量广告计划数据
|
|
- getCampaignList(token,null,null);
|
|
|
|
|
|
+ getCampaignList(token, null, null);
|
|
//1:获取全量广告组数据
|
|
//1:获取全量广告组数据
|
|
- getGroupList(token,null,null);
|
|
|
|
|
|
+ getGroupList(token, null, null);
|
|
//1:获取全量创意数据
|
|
//1:获取全量创意数据
|
|
- getCreativeList(token,null,null);
|
|
|
|
|
|
+ getCreativeList(token, null, null);
|
|
//2:获取全量视频素材数据
|
|
//2:获取全量视频素材数据
|
|
- getVideoList(token,null,null);
|
|
|
|
|
|
+ getVideoList(token, null, null);
|
|
//获取图片信息数据
|
|
//获取图片信息数据
|
|
getImageList(token, null, null);
|
|
getImageList(token, null, null);
|
|
countDownLatch.countDown();
|
|
countDownLatch.countDown();
|
|
@@ -1299,7 +1324,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
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){
|
|
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
param.put("start_date", DateUtils.formatDate(startDate));
|
|
param.put("start_date", DateUtils.formatDate(startDate));
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
}
|
|
}
|
|
@@ -1341,7 +1366,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
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){
|
|
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
param.put("start_date", DateUtils.formatDate(startDate));
|
|
param.put("start_date", DateUtils.formatDate(startDate));
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
}
|
|
}
|
|
@@ -1416,6 +1441,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
private void addGroup(Long advertiserId, JSONArray details) {
|
|
private void addGroup(Long advertiserId, JSONArray details) {
|
|
@@ -1508,7 +1535,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
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){
|
|
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
param.put("start_date", DateUtils.formatDate(startDate));
|
|
param.put("start_date", DateUtils.formatDate(startDate));
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
}
|
|
}
|
|
@@ -1631,7 +1658,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
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){
|
|
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
param.put("start_date", DateUtils.formatDate(startDate));
|
|
param.put("start_date", DateUtils.formatDate(startDate));
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
param.put("end_date", DateUtils.formatDate(endDate));
|
|
}
|
|
}
|
|
@@ -2585,7 +2612,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- @Autowired IKuaiShouImageGetService kuaiShouImageGetService;
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ IKuaiShouImageGetService kuaiShouImageGetService;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询图片列表
|
|
* 查询图片列表
|
|
@@ -2598,7 +2626,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
/**
|
|
/**
|
|
* 查询图片列表
|
|
* 查询图片列表
|
|
*/
|
|
*/
|
|
- private void getImageList(CtopOauthToken token, Date startDate, Date endDate, int page ) {
|
|
|
|
|
|
+ private void getImageList(CtopOauthToken token, Date startDate, Date endDate, int page) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_LIST;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_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");
|
|
@@ -2607,7 +2635,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
//传参
|
|
//传参
|
|
JSONObject param = new JSONObject();
|
|
JSONObject param = new JSONObject();
|
|
param.put("advertiser_id", token.getAccountId());
|
|
param.put("advertiser_id", token.getAccountId());
|
|
- if(startDate != null && endDate != null){
|
|
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
param.put("startDate", DateUtils.formatDate(startDate));
|
|
param.put("startDate", DateUtils.formatDate(startDate));
|
|
param.put("endDate", DateUtils.formatDate(endDate));
|
|
param.put("endDate", DateUtils.formatDate(endDate));
|
|
}
|
|
}
|
|
@@ -2633,7 +2661,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
var detailJson = details.getJSONObject(i);
|
|
var detailJson = details.getJSONObject(i);
|
|
var kuaiShouImageGet = JSONObject.toJavaObject(detailJson, KuaiShouImageGet.class);
|
|
var kuaiShouImageGet = JSONObject.toJavaObject(detailJson, KuaiShouImageGet.class);
|
|
|
|
|
|
- if(StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))){
|
|
|
|
|
|
+ if (StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
kuaiShouImageGet.setAccountId(token.getAccountId());
|
|
kuaiShouImageGet.setAccountId(token.getAccountId());
|
|
@@ -2648,8 +2676,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
/**
|
|
/**
|
|
* 查询图片列表---测试使用
|
|
* 查询图片列表---测试使用
|
|
*/
|
|
*/
|
|
- @Override
|
|
|
|
- public void getImageList(String token, Long accountId, Date startDate, Date endDate, int page ) {
|
|
|
|
|
|
+ public void getImageList(String token, Long accountId, Date startDate, Date endDate, int page) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_LIST;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_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");
|
|
@@ -2658,7 +2685,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
//传参
|
|
//传参
|
|
JSONObject param = new JSONObject();
|
|
JSONObject param = new JSONObject();
|
|
param.put("advertiser_id", accountId);
|
|
param.put("advertiser_id", accountId);
|
|
- if(startDate != null && endDate != null){
|
|
|
|
|
|
+ if (startDate != null && endDate != null) {
|
|
param.put("startDate", DateUtils.formatDate(startDate));
|
|
param.put("startDate", DateUtils.formatDate(startDate));
|
|
param.put("endDate", DateUtils.formatDate(endDate));
|
|
param.put("endDate", DateUtils.formatDate(endDate));
|
|
}
|
|
}
|
|
@@ -2669,8 +2696,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
//String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
//String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
|
|
|
//test start
|
|
//test start
|
|
- Map<String,Object> map = new HashMap<>();
|
|
|
|
- Map<String,Object> map1 = new HashMap<>();
|
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ Map<String, Object> map1 = new HashMap<>();
|
|
|
|
|
|
List<KuaiShouImageGet> list = new ArrayList<>();
|
|
List<KuaiShouImageGet> list = new ArrayList<>();
|
|
KuaiShouImageGet kuaiShouImageGet1 = new KuaiShouImageGet();
|
|
KuaiShouImageGet kuaiShouImageGet1 = new KuaiShouImageGet();
|
|
@@ -2683,11 +2710,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
kuaiShouImageGet1.setSignature("44a20b91b0727fa2abb68b19c0456422");
|
|
kuaiShouImageGet1.setSignature("44a20b91b0727fa2abb68b19c0456422");
|
|
list.add(kuaiShouImageGet1);
|
|
list.add(kuaiShouImageGet1);
|
|
|
|
|
|
- map1.put("details",list);
|
|
|
|
- map1.put("total_count",4);
|
|
|
|
- map.put("data",map1);
|
|
|
|
- map.put("message","OK");
|
|
|
|
- map.put("code",0);
|
|
|
|
|
|
+ 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);
|
|
String result = JSONObject.toJSONString(map);
|
|
//test end
|
|
//test end
|
|
|
|
|
|
@@ -2708,7 +2735,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
var detailJson = details.getJSONObject(i);
|
|
var detailJson = details.getJSONObject(i);
|
|
var kuaiShouImageGet = JSONObject.toJavaObject(detailJson, KuaiShouImageGet.class);
|
|
var kuaiShouImageGet = JSONObject.toJavaObject(detailJson, KuaiShouImageGet.class);
|
|
|
|
|
|
- if(StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))){
|
|
|
|
|
|
+ if (StringUtils.isBlank(String.valueOf(kuaiShouImageGet.getImageToken()))) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
kuaiShouImageGet.setAccountId(accountId);
|
|
kuaiShouImageGet.setAccountId(accountId);
|
|
@@ -2717,6 +2744,167 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
imageGets.add(kuaiShouImageGet);
|
|
imageGets.add(kuaiShouImageGet);
|
|
}
|
|
}
|
|
kuaiShouImageGetService.replaceBatch(imageGets);
|
|
kuaiShouImageGetService.replaceBatch(imageGets);
|
|
- getImageList(token, accountId, startDate, endDate, page+1 );
|
|
|
|
|
|
+ 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();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|