Browse Source

渠道号。。。获取已使用渠道号列表

zhaoxian 4 năm trước cách đây
mục cha
commit
88eedc5114

+ 2 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/UserAllocationMapper.java

@@ -69,4 +69,6 @@ public interface UserAllocationMapper extends BaseMapper<UserAllocation> {
     void updCwjsSettlementStatus(@Param("id") String id, @Param("status") Integer status);
 
     List<UserAllocation> getAccountInfoBySalesId(@Param("sales")Set<String> sales,@Param("mediaId")String mediaId,@Param("advertiserId")String advertiserId,@Param("productId")String productId);
+
+    List<Long> getAccountListByProjectId(@Param("projectId") Long projectId);
 }

+ 8 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/mapper/xml/UserAllocationMapper.xml

@@ -245,6 +245,14 @@
         WHERE del_flag = 0
           and account_id = #{accountId}
     </select>
+
+    <!-- 根据账户id 查看财务账户 -->
+    <select id="getAccountListByProjectId" resultType="java.lang.Long">
+        select account_id from ctop_user_allocation
+        WHERE account_status = 0
+          AND project_id = #{projectId}
+    </select>
+
     <select id="getAccountInfoBySalesId" resultType="cn.com.ctop.common.module.entity.UserAllocation">
         select cua.*
             from ctop_user_allocation cua

+ 1 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/IUserAllocationService.java

@@ -71,4 +71,5 @@ public interface IUserAllocationService extends IService<UserAllocation> {
 
     Result<UserAllocation> editUserAlloCation(UserAllocation userAllocation);
 
+    List<Long> getAccountListByProjectId(Long projectId);
 }

+ 5 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/service/impl/UserAllocationServiceImpl.java

@@ -307,5 +307,10 @@ public class UserAllocationServiceImpl extends ServiceImpl<UserAllocationMapper,
         return result;
     }
 
+    @Override
+    public List<Long> getAccountListByProjectId(Long projectId) {
+        return userAllocationMapper.getAccountListByProjectId(projectId);
+    }
+
 
 }

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

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.channel.controller;
 
+import cn.com.ctop.common.module.service.ISysRoleExtService;
 import cn.com.ctop.common.module.utils.Check;
 import cn.com.ctop.common.module.utils.ExportExcelUtils;
 import cn.com.ctop.kuaishou.modules.channel.entity.KuaishouChannel;
@@ -60,17 +61,23 @@ import java.util.Map;
 public class KuaishouChannelController {
     @Autowired
     private IKuaishouChannelService kuaishouChannelService;
-
+    @Autowired
+    private ISysRoleExtService sysRoleService;
     /**
      * 查询渠道号管理首页数据
      */
     @GetMapping(value = "/channelManagementHome")
-    public Result<Object> channelManagementHome(Long productId, Long projectId, Long accountId,
+    public Result<Object> channelManagementHome(Long productId, Long projectId, Long accountId,String userId,
                                                 @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                 @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
         try {
+            String roleCode = sysRoleService.getRoleCodeByUserId(userId);
+            if ("admin".equals(roleCode) || roleCode.contains("sale") || "meidaManager".equals(roleCode)) {
+                userId = null;
+            }
+
             PageHelper.startPage(pageNo, pageSize);
-            return kuaishouChannelService.channelManagementHome(productId, projectId, accountId);
+            return kuaishouChannelService.channelManagementHome(productId, projectId, accountId,userId);
         } catch (Exception e) {
             e.printStackTrace();
             return Result.error("查询渠道号管理首页数据异常");
@@ -164,8 +171,8 @@ public class KuaishouChannelController {
             OutputStream os = response.getOutputStream();
             ExportExcelUtils eeu = new ExportExcelUtils();
             XSSFWorkbook workbook = new XSSFWorkbook();
-            String[] titles = {"产品", "项目", "使用范围(1账户,2项目)", "账户ID", "渠道号创建人", "渠道号(数字加字母)", "渠道号名称", "下载链接", "应用包名", "应用名称", "应用标记", "隐私政策链接"
-                    , "第三方点击监测链接", "是否关联单品(0否,1是)", "关联单品名称", "使用层级(账户:account,计划:plan,组:group)", "是否循环(0否,1是)", "循环次数", "调起链接(选填)", "第三方actionBar监测链接(选填)"};
+            String[] titles = {"产品(固定项,勿修改)", "项目(固定项,勿修改)", "使用范围(1代表账户,2代表项目)", "账户ID(和项目对应)", "渠道号创建人(固定项,勿修改)", "渠道号(如:数字加字母)", "渠道号名称", "下载链接", "应用包名", "应用名称", "应用标记", "隐私政策链接"
+                    , "第三方点击监测链接", "是否关联单品(0代表不关联,1代表关联)", "关联单品名称", "使用层级(账户:account,计划:plan,组:group)", "是否循环(0代表不循环,1代表循环)", "循环次数", "调起链接(选填)", "第三方actionBar监测链接(选填)"};
             List<List<Object>> list = new ArrayList<>();
             List<Object> ids = new ArrayList<>();
             ids.add(productId);//产品

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

@@ -18,7 +18,7 @@ import java.util.List;
  */
 public interface KuaishouChannelMapper extends BaseMapper<KuaishouChannel> {
 
-    List<JSONObject> channelManagementHome(@Param("productId") Long productId, @Param("projectId") Long projectId, @Param("accountId") Long accountId);
+    List<JSONObject> channelManagementHome(@Param("productId") Long productId, @Param("projectId") Long projectId, @Param("accountId") Long accountId, @Param("userId") String userId);
 
     Long channelNumberDetailsTotal(KuaishouChannel kuaishouChannel);
 

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

@@ -16,7 +16,7 @@
         FROM ctop_kuaishou_channel t1
         LEFT JOIN sys_user t2 ON t1.user_id = t2.id
         where account_id is not null
-
+        and t1.user_id = #{userId}
         <if test="projectId != null">
             and project_id = #{projectId}
         </if>
@@ -40,6 +40,7 @@
         FROM ctop_kuaishou_channel t1
         LEFT JOIN sys_user t2 ON t1.user_id = t2.id
         where account_id is null
+        and t1.user_id = #{userId}
         <if test="projectId != null">
             and project_id = #{projectId}
         </if>

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

@@ -15,7 +15,7 @@ import org.springframework.web.multipart.MultipartFile;
  */
 public interface IKuaishouChannelService extends IService<KuaishouChannel> {
 
-    Result<Object> channelManagementHome(Long productId, Long projectId, Long accountId);
+    Result<Object> channelManagementHome(Long productId, Long projectId, Long accountId,String userId);
 
     Result<Object> channelNumberDetails(KuaishouChannel kuaishouCha, Integer pageNo, Integer pageSizennel);
 

+ 11 - 4
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/channel/service/impl/KuaishouChannelItemsServiceImpl.java

@@ -11,6 +11,7 @@ import cn.com.ctop.kuaishou.modules.channel.service.IKuaishouChannelItemsRelServ
 import cn.com.ctop.kuaishou.modules.channel.service.IKuaishouChannelItemsService;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageInfo;
 import org.apache.poi.hssf.usermodel.HSSFCell;
@@ -106,10 +107,16 @@ public class KuaishouChannelItemsServiceImpl extends ServiceImpl<KuaishouChannel
             if (Check.isNull(object.getLong("id")) || Check.isNull(object.getLong("channelId"))) {
                 continue;
             }
-            KuaishouChannelItemsRel rel = new KuaishouChannelItemsRel();
-            rel.setItemId(object.getLong("id"));
-            rel.setChannelId(object.getLong("channelId"));
-            channelItemsRelService.save(rel);
+            QueryWrapper<KuaishouChannelItemsRel> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("channel_id", object.getLong("channelId"));
+            queryWrapper.eq("item_id", object.getLong("id"));
+            KuaishouChannelItemsRel one = channelItemsRelService.getOne(queryWrapper);
+            if (Check.isNull(one)) {
+                KuaishouChannelItemsRel rel = new KuaishouChannelItemsRel();
+                rel.setItemId(object.getLong("id"));
+                rel.setChannelId(object.getLong("channelId"));
+                channelItemsRelService.save(rel);
+            }
         }
         return Result.ok("绑定成功");
     }

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

@@ -115,8 +115,8 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
 
 
     @Override
-    public Result<Object> channelManagementHome(Long productId, Long projectId, Long accountId) {
-        List<JSONObject> list = channelMapper.channelManagementHome(productId, projectId, accountId);
+    public Result<Object> channelManagementHome(Long productId, Long projectId, Long accountId,String userId) {
+        List<JSONObject> list = channelMapper.channelManagementHome(productId, projectId, accountId,userId);
         return Result.ok(new PageInfo<>(list));
     }
 
@@ -204,14 +204,14 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
             /**==========================范围是 项目==========================*/
             if (usageRange == 2) {
                 String usageLevel = strategy.getUsageLevel();
+                //获取项目下账户集
+                List<Long> accountList = userAllocationService.getAccountListByProjectId(strategy.getProjectId());
+                if (Check.isNull(accountList)) {
+                    return Result.error("未获取有效账户");
+                }
                 if ("account".equals(usageLevel)) {
                     /**-----------------项目维度:使用层级是账户-----------------*/
-                    //获取项目下账户集
-                    List<JSONObject> accountList = userAllocationService.getAccountListByProject(strategy.getProjectId());
-                    int length = 0;
-                    if (!Check.isNull(accountList) && !accountList.isEmpty()) {
-                        length = accountList.size();
-                    }
+                    int length = accountList.size();
                     //待循环的数组长度
                     int size = numberMax - numberMin + 1;
                     //项目下有账户
@@ -222,14 +222,14 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                             for (int i = numberMin; i <= numberMax; i++) {
                                 length = --length;
                                 if (length >= 0) {
-                                    JSONObject account = accountList.get(length);
-                                    if (!Check.isNull(account)) {
+                                    Long accountId = accountList.get(length);
+                                    if (!Check.isNull(accountId)) {
                                         //获取token
                                         CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
                                         //获取应用图片token
                                         JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
                                         strategy.setImageToken(tokenJson.getString("imageToken"));
-                                        strategy.setAccountId(account.getLong("accountId"));
+                                        strategy.setAccountId(accountId);
                                         KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
                                         createApp(replaceData, token, null);
                                         createChannel(replaceData, i, 1);
@@ -243,14 +243,14 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                                 for (int i = numberMin; i <= numberMax; i++) {
                                     length = --length;
                                     if (length >= 0) {
-                                        JSONObject account = accountList.get(length);
-                                        if (!Check.isNull(account)) {
+                                        Long accountId = accountList.get(length);
+                                        if (!Check.isNull(accountId)) {
                                             //获取token
                                             CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
                                             //获取应用图片token
                                             JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
                                             strategy.setImageToken(tokenJson.getString("imageToken"));
-                                            strategy.setAccountId(account.getLong("accountId"));
+                                            strategy.setAccountId(accountId);
                                             KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
                                             createApp(replaceData, token, null);
                                             createChannel(replaceData, i, 1);
@@ -266,23 +266,23 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                                     //账户集能循环次数大于设置最大可循环次数时,则取设置的数据
                                     times = cycleTimes;
                                 }
-                                List<List<JSONObject>> accountSubLists = Lists.partition(accountList, size);
+                                List<List<Long>> accountSubLists = Lists.partition(accountList, size);
                                 for (int i = 0; i < accountSubLists.size(); i++) {
-                                    List<JSONObject> accountSubList = accountSubLists.get(i);
+                                    List<Long> accountSubList = accountSubLists.get(i);
                                     if (times > i) {
                                         //k获取账户子集的数据
                                         int k = -1;
                                         for (int j = numberMin; j <= numberMax; j++) {
                                             k = k + 1;
                                             if (k < accountSubList.size()) {
-                                                JSONObject account = accountSubList.get(k);
-                                                if (!Check.isNull(account)) {
+                                                Long accountId = accountSubList.get(k);
+                                                if (!Check.isNull(accountId)) {
                                                     //获取token
                                                     CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
                                                     //获取应用图片token
                                                     JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
                                                     strategy.setImageToken(tokenJson.getString("imageToken"));
-                                                    strategy.setAccountId(account.getLong("accountId"));
+                                                    strategy.setAccountId(accountId);
                                                     KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, j);
                                                     createApp(replaceData, token, null);
                                                     createChannel(replaceData, j, i + 1);
@@ -296,13 +296,23 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                     }
                 } else {
                     /**-----------------项目维度:使用层级是计划、组-----------------*/
-                    ilist.forEach(i -> executorService.submit(() -> {
-                        try {
-                            KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
-                            createApp(replaceData, null, null);
-                            createChannel(replaceData, i, 1);
-                        } catch (Exception e) {
-                            e.printStackTrace();
+                    accountList.forEach(accountId -> executorService.submit(() -> {
+                        //获取token
+                        CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+                        //获取应用图片token
+                        JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
+                        //使用范围是账户时,查询旧app来做匹配
+                        List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(accountId);
+                        strategy.setImageToken(tokenJson.getString("imageToken"));
+                        strategy.setAccountId(accountId);
+                        for (int i = numberMin; i <= numberMax; i++) {
+                            try {
+                                KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
+                                createApp(replaceData, token, oldAppList);
+                                createChannel(replaceData, i, 1);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
                         }
                     }));
                 }
@@ -646,6 +656,8 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                 String url = eeu.getCellValue(row.getCell(7));
                 if (Check.isNull(url)) {
                     return Result.error("解析数据失败,文档中第" + (i + 1) + "行,下载链接列缺失数据");
+                } else if (!url.contains("http")) {
+                    return Result.error("解析数据失败,文档中第" + (i + 1) + "行,下载链接格式不正确");
                 }
                 String packageName = eeu.getCellValue(row.getCell(8));
                 if (Check.isNull(packageName)) {
@@ -662,10 +674,14 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
                 String appPrivacyUrl = eeu.getCellValue(row.getCell(11));
                 if (Check.isNull(appPrivacyUrl)) {
                     return Result.error("解析数据失败,文档中第" + (i + 1) + "行,隐私政策链接列缺失数据");
+                } else if (!appPrivacyUrl.contains("http")) {
+                    return Result.error("解析数据失败,文档中第" + (i + 1) + "行,隐私政策链接格式不正确");
                 }
                 String clickTrackUrl = eeu.getCellValue(row.getCell(12));
                 if (Check.isNull(clickTrackUrl)) {
                     return Result.error("解析数据失败,文档中第" + (i + 1) + "行,第三方点击监测链接列缺失数据");
+                } else if (!clickTrackUrl.contains("http")) {
+                    return Result.error("解析数据失败,文档中第" + (i + 1) + "行,第三方点击监测链接格式不正确");
                 }
                 String isHaveItem = eeu.getCellValue(row.getCell(13));
                 if (Check.isNull(isHaveItem)) {
@@ -732,8 +748,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
         KuaishouChannelCreateStrategy strategy = JSONObject.parseObject(request.toJSONString(), KuaishouChannelCreateStrategy.class);
         if (!Check.isNull(strategy)) {
             JSONObject obj = projectMapper.getProduct(strategy.getAccountId(), strategy.getProjectId());
-            strategy.setProjectId(obj.getLong("projectId"));
-            strategy.setProductId(obj.getLong("productId"));
+            if (!Check.isNull(obj)) {
+                strategy.setProjectId(obj.getLong("projectId"));
+                strategy.setProductId(obj.getLong("productId"));
+            }
             strategy.setCreateType(createType);
             Integer usageRange = strategy.getUsageRange();
             QueryWrapper<KuaishouChannelCreateStrategy> queryWrapper = new QueryWrapper<>();
@@ -765,45 +783,63 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
             try {
                 strategy.setStateDate(DateUtils.getDate(DateUtils.WEB_FORMAT));
                 channelCreateStrategyService.save(strategy);
+
                 /**==========================范围是 项目==========================*/
                 if (usageRange == 2) {
+                    List<Long> accountList = userAllocationService.getAccountListByProjectId(strategy.getProjectId());
+                    if (Check.isNull(accountList)) {
+                        return Result.error("未获取有效账户");
+                    }
                     Integer cycleTimes = strategy.getCycleTimes();//循环次数
                     String usageLevel = strategy.getUsageLevel();//使用层级
                     if ("account".equals(usageLevel)) {
                         /**-----------------项目维度:使用层级是账户-----------------*/
-                        //获取项目下账户集
-                        List<JSONObject> accountList = userAllocationService.getAccountListByProject(strategy.getProjectId());
-                        int length = 0;
-                        if (!Check.isNull(accountList) && !accountList.isEmpty()) {
-                            length = accountList.size();
-                        }
+                        int length = accountList.size();
                         //项目下有账户,循环次数大于账户数
                         if (length > 0 && cycleTimes >= length) {
                             /**-----------------项目维度:循环次数 大于 项目下账户总数-----------------*/
-                            for (JSONObject account : accountList) {
+                            for (Long accountId : accountList) {
                                 //获取token
                                 CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
                                 //获取应用图片token
                                 JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
                                 strategy.setImageToken(tokenJson.getString("imageToken"));
-                                strategy.setAccountId(account.getLong("accountId"));
+                                strategy.setAccountId(accountId);
                                 createApp(strategy, token, null);
-                                createChannel(strategy, 1, 1);
+                                createChannel(strategy, 0, 1);
                             }
                         } else {
-                            List<List<JSONObject>> accountSubLists = Lists.partition(accountList, cycleTimes);
-                            List<JSONObject> list = accountSubLists.get(0);
-                            for (JSONObject account : list) {
+                            List<List<Long>> accountSubLists = Lists.partition(accountList, cycleTimes);
+                            List<Long> list = accountSubLists.get(0);
+                            for (int i = 0; i < list.size(); i++) {
                                 //获取token
                                 CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
                                 //获取应用图片token
                                 JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
                                 strategy.setImageToken(tokenJson.getString("imageToken"));
-                                strategy.setAccountId(account.getLong("accountId"));
+                                strategy.setAccountId(list.get(i));
                                 createApp(strategy, token, null);
-                                createChannel(strategy, 1, 1);
+                                createChannel(strategy, 0, i + 1);
                             }
                         }
+                    } else {
+                        /**-----------------项目维度:使用层级是计划、组-----------------*/
+                        accountList.forEach(accountId -> executorService.submit(() -> {
+                            //获取token
+                            CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
+                            //获取应用图片token
+                            JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
+                            //使用范围是账户时,查询旧app来做匹配
+                            List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(accountId);
+                            strategy.setImageToken(tokenJson.getString("imageToken"));
+                            strategy.setAccountId(accountId);
+                            try {
+                                createApp(strategy, token, oldAppList);
+                                createChannel(strategy, 0, 1);
+                            } catch (Exception e) {
+                                e.printStackTrace();
+                            }
+                        }));
                     }
                 } else {
                     /**==========================范围是 账户==========================*/
@@ -1142,100 +1178,4 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
             createNewApp(channel, accountId, count + 1);
         }
     }
-
-
-    //TODO
-    public Result<Object> queryChannelssss(Long accountId, String level) throws Exception {
-        Integer usageRange = null;
-        String usageLevel = null;
-        Integer isCycle = null;
-        //查询渠道号,若不存在,则通过账户ID ——> 项目id ——> 获取渠道号策略集,若策略集合也为空,则说明该账户没有创建过渠道号
-        KuaishouChannel channel = channelMapper.queryByAccountId(accountId);
-        if (Check.isNull(channel)) {
-            List<KuaishouChannelCreateStrategy> strategys = channelCreateStrategyService.queryChannelStrategyByAccountId(accountId);
-            //查询到
-            if (Check.isNull(strategys) || strategys.isEmpty()) {
-                return Result.error("渠道号获取失败,该账户没有创建过渠道号");
-            }
-            //所有策略下的 使用范围,使用层级,是否循环保持一致
-            KuaishouChannelCreateStrategy createStrategy = strategys.get(0);
-            usageRange = createStrategy.getUsageRange();
-            usageLevel = createStrategy.getUsageLevel();
-            isCycle = createStrategy.getIsCycle();
-            //若有渠道号策略,则必须创建渠道号,除非渠道号已经建满(是否循环,循环次数决定)
-            //判断是否已创建过渠道号,若未创建,则进行创建
-        } else {
-            usageRange = channel.getUsageRange();
-            usageLevel = channel.getUsageLevel();
-            isCycle = channel.getIsCycle();
-            //创建的是组级渠道号,查询的是计划层级,这种情况下查不到
-
-
-            //通过账户id查询渠道号,查到则返回
-            List<KuaishouChannel> list = getChannelList(accountId, null);
-            if (Check.isNull(list) || list.isEmpty()) {
-                return Result.error("渠道号获取失败,该账户不符合生成渠道号的条件");
-            }
-            for (KuaishouChannel kuaishouChannel : list) {
-                //appId为空,则去创建应用
-                if (Check.isNull(kuaishouChannel.getAppId())) {
-                    createNewApp(kuaishouChannel, accountId, 1);
-                    if (Check.isNull(kuaishouChannel.getAppId())) {
-                        continue;
-                    } else {
-                        kuaishouChannel.setUsageTimes(kuaishouChannel.getUsageTimes() + 1);
-                        this.saveOrUpdate(kuaishouChannel);
-                        return Result.ok(kuaishouChannel.getAppId());
-                    }
-                } else {
-                    kuaishouChannel.setUsageTimes(kuaishouChannel.getUsageTimes() + 1);
-                    this.saveOrUpdate(kuaishouChannel);
-                    return Result.ok(kuaishouChannel.getAppId());
-                }
-            }
-        }
-        return null;
-    }
-
-    /**
-     * 1、通过账户id查询渠道号,查到则返回
-     */
-    private List<KuaishouChannel> getChannelList(Long accountId, Long number) throws Exception {
-        if (Check.isNull(number)) {
-            //获取上次被使用的渠道主键
-            number = getChannelNumber(accountId, null);
-        } else if (0L == number) {
-            //渠道号查询从0开始
-            getChannelNumber(accountId, 0L);
-        }
-        List<KuaishouChannel> list = channelMapper.queryFollowOrder(accountId, number, 1);
-        if (Check.isNull(list) || list.isEmpty()) {
-            list = channelMapper.queryFollowOrder(accountId, number, 2);
-        }
-        if (Check.isNull(list) && number == 0L) {
-            return null;
-        }
-        if (Check.isNull(list)) {
-            return getChannelList(accountId, 0L);
-        }
-        return list;
-    }
-
-    private Long getChannelNumber(Long accountId, Long number) {
-        Long count = 0L;
-        String key = accountId + CHANNEL;
-        if (Check.isNull(number)) {
-            Object countObject = redisUtil.get(key);
-            if (Check.isNull(countObject)) {
-                redisUtil.set(key, count);
-            } else {
-                count = Long.valueOf(countObject.toString()) + 1;
-                redisUtil.set(key, count);
-            }
-        } else {
-            redisUtil.set(key, count);
-        }
-        return count;
-    }
-
 }