|
@@ -182,6 +182,15 @@ public class ThirdPartyPushMessageStrategyV1 implements ReplyStrategyService {
|
|
|
if (CollectionUtils.isEmpty(smallDataCgiReplyList)) {
|
|
|
return smallDataCgiReplyList;
|
|
|
}
|
|
|
+ boolean hasPage = true;
|
|
|
+ for (CgiReplyBucketData cgiReplyBucketData : smallDataCgiReplyList) {
|
|
|
+ if (StringUtils.isEmpty(cgiReplyBucketData.getMiniPagePath())) {
|
|
|
+ hasPage = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (hasPage) {
|
|
|
+ return smallDataCgiReplyList;
|
|
|
+ }
|
|
|
Set<String> keys = smallDataCgiReplyList.stream().map(x -> x.getGhId() + "&" + x.getMiniVideoId() + "&" + x.getSort()).collect(Collectors.toSet());
|
|
|
Map<String, SmallPageUrlDetail> keyPageUrl = new HashMap<>();
|
|
|
// gh-id + videoId + sort 复用同一page_url及落地页id
|
|
@@ -237,69 +246,106 @@ public class ThirdPartyPushMessageStrategyV1 implements ReplyStrategyService {
|
|
|
continue;
|
|
|
}
|
|
|
if (Objects.equals(StrategyStatusEnum.DEFAULT.status, bucketDataParam.getStrategyStatus())) {
|
|
|
- if (CollectionUtils.isEmpty(bucketDataParam.getVideos())) {
|
|
|
+ if (CollectionUtils.isEmpty(bucketDataParam.getVideos()) && CollectionUtils.isEmpty(bucketDataParam.getMiniPageDatas())) {
|
|
|
return null;
|
|
|
}
|
|
|
CgiReplyBucketDataExample countExample = new CgiReplyBucketDataExample();
|
|
|
countExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key)
|
|
|
.andGhIdEqualTo(bucketDataParam.getGhId());
|
|
|
long allCount = cgiReplyBucketDataMapper.countByExample(countExample);
|
|
|
- if (allCount == bucketDataParam.getVideos().size()) {
|
|
|
- int existNum = 0;
|
|
|
+ if (!CollectionUtils.isEmpty(bucketDataParam.getVideos())) {
|
|
|
+ if (allCount == bucketDataParam.getVideos().size()) {
|
|
|
+ int existNum = 0;
|
|
|
+ for (int i = 0; i < bucketDataParam.getVideos().size(); i++) {
|
|
|
+ int sort = i + 1;
|
|
|
+ Long videoId = bucketDataParam.getVideos().get(i);
|
|
|
+ CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
|
|
|
+ cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key)
|
|
|
+ .andGhIdEqualTo(bucketDataParam.getGhId()).andMiniVideoIdEqualTo(videoId).andSortEqualTo(sort);
|
|
|
+ long count = cgiReplyBucketDataMapper.countByExample(cgiReplyBucketDataExample);
|
|
|
+ if (count > 0) {
|
|
|
+ existNum++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (existNum == bucketDataParam.getVideos().size()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<Long, VideoDetail> videoDetailMap = touLiuHttpClient.getVideoDetailRequest(bucketDataParam.getVideos());
|
|
|
+ List<ContentPlatformGzhPlanVideo> gzhPlanVideoList = contentPlatformPlanService.getGzhPlanVideoListByCooperateAccountId(bucketDataParam.getGhId());
|
|
|
+ Map<Long, ContentPlatformGzhPlanVideo> gzhPlanVideoMap = gzhPlanVideoList.stream()
|
|
|
+ .collect(Collectors.toMap(ContentPlatformGzhPlanVideo::getVideoId, x -> x, (a, b) -> b));
|
|
|
for (int i = 0; i < bucketDataParam.getVideos().size(); i++) {
|
|
|
int sort = i + 1;
|
|
|
Long videoId = bucketDataParam.getVideos().get(i);
|
|
|
- CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
|
|
|
- cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key)
|
|
|
- .andGhIdEqualTo(bucketDataParam.getGhId()).andMiniVideoIdEqualTo(videoId).andSortEqualTo(sort);
|
|
|
- long count = cgiReplyBucketDataMapper.countByExample(cgiReplyBucketDataExample);
|
|
|
- if (count > 0) {
|
|
|
- existNum++;
|
|
|
- }
|
|
|
- }
|
|
|
- if (existNum == bucketDataParam.getVideos().size()) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- Map<Long, VideoDetail> videoDetailMap = touLiuHttpClient.getVideoDetailRequest(bucketDataParam.getVideos());
|
|
|
- List<ContentPlatformGzhPlanVideo> gzhPlanVideoList = contentPlatformPlanService.getGzhPlanVideoListByCooperateAccountId(bucketDataParam.getGhId());
|
|
|
- Map<Long, ContentPlatformGzhPlanVideo> gzhPlanVideoMap = gzhPlanVideoList.stream()
|
|
|
- .collect(Collectors.toMap(ContentPlatformGzhPlanVideo::getVideoId, x -> x, (a, b) -> b));
|
|
|
- for (int i = 0; i < bucketDataParam.getVideos().size(); i++) {
|
|
|
- int sort = i + 1;
|
|
|
- Long videoId = bucketDataParam.getVideos().get(i);
|
|
|
- CgiReplyBucketData cgiReplyBucketData = new CgiReplyBucketData();
|
|
|
- cgiReplyBucketData.setStrategy(key);
|
|
|
- cgiReplyBucketData.setSort(sort);
|
|
|
- cgiReplyBucketData.setGhId(bucketDataParam.getGhId());
|
|
|
- cgiReplyBucketData.setMsgType(1);
|
|
|
- VideoDetail videoDetail = videoDetailMap.get(videoId);
|
|
|
- ContentPlatformGzhPlanVideo gzhPlanVideo = gzhPlanVideoMap.get(videoId);
|
|
|
- // 内容合作平台视频标题和封面
|
|
|
- if (Objects.nonNull(gzhPlanVideo) && Objects.nonNull(videoDetail)) {
|
|
|
- cgiReplyBucketData.setTitle(ContentPlatformPlanService.getVideoTitle(gzhPlanVideo));
|
|
|
- String cover = ContentPlatformPlanService.getVideoCover(gzhPlanVideo);
|
|
|
- if (StringUtils.isNotEmpty(cover)) {
|
|
|
- String coverSuffix = videoDetail.getCover().substring(videoDetail.getCover().indexOf("?"));
|
|
|
- if (cover.contains("?") && cover.contains("image/resize")) {
|
|
|
- coverSuffix = videoDetail.getCover().substring(videoDetail.getCover().indexOf("/watermark"));
|
|
|
+ CgiReplyBucketData cgiReplyBucketData = new CgiReplyBucketData();
|
|
|
+ cgiReplyBucketData.setStrategy(key);
|
|
|
+ cgiReplyBucketData.setSort(sort);
|
|
|
+ cgiReplyBucketData.setGhId(bucketDataParam.getGhId());
|
|
|
+ cgiReplyBucketData.setMsgType(1);
|
|
|
+ VideoDetail videoDetail = videoDetailMap.get(videoId);
|
|
|
+ ContentPlatformGzhPlanVideo gzhPlanVideo = gzhPlanVideoMap.get(videoId);
|
|
|
+ // 内容合作平台视频标题和封面
|
|
|
+ if (Objects.nonNull(gzhPlanVideo) && Objects.nonNull(videoDetail)) {
|
|
|
+ cgiReplyBucketData.setTitle(ContentPlatformPlanService.getVideoTitle(gzhPlanVideo));
|
|
|
+ String cover = ContentPlatformPlanService.getVideoCover(gzhPlanVideo);
|
|
|
+ if (StringUtils.isNotEmpty(cover)) {
|
|
|
+ String coverSuffix = videoDetail.getCover().substring(videoDetail.getCover().indexOf("?"));
|
|
|
+ if (cover.contains("?") && cover.contains("image/resize")) {
|
|
|
+ coverSuffix = videoDetail.getCover().substring(videoDetail.getCover().indexOf("/watermark"));
|
|
|
+ }
|
|
|
+ if (!cover.contains("yishihui")) {
|
|
|
+ coverSuffix = "?x-oss-process=image/resize,m_fill,w_600,h_480,limit_0/format,jpg";
|
|
|
+ }
|
|
|
+ cgiReplyBucketData.setCoverUrl(cover + coverSuffix);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (videoDetail != null && StringUtils.isNotEmpty(videoDetail.getCover())) {
|
|
|
+ cgiReplyBucketData.setCoverUrl(videoDetail.getCover());
|
|
|
}
|
|
|
- if (!cover.contains("yishihui")) {
|
|
|
- coverSuffix = "?x-oss-process=image/resize,m_fill,w_600,h_480,limit_0/format,jpg";
|
|
|
+ if (videoDetail != null && StringUtils.isNotEmpty(videoDetail.getTitle())) {
|
|
|
+ cgiReplyBucketData.setTitle(videoDetail.getTitle());
|
|
|
}
|
|
|
- cgiReplyBucketData.setCoverUrl(cover + coverSuffix);
|
|
|
}
|
|
|
- } else {
|
|
|
- if (videoDetail != null && StringUtils.isNotEmpty(videoDetail.getCover())) {
|
|
|
- cgiReplyBucketData.setCoverUrl(videoDetail.getCover());
|
|
|
+ cgiReplyBucketData.setMiniAppId(SMALL_APP_Id);
|
|
|
+ cgiReplyBucketData.setMiniVideoId(videoId);
|
|
|
+ result.add(cgiReplyBucketData);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (!CollectionUtils.isEmpty(bucketDataParam.getMiniPageDatas())) {
|
|
|
+ if (allCount == bucketDataParam.getVideos().size()) {
|
|
|
+ int existNum = 0;
|
|
|
+ for (int i = 0; i < bucketDataParam.getMiniPageDatas().size(); i++) {
|
|
|
+ int sort = i + 1;
|
|
|
+ MiniPageData miniPageData = bucketDataParam.getMiniPageDatas().get(i);
|
|
|
+ CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
|
|
|
+ cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key)
|
|
|
+ .andGhIdEqualTo(bucketDataParam.getGhId()).andMiniPagePathEqualTo(miniPageData.getPage()).andSortEqualTo(sort);
|
|
|
+ long count = cgiReplyBucketDataMapper.countByExample(cgiReplyBucketDataExample);
|
|
|
+ if (count > 0) {
|
|
|
+ existNum++;
|
|
|
+ }
|
|
|
}
|
|
|
- if (videoDetail != null && StringUtils.isNotEmpty(videoDetail.getTitle())) {
|
|
|
- cgiReplyBucketData.setTitle(videoDetail.getTitle());
|
|
|
+ if (existNum == bucketDataParam.getMiniPageDatas().size()) {
|
|
|
+ return null;
|
|
|
}
|
|
|
}
|
|
|
- cgiReplyBucketData.setMiniAppId(SMALL_APP_Id);
|
|
|
- cgiReplyBucketData.setMiniVideoId(videoId);
|
|
|
- result.add(cgiReplyBucketData);
|
|
|
+ for (int i = 0; i < bucketDataParam.getMiniPageDatas().size(); i++) {
|
|
|
+ int sort = i + 1;
|
|
|
+ MiniPageData miniPageData = bucketDataParam.getMiniPageDatas().get(i);
|
|
|
+ CgiReplyBucketData cgiReplyBucketData = new CgiReplyBucketData();
|
|
|
+ cgiReplyBucketData.setStrategy(key);
|
|
|
+ cgiReplyBucketData.setSort(sort);
|
|
|
+ cgiReplyBucketData.setGhId(bucketDataParam.getGhId());
|
|
|
+ cgiReplyBucketData.setMsgType(1);
|
|
|
+ cgiReplyBucketData.setCoverUrl(miniPageData.getCover());
|
|
|
+ cgiReplyBucketData.setTitle(miniPageData.getTitle());
|
|
|
+ cgiReplyBucketData.setMiniPagePath(miniPageData.getPage());
|
|
|
+ cgiReplyBucketData.setMiniAppId(SMALL_APP_Id);
|
|
|
+ result.add(cgiReplyBucketData);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return null;
|
|
|
}
|
|
|
} else {
|
|
|
// 获取最新dt的策略
|