Quellcode durchsuchen

任务#2571 私域直播、展会直播相关接口开发

wzg vor 4 Jahren
Ursprung
Commit
d5212205af

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

@@ -0,0 +1,17 @@
+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,
+       (
+           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

+ 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='˽ÓòÖ±²¥'

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

@@ -0,0 +1 @@
+SELECT mobileuniqueviewer + pcuniqueviewer as num FROM tlive_data

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

@@ -0,0 +1 @@
+SELECT PCPLAYDURATION + MOBILEPLAYDURATION as num FROM tlive_data

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

@@ -0,0 +1 @@
+SELECT  PCVIDEOVIEW+MOBILEVIDEOVIEW  as num FROM tlive_data

+ 69 - 0
src/dsb/com/cnd3b/restcontroller/customer/live/live.java

@@ -3,6 +3,7 @@ package com.cnd3b.restcontroller.customer.live;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.Controller;
+import com.cnd3b.common.data.Row;
 import com.cnd3b.common.data.Rows;
 import com.cnd3b.common.data.SQLFactory;
 import com.cnd3b.common.data.db.DataPool;
@@ -84,4 +85,72 @@ public class live extends Controller {
         Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
         return getSucReturnObject().setData(rows).toString();
     }
+
+
+    /**
+     * 私域直播详情
+     *
+     * @return
+     */
+    public String getSYLiveInfo() {
+        SQLFactory sqlFactory = new SQLFactory(this, "私域直播详情");
+        sqlFactory.addParameter("siteid", siteid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+        return getSucReturnObject().setData(rows).toString();
+
+    }
+
+    /**
+     * 私域直播数据统计
+     *
+     * @return
+     */
+    public String getSYLiveDataCount() {
+
+        JSONObject resultObject = new JSONObject();
+        //观看次数(次)
+        double viewCounts = getCount("观看次数", "num");
+        resultObject.put("viewCounts", String.format("%.2f", viewCounts));
+        //观看时长(分钟)
+        double viewDuration = getCount("观看时长", "num");
+        resultObject.put("viewDuration", String.format("%.2f", viewDuration));
+        //观看人数(人)
+        double viewers = getCount("观看人数", "num");
+        resultObject.put("viewers", String.format("%.2f", viewers));
+        //人均观看次数(次)
+        resultObject.put("viewCountsAvg", String.format("%.2f", viewCounts / viewers));
+        //人均观看时长(分钟)
+        resultObject.put("viewDurationAvg", String.format("%.2f", viewDuration / viewers));
+
+        return getSucReturnObject().setData(resultObject).toString();
+    }
+
+    /**
+     * 获取数量
+     *
+     * @param SQLMODELNAME SQL名称
+     * @param fieldname    取数据的字段名称
+     * @return
+     */
+    public double getCount(String SQLMODELNAME, String fieldname) {
+        SQLFactory sqlFactory = new SQLFactory(this, SQLMODELNAME);
+        sqlFactory.addParameter("siteid", siteid);
+        Rows rows = sqlFactory.runSqlQuery();
+        return rows.isEmpty() ? 0 : rows.get(0).getDouble(fieldname);
+    }
+
+    /**
+     * 私域直播用户观看列表
+     *
+     * @return
+     */
+    public String getSYLiveUserList() {
+        SQLFactory sqlFactory = new SQLFactory(this, "私域直播用户观看列表");
+        sqlFactory.addParameter_SQL("siteid", siteid);
+        Rows rows = dbConnect.runSqlQuery(sqlFactory.getSQL());
+
+        return getSucReturnObject().setData(rows).toString();
+    }
+
+
 }