|
@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.utils.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
|
|
import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
|
|
@@ -202,6 +203,47 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ public void getVideoList(CtopOauthToken token) {
|
|
|
|
+ getVideoListByPage(token, 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void getVideoListByPage(CtopOauthToken token, 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.getAccessToken());
|
|
|
|
+ Map<String, Object> param = new HashMap<>();
|
|
|
|
+ param.put("advertiser_id", token.getAccountId());
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (int i = 0; i < details.size(); i++) {
|
|
|
|
+ var detailJson = details.getJSONObject(i);
|
|
|
|
+ var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
|
|
|
|
+ kuaiShouVideoGet.setAccountId(token.getAccountId());
|
|
|
|
+ kuaiShouVideoGet.setId("" + token.getAccountId() + kuaiShouVideoGet.getPhotoId());
|
|
|
|
+ kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
|
|
|
|
+ }
|
|
|
|
+ getVideoListByPage(token, page + 1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouVideoGetService kuaiShouVideoGetService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
public void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate) {
|
|
public void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate) {
|
|
getAccountDailyReportByPage(token, startDate, endDate, 1);
|
|
getAccountDailyReportByPage(token, startDate, endDate, 1);
|
|
}
|
|
}
|
|
@@ -1242,12 +1284,65 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
}
|
|
}
|
|
creativeService.saveOrUpdate(creative);
|
|
creativeService.saveOrUpdate(creative);
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
getCreativeList(accessToken, advertiserId, page + 1);
|
|
getCreativeList(accessToken, advertiserId, page + 1);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 获取视频信息数据
|
|
|
|
+ *
|
|
|
|
+ * @param accessToken
|
|
|
|
+ * @param advertiserId
|
|
|
|
+ * @param photoId
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void getVideoInfo(String accessToken, Long advertiserId, String photoId) {
|
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_GET;
|
|
|
|
+ Map<String, String> headers = new HashMap<String, String>();
|
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
|
+ headers.put("Access-Token", accessToken);
|
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
|
+ param.put("advertiser_id", advertiserId);
|
|
|
|
+ JSONArray photosArray = new JSONArray();
|
|
|
|
+ photosArray.add(photoId);
|
|
|
|
+ param.put("photo_ids", photosArray);
|
|
|
|
+ try {
|
|
|
|
+ String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
+ if (!Check.isNull(resultJson)) {
|
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
|
+ if (code == 0) {
|
|
|
|
+ JSONArray dataArray = resultJson.getJSONArray("data");
|
|
|
|
+ if (!Check.isNull(dataArray)) {
|
|
|
|
+ for (int i = 0; i < dataArray.size(); i++) {
|
|
|
|
+ JSONObject detailJson = dataArray.getJSONObject(i);
|
|
|
|
+ if (!Check.isNull(detailJson)) {
|
|
|
|
+ KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
|
|
|
|
+ videoGet.setId(detailJson.getString("photo_id"));
|
|
|
|
+ videoGet.setAccountId(advertiserId);
|
|
|
|
+ videoGet.setWidth(detailJson.getInteger("width"));
|
|
|
|
+ videoGet.setHeight(detailJson.getInteger("height"));
|
|
|
|
+ videoGet.setUrl(detailJson.getLong("unit_id"));
|
|
|
|
+ videoGet.setCoverUrl(detailJson.getString("creative_name"));
|
|
|
|
+ videoGet.setPhotoId(detailJson.getString("photo_id"));
|
|
|
|
+ //videoGet.setSignature(UUID.randomUUID().toString());
|
|
|
|
+ kuaiShouVideoGetService.saveOrUpdate(videoGet);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 获取 创意信息
|
|
* 获取 创意信息
|
|
*
|
|
*
|
|
* @param accessToken
|
|
* @param accessToken
|