|
@@ -1,31 +1,34 @@
|
|
|
package org.jeecg.modules.bytedance.advertise.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
-import org.jeecg.modules.bytedance.advertise.dockapi.marketing;
|
|
|
-import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAdDplinkInfo;
|
|
|
-import org.jeecg.modules.bytedance.advertise.entity.AiBytedanceAdvertiserStrategy;
|
|
|
-import org.jeecg.modules.bytedance.advertise.entity.ByteDanceVideoInfo;
|
|
|
-import org.jeecg.modules.bytedance.advertise.entity.UpdAdStaOrCpaOrBudget;
|
|
|
+import org.jeecg.modules.bytedance.advertise.dockapi.Marketing;
|
|
|
+import org.jeecg.modules.bytedance.advertise.entity.*;
|
|
|
import org.jeecg.modules.bytedance.advertise.enums.BytedanceCreativeMatTypeEnum;
|
|
|
import org.jeecg.modules.bytedance.advertise.mapper.AiBytedanceAdvertiserStrategyMapper;
|
|
|
-import org.jeecg.modules.bytedance.advertise.service.IAiBytedanceAdDplinkInfoService;
|
|
|
-import org.jeecg.modules.bytedance.advertise.service.IAiBytedanceAdvertiserStrategyService;
|
|
|
-import org.jeecg.modules.bytedance.advertise.service.IByteDanceVideoInfoService;
|
|
|
+import org.jeecg.modules.bytedance.advertise.service.*;
|
|
|
import org.jeecg.modules.bytedance.advertise.vo.AdConvertQueryVo;
|
|
|
import org.jeecg.modules.bytedance.advertise.vo.AdGroupSearchVo;
|
|
|
import org.jeecg.modules.bytedance.advertise.vo.PlanSearchVo;
|
|
|
import org.jeecg.modules.bytedance.common.constant.BytedanceConstant;
|
|
|
import org.jeecg.modules.bytedance.common.entity.CtopOauthToken;
|
|
|
+import org.jeecg.modules.bytedance.common.entity.MaterialInfo;
|
|
|
import org.jeecg.modules.bytedance.common.entity.UserAllocation;
|
|
|
import org.jeecg.modules.bytedance.common.service.ICtopOauthTokenService;
|
|
|
+import org.jeecg.modules.bytedance.common.service.IMaterialInfoService;
|
|
|
import org.jeecg.modules.bytedance.common.service.IUserAllocationService;
|
|
|
+import org.jeecg.modules.bytedance.common.utils.Check;
|
|
|
+import org.jeecg.modules.bytedance.common.utils.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -93,16 +96,557 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
}
|
|
|
//根据dpLink获取组名称
|
|
|
String campaignName = getCampaignName(dpIndex,strategy);
|
|
|
- //2:创建计划
|
|
|
- //3:创建创意
|
|
|
+ Long campaignId = getCampaignId(strategy,campaignName,token);
|
|
|
+ if(null == campaignId){
|
|
|
+ return videoCnt;
|
|
|
+ }
|
|
|
+ for (ByteDanceVideoInfo video:videoInfos) {
|
|
|
+ /**
|
|
|
+ * 2:创建计划
|
|
|
+ */
|
|
|
+ //1:应用直达链接
|
|
|
+ strategy.setAdOpenUrl(strategy.getAdOpenUrl().replace("{{dp链接下标}}",dpIndex.toString()));
|
|
|
+ String dplinkCode = StringUtils.getParamFromUrl(strategy.getAdOpenUrl(),"bc_fl_src");
|
|
|
+ String adName = getAdName(strategy,dplinkCode,video);
|
|
|
+ JSONObject adParams = getAdParams(strategy,adName,campaignId);
|
|
|
+ Long adId = createAdInfo(token,strategy,adParams);
|
|
|
+ if(null == adId){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //3:创建创意
|
|
|
+ JSONObject creativeParams = getCreativeParams(strategy,adId,video,token);
|
|
|
+
|
|
|
+ }
|
|
|
return videoCnt;
|
|
|
}
|
|
|
|
|
|
- private String getCampaignName(Long dpIndex, AiBytedanceAdvertiserStrategy strategy) {
|
|
|
- Long unitCreativeNum = strategy.getCampaignAdCnt();
|
|
|
+ private JSONObject getCreativeParams(AiBytedanceAdvertiserStrategy strategy, Long adId,ByteDanceVideoInfo videoInfo,CtopOauthToken token) {
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id",strategy.getAccountId());
|
|
|
+ params.put("ad_id",adId);
|
|
|
+ String inventoryType = strategy.getCreativeInventoryType();
|
|
|
+ if(null!=inventoryType&&!"".equals(inventoryType)){
|
|
|
+ JSONArray inventoryTypeArray = JSON.parseArray(inventoryType);
|
|
|
+ if(!Check.isNull(inventoryTypeArray)){
|
|
|
+ params.put("inventory_type",inventoryTypeArray);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Integer smartInventory = strategy.getCreativeSmartInventory();
|
|
|
+ if(null!=smartInventory&&smartInventory!=0){
|
|
|
+ params.put("smart_inventory",smartInventory);
|
|
|
+ }
|
|
|
+
|
|
|
+ String sceneInventory = strategy.getCreativeSceneInventory();
|
|
|
+ if(!Check.isNull(sceneInventory)){
|
|
|
+ params.put("scene_inventory",sceneInventory);
|
|
|
+ }
|
|
|
+ //程序化创意 非dpa
|
|
|
+ params.put("creative_material_mode","STATIC_ASSEMBLE");
|
|
|
+ //是否自动生成视频素材
|
|
|
+ Integer isPresentedVideo = strategy.getCreativeIsPresentedVideo();
|
|
|
+ if(null!=isPresentedVideo&&isPresentedVideo!=0){
|
|
|
+ params.put("is_presented_video",isPresentedVideo);
|
|
|
+ }
|
|
|
+ //是否开启衍生计划
|
|
|
+ Integer generateDerivedAd = strategy.getCreativeGenerateDerivedAd();
|
|
|
+ if(null!=generateDerivedAd&&generateDerivedAd!=0){
|
|
|
+ params.put("generate_derived_ad",generateDerivedAd);
|
|
|
+ }
|
|
|
+ //视频素材
|
|
|
+ JSONArray imageArray = new JSONArray();
|
|
|
+ JSONObject imageObject = new JSONObject();
|
|
|
+ //视频类型
|
|
|
+ if(videoInfo.getType() == 1){
|
|
|
+ //横版视频
|
|
|
+ imageObject.put("image_mode","CREATIVE_IMAGE_MODE_VIDEO");
|
|
|
+ }
|
|
|
+ if(videoInfo.getType() == 2){
|
|
|
+ //竖版视频
|
|
|
+ imageObject.put("image_mode","CREATIVE_IMAGE_MODE_VIDEO_VERTICAL");
|
|
|
+ }
|
|
|
+ imageObject.put("video_id",videoInfo.getVid());
|
|
|
+ //获取视频封面id
|
|
|
+ String imageId = getSuggestImageId(token,videoInfo.getVid());
|
|
|
+ if(!Check.isNull(imageId)){
|
|
|
+ imageObject.put("image_id",imageId);
|
|
|
+ }
|
|
|
+ params.put("image_list",imageArray);
|
|
|
+ JSONArray titleArray = new JSONArray();
|
|
|
+ List<BytedanceVideoSlogenInfo>slogenInfos = slogenInfoService.listByParams(videoInfo.getSignature(),1);
|
|
|
+ if(!Check.isNull(slogenInfos)){
|
|
|
+ slogenInfos.forEach(slogenInfo->{
|
|
|
+ JSONObject titleObject = new JSONObject();
|
|
|
+ titleObject.put("title",slogenInfo.getSlogan());
|
|
|
+ titleArray.add(titleObject);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(Check.isNull(titleArray)){
|
|
|
+ params.put("title_list",titleArray);
|
|
|
+ }
|
|
|
+ //广告来源
|
|
|
+ String source = strategy.getCreativeSource();
|
|
|
+ if(!Check.isNull(source)){
|
|
|
+ params.put("source",source);
|
|
|
+ }
|
|
|
+ //推广抖音号
|
|
|
+ String iesCoreUserId = strategy.getCreativeIesCoreUserId();
|
|
|
+ if(!Check.isNull(iesCoreUserId)){
|
|
|
+ params.put("ies_core_user_id",iesCoreUserId);
|
|
|
+ }
|
|
|
+ //主页作品列表隐藏广告内容
|
|
|
+ Integer isFeedAndFavSee = strategy.getCreativeIsFeedAndFavSee();
|
|
|
+ if(null!=isFeedAndFavSee&&isFeedAndFavSee!=0){
|
|
|
+ params.put("is_feed_and_fav_see",isFeedAndFavSee);
|
|
|
+ }
|
|
|
+ //是否开启自动生成素材
|
|
|
+ Integer creativeAutoGenerateSwitch = strategy.getCreativeAutoGenerateSwitch();
|
|
|
+ if(null!=creativeAutoGenerateSwitch&&creativeAutoGenerateSwitch!=1){
|
|
|
+ params.put("creative_auto_generate_switch",creativeAutoGenerateSwitch);
|
|
|
+ }
|
|
|
+ String appName = strategy.getCreativeAppName();
|
|
|
+ if(!Check.isNull(appName)){
|
|
|
+ params.put("app_name",appName);
|
|
|
+ }
|
|
|
+
|
|
|
+ String subTitle = strategy.getCreativeSubTitle();
|
|
|
+ if(!Check.isNull(subTitle)){
|
|
|
+ params.put("sub_title",subTitle);
|
|
|
+ }
|
|
|
+
|
|
|
+ String webUrl = strategy.getCreativeWebUrl();
|
|
|
+ if(!Check.isNull(webUrl)){
|
|
|
+ params.put("web_url",webUrl);
|
|
|
+ }
|
|
|
+
|
|
|
+ String actionText = strategy.getCreativeActionText();
|
|
|
+ if(!Check.isNull(actionText)){
|
|
|
+ params.put("action_text",actionText);
|
|
|
+ }
|
|
|
+
|
|
|
+ String playableUrl = strategy.getCreativePlayableUrl();
|
|
|
+ if(!Check.isNull(playableUrl)){
|
|
|
+ params.put("playable_url",playableUrl);
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer isCommentDisable = strategy.getCreativeIsCommentDisable();
|
|
|
+ if(!Check.isNull(isCommentDisable)&&isCommentDisable!=0){
|
|
|
+ params.put("is_comment_disable",appName);
|
|
|
+ }
|
|
|
+ String creativeDisplayMode = strategy.getCreativeDisplayMode();
|
|
|
+ if(!Check.isNull(creativeDisplayMode)){
|
|
|
+ params.put("creative_display_mode",creativeDisplayMode);
|
|
|
+ }
|
|
|
+// 允许客户端下载视频功能
|
|
|
+// Integer adDownloadStatus = strategy.getCreativeAdDownloadStatus();
|
|
|
+// if(!Check.isNull(adDownloadStatus)&&adDownloadStatus!=0){
|
|
|
+// params.put("ad_download_status",adDownloadStatus);
|
|
|
+// }
|
|
|
+ //商品推广卡片
|
|
|
+
|
|
|
+ return params;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IBytedanceVideoSlogenInfoService slogenInfoService;
|
|
|
+ private String getSuggestImageId(CtopOauthToken token, String vid) {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ private Long createAdInfo(CtopOauthToken token, AiBytedanceAdvertiserStrategy strategy, JSONObject adParams) {
|
|
|
+ Result result = Marketing.createAdvertiserPlan(token,adParams,strategy);
|
|
|
+ if(result.getCode()!=200){
|
|
|
+ //TODO 计划创建异常 后续需要加日志
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return (Long)result.getResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ private JSONObject getAdParams(AiBytedanceAdvertiserStrategy strategy, String adName, Long campaignId) {
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ //公共参数
|
|
|
+ params.put("advertiser_id",strategy.getAccountId());
|
|
|
+ params.put("campaign_id",campaignId);
|
|
|
+ params.put("name",adName);
|
|
|
+ //投放范围
|
|
|
+ params.put("delivery_range",strategy.getAdDeliveryRange());
|
|
|
+ if(!Check.isNull(strategy.getAdUnionVideoType())){
|
|
|
+ params.put("union_video_type",strategy.getAdUnionVideoType());
|
|
|
+ }
|
|
|
+ //投放目标
|
|
|
+ params.put("download_type",strategy.getAdDownloadType());
|
|
|
+ if(!Check.isNull(strategy.getAdDownloadUrl())){
|
|
|
+ params.put("download_url",strategy.getAdDownloadUrl());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdQuickAppUrl())){
|
|
|
+ params.put("quick_app_url",strategy.getAdQuickAppUrl());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdExternalUrl())){
|
|
|
+ params.put("external_url",strategy.getAdExternalUrl());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdAppType())){
|
|
|
+ params.put("app_type",strategy.getAdAppType());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdPackage())){
|
|
|
+ params.put("package",strategy.getAdPackage());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdDownloadMode())){
|
|
|
+ params.put("download_mode",strategy.getAdDownloadMode());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdConvertId())){
|
|
|
+ params.put("convert_id",strategy.getAdConvertId());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdOpenUrl())){
|
|
|
+ params.put("open_url",strategy.getAdOpenUrl());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdAdvancedCreativeType())){
|
|
|
+ params.put("advanced_creative_type",strategy.getAdAdvancedCreativeType());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdGamePackageDesc())){
|
|
|
+ params.put("game_package_desc",strategy.getAdGamePackageDesc());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdGamePackageBatchId())){
|
|
|
+ params.put("game_package_batch_id",strategy.getAdGamePackageBatchId());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdGamePackageThumbnailId())){
|
|
|
+ JSONArray ids = JSON.parseArray(strategy.getAdGamePackageThumbnailId());
|
|
|
+ if(null == ids&&!ids.isEmpty()){
|
|
|
+ params.put("game_package_thumbnail_ids",ids);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //用户定向
|
|
|
+ if(!Check.isNull(strategy.getAdAudiencePackageId())){
|
|
|
+ params.put("audience_package_id",strategy.getAdAudiencePackageId());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdDistrict())){
|
|
|
+ params.put("district",strategy.getAdDistrict());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdCity())){
|
|
|
+ JSONArray city = JSON.parseArray(strategy.getAdCity());
|
|
|
+ if(null == city&&!city.isEmpty()){
|
|
|
+ params.put("city",city);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdLocationType())){
|
|
|
+ params.put("location_type",strategy.getAdLocationType());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdGender())){
|
|
|
+ params.put("gender",strategy.getAdGender());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdAge())){
|
|
|
+ JSONArray age = JSON.parseArray(strategy.getAdAge());
|
|
|
+ if(null!=age&&!age.isEmpty()){
|
|
|
+ params.put("age",age);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdRetargetingTagsInclude())){
|
|
|
+ JSONArray retargetingTagsInclude = JSON.parseArray(strategy.getAdRetargetingTagsInclude());
|
|
|
+ if(null!=retargetingTagsInclude&&!retargetingTagsInclude.isEmpty()){
|
|
|
+ params.put("retargeting_tags_include",retargetingTagsInclude);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdRetargetingTagsExclude())){
|
|
|
+ JSONArray getAdRetargetingTagsExclude = JSON.parseArray(strategy.getAdRetargetingTagsExclude());
|
|
|
+ if(null!=getAdRetargetingTagsExclude&&!getAdRetargetingTagsExclude.isEmpty()){
|
|
|
+ params.put("retargeting_tags_exclude",getAdRetargetingTagsExclude);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdInterestActionMode())){
|
|
|
+ params.put("interest_action_mode",strategy.getAdInterestActionMode());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdActionScene())){
|
|
|
+ JSONArray actionScene = JSON.parseArray(strategy.getAdActionScene());
|
|
|
+ if(null!=actionScene&&!actionScene.isEmpty()){
|
|
|
+ params.put("action_scene",actionScene);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdActionDays())){
|
|
|
+ params.put("action_days",strategy.getAdActionDays());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdActionCategories())){
|
|
|
+ JSONArray actionCategories = JSON.parseArray(strategy.getAdActionCategories());
|
|
|
+ if(null!=actionCategories&&!actionCategories.isEmpty()){
|
|
|
+ params.put("action_categories",actionCategories);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdActionWords())){
|
|
|
+ JSONArray actionWords = JSON.parseArray(strategy.getAdActionWords());
|
|
|
+ if(null!=actionWords&&!actionWords.isEmpty()){
|
|
|
+ params.put("action_words",actionWords);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdInterestCategories())){
|
|
|
+ JSONArray interestCategories = JSON.parseArray(strategy.getAdInterestCategories());
|
|
|
+ if(null!=interestCategories&&!interestCategories.isEmpty()){
|
|
|
+ params.put("interest_categories",interestCategories);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdInterestWords())){
|
|
|
+ JSONArray interestWords = JSON.parseArray(strategy.getAdInterestWords());
|
|
|
+ if(null!=interestWords&&!interestWords.isEmpty()){
|
|
|
+ params.put("interest_words",interestWords);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdAwemeFanBehaviors())){
|
|
|
+ JSONArray awemeFanBehaviors = JSON.parseArray(strategy.getAdAwemeFanBehaviors());
|
|
|
+ if(null!=awemeFanBehaviors&&!awemeFanBehaviors.isEmpty()){
|
|
|
+ params.put("aweme_fan_behaviors",awemeFanBehaviors);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdAwemeFanCategories())){
|
|
|
+ JSONArray awemeFanCategories = JSON.parseArray(strategy.getAdAwemeFanCategories());
|
|
|
+ if(null!=awemeFanCategories&&!awemeFanCategories.isEmpty()){
|
|
|
+ params.put("aweme_fan_categories",awemeFanCategories);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdAwemeFanAccounts())){
|
|
|
+ JSONArray awemeFanAccount = JSON.parseArray(strategy.getAdAwemeFanAccounts());
|
|
|
+ if(null!=awemeFanAccount&&!awemeFanAccount.isEmpty()){
|
|
|
+ params.put("aweme_fan_accounts",awemeFanAccount);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdAwemeFansNumbers())){
|
|
|
+ JSONArray awemeFansNumbers = JSON.parseArray(strategy.getAdAwemeFansNumbers());
|
|
|
+ if(null!=awemeFansNumbers&&!awemeFansNumbers.isEmpty()){
|
|
|
+ params.put("aweme_fans_numbers",awemeFansNumbers);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdFilterAwemeAbnormalActive())){
|
|
|
+ params.put("filter_aweme_abnormal_active",strategy.getAdFilterAwemeAbnormalActive());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdFilterAwemeFansCount())){
|
|
|
+ params.put("filter_aweme_fans_count",strategy.getAdFilterAwemeFansCount());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdFilterOwnAwemeFans())){
|
|
|
+ params.put("filter_own_aweme_fans",strategy.getAdFilterOwnAwemeFans());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdSuperiorPopularityType())){
|
|
|
+ params.put("superior_popularity_type",strategy.getAdSuperiorPopularityType());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdFlowPackage())){
|
|
|
+ JSONArray flowPackage = JSON.parseArray(strategy.getAdFlowPackage());
|
|
|
+ if(null!=flowPackage&&!flowPackage.isEmpty()){
|
|
|
+ params.put("flow_package",flowPackage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdExcludeFlowPackage())){
|
|
|
+ JSONArray excludeFlowPackage = JSON.parseArray(strategy.getAdExcludeFlowPackage());
|
|
|
+ if(null!=excludeFlowPackage&&!excludeFlowPackage.isEmpty()){
|
|
|
+ params.put("exclude_flow_package",excludeFlowPackage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdPlatform())){
|
|
|
+ JSONArray platform = JSON.parseArray(strategy.getAdPlatform());
|
|
|
+ if(null!=platform&&!platform.isEmpty()){
|
|
|
+ params.put("platform",platform);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!Check.isNull(strategy.getAdAndroidOsv())){
|
|
|
+ params.put("android_osv",strategy.getAdAndroidOsv());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!Check.isNull(strategy.getAdAdIosOsv())){
|
|
|
+ params.put("ios_osv",strategy.getAdAdIosOsv());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdAc())){
|
|
|
+ JSONArray ac = JSON.parseArray(strategy.getAdAc());
|
|
|
+ if(null!=ac&&!ac.isEmpty()){
|
|
|
+ params.put("ac",ac);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdCarrier())){
|
|
|
+ JSONArray carrier = JSON.parseArray(strategy.getAdCarrier());
|
|
|
+ if(null!=carrier&&!carrier.isEmpty()){
|
|
|
+ params.put("carrier",carrier);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdDeviceType())){
|
|
|
+ JSONArray deviceType = JSON.parseArray(strategy.getAdDeviceType());
|
|
|
+ if(null!=deviceType&&!deviceType.isEmpty()){
|
|
|
+ params.put("device_type",deviceType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!Check.isNull(strategy.getAdHideIfExists())){
|
|
|
+ params.put("hide_if_exists",strategy.getAdHideIfExists());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdConvertedTimeDuration())){
|
|
|
+ params.put("converted_time_duration",strategy.getAdConvertedTimeDuration());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdHideIfConverted())){
|
|
|
+ params.put("hide_if_converted",strategy.getAdHideIfConverted());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!Check.isNull(strategy.getAdActivateType())){
|
|
|
+ JSONArray activateType = JSON.parseArray(strategy.getAdActivateType());
|
|
|
+ if(null!=activateType&&!activateType.isEmpty()){
|
|
|
+ params.put("activate_type",activateType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdArticleCategory())){
|
|
|
+ JSONArray articleCategory = JSON.parseArray(strategy.getAdArticleCategory());
|
|
|
+ if(null!=articleCategory&&!articleCategory.isEmpty()){
|
|
|
+ params.put("article_category",articleCategory);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdDeviceBrand())){
|
|
|
+ JSONArray deviceBrand = JSON.parseArray(strategy.getAdDeviceBrand());
|
|
|
+ if(null!=deviceBrand&&!deviceBrand.isEmpty()){
|
|
|
+ params.put("device_brand",deviceBrand);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdLaunchPrice())){
|
|
|
+ JSONArray launchPrice = JSON.parseArray(strategy.getAdLaunchPrice());
|
|
|
+ if(null!=launchPrice&&!launchPrice.isEmpty()){
|
|
|
+ params.put("launch_price",launchPrice);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdAutoExtendEnabled())){
|
|
|
+ params.put("auto_extend_enabled",strategy.getAdAutoExtendEnabled());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdAutoExtendTargets())){
|
|
|
+ JSONArray autoExtendTargets = JSON.parseArray(strategy.getAdAutoExtendTargets());
|
|
|
+ if(null!=autoExtendTargets&&!autoExtendTargets.isEmpty()){
|
|
|
+ params.put("auto_extend_targets",autoExtendTargets);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //预算与出价
|
|
|
+ if(!Check.isNull(strategy.getAdSmartBidType())){
|
|
|
+ params.put("smart_bid_type",strategy.getAdSmartBidType());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdAdjustCpa())){
|
|
|
+ params.put("adjust_cpa",strategy.getAdAdjustCpa());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdFlowControlMode())){
|
|
|
+ params.put("flow_control_mode",strategy.getAdFlowControlMode());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdBudgetMode())){
|
|
|
+ params.put("budget_mode",strategy.getAdBudgetMode());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdBudget())){
|
|
|
+ params.put("budget",strategy.getAdBudget());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdScheduleType())){
|
|
|
+ params.put("schedule_type",strategy.getAdScheduleType());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdStartTime())){
|
|
|
+ params.put("start_time",strategy.getAdStartTime());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdAdjustCpa())){
|
|
|
+ params.put("end_time",strategy.getAdEndTime());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdScheduleTime())){
|
|
|
+ params.put("schedule_time",strategy.getAdScheduleTime());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdPricing())){
|
|
|
+ params.put("pricing",strategy.getAdPricing());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdBid())){
|
|
|
+ params.put("bid",strategy.getAdBid());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdCpaBid())){
|
|
|
+ params.put("cpa_bid",strategy.getAdCpaBid());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdDeepBidType())){
|
|
|
+ params.put("deep_bid_type",strategy.getAdDeepBidType());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdDeepCpabid())){
|
|
|
+ params.put("deep_cpabid",strategy.getAdDeepCpabid());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdLubanRoiGoal())){
|
|
|
+ params.put("luban_roi_goal",strategy.getAdLubanRoiGoal());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getAdRoiGoal())){
|
|
|
+ params.put("roi_goal",strategy.getAdRoiGoal());
|
|
|
+ }
|
|
|
+ return params;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getAdName(AiBytedanceAdvertiserStrategy strategy, String dplinkCode, ByteDanceVideoInfo videoInfo) {
|
|
|
+ String adName = strategy.getAdName();
|
|
|
+ if(null == adName||adName.trim().equals("")){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ if(adName.contains("{{日期}}")){
|
|
|
+ String date = DateUtils.formatDate(new Date(),"yyyyMMdd");
|
|
|
+ adName.replace("{{日期}}",date);
|
|
|
+ }
|
|
|
+ if(adName.contains("{{dp链接标识}}")){
|
|
|
+ adName.replace("{{dp链接标识}}",dplinkCode);
|
|
|
+ }
|
|
|
+ if(adName.contains("{{出价方式}}")){
|
|
|
+ String pricing = strategy.getAdPricing().replace("PRICING_","");
|
|
|
+ adName.replace("{{出价方式}}",pricing);
|
|
|
+ }
|
|
|
+ if(adName.contains("{{素材名称}}")){
|
|
|
+ MaterialInfo info = materialInfoService.getParams(videoInfo.getSignature(),1);
|
|
|
+ adName.replace("{{素材名称}}",info.getMaterialName());
|
|
|
+ }
|
|
|
+ return adName;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IMaterialInfoService materialInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IByteDanceCampaignService campaignService;
|
|
|
+ private Long getCampaignId(AiBytedanceAdvertiserStrategy strategy, String campaignName,CtopOauthToken token) {
|
|
|
+ ByteDanceCampaign campaign = campaignService.getOneByParams(strategy.getAccountId(),campaignName);
|
|
|
+ if(null != campaign){
|
|
|
+ return campaign.getId();
|
|
|
+ }
|
|
|
+ //创建组信息
|
|
|
+ JSONObject campaignParam = new JSONObject();
|
|
|
+ campaignParam.put("advertiser_id",strategy.getAccountId());
|
|
|
+ campaignParam.put("campaign_name",campaignName);
|
|
|
+ campaignParam.put("landing_type",strategy.getCampaignLandingType());
|
|
|
+
|
|
|
+ campaignParam.put("budget_mode",strategy.getCampaignBudgetMode());
|
|
|
+ //日预算必须设定预算金额
|
|
|
+ if(null!=strategy.getCampaignBudgetMode()&&strategy.getCampaignBudgetMode().equals("BUDGET_MODE_DAY")){
|
|
|
+ campaignParam.put("budget",strategy.getCampaignBudget());
|
|
|
+ }
|
|
|
+ if(!Check.isNull(strategy.getCampaignDeliveryRelatedNum())){
|
|
|
+ campaignParam.put("delivery_related_num",strategy.getCampaignDeliveryRelatedNum());
|
|
|
+ }
|
|
|
+ //创建组
|
|
|
+ Result campaignData = Marketing.createCampaign(token, campaignParam);
|
|
|
+ if(campaignData.getCode()!=200){
|
|
|
+ //TODO 组创建异常 后续需要加日志
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return (Long)campaignData.getResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getCampaignName(Long dpIndex, AiBytedanceAdvertiserStrategy strategy) {
|
|
|
+ //根据每个组的计划个数计算目前计划所属的组下标范围 比如 1 则下标范围为 1/50 56则下标范围为 51/100
|
|
|
+ String rangeIndex = getRangeIndex(strategy.getDpLinkStartIndex(),strategy.getDpLinkEndIndex(),strategy.getCampaignAdCnt(),dpIndex);
|
|
|
+ if(null == rangeIndex||rangeIndex.equals("")){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return strategy.getCampaignName()+rangeIndex;
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getRangeIndex(Long dpLinkStartIndex,Long dpLinkEndIndex, Long campaignAdCnt, Long dpIndex) {
|
|
|
+ if(dpIndex<dpLinkStartIndex||dpIndex>dpLinkEndIndex){
|
|
|
+ //超出下标范围
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Long startIndex ;
|
|
|
+ Long endIndex ;
|
|
|
+ //计算当前下标值和范围区段的余数
|
|
|
+ Long yzIndex = (dpIndex-dpLinkStartIndex+1)%campaignAdCnt;
|
|
|
+ if(yzIndex == 0){
|
|
|
+ startIndex = dpIndex-campaignAdCnt+1;
|
|
|
+ endIndex = dpIndex;
|
|
|
+ }else{
|
|
|
+ startIndex = dpIndex-yzIndex+1;
|
|
|
+ endIndex = dpIndex-yzIndex+campaignAdCnt;
|
|
|
+ }
|
|
|
+ return "-("+startIndex+"/"+endIndex+")";
|
|
|
+ }
|
|
|
+
|
|
|
@Autowired
|
|
|
private IAiBytedanceAdDplinkInfoService adDplinkInfoService;
|
|
|
@Autowired
|
|
@@ -121,7 +665,10 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String url = "taobaolite://m.ltao.com/open/index.html?action=ali.open.nav&module=h5&bootImage=0&source=toutiao&packageName=com.taobao.litetao&h5Url=https%3A%2F%2Fpages.tmall.com%2Fwow%2Fz%2Fsale%2FdynamicSolution%2Fsfbthp%3FdisableNav%3DYES%26wh_kangarooprefetch%3Dtrue%26needLogin%3Dtrue&bc_fl_src=sf_jrtt_huichuangzh_ptbt_{{dp链接下标}}&backurl=__back_url__";
|
|
|
+ System.out.println(StringUtils.getParamFromUrl(url,"bc_fl_src"));
|
|
|
+ }
|
|
|
/**
|
|
|
* 修改状态 (0开-1关)
|
|
|
* @param
|
|
@@ -150,7 +697,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
priceList.add(mapPrice);
|
|
|
|
|
|
// api 更新计划出价
|
|
|
- updResult = marketing.updatePlanBid(token,updAdStaOrCpaOrBudget.getAccountId(),priceList);
|
|
|
+ updResult = Marketing.updatePlanBid(token,updAdStaOrCpaOrBudget.getAccountId(),priceList);
|
|
|
if (!"200".equals(updResult.getCode())){
|
|
|
return Result.error(updResult.getMessage());
|
|
|
}
|
|
@@ -165,7 +712,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
mapPrice.put("budget",updAdStaOrCpaOrBudget.getBudget());
|
|
|
priceList.add(mapPrice);
|
|
|
// api 修改计划 预算
|
|
|
- updResult = marketing.updatePlanBudget(token,updAdStaOrCpaOrBudget.getAccountId(),priceList);
|
|
|
+ updResult = Marketing.updatePlanBudget(token,updAdStaOrCpaOrBudget.getAccountId(),priceList);
|
|
|
if (!"200".equals(updResult.getCode())){
|
|
|
return Result.error(updResult.getMessage());
|
|
|
}
|
|
@@ -195,7 +742,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
|
|
|
}
|
|
|
// 获取行业列表
|
|
|
- Result industryList = marketing.getToolIndustryList(token,type);
|
|
|
+ Result industryList = Marketing.getToolIndustryList(token,type);
|
|
|
log.error("行业列表=======>>>>>>>>>>>", industryList.getResult());
|
|
|
return Result.successMsg("获取行业列表成功。", industryList.getResult());
|
|
|
}
|
|
@@ -221,7 +768,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
|
|
|
}
|
|
|
// 获取广告组
|
|
|
- Result industryList = marketing.getCampaignGroupList(token,accountId,adGroupSearchVoList,pageNo,pageSize);
|
|
|
+ Result industryList = Marketing.getCampaignGroupList(token,accountId,adGroupSearchVoList,pageNo,pageSize);
|
|
|
log.error("获取广告组=======>>>>>>>>>>>", industryList.getResult());
|
|
|
return Result.successMsg("获取广告组成功。", industryList.getResult());
|
|
|
}
|
|
@@ -247,7 +794,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
|
|
|
}
|
|
|
// 获取计划
|
|
|
- Result industryList = marketing.getPlanList(token,adGroupSearchVoList,pageNo,pageSize);
|
|
|
+ Result industryList = Marketing.getPlanList(token,adGroupSearchVoList,pageNo,pageSize);
|
|
|
log.error("获取广告计划=======>>>>>>>>>>>", industryList.getResult());
|
|
|
return Result.successMsg("获取广告计划成功。", industryList.getResult());
|
|
|
}
|
|
@@ -268,51 +815,10 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
|
|
|
}
|
|
|
// 获取 创意详细信息
|
|
|
- Result industryList = marketing.creativeRead(token,accountId,adId);
|
|
|
+ Result industryList = Marketing.creativeRead(token,accountId,adId);
|
|
|
log.error("获取创意详细信息=======>>>>>>>>>>>", industryList.getResult());
|
|
|
return Result.successMsg("获取创意详细信息成功。", industryList.getResult());
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /**
|
|
|
- * 创建 广告 组-计划-创意
|
|
|
- * @param strategy
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Result createADCreative(AiBytedanceAdvertiserStrategy strategy) {
|
|
|
- CtopOauthToken token = tokenService.getOauthTokenByAccountId(strategy.getAccountId()+"");
|
|
|
- if (null == token) {
|
|
|
- log.info("token获取失败=>accountId:{}", token.getAccountId());
|
|
|
- return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
|
|
|
- }
|
|
|
- // 1:创建广告组
|
|
|
- Result resultCampaign = marketing.createCampaign(token,
|
|
|
- strategy.getCampaignName(),
|
|
|
- strategy.getAdBudgetMode() == null ? BytedanceConstant.BUDGET_MODE_INFINITE : strategy.getAdBudgetMode(),
|
|
|
- strategy.getAdBudget(),
|
|
|
- strategy.getCampaignLandingType());
|
|
|
- //广告组id
|
|
|
- Long campaignId = (Long) resultCampaign.getResult();
|
|
|
- // 2:创建广告计划
|
|
|
- Result resultPlan = marketing.createAdvertiserPlan(token,campaignId,strategy);
|
|
|
- //计划id
|
|
|
- Long planId = (Long) resultPlan.getResult();
|
|
|
- //3:创建创意
|
|
|
- Result creativeInfo = marketing.creativeCreate(token, planId, strategy);
|
|
|
-
|
|
|
- log.error("创意创建=======>>>>>>>>>>>", creativeInfo.getResult());
|
|
|
- //数据入库
|
|
|
- aiBytedanceAdvertiserStrategyMapper.insert(strategy);
|
|
|
- return Result.successMsg("创建成功", strategy);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
*
|
|
|
* @description: 修改 广告 组-计划-创意
|
|
@@ -329,17 +835,17 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
|
|
|
}
|
|
|
// 1:修改广告组
|
|
|
- Result resultCampaign = marketing.updateCampaign(token,
|
|
|
+ Result resultCampaign = Marketing.updateCampaign(token,
|
|
|
"广告组id",groupModifyTime,
|
|
|
strategy.getCampaignName(),strategy.getCampaignBudgetMode(),strategy.getCampaignLandingType());
|
|
|
//广告组id
|
|
|
Long campaignId = (Long) resultCampaign.getResult();
|
|
|
// 2:修改广告计划
|
|
|
- Result resultPlan = marketing.updateAdvertiserPlan(token,"计划id",planModifyTime,strategy);
|
|
|
+ Result resultPlan = Marketing.updateAdvertiserPlan(token,"计划id",planModifyTime,strategy);
|
|
|
//计划id
|
|
|
Object planId = resultPlan.getResult();
|
|
|
//3:修改创意 TODO 拼接创意参数
|
|
|
- Result creativeInfo = marketing.creativeUpdate(token, "计划id","创意时间戳",null);
|
|
|
+ Result creativeInfo = Marketing.creativeUpdate(token, "计划id","创意时间戳",null);
|
|
|
//数据修改
|
|
|
aiBytedanceAdvertiserStrategyMapper.updateById(strategy);
|
|
|
return Result.successMsg("修改成功", strategy);
|
|
@@ -360,7 +866,7 @@ public class AiBytedanceAdvertiserStrategyServiceImpl extends ServiceImpl<AiByte
|
|
|
log.info("token获取失败=>accountId:{}", token.getAccountId());
|
|
|
return Result.error("token获取失败====>>>>accountId:"+token.getAccountId());
|
|
|
}
|
|
|
- Result resultCampaign = marketing.getToolConvertQuery(token,adConvertQueryVo);
|
|
|
+ Result resultCampaign = Marketing.getToolConvertQuery(token,adConvertQueryVo);
|
|
|
return Result.successMsg("查询广告计划可用转化目标成功。", resultCampaign.getResult());
|
|
|
}
|
|
|
|