|
@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.entity.MaterialImageInfo;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.IMaterialCutFrameService;
|
|
import cn.com.ctop.common.module.service.IMaterialCutFrameService;
|
|
import cn.com.ctop.common.module.service.IMaterialImageInfoService;
|
|
import cn.com.ctop.common.module.service.IMaterialImageInfoService;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAccountTargetTemplate;
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyMapCreative;
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyMapCreative;
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouNewCreateCampaign;
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouNewCreateCampaign;
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouStrategyMapCreativeService;
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouStrategyMapCreativeService;
|
|
@@ -49,13 +50,8 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
|
|
private IKuaiShouMaterialUploadService materialUploadService;
|
|
private IKuaiShouMaterialUploadService materialUploadService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void kuaishouAiAdsNewMaterialCreativity() {
|
|
|
|
- //1、获取基本信息
|
|
|
|
- String filePath = "/ads/timing-task.json";
|
|
|
|
- JSONArray configJsonArray = JsonResourceUtil.getJsonArrFromResource(filePath);
|
|
|
|
- // 只跑一个账户的定时上新任务,怕多个账户在指定的时间内执行不完
|
|
|
|
- JSONObject configJson = configJsonArray.getJSONObject(0);
|
|
|
|
- Long accountId = configJson.getLong("accountId");
|
|
|
|
|
|
+ public void kuaishouAiAdsNewMaterialCreativity(AiKuaishouAccountTargetTemplate targetTemplate) {
|
|
|
|
+ Long accountId = targetTemplate.getAccountId();
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId.toString());
|
|
CtopOauthToken token = tokenService.getOauthTokenByAccountId(accountId.toString());
|
|
if(null == token){
|
|
if(null == token){
|
|
log.info("token获取失败=>accountId:{}",accountId);
|
|
log.info("token获取失败=>accountId:{}",accountId);
|
|
@@ -106,7 +102,7 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
|
|
campaignParams.put("advertiser_id",token.getAccountId());
|
|
campaignParams.put("advertiser_id",token.getAccountId());
|
|
String campaignName = "户14-上下滑&信息流" + "-素材上新-"+ "剪辑-低价-低价包邮-活动-年龄18岁以上-单出价-"+ timestamp;
|
|
String campaignName = "户14-上下滑&信息流" + "-素材上新-"+ "剪辑-低价-低价包邮-活动-年龄18岁以上-单出价-"+ timestamp;
|
|
campaignParams.put("campaign_name",campaignName);
|
|
campaignParams.put("campaign_name",campaignName);
|
|
- campaignParams.put("type",Integer.parseInt(configJson.getString("marketing_goal")));
|
|
|
|
|
|
+ campaignParams.put("type",Integer.parseInt(targetTemplate.getMarketingGoal()));
|
|
campaignParams.put("day_budget",0L);
|
|
campaignParams.put("day_budget",0L);
|
|
Map<String, Object> campaignCreateResult = kuaishouInterfaceService.campaignCreate(token.getAccessToken(), token.getAccountId(), campaignParams);
|
|
Map<String, Object> campaignCreateResult = kuaishouInterfaceService.campaignCreate(token.getAccessToken(), token.getAccountId(), campaignParams);
|
|
Integer code = (Integer) campaignCreateResult.get("code");
|
|
Integer code = (Integer) campaignCreateResult.get("code");
|
|
@@ -125,7 +121,7 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
|
|
for(KuaiShouVideoGet videoItem: newVideos){
|
|
for(KuaiShouVideoGet videoItem: newVideos){
|
|
unitCnt ++;
|
|
unitCnt ++;
|
|
unitName = unitName + "-" + unitCnt;
|
|
unitName = unitName + "-" + unitCnt;
|
|
- JSONObject unitParams = createUnitParams(token, newCampaignId, configJson, unitName);
|
|
|
|
|
|
+ JSONObject unitParams = createUnitParams(token, newCampaignId, targetTemplate, unitName);
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
|
|
Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams,1);
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
Integer unitCode = (Integer) unitCreateResult.get("code");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
String unitMessage = (String) unitCreateResult.get("message");
|
|
@@ -142,14 +138,14 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
|
|
log.info("未获取到视频封面=>videoSignature:{}",videoItem.getSignature());
|
|
log.info("未获取到视频封面=>videoSignature:{}",videoItem.getSignature());
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- JSONObject creativeParams = creativeParams(token, unitId, videoItem, configJson);
|
|
|
|
- createCreativeByImage(cutFrameList, orgFrameList,token, creativeParams, newCampaignId, unitId, videoItem,5);
|
|
|
|
|
|
+ JSONObject creativeParams = creativeParams(token, unitId, videoItem, targetTemplate);
|
|
|
|
+ createCreativeByImage(cutFrameList, orgFrameList,token, creativeParams, newCampaignId, unitId, videoItem,targetTemplate.getImageNumber());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- private JSONObject creativeParams(CtopOauthToken token,Long unitId,KuaiShouVideoGet videoItem,JSONObject configJson){
|
|
|
|
|
|
+ private JSONObject creativeParams(CtopOauthToken token,Long unitId,KuaiShouVideoGet videoItem,AiKuaishouAccountTargetTemplate targetTemplate){
|
|
JSONObject creativeParams = new JSONObject();
|
|
JSONObject creativeParams = new JSONObject();
|
|
creativeParams.put("advertiser_id",token.getAccountId());
|
|
creativeParams.put("advertiser_id",token.getAccountId());
|
|
creativeParams.put("unit_id",unitId);
|
|
creativeParams.put("unit_id",unitId);
|
|
@@ -158,7 +154,7 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
|
|
creativeParams.put("action_bar_text","下载抢购");
|
|
creativeParams.put("action_bar_text","下载抢购");
|
|
creativeParams.put("description","不买亏大了!众多商品低至一元!看看你多花了多少冤枉钱!");
|
|
creativeParams.put("description","不买亏大了!众多商品低至一元!看看你多花了多少冤枉钱!");
|
|
// 安卓下载中间页ID
|
|
// 安卓下载中间页ID
|
|
- JSONArray siteIdArray = JSONArray.parseArray(configJson.getString("site_id"));
|
|
|
|
|
|
+ JSONArray siteIdArray = JSONArray.parseArray(targetTemplate.getSiteId());
|
|
if(null == siteIdArray||!siteIdArray.isEmpty()){
|
|
if(null == siteIdArray||!siteIdArray.isEmpty()){
|
|
JSONObject siteObject = siteIdArray.getJSONObject(0);
|
|
JSONObject siteObject = siteIdArray.getJSONObject(0);
|
|
Long appId = siteObject.getLong("appId");
|
|
Long appId = siteObject.getLong("appId");
|
|
@@ -167,14 +163,14 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
|
|
creativeParams.put("site_id",siteId);
|
|
creativeParams.put("site_id",siteId);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(null != configJson.getString("click_track_url")&&!"".equals(configJson.getString("click_track_url"))){
|
|
|
|
- creativeParams.put("click_track_url",configJson.getString("click_track_url"));
|
|
|
|
|
|
+ if(null != targetTemplate.getClickTrackUrl()&&!"".equals(targetTemplate.getClickTrackUrl())){
|
|
|
|
+ creativeParams.put("click_track_url",targetTemplate.getClickTrackUrl());
|
|
}
|
|
}
|
|
- if(null != configJson.getString("impression_url")&&!"".equals(configJson.getString("impression_url"))){
|
|
|
|
- creativeParams.put("impression_url",configJson.getString("impression_url"));
|
|
|
|
|
|
+ if(null != targetTemplate.getImpressionUrl()&&!"".equals(targetTemplate.getImpressionUrl())){
|
|
|
|
+ creativeParams.put("impression_url",targetTemplate.getImpressionUrl());
|
|
}
|
|
}
|
|
- if(null != configJson.getString("actionbar_click_url")&&!"".equals(configJson.getString("actionbar_click_url"))){
|
|
|
|
- creativeParams.put("actionbar_click_url",configJson.getString("actionbar_click_url"));
|
|
|
|
|
|
+ if(null != targetTemplate.getActionbarClickUrl()&&!"".equals(targetTemplate.getActionbarClickUrl())){
|
|
|
|
+ creativeParams.put("actionbar_click_url",targetTemplate.getActionbarClickUrl());
|
|
}
|
|
}
|
|
return creativeParams;
|
|
return creativeParams;
|
|
}
|
|
}
|
|
@@ -202,32 +198,32 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- private JSONObject createUnitParams(CtopOauthToken token, Long campaignId, JSONObject configJson,
|
|
|
|
|
|
+ private JSONObject createUnitParams(CtopOauthToken token, Long campaignId, AiKuaishouAccountTargetTemplate targetTemplate,
|
|
String unitName) {
|
|
String unitName) {
|
|
// 拼装创建组的入参 json
|
|
// 拼装创建组的入参 json
|
|
JSONObject unitParams = new JSONObject();
|
|
JSONObject unitParams = new JSONObject();
|
|
unitParams.put("advertiser_id",token.getAccountId());
|
|
unitParams.put("advertiser_id",token.getAccountId());
|
|
unitParams.put("campaign_id",campaignId);
|
|
unitParams.put("campaign_id",campaignId);
|
|
unitParams.put("unit_name", unitName);
|
|
unitParams.put("unit_name", unitName);
|
|
- unitParams.put("bid_type",configJson.getIntValue("bid_type"));
|
|
|
|
- unitParams.put("ocpx_action_type",configJson.getIntValue("ocpx_action_type"));
|
|
|
|
|
|
+ unitParams.put("bid_type",targetTemplate.getBidType());
|
|
|
|
+ unitParams.put("ocpx_action_type",targetTemplate.getOcpxActionType());
|
|
|
|
|
|
- if(null!=configJson.getString("use_app_market")&&!"".equals(configJson.getString("use_app_market"))){
|
|
|
|
- unitParams.put("use_app_market",Integer.parseInt(configJson.getString("use_app_market")));
|
|
|
|
|
|
+ if(null!=targetTemplate.getUseAppMarket()&&!"".equals(targetTemplate.getUseAppMarket())){
|
|
|
|
+ unitParams.put("use_app_market",Integer.parseInt(targetTemplate.getUseAppMarket()));
|
|
}
|
|
}
|
|
- if(null!=configJson.getString("app_store")&&!"".equals(configJson.getString("app_store"))){
|
|
|
|
- unitParams.put("app_store",JSONArray.parseArray(configJson.getString("app_store")));
|
|
|
|
|
|
+ if(null!=targetTemplate.getAppStore()&&!"".equals(targetTemplate.getAppStore())){
|
|
|
|
+ unitParams.put("app_store",JSONArray.parseArray(targetTemplate.getAppStore()));
|
|
}
|
|
}
|
|
|
|
|
|
// 在本策略中,都是 OCPM 的出价方式
|
|
// 在本策略中,都是 OCPM 的出价方式
|
|
- unitParams.put("cpa_bid",configJson.getIntValue("cpa_bid"));
|
|
|
|
- unitParams.put("scene_id",JSONArray.parseArray(configJson.getString("scene_id")));
|
|
|
|
|
|
+ unitParams.put("cpa_bid",targetTemplate.getCpaBid());
|
|
|
|
+ unitParams.put("scene_id",JSONArray.parseArray(targetTemplate.getSceneId()));
|
|
unitParams.put("unit_type",4);
|
|
unitParams.put("unit_type",4);
|
|
|
|
|
|
// 格式为yyyy-MM-dd,需大于等于当前时间
|
|
// 格式为yyyy-MM-dd,需大于等于当前时间
|
|
unitParams.put("begin_time",DateUtils.formatDate(new Date()));
|
|
unitParams.put("begin_time",DateUtils.formatDate(new Date()));
|
|
|
|
|
|
- JSONArray appIds = JSONArray.parseArray(configJson.getString("app_ids"));
|
|
|
|
|
|
+ JSONArray appIds = JSONArray.parseArray(targetTemplate.getAppIds());
|
|
if(null!=appIds&&!appIds.isEmpty()){
|
|
if(null!=appIds&&!appIds.isEmpty()){
|
|
unitParams.put("app_id",appIds.getLong(0));
|
|
unitParams.put("app_id",appIds.getLong(0));
|
|
}
|
|
}
|
|
@@ -236,15 +232,15 @@ public class AiKuaishouNewCreateCampaignServiceImpl implements IAiKuaishouNewCre
|
|
|
|
|
|
// 设置定向内容
|
|
// 设置定向内容
|
|
JSONObject targetJsonObject = new JSONObject();
|
|
JSONObject targetJsonObject = new JSONObject();
|
|
- targetJsonObject.put("region",JSONArray.parseArray(configJson.getString("region")));
|
|
|
|
- targetJsonObject.put("ages_range",JSONArray.parseArray(configJson.getString("ages_range")));
|
|
|
|
- targetJsonObject.put("gender",configJson.getIntValue("gender"));
|
|
|
|
- targetJsonObject.put("platform_os",configJson.getIntValue("platform_os"));
|
|
|
|
- JSONArray population = JSONArray.parseArray(configJson.getString("population"));
|
|
|
|
|
|
+ targetJsonObject.put("region",JSONArray.parseArray(targetTemplate.getRegion()));
|
|
|
|
+ targetJsonObject.put("ages_range",JSONArray.parseArray(targetTemplate.getAgesRange()));
|
|
|
|
+ targetJsonObject.put("gender",targetTemplate.getGender());
|
|
|
|
+ targetJsonObject.put("platform_os",targetTemplate.getPlatformOs());
|
|
|
|
+ JSONArray population = JSONArray.parseArray(targetTemplate.getPopulation());
|
|
if(null!=population&&!population.isEmpty()){
|
|
if(null!=population&&!population.isEmpty()){
|
|
targetJsonObject.put("population",population);
|
|
targetJsonObject.put("population",population);
|
|
}
|
|
}
|
|
- JSONArray excludePopulation = JSONArray.parseArray(configJson.getString("exclude_population"));
|
|
|
|
|
|
+ JSONArray excludePopulation = JSONArray.parseArray(targetTemplate.getExcludePopulation());
|
|
if(null!=excludePopulation&&!excludePopulation.isEmpty()){
|
|
if(null!=excludePopulation&&!excludePopulation.isEmpty()){
|
|
targetJsonObject.put("exclude_population",excludePopulation);
|
|
targetJsonObject.put("exclude_population",excludePopulation);
|
|
}
|
|
}
|