|
|
@@ -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();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|