market_statistics_1031

This commit is contained in:
dengbw
2022-10-31 16:37:13 +08:00
parent 06c0f071e3
commit a54f57f6af
+26 -18
View File
@@ -191,8 +191,8 @@ class Statistics extends BaseController
$re_liveUV = $this->mdPolyvSession->sum('liveUV', ['channelId' => $channelId]);
$re_livePV = $this->mdPolyvSession->sum('livePV', ['channelId' => $channelId]);
$re_totalPlayDuration = $this->mdPolyvSession->sum('totalPlayDuration', ['channelId' => $channelId]);
$duration_min = ceil($re_duration['duration'] / 60);
$totalPlayDuration_min = ceil($re_totalPlayDuration['totalPlayDuration'] / 60);
$duration_min = round($re_duration['duration'] / 60);
$totalPlayDuration_min = round($re_totalPlayDuration['totalPlayDuration'] / 60);
$livePV = $re_livePV['livePV'];
$watchDuration = round($totalPlayDuration_min / $re_liveUV['liveUV']);
$pvDuration = round($livePV / $re_liveUV['liveUV'], 1);
@@ -217,23 +217,31 @@ class Statistics extends BaseController
// , ['name' => '直播时长(分)', 'value' => $duration, 'url' => ''], ['name' => '观看数(人次)', 'value' => $livePV, 'url' => '']
// , ['name' => '人均观看(分)', 'value' => $watchDuration, 'url' => ''], ['name' => '人均观看(次)', 'value' => $pvDuration, 'url' => '']];
}
$watch_per = number_format_com($watch / $browse * 100, 1, '');
$order_per = number_format_com($order / $watch * 100, 1, '');
$browse_expected_data = [['name' => "浏览人数(100%)", 'value' => 100], ['name' => "观看人数({$watch_per}%)", 'value' => 66.7], ['name' => "订单数({$order_per}%)", 'value' => 33.3]];
$browse_actual_data = [['name' => '浏览人数', 'value' => $browse], ['name' => '观看人数', 'value' => $watch], ['name' => '订单数', 'value' => $order]];
$funnel_browse = ['title' => '浏览转化漏斗', 'expected_data' => $browse_expected_data, 'actual_data' => $browse_actual_data];
$timeStart = strtotime($re['timeStart']);//直播开始时间
$left_browse_where = "uid in(select uid from lc_market_sylive_activity_kpidata where a_id = {$activityId} AND type = 0 AND kpi = 'browse' AND c_time < {$timeStart})";
$left_browse = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'kpi' => 'browse', 'c_time<' => $timeStart]);
$left_subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'kpi' => 'subscribe']);
$left_watch = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'kpi' => 'watch', $left_browse_where => null]);
$left_order = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'kpi' => 'order', $left_browse_where => null]);
$left_subscribe_per = number_format_com($left_subscribe / $left_browse * 100, 1, '');
$left_watch_per = number_format_com($left_watch / $left_subscribe * 100, 1, '');
$left_order_per = number_format_com($left_order / $left_watch * 100, 1, '');
$left_expected_data = [['name' => "浏览人数100%", 'value' => 100], ['name' => "预约人数({$left_subscribe_per}%)", 'value' => 75]
, ['name' => "观看人数({$left_watch_per}%)", 'value' => 50], ['name' => "订单数({$left_order_per}%)", 'value' => 25]];
$left_actual_data = [['name' => '浏览人数', 'value' => $left_browse], ['name' => '预约人数', 'value' => $left_subscribe]
, ['name' => '观看人数', 'value' => $left_watch], ['name' => '订单数', 'value' => $left_order]];
$funnel_browse = ['title' => '浏览转化漏斗((预热阶段)', 'expected_data' => $left_expected_data, 'actual_data' => $left_actual_data];
$right_browse_where = "uid in(select uid from lc_market_sylive_activity_kpidata where a_id = {$activityId} AND type = 0 AND kpi = 'browse' AND c_time >= {$timeStart})";
$right_browse = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'kpi' => 'browse', 'c_time>=' => $timeStart]);
$right_watch = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'kpi' => 'watch', $right_browse_where => null]);
$right_order = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'kpi' => 'order', $right_browse_where => null]);
$right_watch_per = number_format_com($right_watch / $right_browse * 100, 1, '');
$right_order_per = number_format_com($right_order / $right_watch * 100, 1, '');
$right_expected_data = [['name' => "浏览人数100%", 'value' => 100], ['name' => "观看人数({$right_watch_per}%)", 'value' => 66.7], ['name' => "订单数({$right_order_per}%)", 'value' => 33.3]];
$right_actual_data = [['name' => '浏览人数_' . $right_browse, 'value' => $right_browse], ['name' => '观看人数', 'value' => $right_watch], ['name' => '订单数', 'value' => $right_order]];
$funnel_subscribe = ['title' => '浏览转化漏斗(直播阶段)', 'expected_data' => $right_expected_data, 'actual_data' => $right_actual_data];
$id_in = "uid in(select uid from lc_market_sylive_activity_kpidata where a_id = {$activityId} AND type = 0 AND kpi = 'subscribe')";
$watch_subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'kpi' => 'watch', $id_in => null]);
$order_subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'kpi' => 'order', $id_in => null]);
$subscribe_per = number_format_com($subscribe / $browse * 100, 1, '');
$watch_subscribe_per = number_format_com($watch_subscribe / $subscribe * 100, 1, '');
$order_subscribe_per = number_format_com($order_subscribe / $watch_subscribe * 100, 1, '');
$subscribe_expected_data = [['name' => "浏览人数100%", 'value' => 100], ['name' => "预约人数({$subscribe_per}%)", 'value' => 75]
, ['name' => "观看人数({$watch_subscribe_per}%)", 'value' => 50], ['name' => "订单数({$order_subscribe_per}%)", 'value' => 25]];
$subscribe_actual_data = [['name' => '浏览人数', 'value' => $browse], ['name' => '预约人数', 'value' => $subscribe]
, ['name' => '观看人数', 'value' => $watch_subscribe], ['name' => '订单数', 'value' => $order_subscribe]];
$funnel_subscribe = ['title' => '预约转化漏斗', 'expected_data' => $subscribe_expected_data, 'actual_data' => $subscribe_actual_data];
$data = ['activityId' => $activityId, 'title' => $title, 'activityData1' => $activityData1, 'activityData2' => $activityData2, 'areaData' => $areaData
, 'bizData' => $bizData, 'consultantData' => $consultantData, 'funnelBrowse' => $funnel_browse, 'funnelSubscribe' => $funnel_subscribe];
$this->return_response($data);