|
@@ -313,6 +313,11 @@ public class KuaishouBatchCreativePreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 是否投放开屏广告位 true:投放,false:不投放
|
|
|
+ Integer splashAdSwitch = groupPreview.getSplashAdSwitch();
|
|
|
+ if (!Check.isNull(splashAdSwitch)) {
|
|
|
+ unitJson.put("splash_ad_switch", splashAdSwitch == 1);
|
|
|
+ }
|
|
|
// 试玩 ID
|
|
|
Long playableId = groupPreview.getPlayableId();
|
|
|
if (!Check.isNull(playableId)) {
|
|
@@ -370,7 +375,11 @@ public class KuaishouBatchCreativePreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
updateStatus.setMessage((String) returnUnitMap.get("message"));
|
|
|
updateStatus.setUnitId(unitId);
|
|
|
if (groupPreview.getUnitType() == 4) {
|
|
|
- createCopyCreatives(token, groupPreview.getKuaishouBatchCreativePreviews(), unitId, campaignId);
|
|
|
+ if (scene_id.toJSONString().contains("27") && groupPreview.getSplashAdSwitch() == 1) {//27:开屏广告位
|
|
|
+ createMoreCreative(token, groupPreview.getKuaishouBatchCreativePreviews(), unitId, campaignId);
|
|
|
+ } else {
|
|
|
+ createCopyCreatives(token, groupPreview.getKuaishouBatchCreativePreviews(), unitId, campaignId);
|
|
|
+ }
|
|
|
} else {
|
|
|
createCopyProgramCreatives(token, groupPreview.getKuaishouBatchCreativePreviews(), unitId, campaignId);
|
|
|
}
|
|
@@ -476,13 +485,14 @@ public class KuaishouBatchCreativePreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
}
|
|
|
|
|
|
Map<String, Object> creativeMap = kuaishouInterfaceService.creativeCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), createJson, 1);
|
|
|
+
|
|
|
JSONObject returnJson = new JSONObject();
|
|
|
Integer code = (Integer) creativeMap.get("code");
|
|
|
if (code == 0) {
|
|
|
Long creativeId = (Long) creativeMap.get("creativeId");
|
|
|
updateStatus.setIsSuccess(1);
|
|
|
updateStatus.setMessage((String) creativeMap.get("message"));
|
|
|
- updateStatus.setCreativeId(creativeId);
|
|
|
+ updateStatus.setCreativeId(creativeId + "");
|
|
|
} else {
|
|
|
updateStatus.setIsSuccess(0);
|
|
|
updateStatus.setMessage((String) creativeMap.get("message"));
|
|
@@ -496,6 +506,99 @@ public class KuaishouBatchCreativePreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 根据预览数据创建广告创意(批量)
|
|
|
+ */
|
|
|
+ private void createMoreCreative(CtopOauthToken oauthToken, List<KuaishouBatchCreativePreview> creativePreviewList, Long campaignId, Long unitId) throws Exception {
|
|
|
+ KuaishouBatchCreativePreview updateStatus = new KuaishouBatchCreativePreview();
|
|
|
+ updateStatus.setCampaignId(campaignId);
|
|
|
+ updateStatus.setUnitId(unitId);
|
|
|
+ KuaishouBatchCreativePreview creativePreview = creativePreviewList.get(0);
|
|
|
+ try {
|
|
|
+ JSONObject creativeJson = new JSONObject();
|
|
|
+ creativeJson.put("advertiser_id", oauthToken.getAccountId());
|
|
|
+ creativeJson.put("unit_id", unitId);
|
|
|
+ if (!Check.isNull(creativePreview.getClickTrackUrl())) {
|
|
|
+ creativeJson.put("click_track_url", creativePreview.getClickTrackUrl()); // 第三方点击检测链接
|
|
|
+ }
|
|
|
+ if (!Check.isNull(creativePreview.getImpressionUrl())) {
|
|
|
+ creativeJson.put("impression_url", creativePreview.getImpressionUrl()); // 第三方开始播放监测链接
|
|
|
+ }
|
|
|
+ if (!Check.isNull(creativePreview.getAdPhotoPlayedT3sUrl())) {
|
|
|
+ creativeJson.put("ad_photo_played_t3s_url", creativePreview.getAdPhotoPlayedT3sUrl()); // 第三方有效播放监测链接
|
|
|
+ }
|
|
|
+ if (!Check.isNull(creativePreview.getActionbarClickUrl())) {
|
|
|
+ creativeJson.put("actionbar_click_url", creativePreview.getActionbarClickUrl()); // 第三方点击按钮监测链接
|
|
|
+ }
|
|
|
+ if (!Check.isNull(creativePreview.getCreativeCategory()) && !Check.isNull(creativePreview.getCreativeTag())) {
|
|
|
+ creativeJson.put("creative_category", creativePreview.getCreativeCategory()); // 创意分类
|
|
|
+ creativeJson.put("creative_tag", JSONObject.parseArray(creativePreview.getCreativeTag())); // 创意标签
|
|
|
+ }
|
|
|
+
|
|
|
+ List<JSONObject> creatives = new ArrayList<>();
|
|
|
+ for (KuaishouBatchCreativePreview preview : creativePreviewList) {
|
|
|
+ JSONObject creative = new JSONObject();
|
|
|
+ creative.put("creative_name", creativePreview.getCreativeName()); // 创意名称
|
|
|
+ if (!Check.isNull(creativePreview.getPhotoId())) {
|
|
|
+ creative.put("photo_id", creativePreview.getPhotoId()); // 视频ID
|
|
|
+ KuaiShouVideoGet video = videoGetService.getVideoByPhotoId(Long.valueOf(creativePreview.getPhotoId()));
|
|
|
+ if (Check.isNull(video)) {
|
|
|
+ log.info("账户:{},photoId:{} 没有查询到视频,素材类型指定为竖版视频", oauthToken.getAccountId(), creativePreview.getPhotoId());
|
|
|
+ creative.put("creative_material_type", 1); // 素材类型
|
|
|
+ } else {
|
|
|
+ if (0 == video.getIsKaiPing()) {
|
|
|
+ creative.put("creative_material_type", 11);// 11-开屏视频
|
|
|
+ creative.put("splash_photo_ids", JSONObject.parseArray(creativePreview.getSplashPhotoIds())); // 安卓下载中间页ID
|
|
|
+ } else {
|
|
|
+ creative.put("creative_material_type", video.getMaterialType());//1:竖版视频 2:横版视频
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!Check.isNull(creativePreview.getImageTokens())) {
|
|
|
+ creative.put("image_tokens", Arrays.asList(creativePreview.getImageTokens()));
|
|
|
+ creative.put("creative_material_type", creativePreview.getMaterialType());
|
|
|
+ }
|
|
|
+ if (!Check.isNull(creativePreview.getActionBarText())) {
|
|
|
+ creative.put("action_bar_text", creativePreview.getActionBarText()); // 行动号召按钮文案
|
|
|
+ }
|
|
|
+ if (!Check.isNull(creativePreview.getDescription())) {
|
|
|
+ creative.put("description", creativePreview.getDescription()); // 广告语
|
|
|
+ }
|
|
|
+ if (!Check.isNull(creativePreview.getStickerTitle())) {
|
|
|
+ creative.put("sticker_title", creativePreview.getStickerTitle()); // 封面广告语标题
|
|
|
+ }
|
|
|
+ if (!Check.isNull(creativePreview.getOverlayType())) {
|
|
|
+ creative.put("overlay_type", creativePreview.getOverlayType()); // 贴纸样式类型
|
|
|
+ }
|
|
|
+ if (!Check.isNull(creativePreview.getSiteId())) {
|
|
|
+ creative.put("site_id", creativePreview.getSiteId()); // 安卓下载中间页ID
|
|
|
+ }
|
|
|
+ creatives.add(creative);
|
|
|
+ }
|
|
|
+ creativeJson.put("creatives", creatives);
|
|
|
+ Map<String, Object> creativeMap = kuaishouInterfaceService.batchCreativeCreate(oauthToken.getAccessToken(), oauthToken.getAccountId(), creativeJson, 1, null);
|
|
|
+ JSONObject returnJson = new JSONObject();
|
|
|
+ Integer code = (Integer) creativeMap.get("code");
|
|
|
+ if (code == 0) {
|
|
|
+ JSONArray creativeIds = (JSONArray) creativeMap.get("ids");
|
|
|
+ updateStatus.setIsSuccess(1);
|
|
|
+ updateStatus.setMessage((String) creativeMap.get("message"));
|
|
|
+ updateStatus.setCreativeId(creativeIds.toJSONString());
|
|
|
+ } else {
|
|
|
+ updateStatus.setIsSuccess(0);
|
|
|
+ updateStatus.setMessage((String) creativeMap.get("message"));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("创建广告创意过程中调用快手接口异常", e);
|
|
|
+ updateStatus.setIsSuccess(0);
|
|
|
+ updateStatus.setMessage("创建广告创意过程中调用快手接口异常");
|
|
|
+ }
|
|
|
+ for (KuaishouBatchCreativePreview preview : creativePreviewList) {
|
|
|
+ updateStatus.setId(preview.getId());
|
|
|
+ creativePreviewMapper.updateById(updateStatus);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 执行多线程创建程序化创意
|
|
|
*/
|
|
|
private void createCopyProgramCreatives(CtopOauthToken token, List<KuaishouBatchCreativePreview> creativePreviewList, Long unitId, Long campaignId) {
|
|
@@ -580,7 +683,7 @@ public class KuaishouBatchCreativePreviewServiceImpl extends ServiceImpl<Kuaisho
|
|
|
Long creativeId = (Long) creativeMap.get("creativeId");
|
|
|
updateStatus.setIsSuccess(1);
|
|
|
updateStatus.setMessage((String) creativeMap.get("message"));
|
|
|
- updateStatus.setCreativeId(creativeId);
|
|
|
+ updateStatus.setCreativeId(creativeId + "");
|
|
|
} else {
|
|
|
updateStatus.setIsSuccess(0);
|
|
|
updateStatus.setMessage((String) creativeMap.get("message"));
|