Ver código fonte

渠道号。。。修改bug

zhaoxian 4 anos atrás
pai
commit
a8216a46f2
15 arquivos alterados com 125 adições e 141 exclusões
  1. 14 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/ai/service/impl/AiKuaishouCreateCreativeServiceImpl.java
  2. 30 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouAppListController.java
  3. 3 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouAppListMapper.java
  4. 10 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouAppListMapper.xml
  5. 3 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouAppListService.java
  6. 9 0
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouAppListServiceImpl.java
  7. 4 4
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/controller/KuaishouChannelController.java
  8. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/KuaishouChannelMapper.java
  9. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/KuaishouChannelRelMapper.java
  10. 1 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelMapper.xml
  11. 5 3
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/xml/KuaishouChannelRelMapper.xml
  12. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/IKuaishouChannelRelService.java
  13. 1 1
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/IKuaishouChannelService.java
  14. 2 2
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelRelServiceImpl.java
  15. 40 121
      jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelServiceImpl.java

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

@@ -295,11 +295,16 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 return videoCnt;
             }
             Long appId = null;
+            String appName = null;
             if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
                 appId = JSONArray.parseArray(strategy.getAppIdArray()).getLong(0);
                 if (Check.isNull(appId)) {
                     return videoCnt;
                 }
+                KuaiShouAppList appInfo = appListService.getAppInfo(accountId, appId);
+                if(!Check.isNull(appInfo)){
+                    appName = appInfo.getAppName();
+                }
             }
             //渠道号应用层级,account-账户,plan-计划,group-组
             String level = strategy.getUsageLevel();
@@ -307,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);
+                    Result<Object> result = channelService.queryChannel(accountId, level,appName);
                     Integer code = result.getCode();
                     if (code == 200) {
                         channel = (KuaishouChannel) result.getResult();
@@ -349,7 +354,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 //获取组级渠道号
                 if (!Check.isNull(useChannel) && useChannel == 1 && "group".equals(level)) {
                     try {
-                        Result<Object> result = channelService.queryChannel(accountId, level);
+                        Result<Object> result = channelService.queryChannel(accountId, level,appName);
                         Integer code = result.getCode();
                         if (code == 200) {
                             channel = (KuaishouChannel) result.getResult();
@@ -616,6 +621,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 return;
             }
             Long appId = null;
+            String appName = null;
             String appIdString = strategy.getAppIdArray();
             if (strategy.getCampaignType() == 2 || strategy.getCampaignType() == 7) {
                 if (!Check.isNull(appIdString) && !Check.isNull(JSON.parseArray(appIdString))) {
@@ -623,6 +629,10 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                     if (Check.isNull(appId)) {
                         return;
                     }
+                    KuaiShouAppList appInfo = appListService.getAppInfo(accountId, appId);
+                    if(!Check.isNull(appInfo)){
+                        appName = appInfo.getAppName();
+                    }
                 }
             }
             Long newCampaignId = getCampaignId(strategy, token, replaceString, "TODAY", createType, appId, strategyUuid);
@@ -635,7 +645,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);
+                    Result<Object> result = channelService.queryChannel(accountId, level,appName);
                     Integer code = result.getCode();
                     if (code == 200) {
                         channel = (KuaishouChannel) result.getResult();
@@ -672,7 +682,7 @@ public class AiKuaishouCreateCreativeServiceImpl implements IAiKuaishouCreateCre
                 //获取组级渠道号
                 if (!Check.isNull(useChannel) && useChannel == 1 && "group".equals(level)) {
                     try {
-                        Result<Object> result = channelService.queryChannel(accountId, level);
+                        Result<Object> result = channelService.queryChannel(accountId, level,appName);
                         Integer code = result.getCode();
                         if (code == 200) {
                             channel = (KuaishouChannel) result.getResult();

+ 30 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaiShouAppListController.java

@@ -19,7 +19,14 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
@@ -70,6 +77,28 @@ public class KuaiShouAppListController {
         return result;
     }
 
+    @PostMapping(value = "/getAppNames")
+    public Result<List<KuaiShouAppList>> getAppNames(@RequestBody JSONObject requestJson) {
+        Result<List<KuaiShouAppList>> result = new Result<>();
+        try {
+            if (Check.isNull(requestJson.getJSONArray("appIdArray"))) {
+                throw new Exception("请选择应用id");
+            }
+            JSONArray appIds = requestJson.getJSONArray("appIdArray");
+            if (Check.isNull(appIds)) {
+                throw new Exception("应用id列表不能为空");
+            }
+            List<KuaiShouAppList> list = kuaiShouAppListService.getAppNames(appIds);
+            result.setResult(list);
+            result.setSuccess(true);
+            result.setMessage("刷新成功");
+        } catch (Exception e) {
+            result.setSuccess(false);
+            result.success(e.getMessage());
+        }
+        return result;
+    }
+
 
     /**
      * 分页列表查询

+ 3 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/KuaiShouAppListMapper.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.mapper;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -15,4 +16,6 @@ import java.util.List;
 public interface KuaiShouAppListMapper extends BaseMapper<KuaiShouAppList> {
 
     void replaceBatch(@Param("addList") List<KuaiShouAppList> addList);
+
+    List<KuaiShouAppList> getAppNames(@Param("appIds") JSONArray appIds);
 }

+ 10 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/mapper/xml/KuaiShouAppListMapper.xml

@@ -31,4 +31,14 @@
         </foreach>
     </insert>
 
+    <select id="getAppNames" resultType="cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList">
+        SELECT account_id,app_id,app_version,app_name,package_name
+        FROM ctop_kuaishou_app_list
+        WHERE app_id IN
+        <foreach collection="appIds" item="item" separator=","
+                 open="(" close=")">
+            #{item}
+        </foreach>
+    </select>
+
 </mapper>

+ 3 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaiShouAppListService.java

@@ -1,6 +1,7 @@
 package cn.com.ctop.kuaishou.modules.batch.service;
 
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.extension.service.IService;
 
 import java.util.List;
@@ -16,4 +17,6 @@ public interface IKuaiShouAppListService extends IService<KuaiShouAppList> {
     KuaiShouAppList getAppInfo(Long accountId, Long appId);
 
     List<KuaiShouAppList> getAppListByAccountId(Long accountId);
+
+    List<KuaiShouAppList> getAppNames(JSONArray appIds);
 }

+ 9 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaiShouAppListServiceImpl.java

@@ -3,8 +3,10 @@ package cn.com.ctop.kuaishou.modules.batch.service.impl;
 import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
 import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouAppListMapper;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAppListService;
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
@@ -18,6 +20,8 @@ import java.util.List;
 @Service
 public class KuaiShouAppListServiceImpl extends ServiceImpl<KuaiShouAppListMapper, KuaiShouAppList> implements IKuaiShouAppListService {
 
+    @Autowired
+    private KuaiShouAppListMapper shouAppListMapper;
     @Override
     public KuaiShouAppList getAppInfo(Long accountId, Long appId) {
         QueryWrapper<KuaiShouAppList> queryWrapper = new QueryWrapper<>();
@@ -35,4 +39,9 @@ public class KuaiShouAppListServiceImpl extends ServiceImpl<KuaiShouAppListMappe
         queryWrapper.eq("platform", 1);
         return this.list(queryWrapper);
     }
+
+    @Override
+    public List<KuaiShouAppList> getAppNames(JSONArray appIds) {
+        return shouAppListMapper.getAppNames(appIds);
+    }
 }

+ 4 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/controller/KuaishouChannelController.java

@@ -258,12 +258,12 @@ public class KuaishouChannelController {
      * 通过账户查询渠道号接口
      */
     @PostMapping(value = "/queryChannel")
-    public Result<Object> queryChannel(Long accountId, String usageLevel) {
+    public Result<Object> queryChannel(Long accountId, String usageLevel,String appName) {
         try {
-            if (Check.isNull(accountId) || Check.isNull(usageLevel)) {
+            if (Check.isNull(accountId) || Check.isNull(usageLevel)|| Check.isNull(appName)) {
                 return Result.error("缺失参数");
             }
-            return kuaishouChannelService.queryChannel(accountId, usageLevel);
+            return kuaishouChannelService.queryChannel(accountId, usageLevel,appName);
         } catch (Exception e) {
             e.printStackTrace();
             log.error("通过账户查询渠道号异常", e);
@@ -277,7 +277,7 @@ public class KuaishouChannelController {
     @PostMapping(value = "/queryChannelLevel")
     public Result<Object> queryChannelLevel(@RequestBody JSONObject request) {
         try {
-            if (Check.isNull(request.getLong("accountId")) || Check.isNull(request.getJSONArray("appIdArray"))) {
+            if (Check.isNull(request.getLong("accountId")) || Check.isNull(request.getJSONArray("appNameArray"))) {
                 return Result.error("缺失参数");
             }
             return kuaishouChannelService.queryChannelLevel(request);

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

@@ -44,5 +44,5 @@ public interface KuaishouChannelMapper extends BaseMapper<KuaishouChannel> {
 
     List<KuaishouChannel> queryChannelByHaveCycleTimes(@Param("haveCycleTimes") Integer haveCycleTimes, @Param("usageLevel") String usageLevel, @Param("strategys") List<KuaishouChannelCreateStrategy> strategys);
 
-    List<JSONObject> queryItemsListByAccountId(@Param("accountId") Long accountId, @Param("appId") Long appId);
+    List<JSONObject> queryItemsListByAccountId(@Param("accountId") Long accountId, @Param("appName") String appName);
 }

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/mapper/KuaishouChannelRelMapper.java

@@ -13,7 +13,7 @@ import org.apache.ibatis.annotations.Param;
  */
 public interface KuaishouChannelRelMapper extends BaseMapper<KuaishouChannelRel> {
 
-    KuaishouChannelRel queryByAccountChannelCode(@Param("channelCode") String channelCode, @Param("accountId") Long accountId);
+    KuaishouChannelRel queryByAccountChannelCode(@Param("channelCode") String channelCode, @Param("accountId") Long accountId, @Param("appName")  String appName);
 
     Integer queryUsePlanCount(@Param("accountId") Long accountId, @Param("channelCode") String channelCode);
 

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

@@ -220,7 +220,6 @@
         AND state = 1
         and usage_level = #{usageLevel}
         ORDER BY usage_times
-        limit 20
     </select>
 
 
@@ -247,7 +246,7 @@
                 INNER JOIN ctop_kuaishou_channel_app_info tt4 ON tt1.app_id = tt4.app_id
         WHERE
             tt1.account_id = #{accountId}
-          AND tt1.app_id = #{appId}
+          AND tt4.app_name = #{appName}
         GROUP BY
             tt2.item_name
     </select>

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

@@ -5,9 +5,11 @@
     <select id="queryByAccountChannelCode"
             resultType="cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannelRel">
         SELECT *
-        FROM ctop_kuaishou_channel_rel
-        WHERE account_id = #{accountId}
-          AND channel_code = #{channelCode} limit 1
+        FROM ctop_kuaishou_channel_rel t1
+                 LEFT JOIN ctop_kuaishou_channel_app_info t2 ON t1.app_id = t2.app_id
+        WHERE t1.account_id =#{channelCode}
+          AND t2.app_name = #{appName}
+          AND channel_code =  #{channelCode} limit 1
     </select>
 
     <select id="queryUsePlanCount" resultType="java.lang.Integer">

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/IKuaishouChannelRelService.java

@@ -12,7 +12,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface IKuaishouChannelRelService extends IService<KuaishouChannelRel> {
 
-    KuaishouChannelRel queryByAccountChannelCode(String channelCode, Long accountId);
+    KuaishouChannelRel queryByAccountChannelCode(String channelCode, Long accountId,String appName);
 
     Integer queryUsePlanCount(Long accountId, String channelCode);
 

+ 1 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/IKuaishouChannelService.java

@@ -30,7 +30,7 @@ public interface IKuaishouChannelService extends IService<KuaishouChannel> {
 
     Result<Object> customizedCreate(JSONObject request, Integer createType) throws Exception;
 
-    Result<Object> queryChannel(Long accountId, String usageLevel) throws Exception;
+    Result<Object> queryChannel(Long accountId, String usageLevel,String appName) throws Exception;
 
     Result<Object> queryChannelLevel(JSONObject request);
 

+ 2 - 2
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelRelServiceImpl.java

@@ -20,8 +20,8 @@ public class KuaishouChannelRelServiceImpl extends ServiceImpl<KuaishouChannelRe
     private KuaishouChannelRelMapper channelRelMapper;
 
     @Override
-    public KuaishouChannelRel queryByAccountChannelCode(String channelCode, Long accountId) {
-        return channelRelMapper.queryByAccountChannelCode(channelCode, accountId);
+    public KuaishouChannelRel queryByAccountChannelCode(String channelCode, Long accountId,String appName) {
+        return channelRelMapper.queryByAccountChannelCode(channelCode, accountId, appName);
     }
 
     @Override

+ 40 - 121
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelServiceImpl.java

@@ -107,8 +107,8 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
 
     @Autowired
     private ICtopOauthTokenService tokenService;
-    private static final String CHANNEL_STR = "-{{渠道号}}-";
-    private static final String NUMBER_STR = "-{{编号}}-";
+    private static final String CHANNEL_STR = "{{渠道号}}";
+    private static final String NUMBER_STR = "{{编号}}";
     private static final String CHANNEL = "_channel_FLAG";
 
     static ExecutorService executorService = Executors.newFixedThreadPool(5);
@@ -182,7 +182,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
             //根据命名格式获取
             queryWrapper.eq("channel_code", strategy.getChannelCode());
             KuaishouChannelCreateStrategy sameNameOne = channelCreateStrategyService.getOne(queryWrapper);
-            if (!Check.isNull(sameNameOne) && one.getNumberMax() >= strategy.getNumberMin()) {
+            if (!Check.isNull(sameNameOne) && one.getCreateType() == 1 && one.getNumberMax() >= strategy.getNumberMin()) {
                 return Result.error("创建失败,编号重叠,现有最大编号为:" + one.getNumberMax());
             }
         }
@@ -569,11 +569,22 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
         //渠道号
         String channelCode = strategy.getChannelCode().replace(NUMBER_STR, numberStr).trim();
         channelStrategy.setChannelCode(channelCode);
-        if (strategy.getChannelName().contains(CHANNEL_STR) || strategy.getChannelName().contains(NUMBER_STR)) {
-            channelStrategy.setChannelName(strategy.getChannelName().replace(CHANNEL_STR, channelCode).replace(NUMBER_STR, numberStr).trim());
+        String channelName = strategy.getChannelName();
+        if (channelName.contains(CHANNEL_STR) || channelName.contains(NUMBER_STR)) {
+            channelName = channelName.replace(CHANNEL_STR, channelCode).replace(NUMBER_STR, numberStr).trim();
+            channelName = channelName.replace("--", "-");
+            channelName = channelName.replace("--", "-");
+            if (channelName.startsWith("-")) {
+                channelName = channelName.substring(1, channelName.length());
+            }
+            if (channelName.endsWith("-")) {
+                channelName = channelName.substring(0, channelName.length() - 1);
+            }
+            channelStrategy.setChannelName(channelName);
         }
-        if (!Check.isNull(strategy.getSchemaUri()) && strategy.getSchemaUri().contains(CHANNEL_STR)) {
-            channelStrategy.setSchemaUri(strategy.getSchemaUri().replace(CHANNEL_STR, channelCode).trim());
+        String schemaUri = strategy.getSchemaUri();
+        if (!Check.isNull(schemaUri) && schemaUri.contains(CHANNEL_STR)) {
+            channelStrategy.setSchemaUri(schemaUri.replace(CHANNEL_STR, channelCode).trim());
         }
         if (strategy.getUrl().contains(CHANNEL_STR)) {
             channelStrategy.setUrl(strategy.getUrl().replace(CHANNEL_STR, channelCode).trim());
@@ -869,7 +880,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
     }
 
     @Override
-    public Result<Object> queryChannel(Long accountId, String level) throws Exception {
+    public Result<Object> queryChannel(Long accountId, String level, String appName) throws Exception {
         //查询账户策略
         List<KuaishouChannelCreateStrategy> strategys = channelCreateStrategyService.queryChannelStrategyByAccountId(accountId);
         if (Check.isNull(strategys) || strategys.isEmpty()) {
@@ -890,26 +901,25 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
             /**============================账户范围============================*/
             if ("account".equals(usageLevel)) {
                 //---------------------账户层级---------------------
-                return doAccountRangeAccountLevel(accountId, strategys);
+                return doAccountRangeAccountLevel(accountId, strategys, appName);
             } else if ("plan".equals(usageLevel) && usageLevel.equals(level)) {
                 //---------------------计划层级---------------------
-                return doAccountRangePlanLevel(accountId, strategys);
+                return doPlanLevel(accountId, strategys, appName);
             } else if ("group".equals(usageLevel)) {
                 //---------------------组层级---------------------
-                return doAccountRangeGroupLevel(accountId, strategys);
+                return doGroupLevel(accountId, strategys, appName);
             }
-
         } else {
             /**============================项目范围============================*/
             if ("account".equals(usageLevel)) {
                 //---------------------账户层级---------------------
-                return doAccountRangePlanLevel(accountId, strategys);
+                return doAccountRangeAccountLevel(accountId, strategys, appName);
             } else if ("plan".equals(usageLevel) && usageLevel.equals(level)) {
                 //---------------------计划层级---------------------
-                return doProjectRangePlanLevel(accountId, strategys);
+                return doPlanLevel(accountId, strategys, appName);
             } else if ("group".equals(usageLevel)) {
                 //---------------------组层级---------------------
-                return doProjectRangeGroupLevel(accountId, strategys);
+                return doGroupLevel(accountId, strategys, appName);
             }
         }
         return Result.error("未查到渠道号");
@@ -918,15 +928,15 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
     @Override
     public Result<Object> queryChannelLevel(JSONObject data) {
         Long accountId = data.getLong("accountId");
-        JSONArray appIdArray = data.getJSONArray("appIdArray");
-        Long appId = appIdArray.getLong(0);
+        JSONArray appNameArray = data.getJSONArray("appNameArray");
+        String appName = appNameArray.getString(0);
         KuaishouChannel channel = channelMapper.queryByAccountId(accountId);
         if (Check.isNull(channel)) {
             return Result.ok("没有渠道号");
         }
         JSONObject request = new JSONObject();
         if (channel.getIsHaveItem() == 1) {
-            List<JSONObject> list = channelMapper.queryItemsListByAccountId(accountId,appId);
+            List<JSONObject> list = channelMapper.queryItemsListByAccountId(accountId, appName);
             request.put("list", list);
         }
         request.put("channel", channel);
@@ -969,11 +979,11 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
         }
     }
 
-    private Result<Object> doAccountRangeAccountLevel(Long accountId, List<KuaishouChannelCreateStrategy> strategys) throws Exception {
+    private Result<Object> doAccountRangeAccountLevel(Long accountId, List<KuaishouChannelCreateStrategy> strategys, String appName) throws Exception {
         List<KuaishouChannel> channelList = channelMapper.queryByAccountIdLevel(accountId, "account");
         if (!Check.isNull(channelList)) {
             for (KuaishouChannel channel : channelList) {
-                KuaishouChannelRel channelRel = channelRelService.queryByAccountChannelCode(channel.getChannelCode(), accountId);
+                KuaishouChannelRel channelRel = channelRelService.queryByAccountChannelCode(channel.getChannelCode(), accountId, appName);
                 if (Check.isNull(channelRel)) {
                     continue;
                 }
@@ -996,14 +1006,14 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
     }
 
     //通过账户范围计划层级查询
-    private Result<Object> doAccountRangePlanLevel(Long accountId, List<KuaishouChannelCreateStrategy> strategys) throws
+    private Result<Object> doPlanLevel(Long accountId, List<KuaishouChannelCreateStrategy> strategys, String appName) throws
             Exception {
         List<Integer> haveCycleTimesList = channelMapper.queryUsedLevel(strategys);
         if (Check.isNull(haveCycleTimesList)) {
             return Result.error("渠道号已无效");
         }
         for (Integer haveCycleTimes : haveCycleTimesList) {
-            //获取20个可用渠道号,筛查出一个返回给前端
+            //获取可用渠道号,筛查出一个返回给前端
             List<KuaishouChannel> list = channelMapper.queryChannelByHaveCycleTimes(haveCycleTimes, "plan", strategys);
             if (Check.isNull(list)) {
                 continue;
@@ -1014,103 +1024,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                 //优先判断已经循环的次数 大于 使用次数
                 if (haveCycleTimes > usageTimes) {
                     // 符合条件,获取该渠道号
-                    KuaishouChannelRel channelRel = channelRelService.queryByAccountChannelCode(channel.getChannelCode(), accountId);
-                    if (Check.isNull(channelRel.getAppId())) {
-                        //创建APP
-                        createNewApp(channel, accountId, 1);
-                        if (Check.isNull(channel.getAppId())) {
-                            continue;
-                        } else {
-                            channelRel.setAppId(channel.getAppId());
-                            channelRelService.saveOrUpdate(channelRel);
-                            return Result.ok(channel);
-                        }
-                    } else {
-                        channel.setAppId(channelRel.getAppId());
-                        return Result.ok(channel);
-                    }
-                } else {
-                    //判断可循环次数 大于 已经循环的次数
-                    if (cycleTimes > haveCycleTimes) {
-                        //已循环次数+1
-                        channel.setHaveCycleTimes(haveCycleTimes + 1);
-                        this.saveOrUpdate(channel);
-                    }
-                    continue;
-                }
-            }
-        }
-        return Result.ok("未查询到渠道号");
-    }
-
-    //通过账户范围广告组层级查询
-    private Result<Object> doAccountRangeGroupLevel(Long
-                                                            accountId, List<KuaishouChannelCreateStrategy> strategys) throws Exception {
-        List<Integer> haveCycleTimesList = channelMapper.queryUsedLevel(strategys);
-        if (Check.isNull(haveCycleTimesList)) {
-            return Result.error("渠道号已无效");
-        }
-        for (Integer haveCycleTimes : haveCycleTimesList) {
-            //获取20个可用渠道号,筛查出一个返回给前端
-            List<KuaishouChannel> list = channelMapper.queryChannelByHaveCycleTimes(haveCycleTimes, "group", strategys);
-            if (Check.isNull(list)) {
-                continue;
-            }
-            for (KuaishouChannel channel : list) {
-                Integer cycleTimes = channel.getCycleTimes();//可循环次数
-                Integer usageTimes = channel.getUsageTimes();//使用次数
-                //优先判断已经循环的次数 大于 使用次数
-                if (haveCycleTimes > usageTimes) {
-                    // 符合条件,获取该渠道号
-                    KuaishouChannelRel channelRel = channelRelService.queryByAccountChannelCode(channel.getChannelCode(), accountId);
-                    if (Check.isNull(channelRel.getAppId())) {
-                        //创建APP
-                        createNewApp(channel, accountId, 1);
-                        if (Check.isNull(channel.getAppId())) {
-                            continue;
-                        } else {
-                            channelRel.setAppId(channel.getAppId());
-                            channelRelService.saveOrUpdate(channelRel);
-                            return Result.ok(channel);
-                        }
-                    } else {
-                        channel.setAppId(channelRel.getAppId());
-                        return Result.ok(channel);
-                    }
-                } else {
-                    //判断可循环次数 大于 已经循环的次数
-                    if (cycleTimes > haveCycleTimes) {
-                        //已循环次数+1
-                        channel.setHaveCycleTimes(haveCycleTimes + 1);
-                        this.saveOrUpdate(channel);
+                    KuaishouChannelRel channelRel = channelRelService.queryByAccountChannelCode(channel.getChannelCode(), accountId, appName);
+                    if (Check.isNull(channelRel)) {
+                        continue;
                     }
-                    continue;
-                }
-            }
-        }
-        return Result.ok("未查询到渠道号");
-    }
-
-    //通过项目范围账户层级查询
-    private Result<Object> doProjectRangePlanLevel(Long accountId, List<KuaishouChannelCreateStrategy> strategys) throws
-            Exception {
-        List<Integer> haveCycleTimesList = channelMapper.queryUsedLevel(strategys);
-        if (Check.isNull(haveCycleTimesList)) {
-            return Result.error("渠道号已无效");
-        }
-        for (Integer haveCycleTimes : haveCycleTimesList) {
-            //获取20个可用渠道号,筛查出一个返回给前端
-            List<KuaishouChannel> list = channelMapper.queryChannelByHaveCycleTimes(haveCycleTimes, "plan", strategys);
-            if (Check.isNull(list)) {
-                continue;
-            }
-            for (KuaishouChannel channel : list) {
-                Integer cycleTimes = channel.getCycleTimes();//可循环次数
-                Integer usageTimes = channel.getUsageTimes();//使用次数
-                //优先判断已经循环的次数 大于 使用次数
-                if (haveCycleTimes > usageTimes) {
-                    // 符合条件,获取该渠道号
-                    KuaishouChannelRel channelRel = channelRelService.queryByAccountChannelCode(channel.getChannelCode(), accountId);
                     if (Check.isNull(channelRel.getAppId())) {
                         //创建APP
                         createNewApp(channel, accountId, 1);
@@ -1140,8 +1057,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
     }
 
     //通过项目范围广告组层级查询
-    private Result<Object> doProjectRangeGroupLevel(Long
-                                                            accountId, List<KuaishouChannelCreateStrategy> strategys) throws Exception {
+    private Result<Object> doGroupLevel(Long accountId, List<KuaishouChannelCreateStrategy> strategys, String appName) throws Exception {
         List<Integer> haveCycleTimesList = channelMapper.queryUsedLevel(strategys);
         if (Check.isNull(haveCycleTimesList)) {
             return Result.error("渠道号已无效");
@@ -1158,7 +1074,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                 //优先判断已经循环的次数 大于 使用次数
                 if (haveCycleTimes > usageTimes) {
                     // 符合条件,获取该渠道号
-                    KuaishouChannelRel channelRel = channelRelService.queryByAccountChannelCode(channel.getChannelCode(), accountId);
+                    KuaishouChannelRel channelRel = channelRelService.queryByAccountChannelCode(channel.getChannelCode(), accountId, appName);
+                    if (Check.isNull(channelRel)) {
+                        continue;
+                    }
                     if (Check.isNull(channelRel.getAppId())) {
                         //创建APP
                         createNewApp(channel, accountId, 1);