From f537abe9f3646c739beaf15076246a2f71a347e9 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期四, 20 二月 2025 16:57:55 +0800 Subject: [PATCH] IOS广告增加区域屏蔽 --- src/main/java/com/yeshi/buwan/service/imp/juhe/FunTV2ServiceImpl.java | 169 +++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 113 insertions(+), 56 deletions(-) diff --git a/src/main/java/com/yeshi/buwan/service/imp/juhe/FunTV2ServiceImpl.java b/src/main/java/com/yeshi/buwan/service/imp/juhe/FunTV2ServiceImpl.java index 4990c69..6af9446 100644 --- a/src/main/java/com/yeshi/buwan/service/imp/juhe/FunTV2ServiceImpl.java +++ b/src/main/java/com/yeshi/buwan/service/imp/juhe/FunTV2ServiceImpl.java @@ -6,30 +6,32 @@ import com.yeshi.buwan.dao.juhe.funtv.FunTVVideo2Dao; import com.yeshi.buwan.dao.juhe.funtv.VideoFunTV2Dao; import com.yeshi.buwan.dao.video.AlbumVideoMapDao; -import com.yeshi.buwan.domain.ResourceVideo; import com.yeshi.buwan.domain.VideoDetailInfo; import com.yeshi.buwan.domain.VideoInfo; import com.yeshi.buwan.domain.VideoResource; import com.yeshi.buwan.domain.entity.PlayUrl; +import com.yeshi.buwan.domain.system.DetailSystemConfig; import com.yeshi.buwan.domain.video.AlbumVideoMap; -import com.yeshi.buwan.funtv.FunTVUtil2; -import com.yeshi.buwan.funtv.entity.FunTVAlbum2; -import com.yeshi.buwan.funtv.entity.FunTVShortVideo2; -import com.yeshi.buwan.funtv.entity.FunTVVideo2; -import com.yeshi.buwan.funtv.entity.VideoFunTV2; -import com.yeshi.buwan.service.imp.CategoryVideoService; -import com.yeshi.buwan.service.imp.ResourceVideoService; -import com.yeshi.buwan.service.imp.VideoInfoService; -import com.yeshi.buwan.service.imp.VideoResourceService; +import com.yeshi.buwan.service.imp.*; import com.yeshi.buwan.service.inter.juhe.FunTV2Service; -import com.yeshi.buwan.util.mq.CMQManager; +import com.yeshi.buwan.util.StringUtil; +import com.yeshi.buwan.util.mq.rabbit.RabbitmqManager; import com.yeshi.buwan.util.video.VideoConstant; +import com.yeshi.buwan.videos.funtv.FunTVUtil2; +import com.yeshi.buwan.videos.funtv.entity.FunTVAlbum2; +import com.yeshi.buwan.videos.funtv.entity.FunTVShortVideo2; +import com.yeshi.buwan.videos.funtv.entity.FunTVVideo2; +import com.yeshi.buwan.videos.funtv.entity.VideoFunTV2; +import com.yeshi.buwan.vo.AcceptData; +import net.sf.json.JSONObject; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.Serializable; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; @Service public class FunTV2ServiceImpl implements FunTV2Service { @@ -63,6 +65,12 @@ @Resource private VideoResourceService videoResourceService; + + @Resource + private DetailSystemConfigService detailSystemConfigService; + + @Resource + private RabbitmqManager rabbitmqManager; @Override @@ -102,14 +110,14 @@ videoInfo.setVpicture(newVideoInfo.getVpicture()); videoInfo.setShow(newVideoInfo.getShow()); videoInfo.setVideoType(newVideoInfo.getVideoType()); - videoInfoDao.update(videoInfo); + videoInfoService.update(videoInfo); } } else {//瑙嗛涓嶅瓨鍦� //鍒ゆ柇2涓棰戝疄浣撴槸鍚︿负鍚屼竴瑙嗛 - VideoInfo oldVideo = videoInfoService.getExistSameVideo(newVideoInfo); + VideoInfo oldVideo = videoInfoService.getExistSameVideoWithTime(newVideoInfo); if (oldVideo == null) { //娣诲姞瑙嗛 - Serializable id = videoInfoDao.save(newVideoInfo); + Serializable id = videoInfoService.save(newVideoInfo); newVideoInfo.setId(id + ""); } else {//涓哄悓涓�瑙嗛 //鏇存柊tag @@ -121,11 +129,12 @@ oldVideo.setVpicture(newVideoInfo.getVpicture()); oldVideo.setShow(newVideoInfo.getShow()); oldVideo.setVideoType(newVideoInfo.getVideoType()); - videoInfoDao.update(oldVideo); + videoInfoService.update(oldVideo); } //鍔犲叆涓撹緫瑙嗛鏄犲皠 AlbumVideoMap map = new AlbumVideoMap(); + map.setId(newVideoInfo.getId()); map.setCreateTime(new Date()); map.setVideoId(newVideoInfo.getId()); map.setRootVideoType(newVideoInfo.getVideoType().getId()); @@ -143,7 +152,7 @@ resourceVideoService.addVideoResource(newVideoInfo.getId(), FunTVUtil2.RESOURCE_ID + ""); //娣诲姞瑙嗛鍒嗙被鏄犲皠 categoryVideoService.addCategoryVideo(newVideoInfo.getId(), newVideoInfo.getVideoType().getId()); - CMQManager.getInstance().addSolrMsg(newVideoInfo.getId()); + rabbitmqManager.addSolrMsg(newVideoInfo.getId()); } @Override @@ -151,29 +160,45 @@ FunTVAlbum2 album2 = funTVAlbum2Dao.get(id); if (album2 == null) return null; - List<FunTVVideo2> video2List = funTVVideo2Dao.listByMediaId(id); - if (video2List != null) { - Comparator<FunTVVideo2> cm = new Comparator<FunTVVideo2>() { - @Override - public int compare(FunTVVideo2 o1, FunTVVideo2 o2) { - return Integer.parseInt(o1.getNum()) - Integer.parseInt(o2.getNum()); - } - }; - Collections.sort(video2List, cm); - } + List<FunTVVideo2> video2List = listAllEpisodeList(id); album2.setEpisodes(video2List); return album2; } + private List<FunTVVideo2> getEpisodeList(String mediaId, int page, int pageSize) { + List<FunTVVideo2> video2List = funTVVideo2Dao.listByMediaId(mediaId, (page - 1) * pageSize, pageSize); + return video2List; + } + + private List<FunTVVideo2> listAllEpisodeList(String mediaId) { + int page = 1; + int pageSize = 100; + List<FunTVVideo2> video2List = new ArrayList<>(); + List<FunTVVideo2> tempList = new ArrayList<>(); + do { + tempList = getEpisodeList(mediaId, page, pageSize); + if (tempList != null) + video2List.addAll(tempList); + page++; + } while (tempList != null && tempList.size() > 0); + return video2List; + } + + @Override - public List<VideoDetailInfo> getVideoDetailList(String id) { + public List<VideoDetailInfo> getVideoDetailList(String id, int page, int pageSize) { VideoFunTV2 videoFunTV2 = videoFunTV2Dao.selectByVideoId(id); if (videoFunTV2 == null) return null; - FunTVAlbum2 album2 = getAlbumDetail(videoFunTV2.getMediaId()); + FunTVAlbum2 album2 = funTVAlbum2Dao.get(videoFunTV2.getMediaId()); + if (album2 == null) + return null; + + List<FunTVVideo2> episodeList = getEpisodeList(album2.getId(), page, pageSize); + List<VideoDetailInfo> list = new ArrayList<>(); - if (album2 != null && album2.getEpisodes() != null) - for (FunTVVideo2 video2 : album2.getEpisodes()) + if (episodeList != null) + for (FunTVVideo2 video2 : episodeList) list.add(FunTVUtil2.convertFunTVVideoToVideoDetail(video2, album2)); return list; } @@ -199,19 +224,68 @@ return 1; } + private int getPlayType(AcceptData acceptData, FunTVVideo2 video2) { + //濡傛灉鏄鍦ㄤ笂绾跨殑鐗堟湰灏辩敤SDK鎾斁锛屽惁鍒欓噰鐢℉5 + + DetailSystemConfig config = detailSystemConfigService.getConfigByKey("funshion_sdk_player", acceptData.getDetailSystem(), acceptData.getVersion()); + //榛樿SDK鎾斁 + if (config == null) + return FunTVUtil2.PLAY_HTML; + + String channel = acceptData.getChannel(); + if (StringUtil.isNullOrEmpty(channel)) { + channel = "qq"; + } + channel = channel.toLowerCase().trim(); + JSONObject data = JSONObject.fromObject(config.getValue()); + JSONObject channelJSON = data.optJSONObject(channel); + //娓犻亾涓嶅瓨鍦ㄥ氨褰撳仛QQ娓犻亾鍋氬鐞� + if (channelJSON == null) + channelJSON = data.optJSONObject("qq"); + if (channelJSON == null) + return FunTVUtil2.PLAY_SDK; + + + int version = channelJSON.optInt("version"); + if (acceptData.getVersion() < version) { + //鍙栬瀹氬�� + String type = channelJSON.optString("type"); + if ("html".equalsIgnoreCase(type)) { + return FunTVUtil2.PLAY_HTML; + } else if ("sdk".equalsIgnoreCase(type)) { + return FunTVUtil2.PLAY_SDK; + } else { + return FunTVUtil2.PLAY_NONE; + } + } else { + //鍙栬瀹氱浉鍙嶅�� + String type = channelJSON.optString("type"); + if ("html".equalsIgnoreCase(type)) { + return FunTVUtil2.PLAY_SDK; + } else if ("sdk".equalsIgnoreCase(type)) { + return FunTVUtil2.PLAY_HTML; + } else { + return FunTVUtil2.PLAY_NONE; + } + } + } + + @Override - public PlayUrl getPlayUrl(String detailSystemId, int resourceId, String id, String videoId) { + public PlayUrl getPlayUrl(AcceptData acceptData, String detailSystemId, int resourceId, String id, String videoId) { FunTVVideo2 video2 = funTVVideo2Dao.get(id); VideoResource vr = videoResourceService.getResource(resourceId + ""); - int t = FunTVUtil2.getPlayType(video2); + int t = getPlayType(acceptData, video2); PlayUrl pu = new PlayUrl(); pu.setParams(""); - pu.setPlayType(t); + pu.setPlayType(1); pu.setResource(vr); - + pu.setAid(video2.getMediaId()); + pu.setVid(video2.getId()); + pu.setCode(video2.getCeCode()); if (t == FunTVUtil2.PLAY_NONE) { pu.setUrl(""); - } else if (t == FunTVUtil2.PLAY_HTML) { + } else { pu.setUrl(video2.getFunH5Url()); } return pu; @@ -238,28 +312,11 @@ VideoFunTV2 videoFunTV2 = videoFunTV2Dao.selectByMediaId(mediaId); if (videoFunTV2 == null) return; - - List<ResourceVideo> resourceVideoList = resourceVideoService.getResourceList(videoFunTV2.getVideoId() + ""); - for (int i = 0; i < resourceVideoList.size(); i++) { - ResourceVideo rv = resourceVideoList.get(i); - if (rv.getResource() != null && Integer.parseInt(rv.getResource().getId()) == FunTVUtil2.RESOURCE_ID) { - //鍒犻櫎璧勬簮鏄犲皠 - resourceVideoService.delete(rv); - resourceVideoList.remove(i); - i--; - } - } - - if (resourceVideoList.size() == 0) { - //闅愯棌瑙嗛 - videoInfoService.hiddenVideo(videoFunTV2.getVideoId() + ""); - //鏇存柊鎼滅储寮曟搸 - CMQManager.getInstance().addSolrMsg(videoFunTV2.getVideoId() + ""); - } - + videoFunTV2Dao.deleteByVideoId(videoFunTV2.getVideoId()); + resourceVideoService.delete(videoFunTV2.getVideoId() + "", FunTVUtil2.RESOURCE_ID + ""); //鍒犻櫎濯掍綋涓庡獟浣撳搴旂殑瑙嗛 funTVAlbum2Dao.delete(mediaId); - List<FunTVVideo2> video2List = funTVVideo2Dao.listByMediaId(mediaId); + List<FunTVVideo2> video2List = listAllEpisodeList(mediaId); if (video2List != null) for (FunTVVideo2 video2 : video2List) funTVVideo2Dao.delete(video2.getId()); -- Gitblit v1.8.0