فهرست منبع

渠道号。。。修改bug

zhaoxian 3 سال پیش
والد
کامیت
393cd2f288

+ 17 - 18
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java

@@ -150,7 +150,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             log.info("账户:{},{} 到 {} 未获取到相应素材({})", accountId, startTime, endTime, replaceString);
                             continue;
                         }
-                        Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo.getAppId(), strategyUuid);
+                        Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo.getAppId(), strategyUuid, null);
                         for (KuaiShouVideoGet videoItem : allVideos) {
                             Boolean unitOverrun = getUnitOverrun(accountId);
                             if (unitOverrun) {
@@ -242,7 +242,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             log.info("该账户创意创建已超限=>accountId:{}", accountId);
                             return 0L;
                         }
-                        Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
+                        Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, null);
                         //开始创建组+创意
                         String unitName = getName(strategy.getGroupName(), strategy, createType, videoItem.getPhotoName(), "unit", newCampaignId, appId, null);
                         JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, null);
@@ -302,7 +302,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     return videoCnt;
                 }
                 KuaiShouAppList appInfo = appListService.getAppInfo(accountId, appId);
-                if(!Check.isNull(appInfo)){
+                if (!Check.isNull(appInfo)) {
                     appName = appInfo.getAppName();
                 }
             }
@@ -312,7 +312,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
             KuaishouChannel channel = null;
             if (!Check.isNull(useChannel) && useChannel == 1 && ("account".equals(level) || "plan".equals(level))) {
                 try {
-                    Result<Object> result = channelService.queryChannel(accountId, level,appName);
+                    Result<Object> result = channelService.queryChannel(accountId, level, appName);
                     Integer code = result.getCode();
                     if (code == 200) {
                         channel = (KuaishouChannel) result.getResult();
@@ -329,7 +329,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     e.printStackTrace();
                 }
             }
-            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
+            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
             if (null == newCampaignId) {
                 return videoCnt;
             }
@@ -355,7 +355,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 //获取组级渠道号
                 if (!Check.isNull(useChannel) && useChannel == 1 && "group".equals(level)) {
                     try {
-                        Result<Object> result = channelService.queryChannel(accountId, level,appName);
+                        Result<Object> result = channelService.queryChannel(accountId, level, appName);
                         Integer code = result.getCode();
                         if (code == 200) {
                             channel = (KuaishouChannel) result.getResult();
@@ -490,7 +490,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             log.info("该账户创意创建已超限=>accountId:{}", accountId);
                             return;
                         }
-                        Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo.getAppId(), strategyUuid);
+                        Long newCampaignId = getCampaignId(strategy, token, replaceString, "ALL_CAMPAIGN", createType, appInfo.getAppId(), strategyUuid, null);
                         //创建组+创意
                         List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
                         for (int j = 1; j < splitVideos.size() + 1; j++) {
@@ -573,7 +573,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                             if (!Check.isNull(multipleBids.getTrackUrl())) {
                                 strategy.setClickTrackUrl(multipleBids.getTrackUrl());
                             }
-                            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
+                            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, null);
                             //创建组
                             String unitName = getName(strategy.getGroupName(), strategy, createType, videoGet.getPhotoName(), "unit", newCampaignId, appId, null);
                             JSONObject unitParams = createUnitParams(token, newCampaignId, strategy, unitName, appId, null);
@@ -632,22 +632,18 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                         return;
                     }
                     KuaiShouAppList appInfo = appListService.getAppInfo(accountId, appId);
-                    if(!Check.isNull(appInfo)){
+                    if (!Check.isNull(appInfo)) {
                         appName = appInfo.getAppName();
                     }
                 }
             }
-            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
-            if (null == newCampaignId) {
-                return;
-            }
             //渠道号应用层级,account-账户,plan-计划,group-组
             String level = strategy.getUsageLevel();
             Integer useChannel = strategy.getUseChannel();//0不使用,1使用
             KuaishouChannel channel = null;
             if (!Check.isNull(useChannel) && useChannel == 1 && ("account".equals(level) || "plan".equals(level))) {
                 try {
-                    Result<Object> result = channelService.queryChannel(accountId, level,appName);
+                    Result<Object> result = channelService.queryChannel(accountId, level, appName);
                     Integer code = result.getCode();
                     if (code == 200) {
                         channel = (KuaishouChannel) result.getResult();
@@ -664,7 +660,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     e.printStackTrace();
                 }
             }
-
+            Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid, channel);
+            if (null == newCampaignId) {
+                return;
+            }
             //创意
             List<List<KuaiShouVideoGet>> splitVideos = Lists.partition(allVideos, 5);
             for (int j = 1; j < splitVideos.size() + 1; j++) {
@@ -685,7 +684,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 //获取组级渠道号
                 if (!Check.isNull(useChannel) && useChannel == 1 && "group".equals(level)) {
                     try {
-                        Result<Object> result = channelService.queryChannel(accountId, level,appName);
+                        Result<Object> result = channelService.queryChannel(accountId, level, appName);
                         Integer code = result.getCode();
                         if (code == 200) {
                             channel = (KuaishouChannel) result.getResult();
@@ -1045,7 +1044,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
     }
 
 
-    private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType, Integer createType, Long appId, String uuid) {
+    private Long getCampaignId(AiKuaishouAdvertiserStrategy strategy, CtopOauthToken token, String replaceString, String checkType, Integer createType, Long appId, String uuid, KuaishouChannel channel) {
         Long campaignId = null;
         if ("ALL_CAMPAIGN".equals(checkType)) {
             campaignId = campaignService.getCampaignIdByAccountAndName(strategy.getAccountId(), replaceString);
@@ -1060,7 +1059,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
         // 不存在“上新”计划,则创建一个计划
         JSONObject campaignParams = new JSONObject();
         campaignParams.put("advertiser_id", token.getAccountId());
-        String campaignName = getName(strategy.getCampaignName(), strategy, createType, null, "plan", null, appId, null);
+        String campaignName = getName(strategy.getCampaignName(), strategy, createType, null, "plan", null, appId, channel);
         campaignParams.put("campaign_name", campaignName);
         campaignParams.put("type", strategy.getCampaignType());
         if (null != strategy.getCampaignDayBudget() && strategy.getCampaignDayBudget() != 0) {

+ 7 - 3
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelMapper.xml

@@ -106,9 +106,13 @@
 
     <select id="channelNumberUsageDetailsListTotal" resultType="java.lang.Long">
         SELECT IFNULL(SUM(1), 0)
-        FROM ctop_kuaishou_channel
-        WHERE account_id = #{accountId}
-          AND channel_code = #{channelCode}
+        FROM ctop_kuaishou_channel_rel t3
+                 INNER JOIN ctop_kuaishou_channel t1
+                            ON t1.account_id = t3.account_id AND t1.channel_code = t3.channel_code
+                 LEFT JOIN ctop_user_allocation t2 ON t1.account_id = t2.account_id
+        WHERE t3.account_id = #{accountId}
+          AND t3.channel_code = #{channelCode}
+          AND t3.unit_id is not null
     </select>
 
     <select id="channelNumberUsageDetailsList" resultType="com.alibaba.fastjson.JSONObject">