|
@@ -56,6 +56,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Locale;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
@@ -152,7 +153,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
List<JSONObject> list = channelMapper.channelNumberUsageDetailsList(kuaishouChannel);
|
|
|
for (JSONObject jsonObject : list) {
|
|
|
String time = kuaiShouCreativeService.querMaxCreateTime(jsonObject.getLong("unitId"));
|
|
|
- jsonObject.put("createTime",time);
|
|
|
+ jsonObject.put("createTime", time);
|
|
|
}
|
|
|
PageInfo pageInfo = new PageInfo(list);
|
|
|
pageInfo.setTotal(total);
|
|
@@ -248,7 +249,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
Long accountId = accountList.get(length);
|
|
|
if (!Check.isNull(accountId)) {
|
|
|
//获取token
|
|
|
- CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
//获取应用图片token
|
|
|
JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
|
|
|
if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
@@ -272,7 +273,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
Long accountId = accountList.get(length);
|
|
|
if (!Check.isNull(accountId)) {
|
|
|
//获取token
|
|
|
- CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
//获取应用图片token
|
|
|
JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
|
|
|
if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
@@ -307,7 +308,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
Long accountId = accountSubList.get(k);
|
|
|
if (!Check.isNull(accountId)) {
|
|
|
//获取token
|
|
|
- CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
//获取应用图片token
|
|
|
JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
|
|
|
if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
@@ -374,8 +375,8 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
}
|
|
|
//使用范围是账户时,查询旧app来做匹配
|
|
|
- kuaishouInterfaceService.getAppList(strategy.getAccountId(), token.getAccessToken());
|
|
|
- List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(strategy.getAccountId());
|
|
|
+ kuaishouInterfaceService.getAppList(token.getAccountId(), token.getAccessToken());
|
|
|
+ List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(token.getAccountId());
|
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
|
if (url.contains(CHANNEL_STR)) {
|
|
|
ilist.forEach(i -> executorService.submit(() -> {
|
|
@@ -504,7 +505,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
channelAppInfo.setImageToken(String.valueOf(app.getImageToken()));
|
|
|
JSONObject requestJson = new JSONObject();
|
|
|
requestJson.put("app_id", app.getAppId());
|
|
|
- requestJson.put("advertiser_id", strategy.getAccountId());
|
|
|
+ requestJson.put("advertiser_id", token.getAccountId());
|
|
|
requestJson.put("app_version", strategy.getAppVersion());
|
|
|
requestJson.put("app_privacy_url", strategy.getAppPrivacyUrl());
|
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.APP_UPDATE;
|
|
@@ -544,7 +545,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
if (!Check.isNull(token)) {
|
|
|
String accessToken = token.getAccessToken();
|
|
|
JSONObject requestJson = new JSONObject();
|
|
|
- requestJson.put("advertiser_id", strategy.getAccountId());
|
|
|
+ requestJson.put("advertiser_id", token.getAccountId());
|
|
|
requestJson.put("app_version", strategy.getAppVersion());
|
|
|
requestJson.put("app_name", strategy.getAppName());
|
|
|
requestJson.put("image_token", strategy.getImageToken());
|
|
@@ -792,7 +793,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
obj.put("clickTrackUrl", clickTrackUrl);
|
|
|
obj.put("isHaveItem", isHaveItem);
|
|
|
obj.put("itemName", itemName);
|
|
|
- obj.put("usageLevel", usageLevel);
|
|
|
+ obj.put("usageLevel", usageLevel.toLowerCase());
|
|
|
obj.put("isCycle", isCycleTimes);
|
|
|
obj.put("cycleTimes", cycleTimes);
|
|
|
obj.put("schemaUri", schemaUri);
|
|
@@ -882,7 +883,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
/**-----------------项目维度:循环次数 大于 项目下账户总数-----------------*/
|
|
|
for (Long accountId : accountList) {
|
|
|
//获取token
|
|
|
- CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
//获取应用图片token
|
|
|
JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
|
|
|
if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
@@ -897,6 +898,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
List<List<Long>> accountSubLists = Lists.partition(accountList, cycleTimes);
|
|
|
List<Long> list = accountSubLists.get(0);
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
+ strategy.setAccountId(list.get(i));
|
|
|
//获取token
|
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
|
//获取应用图片token
|
|
@@ -905,7 +907,6 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
}
|
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
|
- strategy.setAccountId(list.get(i));
|
|
|
createApp(strategy, token, null);
|
|
|
createChannel(strategy, 0, i + 1);
|
|
|
}
|
|
@@ -921,7 +922,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
}
|
|
|
//使用范围是账户时,查询旧app来做匹配
|
|
|
- kuaishouInterfaceService.getAppList(strategy.getAccountId(), token.getAccessToken());
|
|
|
+ kuaishouInterfaceService.getAppList(token.getAccountId(), token.getAccessToken());
|
|
|
List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(accountId);
|
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
|
strategy.setAccountId(accountId);
|
|
@@ -943,8 +944,8 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
}
|
|
|
//使用范围是账户时,查询旧app来做匹配
|
|
|
- kuaishouInterfaceService.getAppList(strategy.getAccountId(), token.getAccessToken());
|
|
|
- List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(strategy.getAccountId());
|
|
|
+ kuaishouInterfaceService.getAppList(token.getAccountId(), token.getAccessToken());
|
|
|
+ List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(token.getAccountId());
|
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
|
try {
|
|
|
createApp(strategy, token, oldAppList);
|
|
@@ -962,7 +963,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result<Object> queryChannel(Long accountId, String level, String appName) throws Exception {
|
|
|
+ public Result<Object> queryChannel(Long accountId, String level, String appName, String photoName) throws Exception {
|
|
|
//查询账户策略
|
|
|
List<KuaishouChannelCreateStrategy> strategys = channelCreateStrategyService.queryChannelStrategyByAccountId(accountId);
|
|
|
if (Check.isNull(strategys) || strategys.isEmpty()) {
|
|
@@ -989,7 +990,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
return doPlanLevel(accountId, strategys, appName, 0);
|
|
|
} else if ("group".equals(usageLevel)) {
|
|
|
//---------------------组层级---------------------
|
|
|
- return doGroupLevel(accountId, strategys, appName, 0);
|
|
|
+ return doGroupLevel(accountId, strategys, appName, 0, photoName);
|
|
|
}
|
|
|
} else {
|
|
|
/**============================项目范围============================*/
|
|
@@ -1001,7 +1002,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
return doPlanLevel(accountId, strategys, appName, 0);
|
|
|
} else if ("group".equals(usageLevel)) {
|
|
|
//---------------------组层级---------------------
|
|
|
- return doGroupLevel(accountId, strategys, appName, 0);
|
|
|
+ return doGroupLevel(accountId, strategys, appName, 0, photoName);
|
|
|
}
|
|
|
}
|
|
|
return Result.error("未查到渠道号");
|
|
@@ -1012,14 +1013,15 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
Long accountId = data.getLong("accountId");
|
|
|
JSONArray appNameArray = data.getJSONArray("appNameArray");
|
|
|
String appName = appNameArray.getString(0);
|
|
|
- KuaishouChannel channel = channelMapper.queryByAccountId(accountId);
|
|
|
- if (Check.isNull(channel)) {
|
|
|
- return Result.ok("没有渠道号");
|
|
|
- }
|
|
|
+ KuaishouChannel channel = channelMapper.queryByAccountId(accountId, 1);
|
|
|
JSONObject request = new JSONObject();
|
|
|
- if (channel.getIsHaveItem() == 1) {
|
|
|
- List<JSONObject> list = channelMapper.queryItemsListByAccountId(accountId, appName);
|
|
|
- request.put("list", list);
|
|
|
+ if (!Check.isNull(channel)) {
|
|
|
+ request.put("list", channelMapper.queryItemsListByAccountId(accountId, appName));
|
|
|
+ } else {
|
|
|
+ channel = channelMapper.queryByAccountId(accountId, null);
|
|
|
+ if (Check.isNull(channel)) {
|
|
|
+ return Result.error("该账户没有配置渠道号");
|
|
|
+ }
|
|
|
}
|
|
|
request.put("channel", channel);
|
|
|
return Result.ok(request);
|
|
@@ -1068,10 +1070,30 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public KuaishouChannel queryUsedChannel(Long accountId, Long newCampaignId, String level) {
|
|
|
+ KuaishouChannel channel = channelMapper.queryUsedChannel(accountId, newCampaignId, level);
|
|
|
+ if (!Check.isNull(channel) && channel.getIsHaveItem() == 1) {
|
|
|
+ List<KuaishouChannelItems> list = channelItemsRelService.queryItems(channel.getId());
|
|
|
+ if (Check.isNull(list) || list.isEmpty()) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ channel.setItems(list);
|
|
|
+ }
|
|
|
+ return channel;
|
|
|
+ }
|
|
|
+
|
|
|
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) {
|
|
|
+ if (channel.getIsHaveItem() == 1) {
|
|
|
+ List<KuaishouChannelItems> list = channelItemsRelService.queryItems(channel.getId());
|
|
|
+ if (Check.isNull(list) || list.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ channel.setItems(list);
|
|
|
+ }
|
|
|
KuaishouChannelRel channelRel = channelRelService.queryByAccountChannelCode(channel.getChannelCode(), accountId, appName);
|
|
|
if (Check.isNull(channelRel)) {
|
|
|
continue;
|
|
@@ -1112,6 +1134,13 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
Integer usageTimes = channel.getUsageTimes();//使用次数
|
|
|
//优先判断已经循环的次数 大于 使用次数
|
|
|
if (haveCycleTimes > usageTimes) {
|
|
|
+ if (channel.getIsHaveItem() == 1) {
|
|
|
+ List<KuaishouChannelItems> items = channelItemsRelService.queryItems(channel.getId());
|
|
|
+ if (Check.isNull(items) || items.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ channel.setItems(items);
|
|
|
+ }
|
|
|
// 符合条件,获取该渠道号
|
|
|
KuaishouChannelRel channelRel = channelRelService.queryByAccountChannelCode(channel.getChannelCode(), accountId, appName);
|
|
|
if (Check.isNull(channelRel)) {
|
|
@@ -1153,7 +1182,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
}
|
|
|
|
|
|
//通过项目范围广告组层级查询
|
|
|
- private Result<Object> doGroupLevel(Long accountId, List<KuaishouChannelCreateStrategy> strategys, String appName, int count) throws Exception {
|
|
|
+ private Result<Object> doGroupLevel(Long accountId, List<KuaishouChannelCreateStrategy> strategys, String appName, int count, String photoName) throws Exception {
|
|
|
List<Integer> haveCycleTimesList = channelMapper.queryUsedLevel(strategys);
|
|
|
if (Check.isNull(haveCycleTimesList)) {
|
|
|
return Result.error("渠道号已无效");
|
|
@@ -1169,6 +1198,18 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
Integer usageTimes = channel.getUsageTimes();//使用次数
|
|
|
//优先判断已经循环的次数 大于 使用次数
|
|
|
if (haveCycleTimes > usageTimes) {
|
|
|
+ if (!Check.isNull(channel.getIsHaveItem()) && channel.getIsHaveItem() == 1) {
|
|
|
+ //有单品
|
|
|
+ List<KuaishouChannelItems> itemsList = channelItemsRelService.queryItems(channel.getId());
|
|
|
+ if (Check.isNull(itemsList) || itemsList.isEmpty()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //素材名字和单品关键字做匹配
|
|
|
+ String keyword = itemsList.get(0).getKeyword();
|
|
|
+ if (!photoName.contains(keyword)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
// 符合条件,获取该渠道号
|
|
|
KuaishouChannelRel channelRel = channelRelService.queryByAccountChannelCode(channel.getChannelCode(), accountId, appName);
|
|
|
if (Check.isNull(channelRel)) {
|
|
@@ -1204,7 +1245,7 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
|
}
|
|
|
}
|
|
|
if (count == 0) {
|
|
|
- return doGroupLevel(accountId, strategys, appName, 1);
|
|
|
+ return doGroupLevel(accountId, strategys, appName, 1, photoName);
|
|
|
}
|
|
|
return Result.ok("未查询到渠道号");
|
|
|
}
|