|
@@ -267,4 +267,265 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
|
|
ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS);
|
|
ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_SUCCESS);
|
|
return resultMap;
|
|
return resultMap;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Map<String, Object> batchCreate(JSONObject data) {
|
|
|
|
+ log.info(data.toJSONString());
|
|
|
|
+ Map<String,Object>result = new HashMap<>();
|
|
|
|
+ Long accountId = data.getLong("advertiserId");
|
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
|
+ if(null == token){
|
|
|
|
+ ResultMapUtils.setResultMap(result,StatusCode.COMMON_PARAM_ERROR);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ JSONArray planIds = data.getJSONArray("adIds");
|
|
|
|
+ if(null == planIds||planIds.isEmpty()){
|
|
|
|
+ ResultMapUtils.setResultMap(result,StatusCode.COMMON_PARAM_ERROR);
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
|
|
+ //拼接参数
|
|
|
|
+ JSONObject params = initParams(data);
|
|
|
|
+
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private JSONObject initParams(JSONObject data) {
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
+ String creativeWay = data.getString("creativeWay");
|
|
|
|
+ params.put("advertiser_id",data.getLong("accountId"));
|
|
|
|
+ //###############公共参数开始################################
|
|
|
|
+ JSONArray inventoryType = data.getJSONArray("inventoryType");
|
|
|
|
+ if(null!=inventoryType){
|
|
|
|
+ params.put("inventory_type",inventoryType);
|
|
|
|
+ }
|
|
|
|
+ Integer smartInventory = data.getInteger("smartInventory");
|
|
|
|
+ if(null!=smartInventory){
|
|
|
|
+ params.put("smart_inventory",smartInventory);
|
|
|
|
+ }
|
|
|
|
+ String sceneInventory = data.getString("sceneInventory");
|
|
|
|
+ if(null!=sceneInventory&&!sceneInventory.trim().equals("")){
|
|
|
|
+ params.put("scene_inventory",sceneInventory);
|
|
|
|
+ }
|
|
|
|
+ JSONArray adKeywords = data.getJSONArray("adKeywords");
|
|
|
|
+ if(null!=adKeywords&&!adKeywords.isEmpty()){
|
|
|
|
+ params.put("ad_keywords",adKeywords);
|
|
|
|
+ }
|
|
|
|
+ Long thirdIndustryId = data.getLong("thirdIndustryId");
|
|
|
|
+ if(null!=thirdIndustryId&&thirdIndustryId!=0){
|
|
|
|
+ params.put("third_industry_id",thirdIndustryId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String creativeDisplayMode = data.getString("creativeDisplayMode");
|
|
|
|
+ if(null!=creativeDisplayMode&&creativeDisplayMode.trim().equals("")){
|
|
|
|
+ params.put("creative_display_mode",creativeDisplayMode);
|
|
|
|
+ }
|
|
|
|
+ String trackUrl = data.getString("trackUrl");
|
|
|
|
+ if(null!=trackUrl&&trackUrl.trim().equals("")){
|
|
|
|
+ params.put("track_url",trackUrl);
|
|
|
|
+ }
|
|
|
|
+ String actionTrackUrl = data.getString("actionTrackUrl");
|
|
|
|
+ if(null!=actionTrackUrl&&actionTrackUrl.trim().equals("")){
|
|
|
|
+ params.put("action_track_url",actionTrackUrl);
|
|
|
|
+ }
|
|
|
|
+ String videoPlayEffectiveTrackUrl = data.getString("videoPlayEffectiveTrackUrl");
|
|
|
|
+ if(null!=videoPlayEffectiveTrackUrl&&videoPlayEffectiveTrackUrl.trim().equals("")){
|
|
|
|
+ params.put("video_play_effective_track_url",videoPlayEffectiveTrackUrl);
|
|
|
|
+ }
|
|
|
|
+ String videoPlayDoneTrackUrl = data.getString("videoPlayDoneTrackUrl");
|
|
|
|
+ if(null!=videoPlayDoneTrackUrl&&videoPlayDoneTrackUrl.trim().equals("")){
|
|
|
|
+ params.put("video_play_done_track_url",videoPlayDoneTrackUrl);
|
|
|
|
+ }
|
|
|
|
+ String videoPlayTrackUrl = data.getString("videoPlayTrackUrl");
|
|
|
|
+ if(null!=videoPlayTrackUrl&&videoPlayTrackUrl.trim().equals("")){
|
|
|
|
+ params.put("video_play_track_url",videoPlayTrackUrl);
|
|
|
|
+ }
|
|
|
|
+ Long isCommentDisable = data.getLong("isCommentDisable");
|
|
|
|
+ if(null!=isCommentDisable&&isCommentDisable!=0){
|
|
|
|
+ params.put("is_comment_disable",isCommentDisable);
|
|
|
|
+ }
|
|
|
|
+ Long closeVideoDetail = data.getLong("closeVideoDetail");
|
|
|
|
+ if(null!=closeVideoDetail){
|
|
|
|
+ params.put("close_video_detail",closeVideoDetail);
|
|
|
|
+ }
|
|
|
|
+ Long generateDerivedAd = data.getLong("generateDerivedAd");
|
|
|
|
+ if(null!=generateDerivedAd&&generateDerivedAd!=0){
|
|
|
|
+ params.put("generate_derived_ad",generateDerivedAd);
|
|
|
|
+ }
|
|
|
|
+ String playableUrl = data.getString("playable_url");
|
|
|
|
+ if(null!=playableUrl&&!"".equals(playableUrl.trim())){
|
|
|
|
+ params.put("playable_url",playableUrl);
|
|
|
|
+ }
|
|
|
|
+ Long isPresentedVideo = data.getLong("isPresentedVideo");
|
|
|
|
+ if(null!=isCommentDisable&&isPresentedVideo!=0){
|
|
|
|
+ params.put("is_presented_video",isPresentedVideo);
|
|
|
|
+ }
|
|
|
|
+ Long creativeAutoGenerateSwitch = data.getLong("creativeAutoGenerateSwitch");
|
|
|
|
+ if(null!=creativeAutoGenerateSwitch&&creativeAutoGenerateSwitch!=0){
|
|
|
|
+ params.put("creative_auto_generate_switch",creativeAutoGenerateSwitch);
|
|
|
|
+ }
|
|
|
|
+ String trackUrlSendType = data.getString("trackUrlSendType");
|
|
|
|
+ if(null!=trackUrlSendType&&!"".equals(trackUrlSendType.trim())){
|
|
|
|
+ params.put("track_url_send_type",trackUrlSendType);
|
|
|
|
+ }
|
|
|
|
+ String iesCoreUserId = data.getString("iesCoreUserId");
|
|
|
|
+ if(null!=iesCoreUserId&&!"".equals(iesCoreUserId)){
|
|
|
|
+ params.put("ies_core_user_id",iesCoreUserId);
|
|
|
|
+ }
|
|
|
|
+ Long isFeedAndFavSee = data.getLong("isFeedAndFavSee");
|
|
|
|
+ if(null!=isFeedAndFavSee&&isFeedAndFavSee!=0){
|
|
|
|
+ params.put("is_feed_and_fav_see",isFeedAndFavSee);
|
|
|
|
+ }
|
|
|
|
+ JSONArray subLinkIdList = data.getJSONArray("subLinkIdList");
|
|
|
|
+ if(null!=subLinkIdList&&!subLinkIdList.isEmpty()){
|
|
|
|
+ params.put("sub_link_id_list",subLinkIdList);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String source = data.getString("source");
|
|
|
|
+ if(null!=source&&!source.trim().equals("")){
|
|
|
|
+ params.put("source",source);
|
|
|
|
+ }
|
|
|
|
+ //###############公共参数结束################################
|
|
|
|
+
|
|
|
|
+ //#######推广目的为APP######################################
|
|
|
|
+ String appName = data.getString("appName");
|
|
|
|
+ if(null!=appName&&!appName.trim().equals("")){
|
|
|
|
+ params.put("app_name",appName);
|
|
|
|
+ }
|
|
|
|
+ String webUrl = data.getString("webUrl");
|
|
|
|
+ if(null!=webUrl&&!webUrl.trim().equals("")){
|
|
|
|
+ params.put("web_url",webUrl);
|
|
|
|
+ }
|
|
|
|
+ String actionText = data.getString("actionText");
|
|
|
|
+ if(null!=actionText&&!actionText.trim().equals("")){
|
|
|
|
+ params.put("action_text",actionText);
|
|
|
|
+ }
|
|
|
|
+ String subTitle = data.getString("subTitle");
|
|
|
|
+ if(null!=subTitle&&!subTitle.trim().equals("")){
|
|
|
|
+ params.put("sub_title",subTitle);
|
|
|
|
+ }
|
|
|
|
+ //###############################################
|
|
|
|
+ //############创意推广目的为link的时候###################
|
|
|
|
+ String advancedCreativeType = data.getString("advancedCreativeType");
|
|
|
|
+ if(null!=advancedCreativeType&&!advancedCreativeType.trim().equals("")){
|
|
|
|
+ params.put("advanced_creative_type",advancedCreativeType);
|
|
|
|
+ }
|
|
|
|
+ String advancedCreativeTitle = data.getString("advancedCreativeTitle");
|
|
|
|
+ if(null!=advancedCreativeTitle&&!advancedCreativeTitle.trim().equals("")){
|
|
|
|
+ params.put("advanced_creative_title",advancedCreativeTitle);
|
|
|
|
+ }
|
|
|
|
+ String phoneNumber = data.getString("phoneNumber");
|
|
|
|
+ if(null!=phoneNumber&&!phoneNumber.trim().equals("")){
|
|
|
|
+ params.put("phone_number",phoneNumber);
|
|
|
|
+ }
|
|
|
|
+ String buttonText = data.getString("buttonText");
|
|
|
|
+ if(null!=buttonText&&!buttonText.trim().equals("")){
|
|
|
|
+ params.put("button_text",buttonText);
|
|
|
|
+ }
|
|
|
|
+ String formUrl = data.getString("formUrl");
|
|
|
|
+ if(null!=formUrl&&!formUrl.trim().equals("")){
|
|
|
|
+ params.put("form_url",formUrl);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(null!=creativeWay&&creativeWay.trim().equals("proceduralCreativity")){
|
|
|
|
+ //程序化
|
|
|
|
+ params.put("creative_material_mode","STATIC_ASSEMBLE");
|
|
|
|
+ JSONArray titleList = data.getJSONArray("titleList");
|
|
|
|
+ if(null!=titleList&&!titleList.isEmpty()){
|
|
|
|
+ JSONArray setTitleList = new JSONArray();
|
|
|
|
+ for (int i=0;i<titleList.size();i++){
|
|
|
|
+ JSONObject titleObject = titleList.getJSONObject(i);
|
|
|
|
+ JSONArray creativeWordIds = titleObject.getJSONArray("creativeWordIds");
|
|
|
|
+ titleObject.remove("creativeWordIds");
|
|
|
|
+ if(null!=creativeWordIds&&!creativeWordIds.isEmpty()){
|
|
|
|
+ titleObject.put("creative_word_ids",creativeWordIds);
|
|
|
|
+ }
|
|
|
|
+ setTitleList.add(titleObject);
|
|
|
|
+ }
|
|
|
|
+ params.put("title_list",setTitleList);
|
|
|
|
+ }
|
|
|
|
+ JSONArray imageList = data.getJSONArray("imageList");
|
|
|
|
+ if(null!=imageList&&!imageList.isEmpty()){
|
|
|
|
+ JSONArray setImageList = new JSONArray();
|
|
|
|
+ for (int i=0;i<imageList.size();i++){
|
|
|
|
+ JSONObject imageObject = imageList.getJSONObject(i);
|
|
|
|
+ String imageMode = imageObject.getString("imageMode");
|
|
|
|
+ JSONArray imageIds = imageObject.getJSONArray("imageIds");
|
|
|
|
+ String imageId = imageObject.getString("imageId");
|
|
|
|
+ String videoId = imageObject.getString("videoId");
|
|
|
|
+ Integer templateId = imageObject.getInteger("templateId");
|
|
|
|
+ imageObject.remove("imageMode");
|
|
|
|
+ imageObject.remove("imageIds");
|
|
|
|
+ imageObject.remove("imageId");
|
|
|
|
+ imageObject.remove("videoId");
|
|
|
|
+ imageObject.remove("templateId");
|
|
|
|
+ imageObject.put("image_mode",imageMode);
|
|
|
|
+ if(null!=imageIds&&!imageIds.isEmpty()){
|
|
|
|
+ imageObject.put("image_ids",imageIds);
|
|
|
|
+ }
|
|
|
|
+ if(null!=imageId&&!"".equals(imageId.trim())){
|
|
|
|
+ imageObject.put("image_id",imageId);
|
|
|
|
+ }
|
|
|
|
+ if(null!=videoId&&!"".equals(videoId.trim())){
|
|
|
|
+ imageObject.put("video_id",videoId);
|
|
|
|
+ }
|
|
|
|
+ if(null!=templateId&&templateId!=0){
|
|
|
|
+ imageObject.put("template_id",templateId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setImageList.add(imageObject);
|
|
|
|
+ }
|
|
|
|
+ params.put("image_list",setImageList);
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ //自定义创意
|
|
|
|
+ JSONArray creatives = data.getJSONArray("creatives");
|
|
|
|
+ if(null!=creatives&&!creatives.isEmpty()){
|
|
|
|
+ JSONArray setCreatives = new JSONArray();
|
|
|
|
+ for(int i=0;i<creatives.size();i++){
|
|
|
|
+ JSONObject creativeObject = creatives.getJSONObject(i);
|
|
|
|
+ JSONArray creativeWordIds = creativeObject.getJSONArray("creativeWordIds");
|
|
|
|
+ creativeObject.remove("creativeWordIds");
|
|
|
|
+ if(null!=creativeWordIds&&!creativeWordIds.isEmpty()){
|
|
|
|
+ creativeObject.put("creative_word_ids",creativeWordIds);
|
|
|
|
+ }
|
|
|
|
+ String imageMode = creativeObject.getString("imageMode");
|
|
|
|
+ creativeObject.remove("imageMode");
|
|
|
|
+ creativeObject.put("image_mode",imageMode);
|
|
|
|
+ JSONArray imageIds = creativeObject.getJSONArray("imageIds");
|
|
|
|
+ creativeObject.remove("imageIds");
|
|
|
|
+ if(null!=imageIds&&!imageIds.isEmpty()){
|
|
|
|
+ creativeObject.put("image_ids",imageIds);
|
|
|
|
+ }
|
|
|
|
+ String imageId = creativeObject.getString("imageId");
|
|
|
|
+ creativeObject.remove("imageId");
|
|
|
|
+ if(null!=imageId&&!"".equals(imageId.trim())){
|
|
|
|
+ creativeObject.put("image_id",imageId);
|
|
|
|
+ }
|
|
|
|
+ String videoId = creativeObject.getString("videoId");
|
|
|
|
+ creativeObject.remove("videoId");
|
|
|
|
+ if(null!=videoId&&!"".equals(videoId.trim())){
|
|
|
|
+ creativeObject.put("video_id",videoId);
|
|
|
|
+ }
|
|
|
|
+ Integer templateId = creativeObject.getInteger("templateId");
|
|
|
|
+ creativeObject.remove("templateId");
|
|
|
|
+ if(null!=templateId&&templateId!=0){
|
|
|
|
+ creativeObject.put("template_id",templateId);
|
|
|
|
+ }
|
|
|
|
+ JSONArray dpaDictIds = creativeObject.getJSONArray("dpaDictIds");
|
|
|
|
+ creativeObject.remove("dpaDictIds");
|
|
|
|
+ if(null!=creativeWordIds&&!creativeWordIds.isEmpty()){
|
|
|
|
+ creativeObject.put("creative_word_ids",creativeWordIds);
|
|
|
|
+ }
|
|
|
|
+ Integer derivePosterCid = creativeObject.getInteger("derivePosterCid");
|
|
|
|
+ creativeObject.remove("derivePosterCid");
|
|
|
|
+ if(null!=derivePosterCid&&derivePosterCid!=0){
|
|
|
|
+ creativeObject.put("derive_poster_cid",derivePosterCid);
|
|
|
|
+ }
|
|
|
|
+ setCreatives.add(creativeObject);
|
|
|
|
+ }
|
|
|
|
+ params.put("creatives",setCreatives);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return params;
|
|
|
|
+ }
|
|
}
|
|
}
|