|
@@ -9,8 +9,8 @@ import cn.com.ctop.common.module.service.IUserAllocationService;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.ExportExcelUtils;
|
|
import cn.com.ctop.common.module.utils.ExportExcelUtils;
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
-import cn.com.ctop.common.module.utils.LoadFileUtil;
|
|
|
|
import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.service.IAiKuaiShouAppInfoService;
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouAppPackageService;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouAppList;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAppListService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouAppListService;
|
|
@@ -50,7 +50,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -94,6 +93,9 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
private IKuaiShouAppListService kuaiShouAppListService;
|
|
private IKuaiShouAppListService kuaiShouAppListService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private IAiKuaiShouAppInfoService appInfoService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
private IUserAllocationService userAllocationService;
|
|
private IUserAllocationService userAllocationService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -229,7 +231,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
//获取token
|
|
//获取token
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
//获取应用图片token
|
|
//获取应用图片token
|
|
- JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
|
|
|
|
+ JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
|
|
|
|
+ if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
|
|
+ log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
|
+ }
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setAccountId(accountId);
|
|
strategy.setAccountId(accountId);
|
|
KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
|
|
KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
|
|
@@ -250,7 +255,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
//获取token
|
|
//获取token
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
//获取应用图片token
|
|
//获取应用图片token
|
|
- JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
|
|
|
|
+ JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
|
|
|
|
+ if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
|
|
+ log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
|
+ }
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setAccountId(accountId);
|
|
strategy.setAccountId(accountId);
|
|
KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
|
|
KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, i);
|
|
@@ -282,7 +290,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
//获取token
|
|
//获取token
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
//获取应用图片token
|
|
//获取应用图片token
|
|
- JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
|
|
|
|
+ JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
|
|
|
|
+ if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
|
|
+ log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
|
+ }
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setAccountId(accountId);
|
|
strategy.setAccountId(accountId);
|
|
KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, j);
|
|
KuaishouChannelCreateStrategy replaceData = replaceWildcard(strategy, j);
|
|
@@ -302,7 +313,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
//获取token
|
|
//获取token
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
//获取应用图片token
|
|
//获取应用图片token
|
|
- JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
|
|
|
|
+ JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
|
|
|
|
+ if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
|
|
+ log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
|
+ }
|
|
//使用范围是账户时,查询旧app来做匹配
|
|
//使用范围是账户时,查询旧app来做匹配
|
|
List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(accountId);
|
|
List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(accountId);
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
@@ -335,7 +349,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
//获取token
|
|
//获取token
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
//获取应用图片token
|
|
//获取应用图片token
|
|
- JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
|
|
|
|
+ JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
|
|
|
|
+ if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
|
|
+ log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
|
+ }
|
|
//使用范围是账户时,查询旧app来做匹配
|
|
//使用范围是账户时,查询旧app来做匹配
|
|
List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(strategy.getAccountId());
|
|
List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(strategy.getAccountId());
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
@@ -403,52 +420,6 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 根据图片路径获取md5和账户token
|
|
|
|
- */
|
|
|
|
- private JSONObject getAccountImgToken(String appIconUrl, CtopOauthToken token) {
|
|
|
|
- JSONObject obj = new JSONObject();
|
|
|
|
- try {
|
|
|
|
- appIconUrl = appIconUrl.contains("http") ? appIconUrl : "https:" + appIconUrl;
|
|
|
|
- String newFileUrl = kuaishouAppPackageService.getDownloadPath(appIconUrl);
|
|
|
|
- if (Check.isNull(newFileUrl)) {
|
|
|
|
- log.error("下载图片失败,原路径:" + appIconUrl);
|
|
|
|
- obj.put("message", "下载图片失败,原路径:" + appIconUrl);
|
|
|
|
- return obj;
|
|
|
|
- }
|
|
|
|
- if (Check.isNull(token)) {
|
|
|
|
- log.error("根据图片路径获取md5,获取token失败");
|
|
|
|
- obj.put("message", "根据图片路径获取md5,获取token失败");
|
|
|
|
- return obj;
|
|
|
|
- }
|
|
|
|
- String md5 = null;
|
|
|
|
- try {
|
|
|
|
- md5 = LoadFileUtil.getMD5(newFileUrl);
|
|
|
|
- } catch (IOException e) {
|
|
|
|
- log.error("获取MD5签名失败,路径:" + newFileUrl, e);
|
|
|
|
- }
|
|
|
|
- if (Check.isNull(md5)) {
|
|
|
|
- log.error("获取MD5签名失败,路径:" + newFileUrl);
|
|
|
|
- obj.put("message", "获取MD5签名失败,路径:" + newFileUrl);
|
|
|
|
- return obj;
|
|
|
|
- }
|
|
|
|
- //获取图片MD5
|
|
|
|
- JSONObject dataJson = kuaishouAppPackageService.getImageToken(md5, token.getAccountId(), token);
|
|
|
|
- if (Check.isNull(dataJson)) {
|
|
|
|
- obj.put("message", "通过账户ID(" + token.getAccountId() + ")获取图片token,返回结果为空");
|
|
|
|
- return obj;
|
|
|
|
- }
|
|
|
|
- obj.put("md5", md5);
|
|
|
|
- obj.put("imageToken", dataJson.getString("image_token"));
|
|
|
|
- obj.put("message", "通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + dataJson.getString("message"));
|
|
|
|
- LoadFileUtil.delFile(newFileUrl);
|
|
|
|
- return obj;
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
- return obj;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
* 创建渠道号
|
|
* 创建渠道号
|
|
*/
|
|
*/
|
|
private void createChannel(KuaishouChannelCreateStrategy strategy, Integer number, Integer haveCycleTimes) throws Exception {
|
|
private void createChannel(KuaishouChannelCreateStrategy strategy, Integer number, Integer haveCycleTimes) throws Exception {
|
|
@@ -687,9 +658,12 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
return Result.error("解析数据失败,文档中第" + (i + 1) + "行,账户ID列缺失数据");
|
|
return Result.error("解析数据失败,文档中第" + (i + 1) + "行,账户ID列缺失数据");
|
|
} else {
|
|
} else {
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(Long.valueOf(accountId));
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(Long.valueOf(accountId));
|
|
- JSONObject tokenJson = getAccountImgToken(imageUrl, token);
|
|
|
|
|
|
+ JSONObject tokenJson = appInfoService.uploadAppIconImage(imageUrl, token.getAccountId(), token.getAccessToken());
|
|
|
|
+ if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
|
|
+ log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
|
+ }
|
|
imageToken = tokenJson.getString("imageToken");
|
|
imageToken = tokenJson.getString("imageToken");
|
|
- md5 = tokenJson.getString("md5");
|
|
|
|
|
|
+ md5 = tokenJson.getString("signature");
|
|
if (Check.isNull(imageToken)) {
|
|
if (Check.isNull(imageToken)) {
|
|
return Result.error(tokenJson.getString("message"));
|
|
return Result.error(tokenJson.getString("message"));
|
|
}
|
|
}
|
|
@@ -856,7 +830,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
//获取token
|
|
//获取token
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
//获取应用图片token
|
|
//获取应用图片token
|
|
- JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
|
|
|
|
+ JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
|
|
|
|
+ if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
|
|
+ log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
|
+ }
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setAccountId(accountId);
|
|
strategy.setAccountId(accountId);
|
|
createApp(strategy, token, null);
|
|
createApp(strategy, token, null);
|
|
@@ -869,7 +846,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
//获取token
|
|
//获取token
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
//获取应用图片token
|
|
//获取应用图片token
|
|
- JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
|
|
|
|
+ JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
|
|
|
|
+ if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
|
|
+ log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
|
+ }
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setAccountId(list.get(i));
|
|
strategy.setAccountId(list.get(i));
|
|
createApp(strategy, token, null);
|
|
createApp(strategy, token, null);
|
|
@@ -882,7 +862,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
//获取token
|
|
//获取token
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
//获取应用图片token
|
|
//获取应用图片token
|
|
- JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
|
|
|
|
+ JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
|
|
|
|
+ if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
|
|
+ log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
|
+ }
|
|
//使用范围是账户时,查询旧app来做匹配
|
|
//使用范围是账户时,查询旧app来做匹配
|
|
List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(accountId);
|
|
List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(accountId);
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
@@ -900,7 +883,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
//获取token
|
|
//获取token
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
CtopOauthToken token = tokenService.getTokenByAccountId(strategy.getAccountId());
|
|
//获取应用图片token
|
|
//获取应用图片token
|
|
- JSONObject tokenJson = getAccountImgToken(strategy.getAppIconUrl(), token);
|
|
|
|
|
|
+ JSONObject tokenJson = appInfoService.uploadAppIconImage(strategy.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
|
|
|
|
+ if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
|
|
+ log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
|
+ }
|
|
//使用范围是账户时,查询旧app来做匹配
|
|
//使用范围是账户时,查询旧app来做匹配
|
|
List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(strategy.getAccountId());
|
|
List<KuaiShouAppList> oldAppList = kuaiShouAppListService.getAppListByAccountId(strategy.getAccountId());
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
strategy.setImageToken(tokenJson.getString("imageToken"));
|
|
@@ -1162,7 +1148,10 @@ public class KuaishouChannelServiceImpl extends ServiceImpl<KuaishouChannelMappe
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
KuaishouChannelAppInfo one = channelAppInfoService.getById(channel.getChannelAppInfoId());
|
|
KuaishouChannelAppInfo one = channelAppInfoService.getById(channel.getChannelAppInfoId());
|
|
- JSONObject tokenJson = getAccountImgToken(one.getAppIconUrl(), token);
|
|
|
|
|
|
+ JSONObject tokenJson = appInfoService.uploadAppIconImage(one.getAppIconUrl(), token.getAccountId(), token.getAccessToken());
|
|
|
|
+ if (!Check.isNull(tokenJson) && tokenJson.getInteger("code") != 0) {
|
|
|
|
+ log.error("通过账户ID(" + token.getAccountId() + ")获取图片Token失败,返回信息:" + tokenJson.getString("message"));
|
|
|
|
+ }
|
|
String imageToken = tokenJson.getString("imageToken");
|
|
String imageToken = tokenJson.getString("imageToken");
|
|
JSONObject requestJson = new JSONObject();
|
|
JSONObject requestJson = new JSONObject();
|
|
requestJson.put("advertiser_id", accountId);
|
|
requestJson.put("advertiser_id", accountId);
|