Explorar el Código

添加名称通配符

syh hace 4 años
padre
commit
6a9e6ef840

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

@@ -649,12 +649,18 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         if (!Check.isNull(strategy.getDeepConversionBid())) {
             unitParams.put("deep_conversion_bid", strategy.getDeepConversionBid());
         }
-        //资源位置
+
         Integer sceneId = null;
         String scenceIdString = strategy.getSceneId();
         if (!Check.isNull(scenceIdString) && !Check.isNull(JSON.parseArray(scenceIdString))) {
-            sceneId = JSON.parseArray(strategy.getSceneId()).getInteger(0);
-            unitParams.put("scene_id", JSON.parseArray(strategy.getSceneId()));
+            JSONArray scenceArray =  JSON.parseArray(scenceIdString);
+            sceneId = scenceArray.getInteger(0);
+            //资源位置
+            if(unitType == 7){
+                //程序化
+                scenceArray = cleanPramgramErrorScence(scenceArray);
+            }
+            unitParams.put("scene_id", scenceArray);
         }
 
         //投放开始时间
@@ -806,6 +812,20 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         return unitParams;
     }
 
+    private JSONArray cleanPramgramErrorScence(JSONArray scenceArray) {
+        JSONArray result = new JSONArray();
+        if(null==scenceArray||scenceArray.isEmpty()){
+            return result;
+        }
+        for (int i=0;i<scenceArray.size();i++){
+            Integer senceId =scenceArray.getInteger(i);
+            if(senceId!=5&&senceId!=3){
+                result.add(senceId);
+            }
+        }
+        return result;
+    }
+
     /**
      * 获取定向包
      *
@@ -1038,8 +1058,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     private void createCreative(CtopOauthToken token, JSONObject creativeParams, Long campaignId, Long unitId,
                                 int creativeCnt, KuaiShouVideoGet videoGet) {
         creativeParams.put("creative_name", "自定义创意_" + creativeCnt);
-        Map<String, Object> creativeCreateResult = kuaishouInterfaceService.creativeCreate
-                (token.getAccessToken(), token.getAccountId(), creativeParams, 1);
+        Map<String, Object> creativeCreateResult = kuaishouInterfaceService.creativeCreate(token.getAccessToken(), token.getAccountId(), creativeParams, 1);
         Integer creativeCode = (Integer) creativeCreateResult.get("code");
         String creativeMessage = (String) creativeCreateResult.get("message");
         if (creativeCode != 0) {
@@ -1061,10 +1080,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
      * @param strategy  账户id
      * @return
      */
-    private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy,Integer num,Integer createType) {
-        if(wildcard.contains("{{定向包}}")){
-            String targetName = "";
-        }
+    private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy,Integer num,Integer createType,AiKuaiShouAppInfo appInfo) {
+//        if(wildcard.contains("{{定向包}}")){
+//            String targetName = "";
+//        }
         if(wildcard.contains("{{日期}}")){
             String date = DateUtils.getNowDate("yyyyMMddHHmmss");
             wildcard.replace("{{日期}}","-"+date+"-");
@@ -1074,7 +1093,11 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             wildcard.replace("{{下标号}}","-"+numString+"-");
         }
         if(wildcard.contains("{{应用包名}}")){
-            String targetName = "";
+            String appName = "";
+            if(null!=appInfo){
+                appName = appInfo.getAppName();
+            }
+            wildcard.replace("{{应用包名}}","-"+appName+"-");
         }
         if(wildcard.contains("{{创意制作方式}}")){
             String creatype = KuaishouCreativeCreateTypeEnum.getNameByType(strategy.getOpenProgramCreate());
@@ -1088,6 +1111,13 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             String targetName = KuaishouCreativeMatTypeEnum.getNameByType(strategy.getUnitType().toString()+createType.toString());
             wildcard.replace("{{自定义}}","-"+targetName+"-");
         }
+        wildcard = wildcard.replace("--","-");
+        if(wildcard.startsWith("-")){
+            wildcard = wildcard.substring(1,wildcard.length());
+        }
+        if(wildcard.endsWith("-")){
+            wildcard = wildcard.substring(0,wildcard.length()-1);
+        }
         return wildcard;
     }
 

+ 1 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouGroupServiceImpl.java

@@ -193,6 +193,7 @@ public class KuaiShouGroupServiceImpl extends ServiceImpl<KuaiShouGroupMapper, K
             return;
         }
         addGroupV2(accountId, details);
+        log.info("组数据入库成功=》id:{}",unitId);
     }