|
@@ -132,6 +132,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
private IKuaishouPopulationService populationService;
|
|
private IKuaishouPopulationService populationService;
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaiShouGroupService getKuaiShouGroupService;
|
|
private IKuaiShouGroupService getKuaiShouGroupService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouAdvertiserBaseInfoService KuaiShouAdvertiserBaseInfoService;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -186,6 +188,9 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
getVideoListByPage(token, startDate, endDate, 1);
|
|
getVideoListByPage(token, startDate, endDate, 1);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
private void getVideoListByPage(CtopOauthToken token, String startDate, String endDate, int page) {
|
|
private void getVideoListByPage(CtopOauthToken token, String startDate, String endDate, int page) {
|
|
try {
|
|
try {
|
|
log.info("获取视频数据,accountId:{}", token.getAccountId());
|
|
log.info("获取视频数据,accountId:{}", token.getAccountId());
|
|
@@ -214,6 +219,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
|
|
log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ KuaiShouAdvertiserBaseInfo baseInfo = KuaiShouAdvertiserBaseInfoService.getBaseInfo(token.getAccountId());
|
|
|
|
+ Long userId = null;
|
|
|
|
+ if (!Check.isNull(baseInfo)) {
|
|
|
|
+ userId = Long.valueOf(baseInfo.getUserId());
|
|
|
|
+ }
|
|
for (int i = 0; i < details.size(); i++) {
|
|
for (int i = 0; i < details.size(); i++) {
|
|
var detailJson = details.getJSONObject(i);
|
|
var detailJson = details.getJSONObject(i);
|
|
KuaiShouVideoGet byId = kuaiShouVideoGetService.getById(token.getAccountId() + detailJson.getString("photo_id"));
|
|
KuaiShouVideoGet byId = kuaiShouVideoGetService.getById(token.getAccountId() + detailJson.getString("photo_id"));
|
|
@@ -230,6 +240,8 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
if (!Check.isNull(type)) {
|
|
if (!Check.isNull(type)) {
|
|
kuaiShouVideoGet.setMaterialType(type);
|
|
kuaiShouVideoGet.setMaterialType(type);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ kuaiShouVideoGet.setUserId(userId);
|
|
kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
|
|
kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
|
|
|
|
|
|
Thread thread = new Thread() {
|
|
Thread thread = new Thread() {
|
|
@@ -1380,17 +1392,17 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
* 获取视频信息数据
|
|
* 获取视频信息数据
|
|
*
|
|
*
|
|
* @param accessToken
|
|
* @param accessToken
|
|
- * @param advertiserId
|
|
|
|
|
|
+ * @param accountId
|
|
* @param photoId
|
|
* @param photoId
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public void getVideoInfo(String accessToken, Long advertiserId, String photoId) {
|
|
|
|
|
|
+ public void getVideoInfo(String accessToken, Long accountId, String photoId) {
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_GET;
|
|
String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_GET;
|
|
Map<String, String> headers = new HashMap<String, String>();
|
|
Map<String, String> headers = new HashMap<String, String>();
|
|
headers.put("Content-Type", " application/json");
|
|
headers.put("Content-Type", " application/json");
|
|
headers.put("Access-Token", accessToken);
|
|
headers.put("Access-Token", accessToken);
|
|
JSONObject param = new JSONObject();
|
|
JSONObject param = new JSONObject();
|
|
- param.put("advertiser_id", advertiserId);
|
|
|
|
|
|
+ param.put("advertiser_id", accountId);
|
|
JSONArray photosArray = new JSONArray();
|
|
JSONArray photosArray = new JSONArray();
|
|
photosArray.add(photoId);
|
|
photosArray.add(photoId);
|
|
param.put("photo_ids", photosArray);
|
|
param.put("photo_ids", photosArray);
|
|
@@ -1402,27 +1414,49 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
if (code == 0) {
|
|
if (code == 0) {
|
|
JSONArray dataArray = resultJson.getJSONArray("data");
|
|
JSONArray dataArray = resultJson.getJSONArray("data");
|
|
if (!Check.isNull(dataArray)) {
|
|
if (!Check.isNull(dataArray)) {
|
|
|
|
+ KuaiShouAdvertiserBaseInfo baseInfo = KuaiShouAdvertiserBaseInfoService.getBaseInfo(accountId);
|
|
|
|
+ Long userId = null;
|
|
|
|
+ if (!Check.isNull(baseInfo)) {
|
|
|
|
+ userId = Long.valueOf(baseInfo.getUserId());
|
|
|
|
+ }
|
|
for (int i = 0; i < dataArray.size(); i++) {
|
|
for (int i = 0; i < dataArray.size(); i++) {
|
|
JSONObject detailJson = dataArray.getJSONObject(i);
|
|
JSONObject detailJson = dataArray.getJSONObject(i);
|
|
if (!Check.isNull(detailJson)) {
|
|
if (!Check.isNull(detailJson)) {
|
|
- KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
|
|
|
|
- videoGet.setId(detailJson.getString("photo_id"));
|
|
|
|
- videoGet.setAccountId(advertiserId);
|
|
|
|
- videoGet.setWidth(detailJson.getInteger("width"));
|
|
|
|
- videoGet.setHeight(detailJson.getInteger("height"));
|
|
|
|
- videoGet.setUrl(detailJson.getString("url"));
|
|
|
|
- videoGet.setCoverUrl(detailJson.getString("creative_name"));
|
|
|
|
- videoGet.setPhotoId(detailJson.getString("photo_id"));
|
|
|
|
- kuaiShouVideoGetService.saveOrUpdate(videoGet);
|
|
|
|
|
|
+
|
|
|
|
+ KuaiShouVideoGet byId = kuaiShouVideoGetService.getById(accountId + photoId);
|
|
|
|
+ if (!Check.isNull(byId)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
|
|
|
|
+ kuaiShouVideoGet.setId(accountId + photoId);
|
|
|
|
+
|
|
|
|
+ kuaiShouVideoGet.setAccountId(accountId);
|
|
|
|
+ kuaiShouVideoGet.setStatDate(detailJson.getDate("upload_time"));
|
|
|
|
+ kuaiShouVideoGet.setUpdateTime(new Date());
|
|
|
|
+ Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
|
|
|
|
+ if (!Check.isNull(type)) {
|
|
|
|
+ kuaiShouVideoGet.setMaterialType(type);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ kuaiShouVideoGet.setUserId(userId);
|
|
|
|
+ kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
|
|
|
|
+
|
|
|
|
+ Thread thread = new Thread() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ videoGetService.getKeyFrame(accessToken, accountId, kuaiShouVideoGet.getSignature(), kuaiShouVideoGet.getPhotoId());
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ thread.start();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
|
|
|
|
|
|
+ log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
|
|
}
|
|
}
|
|
|
|
|
|
} else {
|
|
} else {
|
|
- log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
|
|
|
|
|
|
+ log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", accountId, resultJson);
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -2888,6 +2922,11 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
if (Check.isNull(details)) {
|
|
if (Check.isNull(details)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ KuaiShouAdvertiserBaseInfo baseInfo = KuaiShouAdvertiserBaseInfoService.getBaseInfo(accountId);
|
|
|
|
+ Long userId = null;
|
|
|
|
+ if (!Check.isNull(baseInfo)) {
|
|
|
|
+ userId = Long.valueOf(baseInfo.getUserId());
|
|
|
|
+ }
|
|
for (int i = 0; i < details.size(); i++) {
|
|
for (int i = 0; i < details.size(); i++) {
|
|
JSONObject jsonObject = details.getJSONObject(i);
|
|
JSONObject jsonObject = details.getJSONObject(i);
|
|
if (!Check.isNull(jsonObject)) {
|
|
if (!Check.isNull(jsonObject)) {
|
|
@@ -2904,6 +2943,7 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
|
|
kuaiShouVideoGet.setSignature(md5);
|
|
kuaiShouVideoGet.setSignature(md5);
|
|
kuaiShouVideoGet.setStatDate(jsonObject.getDate("sync_date"));
|
|
kuaiShouVideoGet.setStatDate(jsonObject.getDate("sync_date"));
|
|
kuaiShouVideoGet.setChannelType(1);
|
|
kuaiShouVideoGet.setChannelType(1);
|
|
|
|
+ kuaiShouVideoGet.setUserId(userId);
|
|
Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
|
|
Integer type = MaterialEnum.getTypeBySize(kuaiShouVideoGet.getWidth(), kuaiShouVideoGet.getHeight());
|
|
if (!Check.isNull(type)) {
|
|
if (!Check.isNull(type)) {
|
|
kuaiShouVideoGet.setMaterialType(type);
|
|
kuaiShouVideoGet.setMaterialType(type);
|