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/FunTVService.java |  141 ++++++++++++++++++++++++++++------------------
 1 files changed, 86 insertions(+), 55 deletions(-)

diff --git a/src/main/java/com/yeshi/buwan/service/imp/juhe/FunTVService.java b/src/main/java/com/yeshi/buwan/service/imp/juhe/FunTVService.java
index 57996cd..9209ee8 100644
--- a/src/main/java/com/yeshi/buwan/service/imp/juhe/FunTVService.java
+++ b/src/main/java/com/yeshi/buwan/service/imp/juhe/FunTVService.java
@@ -9,11 +9,13 @@
 import com.yeshi.buwan.domain.*;
 import com.yeshi.buwan.domain.entity.PlayUrl;
 import com.yeshi.buwan.domain.push.VideoPushHistory;
-import com.yeshi.buwan.funtv.FunTVUtil;
-import com.yeshi.buwan.funtv.entity.FunTVAlbum;
-import com.yeshi.buwan.funtv.entity.FunTVAlbumVideoMap;
-import com.yeshi.buwan.funtv.entity.FunTVVideo;
-import com.yeshi.buwan.funtv.entity.VideoFunTV;
+import com.yeshi.buwan.util.Constant;
+import com.yeshi.buwan.util.config.SystemConfigUtil;
+import com.yeshi.buwan.videos.funtv.FunTVUtil;
+import com.yeshi.buwan.videos.funtv.entity.FunTVAlbum;
+import com.yeshi.buwan.videos.funtv.entity.FunTVAlbumVideoMap;
+import com.yeshi.buwan.videos.funtv.entity.FunTVVideo;
+import com.yeshi.buwan.videos.funtv.entity.VideoFunTV;
 import com.yeshi.buwan.service.imp.*;
 import com.yeshi.buwan.service.imp.push.PushService;
 import com.yeshi.buwan.util.StringUtil;
@@ -37,8 +39,10 @@
 
     @Resource
     private FunTVVideoDao funTVVideoDao;
+
     @Resource
     private FunTVAlbumDao funTVAlbumDao;
+
     @Resource
     private FunTVAlbumVideoMapDao funTVAlbumVideoMapDao;
 
@@ -62,6 +66,12 @@
 
     @Resource
     private VideoManager videoManager;
+
+    @Resource
+    private ResourceVideoService resourceVideoService;
+
+    @Resource
+    private DetailSystemConfigService detailSystemConfigService;
 
     static Logger logger = Logger.getLogger(FunTVService.class);
 
@@ -150,7 +160,7 @@
                     // 鑾峰彇鏈�鏂颁竴闆嗙殑淇℃伅
                     List<FunTVVideo> plist = funTVVideoDao.listByAid(p.getAid(), "num", Sort.Direction.DESC, 0, 1);
                     if (plist.size() > 0) {
-                        List<VideoDetailInfo> detailList = new ArrayList<VideoDetailInfo>();
+                        List<VideoDetailInfo> detailList = new ArrayList<>();
                         detailList.add(FunTVUtil.convertFunTVVideoToVideoDetail(plist.get(0), p));
                         vi.setVideoDetailList(detailList);
                     }
@@ -304,7 +314,7 @@
 
         final VideoInfo info = FunTVUtil.convertFunTVAlbumToVideoInfo(p);
         // 绫诲瀷璁$畻
-        final List<Integer> typeList = new ArrayList<Integer>();
+        final List<Integer> typeList = new ArrayList<>();
 
         int type = FunTVUtil.getFunTVAlbumType(p);
         boolean exist = false;
@@ -336,31 +346,43 @@
                 }
             }
 
+            Serializable videoId = null;
+
             if (infoList != null && infoList.size() > 0 && isSame) {// 鏃犻渶鍔犲叆
                 updateVideoInfo(info, video, p, isUpdate);
+                videoId = video.getId();
             } else {// 闇�瑕佹柊鍔犲叆videoinfo
-                Serializable id = addVideoInfo(info, p);
+                videoId = addVideoInfo(info, p);
+            }
 
-                if (id != null) {
-                    info.setId(id.toString());
-
+            if (videoId != null) {
+                info.setId(videoId.toString());
+                try {
                     for (Integer ty : typeList) {
                         CategoryVideo cv = new CategoryVideo();
                         cv.setVideo(new VideoInfo(info.getId()));
                         cv.setVideoType(new VideoType(ty));
                         videoService.addCategoryVideo(cv);
                     }
+                }catch(Exception e){
 
-                    VideoFunTV vft = new VideoFunTV();
-                    vft.setAid(p.getAid());
-                    vft.setVideoId(Long.parseLong(info.getId()));
-                    vft.setVid(null);
-                    vft.setId(vft.createId());
-                    saveVideoFunTV(vft);
-
-                    videoResourceService.excuteSQL(String.format(
-                            "insert into wk_resource_video(videoid,resourceid) values(%s,%s)", info.getId(), 19 + ""));
                 }
+
+                VideoFunTV vft = new VideoFunTV();
+                vft.setAid(p.getAid());
+                vft.setVideoId(Long.parseLong(info.getId()));
+                vft.setVid(null);
+                vft.setId(vft.createId());
+                saveVideoFunTV(vft);
+
+                List<VideoResource> videoResources =   videoResourceService.getResourceByVideo(info);
+                for(VideoResource vr:videoResources){
+                    if(vr.getId().equalsIgnoreCase(19+"")){
+                       return;
+                    }
+                }
+                videoResourceService.excuteSQL(String.format(
+                        "insert into wk_resource_video(videoid,resourceid) values(%s,%s)", info.getId(), 19 + ""));
             }
 
         } catch (Exception e) {
@@ -370,18 +392,19 @@
     }
 
     public void addVideoToVideoInfo(final FunTVVideo p) {
+        // 灏嗘暟鎹浆涓篤ideoInfo瀵硅薄
         VideoInfo info = FunTVUtil.convertVideoToVideoInfo(p);
         try {
             synchronized (p.getTitle().intern()) { // 鍙戠幇浜嗘湁閲嶅鐢熸垚VideoInfo.鎵�鏈夋牴鎹悕绉板姞涓攣锛堜竴瀹氳鍔爄ntern()锛塩xx
-
+                // 鏍规嵁鍚嶇О/绫诲瀷/骞翠唬鏌ヨ
                 List<VideoInfo> infoList = videoInfoDao.list("from VideoInfo vi where vi.name=?",
-                        new Serializable[]{p.getTitle()});
+                        new Serializable[]{info.getName()});
                 if (infoList != null && infoList.size() > 0) {// 鏃犻渶鍔犲叆
                     // updateVideoInfo(info, infoList.get(0), p, genre);
                     return;
                 } else {// 闇�瑕佹柊鍔犲叆videoinfo
                     Serializable id = addVideoInfo(info, p);
-                    List<Integer> typeList = new ArrayList<Integer>();
+                    List<Integer> typeList = new ArrayList<>();
                     typeList = FunTVUtil.getShortVideoType(p, p.getCate(), p.getSubCate());
 
                     if (typeList == null || typeList.size() <= 0)
@@ -432,7 +455,7 @@
     }
 
     @SuppressWarnings("unchecked")
-    public PlayUrl getPlayUrl(String detailSystemId, String id, String type, int resourceid, String videoId) {
+    public PlayUrl getPlayUrl(String detailSystemId, String id, String type, int resourceid, String videoId, String channel, int versionCode) {
         logger.info(String.format("%s#%s#%s#%s", detailSystemId, resourceid, type, id));
         PlayUrl playUrl = new PlayUrl();
 
@@ -460,35 +483,48 @@
         playUrl.setParams(object.toString());
         if (fvideo.getPlayMUrl() != null)
             playUrl.setUrl(fvideo.getPlayMUrl().replace("alliance=2501", "malliance=0"));
-        playUrl.setPlayType(1);// 鍏ㄩ儴璺宠浆缃戦〉
+
+        String firstOnLineValue =  detailSystemConfigService.getConfigValueByKey("first_online_versions",detailSystemId, versionCode);
+        if( Constant.IS_HAVE_FIRST_ONLINE && SystemConfigUtil.isFirstOnLine(firstOnLineValue, channel, versionCode)){
+            // 棣栨涓婄嚎璺宠浆鍘熺敓
+            playUrl.setPlayType(2);// 鍘熺敓璺宠浆
+        } else {
+            playUrl.setPlayType(1);// 鍏ㄩ儴璺宠浆缃戦〉
+        }
         return playUrl;
     }
 
-    public List<VideoDetailInfo> getVideoDetailList(String videoid) {
+    public List<VideoDetailInfo> getVideoDetailList(String videoid, int page, int pageSize) {
         List<VideoFunTV> list = videoFunTVNewDao.listByVideoId(Long.parseLong(videoid));
         if (list != null && list.size() > 0) {
             final VideoFunTV vft = list.get(0);
             if (vft != null && vft.getAid() != null) {// 鎸夎妭鐩煡鎵捐棰�
-                FunTVAlbum album = funTVAlbumDao.get(vft.getAid());
-                List<FunTVVideo> videoList = funTVVideoDao.listByAid(album.getAid(), "num", Sort.Direction.ASC, 0, 1000);
-                Comparator<FunTVVideo> cp = new Comparator<FunTVVideo>() {
-                    public int compare(FunTVVideo o1, FunTVVideo o2) {
+                String aid = vft.getAid();
+                FunTVAlbum album = funTVAlbumDao.get(aid);
+//                if (album == null) {
+//                    resourceVideoService.delete(videoid, FunTVUtil.RESOURCE_ID + "");
+//                }
+                final String type = album.getVideoType();
+                Sort.Direction sort = Sort.Direction.ASC;
+                if (type != null)
+                    if (type.contains("鐢靛奖")) {
+                        sort = Sort.Direction.DESC;
+                    } else if (type.contains("鐢佃鍓�")) {
+                        sort = Sort.Direction.ASC;
+                    } else if (type.contains("缁艰壓")) {
+                        sort = Sort.Direction.DESC;
+                    } else if (type.contains("鍔ㄦ极")) {
+                        sort = Sort.Direction.ASC;
+                    } else
+                        sort = Sort.Direction.DESC;
 
-                        long t1 = o1.getNum();
-                        long t2 = o2.getNum();
-                        if (album.getVideoType().contains("鐢靛奖")) {
-                            return (int) (t2 - t1);
-                        } else if (album.getVideoType().contains("鐢佃鍓�")) {
-                            return (int) (t1 - t2);
-                        } else if (album.getVideoType().contains("缁艰壓")) {
-                            return (int) (t2 - t1);
-                        } else if (album.getVideoType().contains("鍔ㄦ极")) {
-                            return (int) (t1 - t2);
-                        } else
-                            return (int) (t2 - t1);
-                    }
-                };
-                Collections.sort(videoList, cp);
+
+                List<FunTVVideo> videoList = funTVVideoDao.listByAid(aid, "num", sort, (page - 1) * pageSize, pageSize);
+                if (album == null && videoList.size() > 0) {//澶勭悊鐢靛奖
+                    album = new FunTVAlbum();
+                    album.setTitle(videoList.get(0).getTitle());
+                    album.setVideoType(videoList.get(0).getCate());
+                }
 
                 List<VideoDetailInfo> detailList = new ArrayList<>();
                 for (FunTVVideo pv : videoList)
@@ -496,14 +532,14 @@
                 return detailList;
             } else if (vft.getVid() != null) {// 鍗曚釜瑙嗛
                 FunTVVideo pv = funTVVideoDao.get(vft.getVid());
-                List<VideoDetailInfo> detailList = new ArrayList<VideoDetailInfo>();
+                List<VideoDetailInfo> detailList = new ArrayList<>();
                 VideoDetailInfo detail = new VideoDetailInfo();
                 detail.setId(Long.parseLong(pv.getVid()));
                 detail.setExtraId(pv.getId() + "");
                 detail.setName(pv.getTitle());
                 detail.setTag(pv.getDesc());
                 detail.setType("funtvvideo");
-                List<VideoUrl> urlList = new ArrayList<VideoUrl>();
+                List<VideoUrl> urlList = new ArrayList<>();
                 VideoUrl vu = new VideoUrl();
                 vu.setAdmin(null);
                 vu.setBaseUrl(pv.getPlayUrl());
@@ -515,6 +551,8 @@
                 detailList.add(detail);
                 return detailList;
             }
+        }else{//鍒犻櫎鏉ユ簮
+            resourceVideoService.delete(videoid,FunTVUtil.RESOURCE_ID+"");
         }
 
         return null;
@@ -575,6 +613,7 @@
         // 鏌ヨ鍑哄搴旂殑VID涓巚ideoid
         final FunTVVideo video = getFunTVVideoByVid(vid);
         if (video != null) {
+            funTVVideoDao.deleteByPrimaryKey(video.getVid());
             String videoId = (String) videoResourceDao.excute(new HibernateCallback<String>() {
 
                 @SuppressWarnings("unchecked")
@@ -582,16 +621,8 @@
                     String videoid = null;
 
                     //TODO 澶勭悊
-                    List<FunTVVideo> list = session
-                            .createQuery("select m.video from FunTVAlbumVideoMap m where m.album.id=" + video.getId())
-                            .list();
                     session.getTransaction().begin();
                     try {
-
-                        for (FunTVVideo tv : list) {// 鍒犻櫎瑙嗛
-                            session.delete(tv);
-                        }
-                        session.delete(video);// 鍒犻櫎涓撹緫
                         List<VideoFunTV> ftlist = session
                                 .createQuery(
                                         "from VideoFunTV vf where vf.vid=" + video.getVid())

--
Gitblit v1.8.0