Procházet zdrojové kódy

实时直播观看人数,获取实时观众列表,实时聊天列表,合作商直播列表

吴志根 před 4 roky
rodič
revize
2767b490a6

+ 27 - 0
src/dsb/com/cnd3b/restcontroller/customer/live/SQL/合作商直播列表.sql

@@ -0,0 +1,27 @@
+select t1.tliveid,
+       t1.siteid,
+       t1.createby,
+       t1.changeby,
+       t1.createdate,
+       t1.changedate,
+       t1.tactivityid,
+       t1.tliveapplyid,
+       t1.tagentsid,
+       t1.fliveurl_web,
+       t1.fliveurl_client,
+       t1.fliveshowurl,
+       t1.categoryid,
+       t1.categoryname,
+       t1.channelname,
+       t1.channelpasswd,
+       t1.channelid,
+       t1.fassistanturl,
+       t1.fisneedauth,
+       t1.secretkey,
+       t1.livestatus,
+       t1.channelcoverimageurl
+from tlive t1
+         inner join tagents t2 on t1.siteid = t2.siteid and t1.tagentsid = t2.tagentsid
+where t1.siteid = $siteid$
+  and t1.tagentsid IN $tagentsidList$
+

+ 17 - 0
src/dsb/com/cnd3b/restcontroller/customer/live/SQL/实时聊天列表.sql

@@ -0,0 +1,17 @@
+SELECT t1.pic,
+       t1.userid,
+       t1.content,
+       t1.accountid,
+       t1.uid,
+       t1.nickname,
+       t1.sourcetype,
+       t1.usersource,
+       t1.banned,
+       t1.id,
+       t1.msgtype,
+       t1.usertype,
+       t1.imageurl,
+       CONVERT(varchar (100), DATEADD(S, convert(float, t1.time) / 1000, '1970-01-01 08:00'), 120) as datetime
+from tlive_usermessages AS t1
+WHERE t1.channelid = $channelid$
+  AND t1.time = $time$

+ 8 - 0
src/dsb/com/cnd3b/restcontroller/customer/live/SQL/实时观众列表.sql

@@ -0,0 +1,8 @@
+SELECT t1.tlive_viewlogid,
+       t1.channelid,
+       CONVERT(varchar (100), DATEADD(S, convert(float, t1.createdtime) / 1000, '1970-01-01 08:00'), 120) as createdtime,
+       t1.param1 AS viewerid,
+       t1.param2 AS viewername
+FROM tlive_viewlog AS t1
+WHERE t1.createdtime = $createdtime$
+  AND t1.channelid = $channelid$

+ 75 - 5
src/dsb/com/cnd3b/restcontroller/customer/live/live.java

@@ -13,6 +13,7 @@ import p2.pao.PaoRemote;
 import p2.pao.PaoSetRemote;
 import p2.util.P2Exception;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 
 public class live extends Controller {
@@ -156,13 +157,13 @@ public class live extends Controller {
             //人次
             liveuv = paoRemote.getInt("liveuv");
             //时长
-            duration = paoRemote.getInt("duration")/60;
+            duration = paoRemote.getInt("duration") / 60;
         }
 
         JSONObject resultObject = new JSONObject();
 
-        resultObject.put("viewers",  livepv);
-        resultObject.put("viewCounts",  liveuv);
+        resultObject.put("viewers", livepv);
+        resultObject.put("viewCounts", liveuv);
         resultObject.put("viewDuration", duration);
         resultObject.put("viewCountsAvg", livepv == 0 ? 0 : liveuv / livepv);
         resultObject.put("viewDurationAvg", livepv == 0 ? 0 : duration / livepv);
@@ -271,13 +272,13 @@ public class live extends Controller {
             //人次
             liveuv = paoRemote.getInt("liveuv");
             //时长
-            duration = paoRemote.getInt("duration")/60;
+            duration = paoRemote.getInt("duration") / 60;
         }
 
         JSONObject resultObject = new JSONObject();
 
         resultObject.put("viewers", livepv);
-        resultObject.put("viewCounts",  liveuv);
+        resultObject.put("viewCounts", liveuv);
         resultObject.put("viewDuration", duration);
         resultObject.put("viewCountsAvg", livepv == 0 ? 0 : liveuv / livepv);
         resultObject.put("viewDurationAvg", livepv == 0 ? 0 : duration / livepv);
@@ -354,4 +355,73 @@ public class live extends Controller {
         Rows rows = sqlFactory.runSqlQuery();
         return rows.isEmpty() ? 0 : rows.get(0).getLong(fieldname);
     }
+
+    /**
+     * 获取实时直播观看人数
+     */
+    public String getRealTimeViewers() {
+        String channelid = content.getString("channelid");
+        String sql = "SELECT [count] FROM tlive_usercount WHERE [time]='" + getDateTime_Str() + "' AND channelid='" + channelid + "'";
+        Rows rows = dbConnect.runSqlQuery(sql);
+        JSONObject resultObject = new JSONObject();
+        resultObject.put("count", rows.isEmpty() ? 0 : rows.get(0).getLong("count"));
+        return getSucReturnObject().setData(resultObject).toString();
+    }
+
+    /**
+     * 获取实时观众列表
+     *
+     * @return
+     */
+    public String getRealTimeViewerList() {
+        String channelid = content.getString("channelid");
+        Long createdtime = getDateTime().getTime() / 1000;
+        SQLFactory sqlFactory = new SQLFactory(this, "实时观众列表", pageSize, pageNumber, "t1.tlive_viewlogid DESC");
+        sqlFactory.addParameter("channelid", channelid);
+        sqlFactory.addParameter("createdtime", createdtime * 1000);
+        System.err.println(sqlFactory.getSQL());
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        return getSucReturnObject().setDataByPaging(rows).preloading(1).toString();
+    }
+
+    /**
+     * 获取实时直播聊天列表
+     *
+     * @return
+     */
+    public String getRealTimeMessageList() {
+        String channelid = content.getString("channelid");
+        Long time = getDateTime().getTime();
+        SQLFactory sqlFactory = new SQLFactory(this, "实时聊天列表", pageSize, pageNumber, "t1.tlive_usermessagid DESC");
+        sqlFactory.addParameter("channelid", channelid);
+        sqlFactory.addParameter("time", time);
+        System.err.println(sqlFactory.getSQL());
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        return getSucReturnObject().setDataByPaging(rows).preloading(1).toString();
+    }
+
+    /**
+     * 获取合作商直播列表(包括私域、展会)
+     *
+     * @return
+     */
+    public String getCooperationAgentsLiveList() {
+
+        //查询合作的商户id
+        String sql = "SELECT tcooperationagentsid FROM tagents_cooperation WHERE tagentsid = '" + tagentsid + "' AND fstatus = '合作';";
+        Rows rows = dbConnect.runSqlQuery(sql);
+        ArrayList<String> tagentsidList = new ArrayList<>();
+        for (Row row : rows) {
+            tagentsidList.add(row.getString("tcooperationagentsid"));
+        }
+        SQLFactory sqlFactory = new SQLFactory(this, "合作商直播列表");
+        sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter_in("tagentsidList", tagentsidList);
+        System.err.println(sqlFactory.getSQL());
+        Rows agentRows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+
+        return getSucReturnObject().setData(agentRows).toString();
+    }
+
+
 }