|
@@ -136,6 +136,124 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
private IKuaiShouAdvertiserBaseInfoService KuaiShouAdvertiserBaseInfoService;
|
|
|
|
|
|
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void getAsyncCreativeListV2(Long accountId, String accessToken, Long campaignId) {
|
|
|
+
|
|
|
+
|
|
|
+ try {
|
|
|
+ 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", accessToken);
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
+ param.put("advertiser_id", accountId);
|
|
|
+ param.put("page_size", 200);
|
|
|
+ param.put("campaign_id", campaignId);
|
|
|
+
|
|
|
+ /* Map<String, Object> deleteMap = new HashMap<>();
|
|
|
+ deleteMap.put("account_id", accountId);
|
|
|
+ deleteMap.put("campaign_id", campaignId);
|
|
|
+ creativeService.removeByMap(deleteMap);*/
|
|
|
+
|
|
|
+
|
|
|
+ String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ if (Check.isNull(resultJson)) {
|
|
|
+ log.error("获取广告创意返回结果为空,advertiserId:{}", accountId);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
+ String message = resultJson.getString("message");
|
|
|
+ if (null == code || code != 0) {
|
|
|
+ log.error("获取广告创意返回结果异常,advertiserId:{},message:{}", accountId, message);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
|
|
|
+ if (null == details || details.size() <= 0) {
|
|
|
+ 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("" + accountId + detailJson.getLong("creative_id"));
|
|
|
+ creative.setAccountId(accountId);
|
|
|
+ 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"));
|
|
|
+ creative.setCreativeUpdateTime(detailJson.getDate("update_time"));
|
|
|
+ creative.setFirstFrameType(detailJson.getInteger("first_frame_type"));
|
|
|
+ creative.setShortSlogan(detailJson.getString("short_slogan"));
|
|
|
+ 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());
|
|
|
+ creative.setSiteId(detailJson.getLong("site_id"));
|
|
|
+ creative.setPhotoId(detailJson.getString("photo_id"));
|
|
|
+ if (detailJson.getLong("photo_id") == 0) {
|
|
|
+ JSONArray photoIds = new JSONArray();
|
|
|
+ JSONObject programmed_creative_material = detailJson.getJSONObject("programmed_creative_material");
|
|
|
+ if (!Check.isNull(programmed_creative_material)) {
|
|
|
+ creative.setProgrammedCreativeMaterial(programmed_creative_material.toJSONString());
|
|
|
+ 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");
|
|
|
+ photoIds.add(String.valueOf(photo_id));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ creative.setPhotoIds(photoIds.toJSONString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ creatives.add(creative);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ creativeService.replaceBatch(creatives);
|
|
|
+
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public void getAdvertiserReportHourly(CtopOauthToken token, Date startDate, Date endDate) {
|
|
|
getAdvertiserReportHourlyByPage(token, startDate, endDate, 1);
|