Pārlūkot izejas kodu

组名称加入素材名称(蒙蒙)

zhaoxian 4 gadi atpakaļ
vecāks
revīzija
47e0a96283

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

@@ -127,7 +127,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         unitCnt++;
                         //开始创建组+创意
                         String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
-                        String unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, timestamp, unitCnt);
+                        String unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, timestamp, unitCnt, videoItem.getPhotoName());
                         JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
                         Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                         Integer unitCode = (Integer) unitCreateResult.get("code");
@@ -185,7 +185,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 }
                 unitCnt++;
                 String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
-                String unitName = getName(strategy.getGroupName(), strategy, createType, null, timestamp, unitCnt);
+                String unitName = getName(strategy.getGroupName(), strategy, createType, null, timestamp, unitCnt, videoItem.getPhotoName());
 
                 Long appId = null;
                 if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
@@ -295,7 +295,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     for (int j = 1; j < splitVideos.size() + 1; j++) {
                         //创建组
                         String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
-                        String unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, timestamp, null);
+                        String unitName = getName(strategy.getGroupName(), strategy, createType, appInfo, timestamp, null, null);
                         JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appInfo.getAppId());
                         Map<String, Object> unitCreateResult = kuaishouInterfaceService.adUnitCreate(token.getAccessToken(), token.getAccountId(), unitParams, 1);
                         Integer unitCode = (Integer) unitCreateResult.get("code");
@@ -338,7 +338,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             for (int j = 1; j < splitVideos.size() + 1; j++) {
                 //创建组
                 String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
-                String unitName = getName(strategy.getGroupName(), strategy, createType, null, timestamp, null);
+                String unitName = getName(strategy.getGroupName(), strategy, createType, null, timestamp, null, null);
                 String appIdString = strategy.getAppIdArray();
                 Long appId = null;
                 if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
@@ -612,6 +612,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         }
     }
 
+
     private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType, Integer createType, AiKuaiShouAppInfo appInfo, String uuid) {
         //  JSONArray campaignList;
         String timestamp = DateUtils.formatDate(new Date(), "yyyyMMddHHmmss");
@@ -644,7 +645,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         // 不存在“上新”计划,则创建一个计划
         JSONObject campaignParams = new JSONObject();
         campaignParams.put("advertiser_id", token.getAccountId());
-        String campaignName = getName(strategy.getCampaignName(), strategy, createType, appInfo, timestamp, null);
+        String campaignName = getName(strategy.getCampaignName(), strategy, createType, appInfo, timestamp, null, null);
         campaignParams.put("campaign_name", campaignName);
         campaignParams.put("type", strategy.getCampaignType());
         if (null != strategy.getCampaignDayBudget() && strategy.getCampaignDayBudget() != 0) {
@@ -1186,7 +1187,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
      * @param strategy 账户id
      * @return
      */
-    private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy, Integer createType, AiKuaiShouAppInfo appInfo, String timestamp, Integer cnt) {
+    private String getName(String wildcard, AiKuaishouAdvertiserStrategy strategy, Integer createType, AiKuaiShouAppInfo appInfo, String timestamp, Integer cnt, String materialName) {
         if (wildcard.contains("{{应用包名}}")) {
             String appName = "";
             if (null != appInfo) {
@@ -1207,6 +1208,15 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             String adsence = getAdSenceByParams(strategy.getSceneId());
             wildcard = wildcard.replace("{{广告位置}}", adsence);
         }
+
+        if (wildcard.contains("{{素材名称}}")) {
+            if (Check.isNull(materialName)) {
+                wildcard = wildcard.replace("{{素材名称}}", "");
+            } else {
+                wildcard = wildcard.replace("{{素材名称}}", materialName);
+            }
+
+        }
         if (!wildcard.contains("{{自定义}}")) {
             wildcard = wildcard + "{{自定义}}";
         }