From 0fc0456a587d985fda71c66b9764fe1d5e3c6421 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 29 七月 2021 19:11:01 +0800
Subject: [PATCH] 分系统完善

---
 src/main/java/com/yeshi/buwan/service/imp/juhe/FunTV2ServiceImpl.java |   63 ++++++++++++++++++++++++++++---
 1 files changed, 57 insertions(+), 6 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 d11fe9d..28fa181 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
@@ -11,20 +11,21 @@
 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.service.inter.system.SystemConfigService;
+import com.yeshi.buwan.util.StringUtil;
 import com.yeshi.buwan.util.mq.CMQManager;
 import com.yeshi.buwan.util.video.VideoConstant;
 import com.yeshi.buwan.vo.AcceptData;
+import net.sf.json.JSONObject;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -64,6 +65,9 @@
 
     @Resource
     private VideoResourceService videoResourceService;
+
+    @Resource
+    private DetailSystemConfigService detailSystemConfigService;
 
 
     @Override
@@ -217,11 +221,58 @@
             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_SDK;
+
+        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(AcceptData acceptData, String detailSystemId, int resourceId, String id, String videoId) {
         FunTVVideo2 video2 = funTVVideo2Dao.get(id);
         VideoResource vr = videoResourceService.getResource(resourceId + "");
-        int t = FunTVUtil2.getPlayType(acceptData,video2);
+        int t = getPlayType(acceptData, video2);
         PlayUrl pu = new PlayUrl();
         pu.setParams("");
         pu.setPlayType(t);
@@ -259,7 +310,7 @@
         if (videoFunTV2 == null)
             return;
         videoFunTV2Dao.deleteByVideoId(videoFunTV2.getVideoId());
-        resourceVideoService.delete(videoFunTV2.getVideoId()+"",FunTVUtil2.RESOURCE_ID+"");
+        resourceVideoService.delete(videoFunTV2.getVideoId() + "", FunTVUtil2.RESOURCE_ID + "");
         //鍒犻櫎濯掍綋涓庡獟浣撳搴旂殑瑙嗛
         funTVAlbum2Dao.delete(mediaId);
         List<FunTVVideo2> video2List = listAllEpisodeList(mediaId);

--
Gitblit v1.8.0