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 |   94 ++++++++++++++++++++++++++++-------------------
 1 files changed, 56 insertions(+), 38 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 4fc35f8..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;
@@ -67,6 +69,9 @@
 
     @Resource
     private ResourceVideoService resourceVideoService;
+
+    @Resource
+    private DetailSystemConfigService detailSystemConfigService;
 
     static Logger logger = Logger.getLogger(FunTVService.class);
 
@@ -155,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);
                     }
@@ -309,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;
@@ -341,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) {
@@ -375,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)
@@ -437,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();
 
@@ -465,7 +483,14 @@
         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;
     }
 
@@ -476,9 +501,9 @@
             if (vft != null && vft.getAid() != null) {// 鎸夎妭鐩煡鎵捐棰�
                 String aid = vft.getAid();
                 FunTVAlbum album = funTVAlbumDao.get(aid);
-                if (album == null) {
-                    resourceVideoService.delete(videoid, FunTVUtil.RESOURCE_ID + "");
-                }
+//                if (album == null) {
+//                    resourceVideoService.delete(videoid, FunTVUtil.RESOURCE_ID + "");
+//                }
                 final String type = album.getVideoType();
                 Sort.Direction sort = Sort.Direction.ASC;
                 if (type != null)
@@ -507,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());
@@ -588,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")
@@ -595,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