zhaoxian 3 éve
szülő
commit
dbb94668bb

+ 30 - 6
ruixuan-launch/src/main/java/com/ruixuan/launch/service/impl/KuaishouLaunchCampaignAutoStrategyServiceImpl.java

@@ -136,8 +136,11 @@ public class KuaishouLaunchCampaignAutoStrategyServiceImpl implements IKuaishouL
             JSONObject ocpx = ocpxActionArr.getJSONObject(i);
             Integer type = ocpx.getInteger("type");
             String cpaBids = ocpx.getString("cpaBid");
+            String[] cpaBidArr = new String[0];
             if (Check.isNotNull(cpaBids)) {
-                String[] cpaBidArr = cpaBids.split("/");
+                cpaBidArr = cpaBids.split("/");
+            }
+            if (cpaBidArr.length > 0) {
                 for (int j = 0; j < cpaBidArr.length; j++) {
                     String cpaBid = cpaBidArr[j];
                     strategyJson.put("cpaBid", cpaBid);
@@ -158,9 +161,24 @@ public class KuaishouLaunchCampaignAutoStrategyServiceImpl implements IKuaishouL
                         }
                     }
                 }
-            }
-
+            } else {
+                for (int k = 0; k < targetTemplate.size(); k++) {
+                    Long targetId = targetTemplate.getLong(k);
+                    KuaishouLaunchTargetTemplate template = kuaishouLaunchTargetTemplateService.selectKuaishouLaunchTargetTemplateById(targetId);
+                    String name = getName(strategyJson, targetId, type, null);
+                    strategyJson.put("unitName", name);
+                    strategyJson = kuaishouLaunchTargetTemplateService.getTargetJson(targetId, strategyJson);
+                    Long unitId = kuaishouLaunchGroupService.insertKuaishouLaunchGroup(strategyJson, token);
+                    if (unitId > 0) {
+                        String createCountKey = DateUtils.dateTime() + strategyJson.getLong("accountId") + strategyJson.getLong("id");
+                        getTimeRedisNumberValue(createCountKey);
+                        strategyJson.put("unitId", unitId);
+                        kuaishouLaunchCreativeService.insertKuaishouLaunchCreative(strategyJson, token);
+                        Thread.sleep(500);
 
+                    }
+                }
+            }
         }
         return 0L;
 
@@ -180,8 +198,12 @@ public class KuaishouLaunchCampaignAutoStrategyServiceImpl implements IKuaishouL
                 unitName = unitName.replace("-{{人群排除名}}-", "");
             } else {
                 unitName = unitName.replace("-{{定向包名}}-", template.getTargetName());
-                unitName = unitName.replace("-{{人群定向名}}-", template.getPopulationName());
-                unitName = unitName.replace("-{{人群排除名}}-", template.getExcludePopulationName());
+                if (Check.isNotNull(template.getPopulationName())) {
+                    unitName = unitName.replace("-{{人群定向名}}-", template.getPopulationName());
+                }
+                if (Check.isNotNull(template.getExcludePopulationName())) {
+                    unitName = unitName.replace("-{{人群排除名}}-", template.getExcludePopulationName());
+                }
             }
         }
 
@@ -195,7 +217,9 @@ public class KuaishouLaunchCampaignAutoStrategyServiceImpl implements IKuaishouL
             unitName = unitName.replace("-{{转化目标}}-", "推广ROI");
         }
 
-        unitName = unitName.replace("-{{出价}}-", cpaBid.divide(new BigDecimal("1000")).toString());
+        if (Check.isNotNull(cpaBid)) {
+            unitName = unitName.replace("-{{出价}}-", cpaBid.divide(new BigDecimal("1000")).toString());
+        }
         String date = DateUtils.dateTime();//yyyyMMdd
         unitName = unitName.replace("-{{日期}}-", date);
         //组序号,必填