Browse Source

修改代码逻辑

syh 4 năm trước cách đây
mục cha
commit
83254312e9

+ 56 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/enums/KuaishouCreativeAdsenceTypeEnum.java

@@ -0,0 +1,56 @@
+package cn.com.ctop.kuaishou.modules.ai.enums;
+
+/**
+ * @author syh
+ */
+public enum KuaishouCreativeAdsenceTypeEnum {
+    /**
+     * 快手广告组投放资源位置
+     */
+    KUAISHOU_CREATIVE_ADSENCE_TYPE_ENUM_SELECT(1,"优选"),
+    KUAISHOU_CREATIVE_ADSENCE_TYPE_ENUM_STICKY(3,"便利贴"),
+    KUAISHOU_CREATIVE_ADSENCE_TYPE_ENUM_ALLIANCE(5,"联盟"),
+    KUAISHOU_CREATIVE_ADSENCE_TYPE_ENUM_SCREEN(6,"上下滑"),
+    KUAISHOU_CREATIVE_ADSENCE_TYPE_ENUM_FEEDS(7,"信息流"),
+    KUAISHOU_CREATIVE_ADSENCE_TYPE_ENUM_ALLIANCE_SCENCE(10,"联盟场景");
+
+    /**
+     * 类型
+     */
+    private Integer type;
+    /**
+     * 名称
+     */
+    private String name;
+
+    KuaishouCreativeAdsenceTypeEnum(Integer type, String name) {
+        this.type = type;
+        this.name = name;
+    }
+
+    public static String getNameByType(Integer type) {
+        for (KuaishouCreativeAdsenceTypeEnum createTypeEnum : KuaishouCreativeAdsenceTypeEnum.values()) {
+            if (createTypeEnum.getType().equals(type)) {
+                return createTypeEnum.getName();
+            }
+        }
+        return "";
+    }
+
+
+    public Integer getType() {
+        return this.type;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public void setName(String value) {
+        this.name = value;
+    }
+}

+ 60 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/enums/KuaishouCreativeMatTypeEnum.java

@@ -0,0 +1,60 @@
+package cn.com.ctop.kuaishou.modules.ai.enums;
+
+/**
+ * @author syh
+ */
+public enum KuaishouCreativeMatTypeEnum {
+    /**
+     * 13 23 分别是历史遗漏素材,归类到上新素材中
+     * type字段 第一位创意创建方式,第二位素材获取方式
+     * 快手创意素材获取类型
+     */
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_NEW("41","自定义上新"),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_HIGH_quality("42","自定义高质量"),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_MISSING("43","自定义上新"),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_CUSTOM_HISTORY("44","自定义历史"),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_NEW("71","程序化上新"),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_HIGH_quality("72","程序化高质量"),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_MISSING("73","程序化上新"),
+    KUAISHOU_CREATIVE_MAT_TYPE_ENUM_PROGRAM_HISTORY("74","程序化历史"),;
+
+    /**
+     * 类型
+     */
+    private String type;
+    /**
+     * 名称
+     */
+    private String name;
+
+    KuaishouCreativeMatTypeEnum(String type, String name) {
+        this.type = type;
+        this.name = name;
+    }
+
+    public static String getNameByType(String type) {
+        for (KuaishouCreativeMatTypeEnum createTypeEnum : KuaishouCreativeMatTypeEnum.values()) {
+            if (createTypeEnum.getType().equals(type)) {
+                return createTypeEnum.getName();
+            }
+        }
+        return "";
+    }
+
+
+    public String getType() {
+        return this.type;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public void setName(String value) {
+        this.name = value;
+    }
+}

+ 19 - 5
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -12,7 +12,9 @@ import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaiShouAppInfo;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouAdvertiserStrategy;
 import cn.com.ctop.kuaishou.modules.ai.entity.AiKuaishouStrategyMapCreative;
 import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouAccountCreativeOverrunInfo;
+import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeAdsenceTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeCreateTypeEnum;
+import cn.com.ctop.kuaishou.modules.ai.enums.KuaishouCreativeMatTypeEnum;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouAppInfoService;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouCreateCreativeService;
 import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaishouStrategyMapCreativeService;
@@ -378,7 +380,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
 
     @Override
     public void customCreativeSupplement(AiKuaishouAdvertiserStrategy strategy,Integer hour) throws ParseException {
-        Long unitNum = strategy.getCustomUnitCnt()/20*hour;
+        Long unitNum = strategy.getCustomUnitCnt()*hour/20;
         log.info("当前时间内需要创建组总数:{}",unitNum);
         //查询当前账户创建自定义类型组数量
         int unitCreateCnt = groupService.queryToDayBuiltCount(strategy.getAccountId());
@@ -1059,7 +1061,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
      * @param strategy  账户id
      * @return
      */
-    private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy,Integer num) {
+    private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy,Integer num,Integer createType) {
         if(wildcard.contains("{{定向包}}")){
             String targetName = "";
         }
@@ -1080,15 +1082,27 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
         if(wildcard.contains("{{广告位置}}")){
             String adsence = getAdSenceByParams(strategy.getSceneId());
+            wildcard.replace("{{广告位置}}","-"+adsence+"-");
         }
         if(wildcard.contains("{{自定义}}")){
-            String targetName = "";
+            String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
+            wildcard.replace("{{自定义}}","-"+targetName+"-");
         }
         return wildcard;
     }
 
-    private String getAdSenceByParams(String sceneId) {
+    private String getAdSenceByParams(String sceneIdString) {
         String adsence = "";
-        return adsence;
+        if(null==sceneIdString||"".equals(sceneIdString)){
+            return adsence;
+        }
+        JSONArray sceneIdArray = JSON.parseArray(sceneIdString);
+        if(null == sceneIdArray||sceneIdArray.isEmpty()){
+            return adsence;
+        }
+        for (int i=0;i < sceneIdArray.size();i++){
+            adsence += KuaishouCreativeAdsenceTypeEnum.getNameByType(sceneIdArray.getInteger(i))+",";
+        }
+        return adsence.substring(0,adsence.length()-1);
     }
 }