Browse Source

Merge remote-tracking branch 'origin/develop' into develop

沈静伟 4 years ago
parent
commit
9e18f1b611

+ 5 - 0
src/dsb/com/cnd3b/restcontroller/customer/live/SQL/展会直播详情.sql

@@ -0,0 +1,5 @@
+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.categoryName='Õ¹»áÖ±²¥' and t1.tagentsid = $tagentsid$

+ 20 - 0
src/dsb/com/cnd3b/restcontroller/customer/live/SQL/直播用户观看列表.sql

@@ -0,0 +1,20 @@
+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,
+       t1.city,
+       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
+where sessionid = $sessionid$
+  and channelid = $channelid$

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

@@ -0,0 +1,8 @@
+SELECT t1.sessionid,
+       t1.description,
+       DATEADD(S, convert(float,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$

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

@@ -1,2 +1,7 @@
-SELECT mobileuniqueviewer + pcuniqueviewer as num FROM tlive_data
-WHERE channelid = $channelid$
+SELECT SUM
+           (t1.num) as num
+FROM (
+         SELECT mobileuniqueviewer + pcuniqueviewer AS num
+         FROM tlive_data
+         WHERE channelid = $channelid$
+     ) AS t1

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

@@ -1,2 +1,7 @@
-SELECT PCPLAYDURATION + MOBILEPLAYDURATION as num FROM tlive_data
-WHERE channelid = $channelid$
+SELECT SUM
+           (t1.num) as num
+FROM (
+         SELECT PCPLAYDURATION + MOBILEPLAYDURATION AS num
+         FROM tlive_data
+         WHERE channelid = $channelid$
+     ) AS t1

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

@@ -1,2 +1,7 @@
-SELECT  PCVIDEOVIEW+MOBILEVIDEOVIEW  as num FROM tlive_data
-WHERE channelid = $channelid$
+SELECT SUM
+           (t1.num) as num
+FROM (
+         SELECT PCVIDEOVIEW + MOBILEVIDEOVIEW AS num
+         FROM tlive_data
+         WHERE channelid = $channelid$
+     ) AS t1

+ 117 - 3
src/dsb/com/cnd3b/restcontroller/customer/live/live.java

@@ -90,6 +90,120 @@ public class live extends Controller {
         return getSucReturnObject().setData(rows).toString();
     }
 
+    /**
+     * 展会直播详情
+     *
+     * @return
+     */
+    public String getLiveInfo() 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 = 0 AND fstatus = '申请'");
+            if (paoSetRemote.isEmpty()) {
+                return getErrReturnObject().setErrCode(3).setErrMsg("无直播间信息").toString();
+            } else {
+                return getErrReturnObject().setErrCode(2).setErrMsg("直播申请中").toString();
+            }
+        } else {
+            return getSucReturnObject().setData(rows).toString();
+        }
+
+
+    }
+
+    /**
+     * 直播数据统计(频道)
+     *
+     * @return
+     */
+    public String getLiveDataCount() {
+        String channelid = content.getString("channelid");
+        JSONObject resultObject = new JSONObject();
+        //观看次数(次)
+        double viewCounts = getCount("观看次数", "num", channelid);
+        resultObject.put("viewCounts", String.format("%.2f", viewCounts));
+        //观看时长(分钟)
+        double viewDuration = getCount("观看时长", "num", channelid);
+        resultObject.put("viewDuration", String.format("%.2f", viewDuration));
+        //观看人数(人)
+        double viewers = getCount("观看人数", "num", channelid);
+        resultObject.put("viewers", String.format("%.2f", viewers));
+        //人均观看次数(次)
+        resultObject.put("viewCountsAvg", String.format("%.2f", viewers == 0.0 ? 0 : viewCounts / viewers));
+        //人均观看时长(分钟)
+        resultObject.put("viewDurationAvg", String.format("%.2f", viewers == 0.0 ? 0 : viewDuration / viewers));
+
+        return getSucReturnObject().setData(resultObject).toString();
+    }
+
+    /**
+     * 直播数据统计(场次)
+     *
+     * @return
+     * @throws P2Exception
+     */
+    public String getLiveDataCountForSession() 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();
+    }
+
+
+    /**
+     * 直播用户观看列表
+     *
+     * @return
+     */
+    public String getLiveUserList() {
+        String channelid = content.getString("channelid");
+        String sessionid = content.getString("sessionid");
+
+        SQLFactory sqlFactory = new SQLFactory(this, "直播用户观看列表");
+        sqlFactory.addParameter("channelid", channelid);
+        sqlFactory.addParameter("sessionid", sessionid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+
+    /**
+     * 直播场次列表查询
+     *
+     * @return
+     */
+    public String getLiveSessionList() {
+
+        String channelid = content.getString("channelid");
+        SQLFactory sqlFactory = new SQLFactory(this, "直播场次列表查询", pageSize, pageNumber, "createdate");
+        sqlFactory.addParameter("channelid", channelid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        return getSucReturnObject().setDataByPaging(rows).preloading(1).toString();
+    }
 
     /**
      * 私域直播详情
@@ -132,6 +246,7 @@ public class live extends Controller {
         //观看人数(人)
         double viewers = getCount("观看人数", "num", channelid);
         resultObject.put("viewers", String.format("%.2f", viewers));
+        System.err.println(viewCounts+","+viewDuration+","+viewers);
         //人均观看次数(次)
         resultObject.put("viewCountsAvg", String.format("%.2f", viewers == 0.0 ? 0 : viewCounts / viewers));
         //人均观看时长(分钟)
@@ -225,7 +340,7 @@ public class live extends Controller {
     public String getSYLiveSessionList() {
 
         String channelid = content.getString("channelid");
-        SQLFactory sqlFactory = new SQLFactory(this, "直播场次列表查询", pageSize, pageNumber, "createdate");
+        SQLFactory sqlFactory = new SQLFactory(this, "私域直播场次列表查询", pageSize, pageNumber, "createdate");
         sqlFactory.addParameter("channelid", channelid);
         Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
         return getSucReturnObject().setDataByPaging(rows).preloading(1).toString();
@@ -241,9 +356,8 @@ public class live extends Controller {
      */
     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);
+        System.err.println(sqlFactory.getSQL());
         Rows rows = sqlFactory.runSqlQuery();
         return rows.isEmpty() ? 0 : rows.get(0).getDouble(fieldname);
     }