From 35994d6ffdd6fbaaf105894c689685988577259a Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Mon, 17 Oct 2022 17:23:41 +0800 Subject: [PATCH] add-sylive-top_view --- common/libraries/market/Sylive_entity.php | 73 +++++++++++++++++++++- home/controllers/h5/market/sylive/Stic.php | 46 +++++++++++++- home/views/h5/market/sylive/stic/area.php | 53 ++++++++++++++++ home/views/h5/market/sylive/stic/index.php | 53 ++++++++++++++-- 4 files changed, 215 insertions(+), 10 deletions(-) diff --git a/common/libraries/market/Sylive_entity.php b/common/libraries/market/Sylive_entity.php index 9773efb1..5305c322 100644 --- a/common/libraries/market/Sylive_entity.php +++ b/common/libraries/market/Sylive_entity.php @@ -17,6 +17,7 @@ class Sylive_entity{ $this->ci->load->model('market/market_sylive_activity_biz_model','mdSytActivityBiz'); $this->ci->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData'); $this->ci->load->model('market/market_sylive_organization_model'); + $this->ci->load->model('live/Live_polyv_viewlog_model', 'mdPolyvViewlog'); } /** @@ -159,8 +160,6 @@ class Sylive_entity{ //门店用户排行数据 public function top_biz_user($aid,$biz_id,$uid,$type='browse',$page=1,$size=50){ - $lists = []; - $total = 0; $where = [ 'parentId' => $biz_id ]; @@ -210,7 +209,77 @@ class Sylive_entity{ ]; return $data; } + //用户用户观看次数排行 + public function top_view_num($channelId,$page=1,$size=10){ + $where = [ + 'channelId' => $channelId + ]; + $total = $this->ci->mdPolyvViewlog->count($where); + $lists = []; + if($total){ + $rows = $this->ci->mdPolyvViewlog->select_groupby('param1',$where,'total desc',$page,$size,'param1,count(id) as total'); + $uids = implode(',',array_unique(array_column($rows,'param1'))); + $users = []; + if($uids){ + $where = [ + "unionid in ('$uids')" => null, + ]; + $users = $this->ci->user_model->map('unionid','',$where,'','','','userId,uname,nickname,headimg'); + } + foreach ($rows as $item) { + $user = $users[$item['uid']] ? $users[$item['uid']][0] : []; + $total = $item['total']; + $lists[] = [ + 'uid' => $user['userId'], + 'name' => $user['nickname'] ? $user['nickname'] : '', + 'headimg' => $user['headimg'] ? $user['headimg'] : self::DEFAULT_HEAD, + 'total' => $total, + 'num' => "{$total}次", + ]; + } + } + $data = [ + 'total' => $total, + 'lists' => $lists + ]; + return $data; + } + //用户用户观看时长排行 + public function top_view_time($channelId,$page=1,$size=10){ + $where = [ + 'channelId' => $channelId + ]; + $total = $this->ci->mdPolyvViewlog->count($where); + $lists = []; + if($total){ + $rows = $this->ci->mdPolyvViewlog->select_groupby('param1',$where,'total desc',$page,$size,'param1,,sum(playDuration) as total'); + $uids = implode(',',array_unique(array_column($rows,'param1'))); + $users = []; + if($uids){ + $where = [ + "unionid in ('$uids')" => null, + ]; + $users = $this->ci->user_model->map('unionid','',$where,'','','','userId,uname,nickname,headimg'); + } + foreach ($rows as $item) { + $user = $users[$item['uid']] ? $users[$item['uid']][0] : []; + $total = $item['total']; + $lists[] = [ + 'uid' => $user['userId'], + 'name' => $user['nickname'] ? $user['nickname'] : '', + 'headimg' => $user['headimg'] ? $user['headimg'] : self::DEFAULT_HEAD, + 'total' => $total, + 'num' => "{$total}秒", + ]; + } + } + $data = [ + 'total' => $total, + 'lists' => $lists + ]; + return $data; + } public function __get($name) { diff --git a/home/controllers/h5/market/sylive/Stic.php b/home/controllers/h5/market/sylive/Stic.php index 114d4072..e4f97745 100644 --- a/home/controllers/h5/market/sylive/Stic.php +++ b/home/controllers/h5/market/sylive/Stic.php @@ -124,7 +124,14 @@ class Stic extends Admin{ ['title' => '预约用户', 'num' => "{$subscribe_count}人",'url'=>'/h5/market/sylive/stic/users?type=all&kpi=subscribe&a_id='.$a_id], ['title' => '预约率', 'num' => $subscribe_count ? round($subscribe_count/$browse_count*100,2)."%" : 0], ]; - $biz_id = $this->group_id==3 ? $this->session['org_id'] : 0; + if($this->group_id==3){ + $org_row = $this->market_sylive_organization_model->get(['organizationId'=>$this->session['org_id']],'parentId'); + $biz_id = $org_row['parentId'] ? $org_row['parentId'] : 0; + }elseif($this->group_id==2){ + $biz_id = $this->session['org_id']; + }else{ + $biz_id = 0; + } $browse_lists = $this->sylive_entity->top_lists($a_id,'browse',1,10,$biz_id); $browse = [ 'title' => '门店浏览排行', @@ -157,6 +164,7 @@ class Stic extends Admin{ $this->show_json([],200); } $cell4 = $cell3 = []; + $view_num = $view_time = []; if($this->group_id<2){ //所有大区 $where = [ 'a_id' => $a_id, @@ -210,6 +218,18 @@ class Stic extends Admin{ $view_count = $this->mdSytActivityKpiData->count($where); //观看数据 $where['kpi'] = 'order'; $order_count = $this->mdSytActivityKpiData->count($where); //下单数据 + $view_num_lists = $this->sylive_entity->top_view_num($row['channelId'],1,10); + $view_num = [ + 'title' => '客户观看次数排行', + 'url' => '', + 'list' => $view_num_lists['lists'] + ]; + $view_time_lists = $this->sylive_entity->top_view_time($row['channelId'],1,10); + $view_time = [ + 'title' => '客户观看时长排行', + 'url' => '', + 'list' => $view_time_lists['lists'] + ]; } $cell1 = [ ['title' => '观看用户', 'num' => "{$view_count}人",'url'=>'/h5/market/sylive/stic/users?type=all&kpi=watch&a_id='.$a_id], @@ -225,7 +245,14 @@ class Stic extends Admin{ ['title' => '人均观看', 'num' => "{$avg_UV_time}秒"], ['title' => '观看次数', 'num' => "{$livePV}次"], ]; - $biz_id = $this->group_id==3 ? $this->session['org_id'] : 0; + if($this->group_id==3){ + $org_row = $this->market_sylive_organization_model->get(['organizationId'=>$this->session['org_id']],'parentId'); + $biz_id = $org_row['parentId'] ? $org_row['parentId'] : 0; + }elseif($this->group_id==2){ + $biz_id = $this->session['org_id']; + }else{ + $biz_id = 0; + } $watch_lists = $this->sylive_entity->top_lists($a_id,'watch',1,10,$biz_id); $view = [ 'title' => '门店观看排行', @@ -244,7 +271,9 @@ class Stic extends Admin{ 'cell3' => $cell3, 'cell4' => $cell4, 'view' => $view, - 'order' => $order + 'order' => $order, + 'view_num' => $view_num, + 'view_time' => $view_time, ]; $this->show_json($data,200); } @@ -365,6 +394,17 @@ class Stic extends Admin{ 'title' => '本店订单排行', 'list' => $order_rows['lists'] ]; + $view_num_lists = $this->sylive_entity->top_view_num($row['channelId'],1,10); + $data['view_num'] = [ + 'title' => '客户观看次数排行', + 'list' => $view_num_lists['lists'] + ]; + $view_time_lists = $this->sylive_entity->top_view_time($row['channelId'],1,10); + $data['view_time'] = [ + 'title' => '客户观看时长排行', + 'url' => '', + 'list' => $view_time_lists['lists'] + ]; } $this->show_json($data,200); } diff --git a/home/views/h5/market/sylive/stic/area.php b/home/views/h5/market/sylive/stic/area.php index a313a73b..1a9afb2e 100644 --- a/home/views/h5/market/sylive/stic/area.php +++ b/home/views/h5/market/sylive/stic/area.php @@ -168,6 +168,49 @@
暂时无数据
+ +
+
+ + 查看更多 +
+
+
+
+
+ # + {{index+1}} + {{item.name}} + {{item.tip}} +
+
{{item.num}}
+
+
+
+
暂时无数据
+
+ + +
+
+ + 查看更多 +
+
+
+
+
+ # + {{index+1}} + {{item.name}} + {{item.tip}} +
+
{{item.num}}
+
+
+
+
暂时无数据
+
@@ -215,6 +258,16 @@ title:'', url:'', list:[], + }, + view_num:{ + title:'', + url:'', + list:[], + }, + view_time:{ + title:'', + url:'', + list:[], } }, }, diff --git a/home/views/h5/market/sylive/stic/index.php b/home/views/h5/market/sylive/stic/index.php index 04ace813..15418a19 100644 --- a/home/views/h5/market/sylive/stic/index.php +++ b/home/views/h5/market/sylive/stic/index.php @@ -78,11 +78,11 @@ -
+
-
+
# @@ -95,12 +95,45 @@
暂时无数据
- -
+
-
+
+
+
+ # + {{index+1}} + {{item.name}} + {{item.tip}} +
+
{{item.num}}
+
+
+
暂时无数据
+
+
+
+ +
+
+
+
+ # + {{index+1}} + {{item.name}} + {{item.tip}} +
+
{{item.num}}
+
+
+
暂时无数据
+
+
+
+ +
+
# @@ -177,6 +210,14 @@ order:{ title:'', list:[], + }, + view_num:{ + title:'', + list:[], + }, + view_time:{ + title:'', + list:[], } }, isDataEnd: false, @@ -301,6 +342,8 @@ }else{ // 直播 that.live.view = res.data.view that.live.order = res.data.order + that.live.view_num = res.data.view_num + that.live.view_time = res.data.view_time } if (res.data.total == 0) { that.isNoData = true;