Bläddra i källkod

私域直播数据统计(频道),私域直播用户观看列表,私域直播场次列表查询,私域直播数据统计(场次)

wzg 4 år sedan
förälder
incheckning
91bd0e9a92

+ 8 - 0
src/dsb/com/cnd3b/restcontroller/customer/live/SQL/直播场次列表查询.sql

@@ -0,0 +1,8 @@
+SELECT t1.sessionid,
+       t1.description,
+       DATEADD(S, t1.starttime / 1000, '1970-01-01 08:00:00') as starttime,
+       t1.liveuv,
+       t1.livepv,
+       t1.duration
+FROM tlive_sessiondata AS t1
+WHERE t1.channelid = $channelid$

+ 8 - 5
src/dsb/com/cnd3b/restcontroller/customer/live/SQL/私域直播用户观看列表.sql

@@ -1,5 +1,5 @@
-SELECT t1.PARAM2 AS name,
-       t1.PARAM1 AS userid,
+SELECT t1.PARAM2                                                AS name,
+       t1.PARAM1                                                AS userid,
        t1.playduration,
        DATEADD(S, t1.createdtime / 1000, '1970-01-01 08:00:00') as datetime,
        t1.province,
@@ -7,11 +7,14 @@ SELECT t1.PARAM2 AS name,
        t1.ipaddress,
        t1.useragent,
        t1.ismobile,
+       t1.browser,
        (
            SELECT COUNT
                       (*) AS num
            FROM tlive_viewlog AS t2
            WHERE t1.param1 = t2.param1
-       )         AS viewcount,
-       t1.param3 AS viewtype
-FROM tlive_viewlog AS t1
+       )                                                        AS viewcount,
+       t1.param3                                                AS viewtype
+FROM tlive_viewlog AS t1
+where sessionid = $sessionid$
+  and channelid = $channelid$

+ 1 - 1
src/dsb/com/cnd3b/restcontroller/customer/live/SQL/私域直播详情.sql

@@ -2,4 +2,4 @@ select t1.tliveid, t1.siteid, t1.createby, t1.changeby, t1.createdate, t1.change
        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.categoryName='˽ÓòÖ±²¥'
+where t1.siteid=$siteid$ and t1.categoryName='˽ÓòÖ±²¥' and t1.tagentsid = $tagentsid$

+ 2 - 1
src/dsb/com/cnd3b/restcontroller/customer/live/SQL/观看人数.sql

@@ -1 +1,2 @@
-SELECT mobileuniqueviewer + pcuniqueviewer as num FROM tlive_data
+SELECT mobileuniqueviewer + pcuniqueviewer as num FROM tlive_data
+WHERE channelid = $channelid$

+ 2 - 1
src/dsb/com/cnd3b/restcontroller/customer/live/SQL/观看时长.sql

@@ -1 +1,2 @@
-SELECT PCPLAYDURATION + MOBILEPLAYDURATION as num FROM tlive_data
+SELECT PCPLAYDURATION + MOBILEPLAYDURATION as num FROM tlive_data
+WHERE channelid = $channelid$

+ 2 - 1
src/dsb/com/cnd3b/restcontroller/customer/live/SQL/观看次数.sql

@@ -1 +1,2 @@
-SELECT  PCVIDEOVIEW+MOBILEVIDEOVIEW  as num FROM tlive_data
+SELECT  PCVIDEOVIEW+MOBILEVIDEOVIEW  as num FROM tlive_data
+WHERE channelid = $channelid$

+ 67 - 9
src/dsb/com/cnd3b/restcontroller/customer/live/live.java

@@ -8,6 +8,7 @@ import com.cnd3b.common.data.Rows;
 import com.cnd3b.common.data.SQLFactory;
 import com.cnd3b.common.data.db.DataPool;
 import com.cnd3b.utility.polyv.Polyv;
+import p2.common.parse.A;
 import p2.pao.PaoRemote;
 import p2.pao.PaoSetRemote;
 import p2.util.P2Exception;
@@ -98,6 +99,7 @@ public class live extends Controller {
     public String getSYLiveInfo() throws P2Exception {
         SQLFactory sqlFactory = new SQLFactory(this, "私域直播详情");
         sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("tagentsid", tagentsid);
         Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
         if (rows.isEmpty()) {
             PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tliveapply", "siteid = '" + siteid + "' AND fissecret = 1 AND fstatus = '申请'");
@@ -114,26 +116,61 @@ public class live extends Controller {
     }
 
     /**
-     * 私域直播数据统计
+     * 私域直播数据统计(频道)
      *
      * @return
      */
     public String getSYLiveDataCount() {
-
+        String channelid = content.getString("channelid");
         JSONObject resultObject = new JSONObject();
         //观看次数(次)
-        double viewCounts = getCount("观看次数", "num");
+        double viewCounts = getCount("观看次数", "num", channelid);
         resultObject.put("viewCounts", String.format("%.2f", viewCounts));
         //观看时长(分钟)
-        double viewDuration = getCount("观看时长", "num");
+        double viewDuration = getCount("观看时长", "num", channelid);
         resultObject.put("viewDuration", String.format("%.2f", viewDuration));
         //观看人数(人)
-        double viewers = getCount("观看人数", "num");
+        double viewers = getCount("观看人数", "num", channelid);
         resultObject.put("viewers", String.format("%.2f", viewers));
+        System.err.println(viewers);
         //人均观看次数(次)
-        resultObject.put("viewCountsAvg", String.format("%.2f", viewCounts / viewers));
+        resultObject.put("viewCountsAvg", String.format("%.2f", viewers == 0.0 ? 0 : viewCounts / viewers));
         //人均观看时长(分钟)
-        resultObject.put("viewDurationAvg", String.format("%.2f", viewDuration / viewers));
+        resultObject.put("viewDurationAvg", String.format("%.2f", viewers == 0.0 ? 0 : viewDuration / viewers));
+
+        return getSucReturnObject().setData(resultObject).toString();
+    }
+
+    /**
+     * 私域直播数据统计(场次)
+     *
+     * @return
+     * @throws P2Exception
+     */
+    public String getSYLiveDataCountForSession() throws P2Exception {
+
+        String sessionid = content.getString("sessionid");
+        double livepv = 0;
+        double liveuv = 0;
+        double duration = 0;
+        PaoSetRemote paoSetRemote = getP2ServerSystemPaoSet("tlive_sessiondata", "sessionid = " + sessionid);
+        if (!paoSetRemote.isEmpty()) {
+            PaoRemote paoRemote = paoSetRemote.getPao(0);
+            //人数
+            livepv = paoRemote.getDouble("livepv");
+            //人次
+            liveuv = paoRemote.getDouble("liveuv");
+            //时长
+            duration = paoRemote.getDouble("duration");
+        }
+
+        JSONObject resultObject = new JSONObject();
+
+        resultObject.put("livepv", String.format("%.2f", livepv));
+        resultObject.put("liveuv", String.format("%.2f", liveuv));
+        resultObject.put("duration", String.format("%.2f", duration));
+        resultObject.put("liveuvAvg", String.format("%.2f", livepv == 0 ? 0 : liveuv / livepv));
+        resultObject.put("durationAvg", String.format("%.2f", livepv == 0 ? 0 : duration / livepv));
 
         return getSucReturnObject().setData(resultObject).toString();
     }
@@ -145,8 +182,12 @@ public class live extends Controller {
      * @return
      */
     public String getSYLiveUserList() {
+        String channelid = content.getString("channelid");
+        String sessionid = content.getString("sessionid");
+
         SQLFactory sqlFactory = new SQLFactory(this, "私域直播用户观看列表");
-        sqlFactory.addParameter_SQL("siteid", siteid);
+        sqlFactory.addParameter("channelid", channelid);
+        sqlFactory.addParameter("sessionid", sessionid);
         Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
 
         return getSucReturnObject().setData(rows).toString();
@@ -176,7 +217,22 @@ public class live extends Controller {
             return getErrReturnObject().setErrMsg("私域直播已申请").toString();
         }
 
+    }
 
+    /**
+     * 私域直播场次列表查询
+     *
+     * @return
+     */
+    public String getSYLiveSessionList() {
+
+        String channelid = content.getString("channelid");
+        SQLFactory sqlFactory = new SQLFactory(this, "直播场次列表查询", pageSize, pageNumber, "createdate");
+        sqlFactory.addParameter("channelid", channelid);
+
+        System.err.println(sqlFactory.getSQL());
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        return getSucReturnObject().setDataByPaging(rows).preloading(1).toString();
     }
 
 
@@ -187,9 +243,11 @@ public class live extends Controller {
      * @param fieldname    取数据的字段名称
      * @return
      */
-    public double getCount(String SQLMODELNAME, String fieldname) {
+    public double getCount(String SQLMODELNAME, String fieldname, String channelid) {
         SQLFactory sqlFactory = new SQLFactory(this, SQLMODELNAME);
         sqlFactory.addParameter("siteid", siteid);
+        sqlFactory.addParameter("tagentsid", tagentsid);
+        sqlFactory.addParameter("channelid", channelid);
         Rows rows = sqlFactory.runSqlQuery();
         return rows.isEmpty() ? 0 : rows.get(0).getDouble(fieldname);
     }