edit-sql_fields_2
This commit is contained in:
@@ -130,7 +130,7 @@ class Activity extends BaseController
|
||||
$teamIds[] = intval($v2['teamId2']);
|
||||
}
|
||||
}
|
||||
$skey = $this->myencryption->base64url_encode("a_id=" . $activityId);
|
||||
$skey = $this->myencryption->base64url_encode("activityId=" . $activityId);
|
||||
$url = http_host_com('home') . "/h5/market/sylive?skey=" . $skey;//活动连接
|
||||
$urlItem = http_host_com('home') . "/h5/market/sylive/act/item?skey=" . $skey;//商品连接
|
||||
$list[] = [
|
||||
@@ -572,7 +572,7 @@ class Activity extends BaseController
|
||||
$status = 1;
|
||||
}
|
||||
$where['status'] = $status;
|
||||
$activityId && $where['item_id'] = $activityId;
|
||||
$activityId && $where['itemId'] = $activityId;
|
||||
$uname && $where['uname LIKE "%' . trim($uname) . '%"'] = null;
|
||||
$mobile && $where['mobile LIKE "%' . trim($mobile) . '%"'] = null;
|
||||
strlen($cfrom) && $where['cfrom'] = $cfrom;
|
||||
@@ -584,10 +584,10 @@ class Activity extends BaseController
|
||||
if ($count) {
|
||||
$res = $this->mdSyliveOrder->select($where, $sort_order, $page, $limit);
|
||||
foreach ($res as $v) {
|
||||
$consultant = $this->consultantGet(['a_id' => $v['item_id'], 'cfrom' => $v['cfrom'], 'uid' => $v['uid']]);
|
||||
$consultant = $this->consultantGet(['activityId' => $v['itemId'], 'cfrom' => $v['cfrom'], 'userId' => $v['userId']]);
|
||||
$list[] = [
|
||||
'id' => $v['id'], 'sid' => $v['sid'], 'uname' => $v['uname'], 'mobile' => $v['mobile'], 'item_title' => $v['item_title']
|
||||
, 'total_price' => $v['total_price'], 'pay_time' => $v['pay_time'] != '0000-00-00 00:00:00' ? $v['pay_time'] : ''
|
||||
'id' => $v['id'], 'sid' => $v['sid'], 'uname' => $v['uname'], 'mobile' => $v['mobile'], 'itemTitle' => $v['itemTitle']
|
||||
, 'totalPrice' => $v['totalPrice'], 'payTime' => $v['payTime'] != '0000-00-00 00:00:00' ? $v['payTime'] : ''
|
||||
, 'statusName' => $this->mdSyliveOrder->statusAry($v['status']), 'cfromName' => $this->mdSyliveOrder->cfromAry($v['cfrom'])
|
||||
, 'createTime' => $v['createTime'], 'area' => $consultant['area'], 'stores' => $consultant['stores'], 'consultant' => $consultant['consultant']
|
||||
];
|
||||
@@ -610,20 +610,20 @@ class Activity extends BaseController
|
||||
private function consultantGet($params)
|
||||
{
|
||||
$area = $stores = $consultant = '';
|
||||
$re = $this->mdSyliveActivityKpidata->get(['a_id' => $params['a_id'], 'uid' => $params['uid'], 'type' => $params['cfrom'], 'kpi' => 'order']);
|
||||
if ($re['cf_uid']) {
|
||||
$re = $this->mdSyliveActivityKpidata->get(['activityId' => $params['activityId'], 'userId' => $params['userId'], 'type' => $params['cfrom'], 'kpi' => 'order']);
|
||||
if ($re['cfUserId']) {
|
||||
if ($params['cfrom'] == 1) {
|
||||
$res_teama = $this->mdSyliveTeam->get(["teamId" => $re['area_id']]);
|
||||
$res_teamb = $this->mdSyliveTeam->get(["teamId" => $re['biz_id']]);
|
||||
$res_teama = $this->mdSyliveTeam->get(["teamId" => $re['areaId']]);
|
||||
$res_teamb = $this->mdSyliveTeam->get(["teamId" => $re['bizId']]);
|
||||
$res_teama['teamName'] && $area = $res_teama['teamName'];
|
||||
$res_teamb['teamName'] && $stores = $res_teamb['teamName'];
|
||||
} else {
|
||||
$res_orga = $this->mdSyliveOrganization->get(["organizationId" => $re['area_id']]);
|
||||
$res_orgb = $this->mdSyliveOrganization->get(["organizationId" => $re['biz_id']]);
|
||||
$res_orga = $this->mdSyliveOrganization->get(["organizationId" => $re['areaId']]);
|
||||
$res_orgb = $this->mdSyliveOrganization->get(["organizationId" => $re['bizId']]);
|
||||
$res_orga['organizationName'] && $area = $res_orga['organizationName'];
|
||||
$res_orgb['organizationName'] && $stores = $res_orgb['organizationName'];
|
||||
}
|
||||
$re_user = $this->mdSyliveUser->get(['userId' => $re['cf_uid']]);
|
||||
$re_user = $this->mdSyliveUser->get(['userId' => $re['cfUserId']]);
|
||||
$re_user['uname'] && $consultant = $re_user['uname'];
|
||||
}
|
||||
return ['area' => $area, 'stores' => $stores, 'consultant' => $consultant];
|
||||
|
||||
@@ -26,7 +26,7 @@ class Order extends BaseController
|
||||
{
|
||||
$page = $this->input_param('page');
|
||||
$limit = $this->input_param('limit');
|
||||
$item_title = $this->input_param('item_title');
|
||||
$itemTitle = $this->input_param('itemTitle');
|
||||
$mobile = $this->input_param('mobile');
|
||||
$name = $this->input_param('name');
|
||||
$status = $this->input_param('status');
|
||||
@@ -48,7 +48,7 @@ class Order extends BaseController
|
||||
$status = 1;
|
||||
}
|
||||
$where['status'] = $status;
|
||||
$item_title && $where['item_title'] = $item_title;
|
||||
$itemTitle && $where['itemTitle'] = $itemTitle;
|
||||
$sid && $where['sid'] = $sid;
|
||||
$str_user_ids = 0;
|
||||
if ($name || $mobile) {
|
||||
@@ -68,7 +68,7 @@ class Order extends BaseController
|
||||
$name = $map_users[$v['uid']]['uname'] ? $map_users[$v['uid']]['uname'] : $map_users[$v['uid']]['nickname'];
|
||||
$mobile = $map_users[$v['uid']]['mobile'];
|
||||
$list[] = [
|
||||
'id' => $v['id'], 'sid' => $v['sid'],'name' => $name, 'mobile' => $mobile, 'item_title' => $v['item_title']
|
||||
'id' => $v['id'], 'sid' => $v['sid'],'name' => $name, 'mobile' => $mobile, 'itemTitle' => $v['itemTitle']
|
||||
, 'total_price' => $v['total_price'], 'pay_time' => $v['pay_time'] != '0000-00-00 00:00:00' ? $v['pay_time'] : ''
|
||||
, 'statusName' => $this->mdSyliveOrder->statusAry($v['status']), 'createTime' => $v['createTime']];
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ class Statistics extends BaseController
|
||||
$bizId = intval($v['bizId']);
|
||||
$re_biz = $this->mdSyliveOrganization->get(['organizationId' => $bizId]);
|
||||
if ($re_biz) {
|
||||
$consultant = $this->mdSyliveActivityKpidata->count(['biz_id' => $bizId, 'type' => 0, 'a_id' => $activityId], 'distinct(cf_uid)');
|
||||
$consultant = $this->mdSyliveActivityKpidata->count(['bizId' => $bizId, 'type' => 0, 'activityId' => $activityId], 'distinct(cfUserId)');
|
||||
$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.uid", 'left')
|
||||
->where(['a.biz_id' => $bizId, 'a.type' => 0, 'a.a_id' => $activityId, 'a.kpi' => 'watch', "unionid!=''" => null])
|
||||
->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) {
|
||||
@@ -101,7 +101,7 @@ class Statistics extends BaseController
|
||||
$areaId = intval($k);
|
||||
$re_area = $this->mdSyliveOrganization->get(['organizationId' => $areaId]);
|
||||
if ($re_area) {
|
||||
$consultant = $this->mdSyliveActivityKpidata->count(['area_id' => $areaId, 'type' => 0, 'a_id' => $activityId], 'distinct(cf_uid)');
|
||||
$consultant = $this->mdSyliveActivityKpidata->count(['areaId' => $areaId, 'type' => 0, 'activityId' => $activityId], 'distinct(cfUserId)');
|
||||
$browse = $this->mdSyliveActivityBiz->sum('browse', ['areaId' => $areaId, 'status>=' => 0, 'activityId' => $activityId]);
|
||||
$subscribe = $this->mdSyliveActivityBiz->sum('subscribe', ['areaId' => $areaId, 'status>=' => 0, 'activityId' => $activityId]);
|
||||
$watch = $this->mdSyliveActivityBiz->sum('watch', ['areaId' => $areaId, 'status>=' => 0, 'activityId' => $activityId]);
|
||||
@@ -110,8 +110,8 @@ class Statistics extends BaseController
|
||||
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.uid", 'left')
|
||||
->where(['a.area_id' => $areaId, 'a.type' => 0, 'a.a_id' => $activityId, 'a.kpi' => 'watch', "unionid!=''" => null])
|
||||
->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) {
|
||||
@@ -138,29 +138,25 @@ class Statistics extends BaseController
|
||||
, 'livePV' => $livePV, 'watchDuration' => $watchDuration];
|
||||
}
|
||||
}
|
||||
$res_user = $this->mdSyliveActivityKpidata->select(['a_id' => $activityId, 'type' => 0, 'cf_uid>' => 0], 'id desc', 0, 0, 'distinct(cf_uid) as userId,biz_id');
|
||||
$userIds = [];
|
||||
$res_user = $this->mdSyliveActivityKpidata->select_groupby('cfUserId', ['activityId' => $activityId, 'type' => 0, 'cfUserId>' => 0], 'id desc', 0, 0, 'cfUserId,bizId');
|
||||
foreach ($res_user as $k => $v) {
|
||||
$userId = intval($v['userId']);
|
||||
if (in_array($userId, $userIds)) {
|
||||
continue;
|
||||
}
|
||||
$re_user = $this->mdSyliveUser->get(['userId' => $userId, 'status>=' => 0]);
|
||||
$cfUserId = intval($v['cfUserId']);
|
||||
$re_user = $this->mdSyliveUser->get(['userId' => $cfUserId, 'status>=' => 0]);
|
||||
if ($re_user) {
|
||||
$userIds[] = $userId;
|
||||
$cfUserIds[] = $cfUserId;
|
||||
$consultantName = $re_user['uname'] ? $re_user['uname'] : $re_user['nickname'];
|
||||
$re_org = $this->mdSyliveOrganization->get(['organizationId' => $v['biz_id'], 'status>=' => 0]);
|
||||
$re_org = $this->mdSyliveOrganization->get(['organizationId' => $v['bizId'], 'status>=' => 0]);
|
||||
$re_org && $consultantName .= "({$re_org['organizationName']})";
|
||||
$browse = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'cf_uid' => $userId, 'kpi' => 'browse']);
|
||||
$subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'cf_uid' => $userId, 'kpi' => 'subscribe']);
|
||||
$watch = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'cf_uid' => $userId, 'kpi' => 'watch']);
|
||||
$order = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'cf_uid' => $userId, 'kpi' => 'order']);
|
||||
$browse = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'cfUserId' => $cfUserId, 'kpi' => 'browse']);
|
||||
$subscribe = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'cfUserId' => $cfUserId, 'kpi' => 'subscribe']);
|
||||
$watch = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'cfUserId' => $cfUserId, 'kpi' => 'watch']);
|
||||
$order = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'cfUserId' => $cfUserId, 'kpi' => 'order']);
|
||||
$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.uid", 'left')
|
||||
->where(['a.cf_uid' => $userId, 'a.a_id' => $activityId, 'a.type' => 0, 'a.kpi' => 'watch', "unionid!=''" => null])
|
||||
->join('lc_market_sylive_user as b', "b.userId=a.userId", 'left')
|
||||
->where(['a.cfUserId' => $cfUserId, 'a.activityId' => $activityId, 'a.type' => 0, 'a.kpi' => 'watch', "unionid!=''" => null])
|
||||
->limit(10000, 0)
|
||||
->get()->result_array();
|
||||
if ($res_watch) {
|
||||
@@ -179,10 +175,10 @@ class Statistics extends BaseController
|
||||
, 'order' => $order, 'livePV' => $livePV, 'watchDuration' => $watchDuration];
|
||||
}
|
||||
}
|
||||
$browse = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'kpi' => 'browse']);
|
||||
$subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'kpi' => 'subscribe']);
|
||||
$watch = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'kpi' => 'watch']);
|
||||
$order = $this->mdSyliveOrder->count(['item_id' => $activityId, 'cfrom' => 0, 'status' => 1]);
|
||||
$browse = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'kpi' => 'browse']);
|
||||
$subscribe = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'kpi' => 'subscribe']);
|
||||
$watch = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'kpi' => 'watch']);
|
||||
$order = $this->mdSyliveOrder->count(['itemId' => $activityId, 'cfrom' => 0, 'status' => 1]);
|
||||
$duration_min = $livePV = $liveUV = $watchDuration = $watchDuration = $pvDuration = 0;
|
||||
if ($channelId) {
|
||||
$re_duration = $this->mdPolyvSession->sum('duration', ['channelId' => $channelId]);
|
||||
@@ -220,11 +216,11 @@ class Statistics extends BaseController
|
||||
// , ['name' => '人均观看(分)', 'value' => $watchDuration, 'url' => ''], ['name' => '人均观看(次)', 'value' => $pvDuration, 'url' => '']];
|
||||
}
|
||||
$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_browse_where = "userId in(select userId from lc_market_sylive_activity_kpidata where activityId = {$activityId} AND type = 0 AND kpi = 'browse' AND createTime < {$timeStart})";
|
||||
$left_browse = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'kpi' => 'browse', 'createTime<' => $timeStart]);
|
||||
$left_subscribe = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'kpi' => 'subscribe']);
|
||||
$left_watch = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'kpi' => 'watch', $left_browse_where => null]);
|
||||
$left_order = $this->mdSyliveActivityKpidata->count(['activityId' => $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, '');
|
||||
@@ -234,10 +230,10 @@ class Statistics extends BaseController
|
||||
, ['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_browse_where = "userId in(select userId from lc_market_sylive_activity_kpidata where activityId = {$activityId} AND type = 0 AND kpi = 'browse' AND createTime >= {$timeStart})";
|
||||
$right_browse = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'kpi' => 'browse', 'createTime>=' => $timeStart]);
|
||||
$right_watch = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'kpi' => 'watch', $right_browse_where => null]);
|
||||
$right_order = $this->mdSyliveActivityKpidata->count(['activityId' => $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]];
|
||||
@@ -285,7 +281,7 @@ class Statistics extends BaseController
|
||||
$bizId = intval($v['bizId']);
|
||||
$re_biz = $this->mdSyliveOrganization->get(['organizationId' => $bizId, 'status>=' => 0]);
|
||||
$bizName = $re_biz ? $re_biz['organizationName'] : '-';
|
||||
$consultant = $this->mdSyliveActivityKpidata->count(['biz_id' => $bizId, 'type' => 0, 'a_id' => $activityId], 'distinct(cf_uid)');
|
||||
$consultant = $this->mdSyliveActivityKpidata->count(['bizId' => $bizId, 'type' => 0, 'activityId' => $activityId], 'distinct(cfUserId)');
|
||||
if ($bizId) {//统计顾问数
|
||||
$consultants = [];
|
||||
$consultants[] = $bizId;
|
||||
@@ -301,8 +297,8 @@ class Statistics extends BaseController
|
||||
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.uid", 'left')
|
||||
->where(['a.biz_id' => $bizId, 'a.type' => 0, 'a.a_id' => $activityId, 'a.kpi' => 'watch', "unionid!=''" => null])
|
||||
->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) {
|
||||
@@ -350,26 +346,26 @@ class Statistics extends BaseController
|
||||
if ($sort && $order) {
|
||||
$sort_order = $sort . ' ' . $order;
|
||||
}
|
||||
$where = ['a_id' => $activityId, 'type' => 0, 'cf_uid>' => 0];
|
||||
$count = $this->mdSyliveActivityKpidata->count($where, 'distinct(cf_uid)');
|
||||
$where = ['activityId' => $activityId, 'type' => 0, 'cfUserId>' => 0];
|
||||
$count = $this->mdSyliveActivityKpidata->count($where, 'cfUserId');
|
||||
if ($count) {
|
||||
$res = $this->mdSyliveActivityKpidata->select($where, $sort_order, $page, $limit, 'distinct(cf_uid) as userId,biz_id');
|
||||
$res = $this->mdSyliveActivityKpidata->select_groupby('cfUserId', $where, $sort_order, $page, $limit, 'cfUserId,bizId');
|
||||
foreach ($res as $v) {
|
||||
$userId = intval($v['userId']);
|
||||
$re_user = $this->mdSyliveUser->get(['userId' => $userId, 'status>=' => 0]);
|
||||
$cfUserId = intval($v['cfUserId']);
|
||||
$re_user = $this->mdSyliveUser->get(['userId' => $cfUserId, 'status>=' => 0]);
|
||||
$consultantName = $re_user['uname'] ? $re_user['uname'] : $re_user['nickname'];
|
||||
$re_org = $this->mdSyliveOrganization->get(['organizationId' => $v['biz_id'], 'status>=' => 0]);
|
||||
$re_org = $this->mdSyliveOrganization->get(['organizationId' => $v['bizId'], 'status>=' => 0]);
|
||||
$re_org && $consultantName .= "({$re_org['organizationName']})";
|
||||
$browse = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'cf_uid' => $userId, 'kpi' => 'browse']);
|
||||
$subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'cf_uid' => $userId, 'kpi' => 'subscribe']);
|
||||
$watch = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'cf_uid' => $userId, 'kpi' => 'watch']);
|
||||
$order = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 0, 'cf_uid' => $userId, 'kpi' => 'order']);
|
||||
$browse = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'cfUserId' => $cfUserId, 'kpi' => 'browse']);
|
||||
$subscribe = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'cfUserId' => $cfUserId, 'kpi' => 'subscribe']);
|
||||
$watch = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'cfUserId' => $cfUserId, 'kpi' => 'watch']);
|
||||
$order = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 0, 'cfUserId' => $cfUserId, 'kpi' => 'order']);
|
||||
$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.uid", 'left')
|
||||
->where(['a.cf_uid' => $userId, 'a.a_id' => $activityId, 'a.type' => 0, 'a.kpi' => 'watch', "unionid!=''" => null])
|
||||
->join('lc_market_sylive_user as b', "b.userId=a.userId", 'left')
|
||||
->where(['a.cfUserId' => $cfUserId, 'a.activityId' => $activityId, 'a.type' => 0, 'a.kpi' => 'watch', "unionid!=''" => null])
|
||||
->limit(10000, 0)
|
||||
->get()->result_array();
|
||||
if ($res_watch) {
|
||||
@@ -416,17 +412,17 @@ class Statistics extends BaseController
|
||||
$channelId = $re['channelId'];
|
||||
$res_biz = $this->mdSyliveActivityTeam->select(['activityId' => $activityId, 'status' => 0], 'browse desc');
|
||||
foreach ($res_biz as $k => $v) {
|
||||
$area_id = intval($v['teamId1']);
|
||||
$biz_id = intval($v['teamId2']);
|
||||
$re_team = $this->mdSyliveTeam->get(['teamId' => $biz_id]);
|
||||
$areaId = intval($v['teamId1']);
|
||||
$bizId = intval($v['teamId2']);
|
||||
$re_team = $this->mdSyliveTeam->get(['teamId' => $bizId]);
|
||||
if ($re_team) {
|
||||
$consultant = $this->mdSyliveActivityKpidata->count(['biz_id' => $biz_id, 'type' => 1, 'a_id' => $activityId], 'distinct(cf_uid)');
|
||||
$consultant = $this->mdSyliveActivityKpidata->count(['bizId' => $bizId, 'type' => 1, 'activityId' => $activityId], 'distinct(cfUserId)');
|
||||
$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.uid", 'left')
|
||||
->where(['a.biz_id' => $biz_id, 'a.type' => 1, 'a.a_id' => $activityId, 'a.kpi' => 'watch', "unionid!=''" => null])
|
||||
->join('lc_market_sylive_user as b', "b.userId=a.userId", 'left')
|
||||
->where(['a.bizId' => $bizId, 'a.type' => 1, 'a.activityId' => $activityId, 'a.kpi' => 'watch', "unionid!=''" => null])
|
||||
->limit(10000, 0)
|
||||
->get()->result_array();
|
||||
if ($res_watch) {
|
||||
@@ -443,16 +439,16 @@ class Statistics extends BaseController
|
||||
}
|
||||
//统计顾问
|
||||
$allConsultant = 0;
|
||||
if ($area_id) {
|
||||
if (!in_array($area_id, $allTeamIds)) {
|
||||
$allTeamIds[] = $area_id;
|
||||
if ($areaId) {
|
||||
if (!in_array($areaId, $allTeamIds)) {
|
||||
$allTeamIds[] = $areaId;
|
||||
}
|
||||
}
|
||||
if ($biz_id) {
|
||||
$allTeamIds[] = $biz_id;
|
||||
if ($bizId) {
|
||||
$allTeamIds[] = $bizId;
|
||||
$consultants = [];
|
||||
$consultants[] = $biz_id;
|
||||
$res_org = $this->mdSyliveTeam->select(['parentId' => $biz_id, 'status>=' => 0], 'teamId desc', 0, 0, 'teamId');
|
||||
$consultants[] = $bizId;
|
||||
$res_org = $this->mdSyliveTeam->select(['parentId' => $bizId, 'status>=' => 0], 'teamId desc', 0, 0, 'teamId');
|
||||
foreach ($res_org as $k2 => $v2) {
|
||||
$allTeamIds[] = $v2['teamId'];
|
||||
$consultants[] = $v2['teamId'];
|
||||
@@ -461,29 +457,29 @@ class Statistics extends BaseController
|
||||
$allConsultant = $this->mdSyliveUser->count(["teamId in({$str_teamId})" => null, 'status>=' => 0, 'teamId>' => 0]);
|
||||
}
|
||||
$consultant > $allConsultant && $allConsultant = $consultant;
|
||||
$teamData[] = ['area_id' => $area_id, 'biz_id' => $biz_id,
|
||||
$teamData[] = ['areaId' => $areaId, 'bizId' => $bizId,
|
||||
'teamName' => $re_team['teamName'], 'consultant' => $consultant . '/' . $allConsultant, 'browse' => $v['browse'], 'subscribe' => $v['subscribe']
|
||||
, 'watch' => $v['watch'], 'order' => $v['orderTotal'], 'livePV' => $livePV, 'watchDuration' => $watchDuration];
|
||||
}
|
||||
}
|
||||
$res_user = $this->mdSyliveActivityKpidata->select(['a_id' => $activityId, 'type' => 1], 'id desc', 0, 0, 'distinct(cf_uid) as userId,biz_id');
|
||||
$res_user = $this->mdSyliveActivityKpidata->select_groupby('cfUserId', ['activityId' => $activityId, 'type' => 1], 'id desc', 0, 0, 'cfUserId,bizId');
|
||||
foreach ($res_user as $k => $v) {
|
||||
$userId = intval($v['userId']);
|
||||
$re_user = $this->mdSyliveUser->get(['userId' => $userId]);
|
||||
$cfUserId = intval($v['cfUserId']);
|
||||
$re_user = $this->mdSyliveUser->get(['userId' => $cfUserId]);
|
||||
if ($re_user) {
|
||||
$consultantName = $re_user['uname'] ? $re_user['uname'] : $re_user['nickname'];
|
||||
$re_team = $this->mdSyliveTeam->get(['teamId' => $v['biz_id']]);
|
||||
$re_team = $this->mdSyliveTeam->get(['teamId' => $v['bizId']]);
|
||||
$re_team && $consultantName .= "({$re_team['teamName']})";
|
||||
$browse = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 1, 'cf_uid' => $userId, 'kpi' => 'browse']);
|
||||
$subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 1, 'cf_uid' => $userId, 'kpi' => 'subscribe']);
|
||||
$watch = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 1, 'cf_uid' => $userId, 'kpi' => 'watch']);
|
||||
$order = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 1, 'cf_uid' => $userId, 'kpi' => 'order']);
|
||||
$browse = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 1, 'cfUserId' => $cfUserId, 'kpi' => 'browse']);
|
||||
$subscribe = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 1, 'cfUserId' => $cfUserId, 'kpi' => 'subscribe']);
|
||||
$watch = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 1, 'cfUserId' => $cfUserId, 'kpi' => 'watch']);
|
||||
$order = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 1, 'cfUserId' => $cfUserId, 'kpi' => 'order']);
|
||||
$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.uid", 'left')
|
||||
->where(['a.cf_uid' => $userId, 'a.a_id' => $activityId, 'a.type' => 1, 'a.kpi' => 'watch', "unionid!=''" => null])
|
||||
->join('lc_market_sylive_user as b', "b.userId=a.userId", 'left')
|
||||
->where(['a.cfUserId' => $cfUserId, 'a.activityId' => $activityId, 'a.type' => 1, 'a.kpi' => 'watch', "unionid!=''" => null])
|
||||
->limit(10000, 0)
|
||||
->get()->result_array();
|
||||
if ($res_watch) {
|
||||
@@ -502,10 +498,10 @@ class Statistics extends BaseController
|
||||
, 'order' => $order, 'livePV' => $livePV, 'watchDuration' => $watchDuration];
|
||||
}
|
||||
}
|
||||
$browse = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 1, 'kpi' => 'browse']);
|
||||
$subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 1, 'kpi' => 'subscribe']);
|
||||
$watch = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 1, 'kpi' => 'watch']);
|
||||
$order = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 1, 'kpi' => 'order']);
|
||||
$browse = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 1, 'kpi' => 'browse']);
|
||||
$subscribe = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 1, 'kpi' => 'subscribe']);
|
||||
$watch = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 1, 'kpi' => 'watch']);
|
||||
$order = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 1, 'kpi' => 'order']);
|
||||
$duration = $livePV = $watchDuration = $watchDuration = $pvDuration = 0;
|
||||
if ($channelId) {
|
||||
$re_duration = $this->mdPolyvSession->sum('duration', ['channelId' => $channelId]);
|
||||
@@ -542,9 +538,9 @@ class Statistics extends BaseController
|
||||
$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];
|
||||
$id_in = "uid in(select uid from lc_market_sylive_activity_kpidata where a_id = {$activityId} AND type=1 AND kpi = 'subscribe')";
|
||||
$watch_subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 1, 'kpi' => 'watch', $id_in => null]);
|
||||
$order_subscribe = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'type' => 1, 'kpi' => 'order', $id_in => null]);
|
||||
$id_in = "userId in(select userId from lc_market_sylive_activity_kpidata where activityId = {$activityId} AND type=1 AND kpi = 'subscribe')";
|
||||
$watch_subscribe = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 1, 'kpi' => 'watch', $id_in => null]);
|
||||
$order_subscribe = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'type' => 1, '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, '');
|
||||
@@ -583,7 +579,7 @@ class Statistics extends BaseController
|
||||
, 'url' => "/sylive/activity/statistics/barchart?activityId={$activityId}&areaId={$areaId}&kpi={$kpi}&type={$type}"];
|
||||
}
|
||||
} else {
|
||||
$res = $this->mdSyliveActivityBiz->select(['activityId' => $activityId, 'status>=' => 0], 'browse desc', 0, 0, 'distinct(areaId) as areaId');
|
||||
$res = $this->mdSyliveActivityBiz->select(['activityId' => $activityId, 'status>=' => 0], 'browse desc', 0, 0, 'distinct(areaId)');
|
||||
foreach ($res as $k => $v) {
|
||||
$areaId = intval($v['areaId']);
|
||||
$re = $this->mdSyliveOrganization->get(['organizationId' => $areaId]);
|
||||
@@ -662,14 +658,14 @@ class Statistics extends BaseController
|
||||
$this->return_json('参数错误');
|
||||
}
|
||||
$data = $dataTitle = $dataValue = [];
|
||||
$res_user = $this->mdSyliveActivityKpidata->select(['a_id' => $activityId, 'biz_id' => $bizId, 'type' => $type]
|
||||
, 'id desc', 0, 0, 'distinct(cf_uid) as userId');
|
||||
$res_user = $this->mdSyliveActivityKpidata->select(['activityId' => $activityId, 'bizId' => $bizId, 'type' => $type]
|
||||
, 'id desc', 0, 0, 'distinct(cfUserId)');
|
||||
foreach ($res_user as $k => $v) {
|
||||
$userId = intval($v['userId']);
|
||||
$re_user = $this->mdSyliveUser->get(['userId' => $userId]);
|
||||
$cfUserId = intval($v['cfUserId']);
|
||||
$re_user = $this->mdSyliveUser->get(['userId' => $cfUserId]);
|
||||
if ($re_user) {
|
||||
$name = $re_user['uname'] ? $re_user['uname'] : $re_user['nickname'];
|
||||
$value = $this->mdSyliveActivityKpidata->count(['a_id' => $activityId, 'cf_uid' => $userId, 'type' => $type, 'kpi' => $kpi]);
|
||||
$value = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'cfUserId' => $cfUserId, 'type' => $type, 'kpi' => $kpi]);
|
||||
$data[] = ['name' => $name ? $name : '-', 'value' => $value];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user