From 22594bfb3a5e5ab3b5b5929f7e2c8240ff94b9a9 Mon Sep 17 00:00:00 2001 From: dengbw Date: Fri, 11 Nov 2022 13:33:52 +0800 Subject: [PATCH] market_draw_1111_2 --- market/controllers/api/sylive/Statistics.php | 122 +++++++++++-------- 1 file changed, 72 insertions(+), 50 deletions(-) diff --git a/market/controllers/api/sylive/Statistics.php b/market/controllers/api/sylive/Statistics.php index db51bad7..9587ae66 100644 --- a/market/controllers/api/sylive/Statistics.php +++ b/market/controllers/api/sylive/Statistics.php @@ -22,6 +22,7 @@ class Statistics extends BaseController $this->load->model('market/Market_sylive_activity_team_model', 'mdSyliveActivityTeam'); $this->load->model('market/Market_sylive_organization_model', 'mdSyliveOrganization'); $this->load->model('market/Market_sylive_user_model', 'mdSyliveUser'); + $this->load->model('market/Market_sylive_viewlog_model', 'mdSyliveViewlog'); $this->load->model('live/Live_polyv_session_model', 'mdPolyvSession'); $this->load->model('live/Live_polyv_viewlog_model', 'mdPolyvViewlog'); } @@ -102,8 +103,11 @@ class Statistics extends BaseController $activityData1 = [['name' => '参与区域数', 'value' => count($areaAry)], ['name' => '参与门店数', 'value' => $biz] , ['name' => '参与/全部顾问数', 'value' => $consultant . '/' . $allConsultant]]; $url = "/sylive/activity/statistics/piechart?activityId={$activityId}&"; - $watch_un = $watch - $liveUV; - $watch_un < 0 && $watch_un = 0; + $watch_un = 0; + if ($liveUV) { + $watch_un = $watch - $liveUV; + $watch_un < 0 && $watch_un = 0; + } $activityData2 = [['name' => '浏览数(人)', 'value' => $browse, 'url' => ''], ['name' => '预约数(人)', 'value' => $subscribe, 'url' => ''] , ['name' => '订单数(单)', 'value' => $order, 'url' => ''], ['name' => '有效观看(人)', 'value' => $liveUV, 'url' => ''], ['name' => '无效观看(人)', 'value' => $watch_un, 'url' => ''] , ['name' => '直播时长(分)', 'value' => $duration_min, 'url' => ''], ['name' => '观看数(人次)', 'value' => $livePV, 'url' => ''] @@ -231,23 +235,29 @@ class Statistics extends BaseController $orderTotal = $this->mdSyliveActivityBiz->sum('orderTotal', ['areaId' => $areaId, 'activityId' => $activityId]); $livePV = $watchDuration = 0; if ($channelId) { - $res_watch = $this->mdSyliveActivityKpidata->db->select('b.unionid') - ->from('lc_market_sylive_activity_kpidata as a') - ->join('lc_market_sylive_user as b', "b.userId=a.userId", 'left') - ->where(['a.areaId' => $areaId, 'a.type' => 0, 'a.activityId' => $activityId, 'a.kpi' => 'watch', "unionid!=''" => null]) - ->limit(10000, 0) - ->get()->result_array(); - if ($res_watch) { - $str_unionids = implode("','", array_column($res_watch, 'unionid')); - $where_pv = ['channelId' => $channelId, 'param3' => 'live']; - $where_pv["param1 in ('" . $str_unionids . "')"] = null; - $livePV = $this->mdPolyvViewlog->count($where_pv); - $re_sum = $this->mdPolyvViewlog->sum('playDuration', $where_pv); - if ($re_sum['playDuration']) { - $playDuration = ceil($re_sum['playDuration'] / 60); - $watchDuration = round($playDuration / $livePV); - } + $livePV = $this->mdSyliveViewlog->count(['areaId' => $areaId, 'activityId' => $activityId, 'type' => 0]); + $re_sum = $this->mdSyliveViewlog->sum('playDuration', ['areaId' => $areaId, 'activityId' => $activityId, 'type' => 0]); + if ($re_sum['playDuration']) { + $playDuration = ceil($re_sum['playDuration'] / 60); + $watchDuration = round($playDuration / $livePV); } +// $res_watch = $this->mdSyliveActivityKpidata->db->select('b.unionid') +// ->from('lc_market_sylive_activity_kpidata as a') +// ->join('lc_market_sylive_user as b', "b.userId=a.userId", 'left') +// ->where(['a.areaId' => $areaId, 'a.type' => 0, 'a.activityId' => $activityId, 'a.kpi' => 'watch', "unionid!=''" => null]) +// ->limit(10000, 0) +// ->get()->result_array(); +// if ($res_watch) { +// $str_unionids = implode("','", array_column($res_watch, 'unionid')); +// $where_pv = ['channelId' => $channelId, 'param3' => 'live']; +// $where_pv["param1 in ('" . $str_unionids . "')"] = null; +// $livePV = $this->mdPolyvViewlog->count($where_pv); +// $re_sum = $this->mdPolyvViewlog->sum('playDuration', $where_pv); +// if ($re_sum['playDuration']) { +// $playDuration = ceil($re_sum['playDuration'] / 60); +// $watchDuration = round($playDuration / $livePV); +// } +// } } $allConsultant = 0; if ($v['biz']) { @@ -390,23 +400,29 @@ class Statistics extends BaseController $consultant > $allConsultant && $allConsultant = $consultant; $livePV = $watchDuration = 0; if ($channelId) { - $res_watch = $this->mdSyliveActivityKpidata->db->select('b.unionid') - ->from('lc_market_sylive_activity_kpidata as a') - ->join('lc_market_sylive_user as b', "b.userId=a.userId", 'left') - ->where(['a.bizId' => $bizId, 'a.type' => 0, 'a.activityId' => $activityId, 'a.kpi' => 'watch', "unionid!=''" => null]) - ->limit(10000, 0) - ->get()->result_array(); - if ($res_watch) { - $str_unionids = implode("','", array_column($res_watch, 'unionid')); - $where_pv = ['channelId' => $channelId, 'param3' => 'live']; - $where_pv["param1 in ('" . $str_unionids . "')"] = null; - $livePV = $this->mdPolyvViewlog->count($where_pv); - $re_sum = $this->mdPolyvViewlog->sum('playDuration', $where_pv); - if ($re_sum['playDuration']) { - $playDuration = ceil($re_sum['playDuration'] / 60); - $watchDuration = round($playDuration / $livePV); - } + $livePV = $this->mdSyliveViewlog->count(['bizId' => $bizId, 'activityId' => $activityId, 'type' => 0]); + $re_sum = $this->mdSyliveViewlog->sum('playDuration', ['bizId' => $bizId, 'activityId' => $activityId, 'type' => 0]); + if ($re_sum['playDuration']) { + $playDuration = ceil($re_sum['playDuration'] / 60); + $watchDuration = round($playDuration / $livePV); } +// $res_watch = $this->mdSyliveActivityKpidata->db->select('b.unionid') +// ->from('lc_market_sylive_activity_kpidata as a') +// ->join('lc_market_sylive_user as b', "b.userId=a.userId", 'left') +// ->where(['a.bizId' => $bizId, 'a.type' => 0, 'a.activityId' => $activityId, 'a.kpi' => 'watch', "unionid!=''" => null]) +// ->limit(10000, 0) +// ->get()->result_array(); +// if ($res_watch) { +// $str_unionids = implode("','", array_column($res_watch, 'unionid')); +// $where_pv = ['channelId' => $channelId, 'param3' => 'live']; +// $where_pv["param1 in ('" . $str_unionids . "')"] = null; +// $livePV = $this->mdPolyvViewlog->count($where_pv); +// $re_sum = $this->mdPolyvViewlog->sum('playDuration', $where_pv); +// if ($re_sum['playDuration']) { +// $playDuration = ceil($re_sum['playDuration'] / 60); +// $watchDuration = round($playDuration / $livePV); +// } +// } } $list[] = [ 'bizName' => $bizName, 'consultant' => $consultant . '/' . $allConsultant, 'browse' => $v['browse'], 'subscribe' => $v['subscribe'] @@ -522,23 +538,29 @@ class Statistics extends BaseController $consultantName = $organizationName . ' ' . $uname; $livePV = $watchDuration = 0; if ($channelId) { - $res_watch = $this->mdSyliveActivityKpidata->db->select('b.unionid') - ->from('lc_market_sylive_activity_kpidata as a') - ->join('lc_market_sylive_user as b', "b.userId=a.userId", 'left') - ->where(['a.cfUserId' => $userId, 'a.activityId' => $activityId, 'a.type' => 0, 'a.kpi' => 'watch', "unionid!=''" => null]) - ->limit(10000, 0) - ->get()->result_array(); - if ($res_watch) { - $str_unionids = implode("','", array_column($res_watch, 'unionid')); - $where_pv = ['channelId' => $channelId, 'param3' => 'live']; - $where_pv["param1 in ('" . $str_unionids . "')"] = null; - $livePV = $this->mdPolyvViewlog->count($where_pv); - $re_sum = $this->mdPolyvViewlog->sum('playDuration', $where_pv); - if ($re_sum['playDuration']) { - $playDuration = ceil($re_sum['playDuration'] / 60); - $watchDuration = round($playDuration / $livePV); - } + $livePV = $this->mdSyliveViewlog->count(['cfUserId' => $userId, 'activityId' => $activityId, 'type' => 0]); + $re_sum = $this->mdSyliveViewlog->sum('playDuration', ['cfUserId' => $userId, 'activityId' => $activityId, 'type' => 0]); + if ($re_sum['playDuration']) { + $playDuration = ceil($re_sum['playDuration'] / 60); + $watchDuration = round($playDuration / $livePV); } +// $res_watch = $this->mdSyliveActivityKpidata->db->select('b.unionid') +// ->from('lc_market_sylive_activity_kpidata as a') +// ->join('lc_market_sylive_user as b', "b.userId=a.userId", 'left') +// ->where(['a.cfUserId' => $userId, 'a.activityId' => $activityId, 'a.type' => 0, 'a.kpi' => 'watch', "unionid!=''" => null]) +// ->limit(10000, 0) +// ->get()->result_array(); +// if ($res_watch) { +// $str_unionids = implode("','", array_column($res_watch, 'unionid')); +// $where_pv = ['channelId' => $channelId, 'param3' => 'live']; +// $where_pv["param1 in ('" . $str_unionids . "')"] = null; +// $livePV = $this->mdPolyvViewlog->count($where_pv); +// $re_sum = $this->mdPolyvViewlog->sum('playDuration', $where_pv); +// if ($re_sum['playDuration']) { +// $playDuration = ceil($re_sum['playDuration'] / 60); +// $watchDuration = round($playDuration / $livePV); +// } +// } } $list[] = ['consultantName' => $consultantName, 'browse' => $v['browse'], 'subscribe' => $v['subscribe'], 'watch' => $v['watch'] , 'order' => $v['orderTotal'], 'livePV' => $livePV, 'watchDuration' => $watchDuration];