浏览代码

广告计划广告组命名

liyuyi@c-top.com.cn 4 年之前
父节点
当前提交
69458d85ad

+ 25 - 13
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ads/service/impl/AiStrategyServiceImpl.java

@@ -95,8 +95,9 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
             JSONObject campaignParams = new JSONObject();
             JSONObject campaignParams = new JSONObject();
             campaignParams.put("advertiser_id",token.getAccountId());
             campaignParams.put("advertiser_id",token.getAccountId());
             Date campaignDate = new Date();
             Date campaignDate = new Date();
-            String timestamp = DateUtils.formatDate(campaignDate,"yyyyMMddHHmmss");
-            campaignParams.put("campaign_name",strategy.getStrategyName()+ timestamp);
+            String timestamp = DateUtils.formatDate(campaignDate,"yyyyMMdd");
+            String campaignName = "户14-上下滑&信息流" + "自定义01"+ "剪辑-低价-低价包邮-活动-年龄18岁以上-单出价-"+ timestamp;
+            campaignParams.put("campaign_name",campaignName);
             campaignParams.put("type",Integer.parseInt(strategy.getMarketingGoal()));
             campaignParams.put("type",Integer.parseInt(strategy.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);
@@ -115,7 +116,8 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
                     // 选择素材,创建创意
                     // 选择素材,创建创意
                     for(KuaiShouVideoGet videoItem: videoGets){
                     for(KuaiShouVideoGet videoItem: videoGets){
                         //拼装广告组参数
                         //拼装广告组参数
-                        JSONObject unitParams = createUnitParams(token,campaignId,strategy,item,timestamp,unitCnt);
+                        String unitName = campaignName + "-" + unitCnt;
+                        JSONObject unitParams = createUnitParams(token, campaignId, strategy, item, 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");
@@ -143,9 +145,11 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
                             createCreativeByImage(cutFrameList,orgFrameList,token,creativeParams,campaignId,unitId,strategy,videoItem,15,null);
                             createCreativeByImage(cutFrameList,orgFrameList,token,creativeParams,campaignId,unitId,strategy,videoItem,15,null);
                         }
                         }
                     }
                     }
+                    unitCnt ++;
                 }else{
                 }else{
                     //混搭素材逻辑
                     //混搭素材逻辑
-                    JSONObject unitParams = createUnitParams(token,campaignId,strategy,item,timestamp,unitCnt);
+                    String unitName = campaignName + "-" + unitCnt;
+                    JSONObject unitParams = createUnitParams(token, campaignId, strategy, item, 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");
@@ -176,6 +180,7 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
                             createCreativeByImage(cutFrameList,orgFrameList,token,creativeParams,campaignId,unitId,strategy,videoItem,1,null);
                             createCreativeByImage(cutFrameList,orgFrameList,token,creativeParams,campaignId,unitId,strategy,videoItem,1,null);
                         }
                         }
                     }
                     }
+                    unitCnt ++;
                 }
                 }
             }
             }
         }else if(scenes.equals(2)){
         }else if(scenes.equals(2)){
@@ -201,8 +206,9 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
             JSONObject campaignParams = new JSONObject();
             JSONObject campaignParams = new JSONObject();
             campaignParams.put("advertiser_id",token.getAccountId());
             campaignParams.put("advertiser_id",token.getAccountId());
             Date campaignDate = new Date();
             Date campaignDate = new Date();
-            String timestamp = DateUtils.formatDate(campaignDate,"yyyyMMddHHmmss");
-            campaignParams.put("campaign_name",strategy.getStrategyName()+ timestamp);
+            String timestamp = DateUtils.formatDate(campaignDate,"yyyyMMdd");
+            String campaignName = "户14-上下滑&信息流" + "通投01"+ "剪辑-低价-低价包邮-活动-年龄18岁以上-单出价-"+ timestamp;
+            campaignParams.put("campaign_name",campaignName);
             campaignParams.put("type",Integer.parseInt(strategy.getMarketingGoal()));
             campaignParams.put("type",Integer.parseInt(strategy.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);
@@ -217,6 +223,7 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
             // 8、根据定向和素材,两层循环 创建组和创意
             // 8、根据定向和素材,两层循环 创建组和创意
             for (AiKuaishouStrategyTargetBase item:getBases) {
             for (AiKuaishouStrategyTargetBase item:getBases) {
                 unitCnt++;
                 unitCnt++;
+                String unitName = campaignName + "-" + unitCnt;
                 if(null!=materialFixType&&materialFixType.trim().equals("single")){
                 if(null!=materialFixType&&materialFixType.trim().equals("single")){
                     // 策略定向拆分数据,写入数据库
                     // 策略定向拆分数据,写入数据库
                     AiKuaishouStrategyTargetUnion targetUnion = new AiKuaishouStrategyTargetUnion(strategyMiddle.getId(),item.getId(),item.getTargetContent());
                     AiKuaishouStrategyTargetUnion targetUnion = new AiKuaishouStrategyTargetUnion(strategyMiddle.getId(),item.getId(),item.getTargetContent());
@@ -224,7 +231,7 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
                     // 选择素材,创建创意
                     // 选择素材,创建创意
                     for(KuaiShouVideoGet videoItem: videoGets){
                     for(KuaiShouVideoGet videoItem: videoGets){
                         //拼装广告组参数
                         //拼装广告组参数
-                        JSONObject unitParams = createUnitParams(token,campaignId,strategy,strategyTemplate, item,timestamp,unitCnt);
+                        JSONObject unitParams = createUnitParams(token,campaignId,strategy,strategyTemplate, item,timestamp,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");
@@ -259,6 +266,8 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
                     // 选择素材,创建创意
                     // 选择素材,创建创意
                     for(KuaiShouVideoGet videoItem: videoGets){
                     for(KuaiShouVideoGet videoItem: videoGets){
                         //拼装广告组参数
                         //拼装广告组参数
+
+
                         JSONObject unitParams = createUnitParams(token,campaignId,strategy,strategyTemplate, item,timestamp,unitCnt);
                         JSONObject unitParams = createUnitParams(token,campaignId,strategy,strategyTemplate, item,timestamp,unitCnt);
                         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");
@@ -293,7 +302,10 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
 
 
     }
     }
 
 
-    private void createCreativeByImage(List<MaterialCutFrame> cutFrameList,List<MaterialImageInfo> orgFrameList,CtopOauthToken token,JSONObject creativeParams,Long campaignId,Long unitId,KuaishouStrategy strategy,KuaiShouVideoGet videoItem,int imageNumber,AiKuaishouStrategyTargetUnion targetUnion){
+    private void createCreativeByImage(List<MaterialCutFrame> cutFrameList,List<MaterialImageInfo> orgFrameList,
+                                       CtopOauthToken token,JSONObject creativeParams,
+                                       Long campaignId,Long unitId,KuaishouStrategy strategy,KuaiShouVideoGet videoItem,
+                                       int imageNumber,AiKuaishouStrategyTargetUnion targetUnion){
         int creativeCnt  = 1;
         int creativeCnt  = 1;
         if (null!=orgFrameList&&!orgFrameList.isEmpty()) {
         if (null!=orgFrameList&&!orgFrameList.isEmpty()) {
             for (int i = 0; i < orgFrameList.size(); i++) {
             for (int i = 0; i < orgFrameList.size(); i++) {
@@ -324,13 +336,13 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
         }
         }
     }
     }
 
 
-    private JSONObject createUnitParams(CtopOauthToken token, Long campaignId, KuaishouStrategy strategy, Long item, String timestamp, int unitCnt) {
+    private JSONObject createUnitParams(CtopOauthToken token, Long campaignId, KuaishouStrategy strategy, Long item,
+                                        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);
-        String uuid = UUID.randomUUID().toString();
-        unitParams.put("unit_name", strategy.getStrategyName() + "cpaBid-" + item.toString()+"-" + uuid + unitCnt);
+        unitParams.put("unit_name", unitName);
         unitParams.put("bid_type",10);
         unitParams.put("bid_type",10);
         unitParams.put("ocpx_action_type",180);
         unitParams.put("ocpx_action_type",180);
 
 
@@ -461,13 +473,13 @@ public class AiStrategyServiceImpl implements IAiStrategyService {
     }
     }
 
 
     private JSONObject createUnitParams(CtopOauthToken token,Long campaignId,KuaishouStrategy strategy,AiKuaishouStrategyTemplate strategyTemplate,
     private JSONObject createUnitParams(CtopOauthToken token,Long campaignId,KuaishouStrategy strategy,AiKuaishouStrategyTemplate strategyTemplate,
-                                        AiKuaishouStrategyTargetBase item,String timestamp,int unitCnt){
+                                        AiKuaishouStrategyTargetBase item,String timestamp,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);
         String uuid = UUID.randomUUID().toString();
         String uuid = UUID.randomUUID().toString();
-        unitParams.put("unit_name", strategy.getStrategyName() + item.getTargetType() + item.getTargetContent() + uuid + unitCnt);
+        unitParams.put("unit_name", unitName);
         unitParams.put("bid_type",10);
         unitParams.put("bid_type",10);
         unitParams.put("ocpx_action_type",180);
         unitParams.put("ocpx_action_type",180);