|
@@ -6,8 +6,8 @@ import cn.com.ctop.common.module.entity.UserAllocation;
|
|
|
import cn.com.ctop.common.module.mapper.CtopOauthTokenMapper;
|
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
|
-import cn.com.ctop.common.module.utils.*;
|
|
|
-import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouCreative;
|
|
|
+import cn.com.ctop.common.module.utils.CtopAdConstant;
|
|
|
+import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouHistoryReportTaskService;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
|
|
@@ -23,7 +23,8 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
-import java.util.*;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
@@ -211,14 +212,17 @@ public class SampleTest {
|
|
|
@Autowired
|
|
|
private IKuaiShouCreativeService creativeService;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Test
|
|
|
public void suZhao() {
|
|
|
|
|
|
|
|
|
- /*Long accountId = 3917130L;
|
|
|
- String token = "9f2caae880367a9477cf1b6bf86e3858";
|
|
|
+ Long accountId = 3917130L;
|
|
|
+ String token = "0a42e23921e486108105263e75561404";
|
|
|
+ kuaishouInterfaceService.getVideoList("e91c778d7de1bd0e9d8f3213d1e0e57c",3820093L, null,null,1);
|
|
|
|
|
|
- String url = "https://ad.e.kuaishou.com/rest/openapi/v1/file/ad/video/su_zao/list";
|
|
|
+ /* String url = "https://ad.e.kuaishou.com/rest/openapi/v1/file/ad/video/su_zao/list";
|
|
|
|
|
|
|
|
|
Map<String, String> headers = new HashMap<String, String>();
|
|
@@ -228,118 +232,11 @@ public class SampleTest {
|
|
|
|
|
|
param.put("advertiser_id", accountId);
|
|
|
param.put("temporal_granularity", "HOURLY");
|
|
|
- param.put("page_size", 499);
|
|
|
param.put("page", 1);
|
|
|
String result = HttpUtils.httpPostRequest(url, param, headers);
|
|
|
System.err.println(result);*/
|
|
|
|
|
|
|
|
|
- String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.CREATIVE_LIST;
|
|
|
- Map<String, String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type", " application/json");
|
|
|
- headers.put("Access-Token", "bd90c55f01d79450c66260bcb15b5c0a");
|
|
|
- Long advertiserId = 23212L;
|
|
|
- JSONObject param = new JSONObject();
|
|
|
- param.put("advertiser_id", 23212);
|
|
|
- // param.put("creative_id", creativeId);
|
|
|
- param.put("page_size", 500);
|
|
|
- param.put("page", 1);
|
|
|
-
|
|
|
- System.err.println(param);
|
|
|
- System.err.println(headers);
|
|
|
-
|
|
|
- String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
|
|
|
- JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
- System.err.println(resultJson);
|
|
|
-
|
|
|
-
|
|
|
- if (Check.isNull(resultJson)) {
|
|
|
- log.error("获取广告创意返回结果为空,advertiserId:{}", advertiserId);
|
|
|
- return;
|
|
|
- }
|
|
|
- Integer code = resultJson.getInteger("code");
|
|
|
- String message = resultJson.getString("message");
|
|
|
- if (null == code || code != 0) {
|
|
|
- log.error("获取广告创意返回结果异常,advertiserId:{},message:{}", advertiserId, message);
|
|
|
- return;
|
|
|
- }
|
|
|
- JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
|
|
|
- if (null == details || details.size() <= 0) {
|
|
|
-// log.error("获取广告创意返回结果数据为空,advertiserId:{}", advertiserId);
|
|
|
- return;
|
|
|
- }
|
|
|
- List<KuaiShouCreative> creatives = new ArrayList<>();
|
|
|
- for (int i = 0; i < details.size(); i++) {
|
|
|
- JSONObject detailJson = JSONObject.parseObject(details.get(i).toString());
|
|
|
- if (!Check.isNull(detailJson)) {
|
|
|
- KuaiShouCreative creative = new KuaiShouCreative();
|
|
|
- creative.setId("" + advertiserId + detailJson.getLong("creative_id"));
|
|
|
- creative.setAccountId(advertiserId);
|
|
|
- creative.setCampaignId(detailJson.getLong("campaign_id"));
|
|
|
- creative.setUnitId(detailJson.getLong("unit_id"));
|
|
|
- creative.setCreativeId(detailJson.getLong("creative_id"));
|
|
|
- creative.setCreativeName(detailJson.getString("creative_name"));
|
|
|
- creative.setCreativeMaterialType(detailJson.getInteger("creative_material_type"));
|
|
|
- //
|
|
|
- if (!Check.isNull(detailJson.getJSONArray("material_url"))) {
|
|
|
- creative.setMaterialUrl(detailJson.getJSONArray("material_url").toJSONString());
|
|
|
- }
|
|
|
-
|
|
|
- if (!Check.isNull(detailJson.getJSONArray("image_tokens"))) {
|
|
|
- creative.setImageTokens(detailJson.getJSONArray("image_tokens").toJSONString());
|
|
|
- }
|
|
|
- creative.setStatus(detailJson.getInteger("status"));
|
|
|
- creative.setPutStatus(detailJson.getInteger("put_status"));
|
|
|
- creative.setCreateChannel(detailJson.getInteger("create_channel"));
|
|
|
- creative.setReviewDetail(detailJson.getString("review_detail"));
|
|
|
- creative.setCoverUrl(detailJson.getString("cover_url"));
|
|
|
- creative.setImageToken(detailJson.getString("image_token"));
|
|
|
- creative.setCoverWidth(detailJson.getString("cover_width"));
|
|
|
- creative.setCoverHeight(detailJson.getString("cover_height"));
|
|
|
- creative.setOverlayBgUrl(detailJson.getString("overlay_bg_url"));
|
|
|
- creative.setOverlayBgImageToken(detailJson.getString("overlay_bg_image_token"));
|
|
|
- creative.setStickerTitle(detailJson.getString("sticker_title"));
|
|
|
- creative.setOverlayType(detailJson.getString("overlay_type"));
|
|
|
- creative.setClickTrackUrl(detailJson.getString("click_track_url"));
|
|
|
- creative.setImpressionUrl(detailJson.getString("impression_url"));
|
|
|
- creative.setAdPhotoPlayedT3sUrl(detailJson.getString("ad_photo_played_t3s_url"));
|
|
|
- creative.setCreativeCreateTime(detailJson.getDate("create_time"));
|
|
|
- JSONObject displayInfoJson = detailJson.getJSONObject("display_info");
|
|
|
- if (!Check.isNull(displayInfoJson)) {
|
|
|
- creative.setDescription(displayInfoJson.getString("description"));
|
|
|
- creative.setActionBarText(displayInfoJson.getString("action_bar_text"));
|
|
|
- }
|
|
|
- creative.setCreateTime(new Date());
|
|
|
- creative.setUpdateTime(new Date());
|
|
|
-
|
|
|
- if (detailJson.getLong("photo_id") == 0) {
|
|
|
- JSONObject programmed_creative_material = detailJson.getJSONObject("programmed_creative_material");
|
|
|
- if (!Check.isNull(programmed_creative_material)) {
|
|
|
- JSONArray materials = programmed_creative_material.getJSONArray("materials");
|
|
|
- if (!Check.isNull(materials)) {
|
|
|
- for (int j = 0; j < materials.size(); j++) {
|
|
|
- JSONObject materialJson = materials.getJSONObject(j);
|
|
|
- if (!Check.isNull(materialJson)) {
|
|
|
- Long photo_id = materialJson.getLong("photo_id");
|
|
|
- creative.setPhotoId(String.valueOf(photo_id));
|
|
|
- creatives.add(creative);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- } else {
|
|
|
- creative.setPhotoId(detailJson.getString("photo_id"));
|
|
|
- creatives.add(creative);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- creativeService.replaceBatch(creatives);
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|