|
@@ -1,7 +1,12 @@
|
|
package cn.com.ctop.kuaishou.modules.batch.service.impl;
|
|
package cn.com.ctop.kuaishou.modules.batch.service.impl;
|
|
|
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
-import cn.com.ctop.common.module.utils.*;
|
|
|
|
|
|
+import cn.com.ctop.common.module.entity.MaterialInfo;
|
|
|
|
+import cn.com.ctop.common.module.mapper.MaterialInfoMapper;
|
|
|
|
+import cn.com.ctop.common.module.utils.Check;
|
|
|
|
+import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
|
+import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
|
|
+import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.mapper.*;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
|
|
@@ -854,9 +859,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
/**
|
|
/**
|
|
* 创建广告计划
|
|
* 创建广告计划
|
|
*
|
|
*
|
|
- * @param accessToken token信息
|
|
|
|
- * @param advertiserId 广告主id
|
|
|
|
- * @param requestJson 请求参数拼装
|
|
|
|
|
|
+ * @param accessToken token信息
|
|
|
|
+ * @param advertiserId 广告主id
|
|
|
|
+ * @param requestJson 请求参数拼装
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> campaignCreate(String accessToken, Long advertiserId, JSONObject requestJson) {
|
|
public Map<String, Object> campaignCreate(String accessToken, Long advertiserId, JSONObject requestJson) {
|
|
@@ -1580,6 +1585,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private MaterialInfoMapper materialInfoMapper;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> videoUpload(Long advertiserId, String accessToken, String videoUrl) {
|
|
public Map<String, Object> videoUpload(Long advertiserId, String accessToken, String videoUrl) {
|
|
Map<String, Object> returnMap = new HashMap<>();
|
|
Map<String, Object> returnMap = new HashMap<>();
|
|
@@ -1600,11 +1608,25 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
log.error("下载文件到本地文件夹失败,filePath:{},accountId:{}", videoUrl, advertiserId);
|
|
log.error("下载文件到本地文件夹失败,filePath:{},accountId:{}", videoUrl, advertiserId);
|
|
throw new Exception("下载文件到本地失败");
|
|
throw new Exception("下载文件到本地失败");
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ QueryWrapper<MaterialInfo> materialInfoQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ materialInfoQueryWrapper.eq("url", videoUrl);
|
|
|
|
+ materialInfoQueryWrapper.eq("status", 1);
|
|
|
|
+ materialInfoQueryWrapper.orderByDesc("create_time");
|
|
|
|
+ materialInfoQueryWrapper.last("limit 1");
|
|
|
|
+ MaterialInfo materialInfo = materialInfoMapper.selectOne(materialInfoQueryWrapper);
|
|
|
|
+ String signature;
|
|
|
|
+ if (Check.isNull(materialInfo) || Check.isNull(materialInfo.getCode())) {
|
|
|
|
+ signature = LoadFileUtil.getMD5(localUrl);
|
|
|
|
+ } else {
|
|
|
|
+ signature = materialInfo.getCode();
|
|
|
|
+ }
|
|
Long startTime = System.currentTimeMillis();
|
|
Long startTime = System.currentTimeMillis();
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_UPLOAD;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_UPLOAD;
|
|
JSONObject requestJson = new JSONObject();
|
|
JSONObject requestJson = new JSONObject();
|
|
requestJson.put("advertiser_id", advertiserId);
|
|
requestJson.put("advertiser_id", advertiserId);
|
|
- Map<String, String> headerMap = new HashMap<String, String>();
|
|
|
|
|
|
+ requestJson.put("signature", signature);
|
|
|
|
+ Map<String, String> headerMap = new HashMap<>();
|
|
headerMap.put("Access-Token", accessToken);
|
|
headerMap.put("Access-Token", accessToken);
|
|
headerMap.put("Content-Type", "multipart/form-data");
|
|
headerMap.put("Content-Type", "multipart/form-data");
|
|
String result = exceptInfoForRestTemplate(url, requestJson, headerMap, localUrl);
|
|
String result = exceptInfoForRestTemplate(url, requestJson, headerMap, localUrl);
|
|
@@ -1615,12 +1637,18 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
JSONObject dataJson = resultJson.getJSONObject("data");
|
|
JSONObject dataJson = resultJson.getJSONObject("data");
|
|
if (!Check.isNull(dataJson)) {
|
|
if (!Check.isNull(dataJson)) {
|
|
KuaiShouVideoUpload kuaiShouVideoUpload = new KuaiShouVideoUpload();
|
|
KuaiShouVideoUpload kuaiShouVideoUpload = new KuaiShouVideoUpload();
|
|
- kuaiShouVideoUpload.setPhotoId(dataJson.getString("photo_id"));
|
|
|
|
|
|
+ String photoId = dataJson.getString("photo_id");
|
|
|
|
+ kuaiShouVideoUpload.setPhotoId(photoId);
|
|
kuaiShouVideoUpload.setAccountId(advertiserId);
|
|
kuaiShouVideoUpload.setAccountId(advertiserId);
|
|
kuaiShouVideoUpload.setSavaPath(videoUrl);
|
|
kuaiShouVideoUpload.setSavaPath(videoUrl);
|
|
|
|
+ kuaiShouVideoUpload.setSignature(dataJson.getString("signature"));
|
|
kuaiShouVideoUpload.setSize(null);
|
|
kuaiShouVideoUpload.setSize(null);
|
|
kuaiShouVideoUpload.setType(null);
|
|
kuaiShouVideoUpload.setType(null);
|
|
kuaiShouVideoUpload.setUploadTime(DateUtils.timeStamp2Date(System.currentTimeMillis()));
|
|
kuaiShouVideoUpload.setUploadTime(DateUtils.timeStamp2Date(System.currentTimeMillis()));
|
|
|
|
+ Map<String, Object> deleteMap = new HashMap<>();
|
|
|
|
+ deleteMap.put("photo_id", photoId);
|
|
|
|
+ deleteMap.put("account_id", advertiserId);
|
|
|
|
+ videoUploadMapper.deleteByMap(deleteMap);
|
|
int i = videoUploadMapper.insert(kuaiShouVideoUpload);
|
|
int i = videoUploadMapper.insert(kuaiShouVideoUpload);
|
|
if (i > 0) {
|
|
if (i > 0) {
|
|
log.info("上传快手视频完成");
|
|
log.info("上传快手视频完成");
|
|
@@ -1639,7 +1667,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
returnMap.put("code", 0);
|
|
returnMap.put("code", 0);
|
|
returnMap.put("message", "视频已上传文件");
|
|
returnMap.put("message", "视频已上传文件");
|
|
returnMap.put("success", true);
|
|
returnMap.put("success", true);
|
|
- returnMap.put("photoId", dataJson.getString("photo_id"));
|
|
|
|
|
|
+ returnMap.put("photoId", photoId);
|
|
return returnMap;
|
|
return returnMap;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|