From fbde62c3ebc7318809513d6edfeae166674db9f5 Mon Sep 17 00:00:00 2001
From: lccsw <805383944@qq.com>
Date: Wed, 14 Dec 2022 17:44:38 +0800
Subject: [PATCH] edit-sylive-live_limit
---
home/controllers/h5/market/sylive2/Stic.php | 88 ++++++++++++---------
home/views/h5/market/sylive2/stic/index.php | 3 +-
2 files changed, 53 insertions(+), 38 deletions(-)
diff --git a/home/controllers/h5/market/sylive2/Stic.php b/home/controllers/h5/market/sylive2/Stic.php
index daa2bb13..476bb916 100644
--- a/home/controllers/h5/market/sylive2/Stic.php
+++ b/home/controllers/h5/market/sylive2/Stic.php
@@ -616,42 +616,56 @@ class Stic extends Admin{
$biz_id = $this->input->get('biz_id');
$row = $this->market_sylive_activity_model->get(['activityId'=>$this->a_id],'activityStart,timeStart,timeEnd');
$xAxisData = [];
+ $title = '';
if($type==2){
- $activityStart = strtotime($row['timeStart']);
- $end_time = strtotime($row['timeEnd']);
- $diff_seconds = $end_time - $activityStart;
- $diff_hour = ceil($diff_seconds/3600);
-// $where = [
-// 'activityId' => $this->a_id,
-// 'bizId' => $biz_id,
-// 'kpi' => 'watch',
-// 'createTime>=' => $activityStart,
-// 'createTime<=' => $end_time,
-// ];
-// $watch_kpi_rows = $this->mdSytActivityKpiData->select_groupby('ctime',$where,'',0,0,'from_unixtime(createTime,"%H") as ctime,count(id) as total');
-// $where['kpi'] = 'order';
-// $order_kpi_rows = $this->mdSytActivityKpiData->select_groupby('ctime',$where,'',0,0,'from_unixtime(createTime,"%H") as ctime,count(id) as total');
-// $temp_s_data = $temp_b_data = [];
- for($i=0;$i<$diff_hour;$i++){
- $xAxisData[] = date('H:00',$activityStart + $i*60*60).'-'.date('H:00',$activityStart + ($i+1)*60*60);
- $watch_data[] = 0;
- $order_data[] = 0;
+ if(time()>=strtotime($row['timeStart'])){ //直播开始后显示
+ $activityStart = strtotime($row['timeStart']);
+ $end_time = strtotime($row['timeEnd']);
+ $diff_seconds = $end_time - $activityStart;
+ $diff_hour = ceil($diff_seconds/3600);
+ $where = [
+ 'activityId' => $this->a_id,
+ 'bizId' => $biz_id,
+ 'kpi' => 'watch',
+ 'createTime>=' => $activityStart,
+ 'createTime<=' => $end_time,
+ ];
+ $watch_kpi_rows = $this->mdSytActivityKpiData->select_groupby('ctime',$where,'',0,0,'from_unixtime(createTime,"%H") as ctime,count(id) as total');
+ $where['kpi'] = 'order';
+ $order_kpi_rows = $this->mdSytActivityKpiData->select_groupby('ctime',$where,'',0,0,'from_unixtime(createTime,"%H") as ctime,count(id) as total');
+ $temp_o_data = $temp_w_data = [];
+ if($watch_kpi_rows){
+ foreach ($watch_kpi_rows as $item) {
+ $temp_w_data[intval($item['ctime'])] = $item['total'];
+ }
+ }
+ if($order_kpi_rows){
+ foreach ($order_kpi_rows as $item) {
+ $temp_o_data[intval($item['ctime'])] = $item['total'];
+ }
+ }
+ $watch_data = $order_data = [];
+ for($i=0;$i<$diff_hour;$i++){
+ $xAxisData[] = date('H:00',$activityStart + $i*60*60).'-'.date('H:00',$activityStart + ($i+1)*60*60);
+ $time = intval(date('H',$activityStart + $i*60*60));
+ $watch_data[] = $temp_w_data[$time] ? $temp_w_data[$time] : 0;;
+ $order_data[] = $temp_o_data[$time] ? $temp_o_data[$time] : 0;;
+ }
+ $title = '直播走势图';
+ $legendData = ['观看数', '订单数'];
+ $seriesData = [
+ [
+ 'name' => '观看数',
+ 'type' => 'line',
+ 'data' => $watch_data
+ ],
+ [
+ 'name' => '订单数',
+ 'type' => 'line',
+ 'data' => $order_data
+ ],
+ ];
}
- $title = '直播走势图';
- $legendData = ['观看数', '订单数'];
- $seriesData = [
- [
- 'name' => '观看数',
- 'type' => 'line',
- 'data' => $watch_data
- ],
- [
- 'name' => '订单数',
- 'type' => 'line',
- 'data' => $order_data
- ],
- ];
-// $xAxisData = ['9:00-10:00', '10:00-11:00', '11:00-12:00', '12:00-13:00'];
}else{
$activityStart = strtotime($row['activityStart'])>0 ? strtotime($row['activityStart']) : strtotime($row['timeStart'])-7*24*60*60;
$end_time = time()< strtotime($row['timeStart']) ? time() : strtotime($row['timeStart']);
@@ -673,7 +687,7 @@ class Stic extends Admin{
$temp_b_data[$item['day']] = $item['total'];
}
}
- if($temp_s_data){
+ if($subscribe_rows){
foreach ($subscribe_rows as $item) {
$temp_s_data[$item['day']] = $item['total'];
}
@@ -686,7 +700,7 @@ class Stic extends Admin{
$subscribe_data[] = $temp_s_data[$day] ? $temp_s_data[$day] : 0;
}
$title = '预热走势图';
- $legendData = ['访问数', '订阅数'];
+ $legendData = ['访问数', '预约数'];
$seriesData = [
[
'name' => '访问数',
@@ -694,7 +708,7 @@ class Stic extends Admin{
'data' => $browse_data
],
[
- 'name' => '订阅数',
+ 'name' => '预约数',
'type' => 'line',
'data' => $subscribe_data
],
diff --git a/home/views/h5/market/sylive2/stic/index.php b/home/views/h5/market/sylive2/stic/index.php
index 9ebd2362..7dbc040b 100644
--- a/home/views/h5/market/sylive2/stic/index.php
+++ b/home/views/h5/market/sylive2/stic/index.php
@@ -293,6 +293,7 @@
this.h_lists = []
this.sub_lists = []
this.list = []
+ this.lineChart = {}
if(this.tabid == 1){
this.getBegin()
}else if(this.tabid == 2){
@@ -334,7 +335,7 @@
that.h_lists = result.data.h_lists
that.sub_lists = result.data.sub_lists
},'json')
- // this.lineData()
+ this.lineData()
},
//获取大区列表