|
@@ -39,14 +39,12 @@ import org.springframework.util.MultiValueMap;
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.client.RestTemplate;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
-import javax.crypto.spec.PBEParameterSpec;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.lang.reflect.ParameterizedType;
|
|
import java.lang.reflect.ParameterizedType;
|
|
import java.lang.reflect.Type;
|
|
import java.lang.reflect.Type;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @author 于萌萌
|
|
* @author 于萌萌
|
|
@@ -100,6 +98,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
private IKuaishouReportDailyAccountService dailyAccountService;
|
|
private IKuaishouReportDailyAccountService dailyAccountService;
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaishouReportHourlyAccountService hourlyAccountService;
|
|
private IKuaishouReportHourlyAccountService hourlyAccountService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private KuaiShouAdvertiserBaseInfoMapper advertiserBaseInfoMapper;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 广告主日报表信息
|
|
* 广告主日报表信息
|
|
@@ -248,6 +248,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
private IKuaishouReportDailyCreativeService dailyCreativeService;
|
|
private IKuaishouReportDailyCreativeService dailyCreativeService;
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaishouReportHourlyCreativeService hourlyCreativeService;
|
|
private IKuaishouReportHourlyCreativeService hourlyCreativeService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public KuaishouResult<KuaishouReportDailyGroup> getGroupDailyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
|
|
public KuaishouResult<KuaishouReportDailyGroup> getGroupDailyReport(String accessToken, Long advertiserId, String startDate, String endDate, int pageSize, int pageNum) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GTOUP_REPORT;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.GTOUP_REPORT;
|
|
@@ -408,7 +409,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
returnMap.put("campaign_id", campaignId);
|
|
returnMap.put("campaign_id", campaignId);
|
|
returnMap.put("success", true);
|
|
returnMap.put("success", true);
|
|
} else {
|
|
} else {
|
|
- log.error("创建广告信息失败,advertiser_id:{},返回信息:{}", advertiserId, resultJson);
|
|
|
|
|
|
+ log.error("创建广告计划失败,advertiser_id:{},返回信息:{}", advertiserId, resultJson);
|
|
returnMap.put("code", -1);
|
|
returnMap.put("code", -1);
|
|
returnMap.put("message", resultJson.getString("message"));
|
|
returnMap.put("message", resultJson.getString("message"));
|
|
returnMap.put("desc", "创建广告计划失败");
|
|
returnMap.put("desc", "创建广告计划失败");
|
|
@@ -453,6 +454,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
headers.put("Content-Type", " application/json");
|
|
headers.put("Content-Type", " application/json");
|
|
String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
|
|
String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
+ log.info("快手创建广告组返回,accountId:{},返回结果:{}", advertiserId, resultJson);
|
|
if (!Check.isNull(resultJson)) {
|
|
if (!Check.isNull(resultJson)) {
|
|
Integer code = resultJson.getInteger("code");
|
|
Integer code = resultJson.getInteger("code");
|
|
if (code == 0) {
|
|
if (code == 0) {
|
|
@@ -466,14 +468,14 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
}
|
|
}
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- log.error("创建广告信息失败,advertiser_id:{},返回信息:{}", advertiserId, resultJson);
|
|
|
|
|
|
+ log.error("创建广告信息失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson);
|
|
returnMap.put("code", -1);
|
|
returnMap.put("code", -1);
|
|
returnMap.put("message", resultJson.getString("message"));
|
|
returnMap.put("message", resultJson.getString("message"));
|
|
returnMap.put("desc", "创建广告组失败");
|
|
returnMap.put("desc", "创建广告组失败");
|
|
returnMap.put("success", false);
|
|
returnMap.put("success", false);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- log.error("快手创建广告计划返回内容为空,advertiser_id:{}", advertiserId);
|
|
|
|
|
|
+ log.error("快手创建广告计划返回内容为空,advertiser_id:{},入参:{}", advertiserId, requestJson);
|
|
returnMap.put("code", -1);
|
|
returnMap.put("code", -1);
|
|
returnMap.put("message", "创建广告组异常");
|
|
returnMap.put("message", "创建广告组异常");
|
|
returnMap.put("desc", "result is null");
|
|
returnMap.put("desc", "result is null");
|
|
@@ -944,7 +946,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), header);
|
|
String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), header);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
- log.info("快手创建创意返回信息:{}", resultJson);
|
|
|
|
|
|
+ log.info("快手创建创意返回:accountId:{},返回结果{}", advertiserId, resultJson);
|
|
if (!Check.isNull(resultJson)) {
|
|
if (!Check.isNull(resultJson)) {
|
|
Integer code = resultJson.getInteger("code");
|
|
Integer code = resultJson.getInteger("code");
|
|
if (code == 0) {
|
|
if (code == 0) {
|
|
@@ -969,14 +971,14 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
returnMap.put("success", true);
|
|
returnMap.put("success", true);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- log.error("创建广告创意失败,advertiser_id:{},返回信息:{}", advertiserId, resultJson);
|
|
|
|
|
|
+ log.error("创建广告创意失败,advertiser_id:{},返回信息:{},入参:{}", advertiserId, resultJson, requestJson);
|
|
returnMap.put("code", -1);
|
|
returnMap.put("code", -1);
|
|
returnMap.put("message", resultJson.getString("message"));
|
|
returnMap.put("message", resultJson.getString("message"));
|
|
- returnMap.put("desc", "上传图片失败");
|
|
|
|
|
|
+ returnMap.put("desc", "创意创建失败");
|
|
returnMap.put("success", false);
|
|
returnMap.put("success", false);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- log.error("快手创建广告创意返回内容为空,advertiser_id:{}", advertiserId);
|
|
|
|
|
|
+ log.error("快手创建广告创意返回内容为空,advertiser_id:{},入参:{}", advertiserId, requestJson);
|
|
returnMap.put("code", -1);
|
|
returnMap.put("code", -1);
|
|
returnMap.put("message", "上传图片异常");
|
|
returnMap.put("message", "上传图片异常");
|
|
returnMap.put("desc", "result is null");
|
|
returnMap.put("desc", "result is null");
|
|
@@ -997,7 +999,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> videoUpload(Long advertiserId, String accessToken, String videoUrl) {
|
|
public Map<String, Object> videoUpload(Long advertiserId, String accessToken, String videoUrl) {
|
|
- log.info("开始上传视频");
|
|
|
|
Map<String, Object> returnMap = new HashMap<>();
|
|
Map<String, Object> returnMap = new HashMap<>();
|
|
try {
|
|
try {
|
|
QueryWrapper<KuaiShouVideoUpload> wrapper = new QueryWrapper<>();
|
|
QueryWrapper<KuaiShouVideoUpload> wrapper = new QueryWrapper<>();
|
|
@@ -1016,6 +1017,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
log.error("下载文件到本地文件夹失败,filePath:{},accountId:{}", videoUrl, advertiserId);
|
|
log.error("下载文件到本地文件夹失败,filePath:{},accountId:{}", videoUrl, advertiserId);
|
|
throw new Exception("下载文件到本地失败");
|
|
throw new Exception("下载文件到本地失败");
|
|
}
|
|
}
|
|
|
|
+ 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);
|
|
@@ -1048,7 +1050,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
queryWrapper.eq("local_url", videoUrl);
|
|
queryWrapper.eq("local_url", videoUrl);
|
|
int y = kuaiShouVideoMapper.update(video, queryWrapper);
|
|
int y = kuaiShouVideoMapper.update(video, queryWrapper);
|
|
if (y > 0) {
|
|
if (y > 0) {
|
|
- log.info("更新快手视频状态成功.accountId:{}", advertiserId);
|
|
|
|
|
|
+ log.info("更新快手视频状态成功.accountId:{},上传耗时:{} ms", advertiserId, System.currentTimeMillis() - startTime);
|
|
}
|
|
}
|
|
|
|
|
|
returnMap.put("code", 0);
|
|
returnMap.put("code", 0);
|
|
@@ -1244,7 +1246,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Map<String, Object> imageUpload(Long advertiserId, String accessToken, String filePath, Integer type) {
|
|
public Map<String, Object> imageUpload(Long advertiserId, String accessToken, String filePath, Integer type) {
|
|
- log.info("上传快手图片");
|
|
|
|
Map<String, Object> returnMap = new HashMap<>();
|
|
Map<String, Object> returnMap = new HashMap<>();
|
|
try {
|
|
try {
|
|
QueryWrapper<KuaiShouImageUploand> queryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<KuaiShouImageUploand> queryWrapper = new QueryWrapper<>();
|
|
@@ -1263,6 +1264,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
log.error("下载文件到本地文件夹失败,filePath:{},accountId:{}", filePath, advertiserId);
|
|
log.error("下载文件到本地文件夹失败,filePath:{},accountId:{}", filePath, advertiserId);
|
|
throw new Exception("下载文件到本地失败");
|
|
throw new Exception("下载文件到本地失败");
|
|
}
|
|
}
|
|
|
|
+ Long startTime = System.currentTimeMillis();
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_UPLOAD;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.IMAGE_UPLOAD;
|
|
JSONObject requestJson = new JSONObject();
|
|
JSONObject requestJson = new JSONObject();
|
|
requestJson.put("advertiser_id", advertiserId);
|
|
requestJson.put("advertiser_id", advertiserId);
|
|
@@ -1289,7 +1291,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
imageUploand.setWidth(dataJson.getLong("width"));
|
|
imageUploand.setWidth(dataJson.getLong("width"));
|
|
int i = imageUploandMapper.insert(imageUploand);
|
|
int i = imageUploandMapper.insert(imageUploand);
|
|
if (i > 0) {
|
|
if (i > 0) {
|
|
- log.info("快手-图片上传成功");
|
|
|
|
|
|
+ log.info("快手-图片上传成功,共耗时:{} ms", System.currentTimeMillis() - startTime);
|
|
}
|
|
}
|
|
returnMap.put("code", 0);
|
|
returnMap.put("code", 0);
|
|
returnMap.put("desc", "上传图片完成");
|
|
returnMap.put("desc", "上传图片完成");
|
|
@@ -1363,6 +1365,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
Map<String, String> header = new HashMap<String, String>();
|
|
Map<String, String> header = new HashMap<String, String>();
|
|
header.put("Content-Type", "multipart/form-data");
|
|
header.put("Content-Type", "multipart/form-data");
|
|
header.put("Access-Token", accessToken);
|
|
header.put("Access-Token", accessToken);
|
|
|
|
+ Long startTime = System.currentTimeMillis();
|
|
String result = exceptInfoForRestTemplate(url, requestJson, header, localUrl);
|
|
String result = exceptInfoForRestTemplate(url, requestJson, header, localUrl);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
JSONObject resultJson = JSONObject.parseObject(result);
|
|
if (!Check.isNull(result)) {
|
|
if (!Check.isNull(result)) {
|
|
@@ -1384,7 +1387,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
appCreate.setUploadTime(new Date().toString());
|
|
appCreate.setUploadTime(new Date().toString());
|
|
int i = appCreateMapper.insert(appCreate);
|
|
int i = appCreateMapper.insert(appCreate);
|
|
if (i > 0) {
|
|
if (i > 0) {
|
|
- log.info("快手创建应用成功");
|
|
|
|
|
|
+ log.info("快手创建应用成功,共耗时:{} ms", System.currentTimeMillis() - startTime);
|
|
}
|
|
}
|
|
returnMap.put("appId", dataJson.getLong("app_id"));
|
|
returnMap.put("appId", dataJson.getLong("app_id"));
|
|
returnMap.put("success", true);
|
|
returnMap.put("success", true);
|
|
@@ -1493,6 +1496,68 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
return returnMap;
|
|
return returnMap;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取快手广告租信息
|
|
|
|
+ *
|
|
|
|
+ * @param accountId
|
|
|
|
+ * @param accessToken
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Map<String, Object> advertiserInfo(Long accountId, String accessToken) {
|
|
|
|
+ Map<String, Object> returnMap = new HashMap<>();
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+ Map<String, Object> deleteMap = new HashMap<>();
|
|
|
|
+ deleteMap.put("account_id", accountId);
|
|
|
|
+ advertiserBaseInfoMapper.deleteByMap(deleteMap);
|
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.ADVERTISER_INFO;
|
|
|
|
+ Map<String, String> headers = new HashMap<String, String>();
|
|
|
|
+ headers.put("Access-Token", accessToken);
|
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
|
+ JSONObject requestJson = new JSONObject();
|
|
|
|
+ requestJson.put("advertiser_id", accountId);
|
|
|
|
+ String result = HttpUtils.kuaiShouhttpPostRequest(url, requestJson.toJSONString(), headers);
|
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
|
+ if (resultJson.getInteger("code") == 0) {
|
|
|
|
+ JSONObject dataJson = resultJson.getJSONObject("data");
|
|
|
|
+ if (!Check.isNull(dataJson)) {
|
|
|
|
+ KuaiShouAdvertiserBaseInfo advertiserBaseInfo = new KuaiShouAdvertiserBaseInfo();
|
|
|
|
+ advertiserBaseInfo.setAccountId(accountId);
|
|
|
|
+ advertiserBaseInfo.setUserId(dataJson.getString("user_id"));
|
|
|
|
+ String corporationName = dataJson.getString("corporation_name");
|
|
|
|
+ advertiserBaseInfo.setCorporationName(corporationName);
|
|
|
|
+ String userName = dataJson.getString("user_name");
|
|
|
|
+ advertiserBaseInfo.setUserName(userName);
|
|
|
|
+ returnMap.put("code", 0);
|
|
|
|
+ returnMap.put("message", "success");
|
|
|
|
+ returnMap.put("userName", userName);
|
|
|
|
+ returnMap.put("corporationName", corporationName);
|
|
|
|
+ int i = advertiserBaseInfoMapper.insert(advertiserBaseInfo);
|
|
|
|
+ if (i > 0) {
|
|
|
|
+ log.info("快手获取广告主基本信息入库完成,accountId:{}", accountId);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.error("快手获取广告主基本信息返回为空,accountId:{}", accountId);
|
|
|
|
+ returnMap.put("code", -1);
|
|
|
|
+ returnMap.put("message", "返回信息为空");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ log.error("快手获取广告主基本信息返回错误,accountId:{},错误信息:{}", accountId, resultJson);
|
|
|
|
+ returnMap.put("code", -1);
|
|
|
|
+ returnMap.put("message", resultJson.getString("message"));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ returnMap.put("code", -1);
|
|
|
|
+ returnMap.put("message", "接口执行失败");
|
|
|
|
+ }
|
|
|
|
+ return returnMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获取应用列表
|
|
* 获取应用列表
|
|
*
|
|
*
|
|
@@ -1609,7 +1674,6 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
}
|
|
}
|
|
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<MultiValueMap<String, Object>>(param, headers);
|
|
HttpEntity<MultiValueMap<String, Object>> httpEntity = new HttpEntity<MultiValueMap<String, Object>>(param, headers);
|
|
ResponseEntity<String> responseEntity = rest.exchange(url, HttpMethod.POST, httpEntity, String.class);
|
|
ResponseEntity<String> responseEntity = rest.exchange(url, HttpMethod.POST, httpEntity, String.class);
|
|
- System.err.println(responseEntity.getBody());
|
|
|
|
return responseEntity.getBody();
|
|
return responseEntity.getBody();
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|