|
@@ -115,8 +115,8 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@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));
|
|
return Result.ok(new PageInfo<>(list));
|
|
}
|
|
}
|
|
|
|
|
|
@@ -204,14 +204,14 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
/**==========================范围是 项目==========================*/
|
|
/**==========================范围是 项目==========================*/
|
|
if (usageRange == 2) {
|
|
if (usageRange == 2) {
|
|
String usageLevel = strategy.getUsageLevel();
|
|
String usageLevel = strategy.getUsageLevel();
|
|
|
|
+ //获取项目下账户集
|
|
|
|
+ List<Long> accountList = userAllocationService.getAccountListByProjectId(strategy.getProjectId());
|
|
|
|
+ if (Check.isNull(accountList)) {
|
|
|
|
+ return Result.error("未获取有效账户");
|
|
|
|
+ }
|
|
if ("account".equals(usageLevel)) {
|
|
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;
|
|
int size = numberMax - numberMin + 1;
|
|
//项目下有账户
|
|
//项目下有账户
|
|
@@ -222,14 +222,14 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
for (int i = numberMin; i <= numberMax; i++) {
|
|
for (int i = numberMin; i <= numberMax; i++) {
|
|
length = --length;
|
|
length = --length;
|
|
if (length >= 0) {
|
|
if (length >= 0) {
|
|
- JSONObject account = accountList.get(length);
|
|
|
|
- if (!Check.isNull(account)) {
|
|
|
|
|
|
+ Long accountId = accountList.get(length);
|
|
|
|
+ if (!Check.isNull(accountId)) {
|
|
//获取token
|
|
//获取token
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
//获取应用图片token
|
|
//获取应用图片token
|
|
JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
- strategy.setAccountId(account.getLong("accountId"));
|
|
|
|
|
|
+ strategy.setAccountId(accountId);
|
|
KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
|
|
KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
|
|
createApp(replaceData, token, null);
|
|
createApp(replaceData, token, null);
|
|
createChannel(replaceData, i, 1);
|
|
createChannel(replaceData, i, 1);
|
|
@@ -243,14 +243,14 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
for (int i = numberMin; i <= numberMax; i++) {
|
|
for (int i = numberMin; i <= numberMax; i++) {
|
|
length = --length;
|
|
length = --length;
|
|
if (length >= 0) {
|
|
if (length >= 0) {
|
|
- JSONObject account = accountList.get(length);
|
|
|
|
- if (!Check.isNull(account)) {
|
|
|
|
|
|
+ Long accountId = accountList.get(length);
|
|
|
|
+ if (!Check.isNull(accountId)) {
|
|
//获取token
|
|
//获取token
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
//获取应用图片token
|
|
//获取应用图片token
|
|
JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
- strategy.setAccountId(account.getLong("accountId"));
|
|
|
|
|
|
+ strategy.setAccountId(accountId);
|
|
KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
|
|
KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
|
|
createApp(replaceData, token, null);
|
|
createApp(replaceData, token, null);
|
|
createChannel(replaceData, i, 1);
|
|
createChannel(replaceData, i, 1);
|
|
@@ -266,23 +266,23 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
//账户集能循环次数大于设置最大可循环次数时,则取设置的数据
|
|
//账户集能循环次数大于设置最大可循环次数时,则取设置的数据
|
|
times = cycleTimes;
|
|
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++) {
|
|
for (int i = 0; i < accountSubLists.size(); i++) {
|
|
- List<JSONObject> accountSubList = accountSubLists.get(i);
|
|
|
|
|
|
+ List<Long> accountSubList = accountSubLists.get(i);
|
|
if (times > i) {
|
|
if (times > i) {
|
|
//k获取账户子集的数据
|
|
//k获取账户子集的数据
|
|
int k = -1;
|
|
int k = -1;
|
|
for (int j = numberMin; j <= numberMax; j++) {
|
|
for (int j = numberMin; j <= numberMax; j++) {
|
|
k = k + 1;
|
|
k = k + 1;
|
|
if (k < accountSubList.size()) {
|
|
if (k < accountSubList.size()) {
|
|
- JSONObject account = accountSubList.get(k);
|
|
|
|
- if (!Check.isNull(account)) {
|
|
|
|
|
|
+ Long accountId = accountSubList.get(k);
|
|
|
|
+ if (!Check.isNull(accountId)) {
|
|
//获取token
|
|
//获取token
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
//获取应用图片token
|
|
//获取应用图片token
|
|
JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
- strategy.setAccountId(account.getLong("accountId"));
|
|
|
|
|
|
+ strategy.setAccountId(accountId);
|
|
KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, j);
|
|
KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, j);
|
|
createApp(replaceData, token, null);
|
|
createApp(replaceData, token, null);
|
|
createChannel(replaceData, j, i + 1);
|
|
createChannel(replaceData, j, i + 1);
|
|
@@ -296,13 +296,23 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
}
|
|
}
|
|
} else {
|
|
} 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));
|
|
String url = eeu.getCellValue(row.getCell(7));
|
|
if (Check.isNull(url)) {
|
|
if (Check.isNull(url)) {
|
|
return Result.error("解析数据失败,文档中第" + (i + 1) + "行,下载链接列缺失数据");
|
|
return Result.error("解析数据失败,文档中第" + (i + 1) + "行,下载链接列缺失数据");
|
|
|
|
+ } else if (!url.contains("http")) {
|
|
|
|
+ return Result.error("解析数据失败,文档中第" + (i + 1) + "行,下载链接格式不正确");
|
|
}
|
|
}
|
|
String packageName = eeu.getCellValue(row.getCell(8));
|
|
String packageName = eeu.getCellValue(row.getCell(8));
|
|
if (Check.isNull(packageName)) {
|
|
if (Check.isNull(packageName)) {
|
|
@@ -662,10 +674,14 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
String appPrivacyUrl = eeu.getCellValue(row.getCell(11));
|
|
String appPrivacyUrl = eeu.getCellValue(row.getCell(11));
|
|
if (Check.isNull(appPrivacyUrl)) {
|
|
if (Check.isNull(appPrivacyUrl)) {
|
|
return Result.error("解析数据失败,文档中第" + (i + 1) + "行,隐私政策链接列缺失数据");
|
|
return Result.error("解析数据失败,文档中第" + (i + 1) + "行,隐私政策链接列缺失数据");
|
|
|
|
+ } else if (!appPrivacyUrl.contains("http")) {
|
|
|
|
+ return Result.error("解析数据失败,文档中第" + (i + 1) + "行,隐私政策链接格式不正确");
|
|
}
|
|
}
|
|
String clickTrackUrl = eeu.getCellValue(row.getCell(12));
|
|
String clickTrackUrl = eeu.getCellValue(row.getCell(12));
|
|
if (Check.isNull(clickTrackUrl)) {
|
|
if (Check.isNull(clickTrackUrl)) {
|
|
return Result.error("解析数据失败,文档中第" + (i + 1) + "行,第三方点击监测链接列缺失数据");
|
|
return Result.error("解析数据失败,文档中第" + (i + 1) + "行,第三方点击监测链接列缺失数据");
|
|
|
|
+ } else if (!clickTrackUrl.contains("http")) {
|
|
|
|
+ return Result.error("解析数据失败,文档中第" + (i + 1) + "行,第三方点击监测链接格式不正确");
|
|
}
|
|
}
|
|
String isHaveItem = eeu.getCellValue(row.getCell(13));
|
|
String isHaveItem = eeu.getCellValue(row.getCell(13));
|
|
if (Check.isNull(isHaveItem)) {
|
|
if (Check.isNull(isHaveItem)) {
|
|
@@ -732,8 +748,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
KuaishouChannelCreateStrategy strategy = JSONObject.parseObject(request.toJSONString(), KuaishouChannelCreateStrategy.class);
|
|
KuaishouChannelCreateStrategy strategy = JSONObject.parseObject(request.toJSONString(), KuaishouChannelCreateStrategy.class);
|
|
if (!Check.isNull(strategy)) {
|
|
if (!Check.isNull(strategy)) {
|
|
JSONObject obj = projectMapper.getProduct(strategy.getAccountId(), strategy.getProjectId());
|
|
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);
|
|
strategy.setCreateType(createType);
|
|
Integer usageRange = strategy.getUsageRange();
|
|
Integer usageRange = strategy.getUsageRange();
|
|
QueryWrapper<KuaishouChannelCreateStrategy> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<KuaishouChannelCreateStrategy> queryWrapper = new QueryWrapper<>();
|
|
@@ -765,45 +783,63 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
try {
|
|
try {
|
|
strategy.setStateDate(DateUtils.getDate(DateUtils.WEB_FORMAT));
|
|
strategy.setStateDate(DateUtils.getDate(DateUtils.WEB_FORMAT));
|
|
channelCreateStrategyService.save(strategy);
|
|
channelCreateStrategyService.save(strategy);
|
|
|
|
+
|
|
/**==========================范围是 项目==========================*/
|
|
/**==========================范围是 项目==========================*/
|
|
if (usageRange == 2) {
|
|
if (usageRange == 2) {
|
|
|
|
+ List<Long> accountList = userAllocationService.getAccountListByProjectId(strategy.getProjectId());
|
|
|
|
+ if (Check.isNull(accountList)) {
|
|
|
|
+ return Result.error("未获取有效账户");
|
|
|
|
+ }
|
|
Integer cycleTimes = strategy.getCycleTimes();//循环次数
|
|
Integer cycleTimes = strategy.getCycleTimes();//循环次数
|
|
String usageLevel = strategy.getUsageLevel();//使用层级
|
|
String usageLevel = strategy.getUsageLevel();//使用层级
|
|
if ("account".equals(usageLevel)) {
|
|
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) {
|
|
if (length > 0 && cycleTimes >= length) {
|
|
/**-----------------项目维度:循环次数 大于 项目下账户总数-----------------*/
|
|
/**-----------------项目维度:循环次数 大于 项目下账户总数-----------------*/
|
|
- for (JSONObject account : accountList) {
|
|
|
|
|
|
+ for (Long accountId : accountList) {
|
|
//获取token
|
|
//获取token
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
//获取应用图片token
|
|
//获取应用图片token
|
|
JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
- strategy.setAccountId(account.getLong("accountId"));
|
|
|
|
|
|
+ strategy.setAccountId(accountId);
|
|
createApp(strategy, token, null);
|
|
createApp(strategy, token, null);
|
|
- createChannel(strategy, 1, 1);
|
|
|
|
|
|
+ createChannel(strategy, 0, 1);
|
|
}
|
|
}
|
|
} else {
|
|
} 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
|
|
//获取token
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
//获取应用图片token
|
|
//获取应用图片token
|
|
JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
- strategy.setAccountId(account.getLong("accountId"));
|
|
|
|
|
|
+ strategy.setAccountId(list.get(i));
|
|
createApp(strategy, token, null);
|
|
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 {
|
|
} else {
|
|
/**==========================范围是 账户==========================*/
|
|
/**==========================范围是 账户==========================*/
|
|
@@ -1142,100 +1178,4 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
createNewApp(channel, accountId, count + 1);
|
|
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;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
}
|
|
}
|