market_statistics_1117_2
This commit is contained in:
@@ -214,10 +214,10 @@ class Statistics extends BaseController
|
||||
$subscribe = $this->mdSyliveActivityBiz->sum('subscribe', ['areaId' => $areaId, 'activityId' => $activityId]);
|
||||
$watch = $this->mdSyliveActivityBiz->sum('watch', ['areaId' => $areaId, 'activityId' => $activityId]);
|
||||
if ($itemId) {
|
||||
$order = $this->mdSyliveActivityKpidata->count(['kpi' => 'order', 'areaId' => $areaId, 'type' => $type, 'itemId' => $itemId, 'activityId' => $activityId]);
|
||||
$orderTotal = $this->mdSyliveActivityKpidata->count(['kpi' => 'order', 'areaId' => $areaId, 'type' => $type, 'itemId' => $itemId, 'activityId' => $activityId]);
|
||||
} else {
|
||||
$orderTotal = $this->mdSyliveActivityBiz->sum('orderTotal', ['areaId' => $areaId, 'activityId' => $activityId]);
|
||||
$order = $orderTotal['orderTotal'];
|
||||
$sumOrder = $this->mdSyliveActivityBiz->sum('orderTotal', ['areaId' => $areaId, 'activityId' => $activityId]);
|
||||
$orderTotal = $sumOrder['orderTotal'];
|
||||
}
|
||||
$livePV = $watchDuration = 0;
|
||||
if ($channelId) {
|
||||
@@ -236,7 +236,7 @@ class Statistics extends BaseController
|
||||
}
|
||||
$consultant > $allConsultant && $allConsultant = $consultant;
|
||||
$list[] = ['areaName' => $re_area['organizationName'], 'biz' => count($v['biz']), 'consultant' => $consultant . '/' . $allConsultant
|
||||
, 'browse' => $browse['browse'], 'subscribe' => $subscribe['subscribe'], 'watch' => $watch['watch'], 'order' => $order
|
||||
, 'browse' => $browse['browse'], 'subscribe' => $subscribe['subscribe'], 'watch' => $watch['watch'], 'order' => $orderTotal
|
||||
, 'livePV' => $livePV, 'watchDuration' => $watchDuration];
|
||||
}
|
||||
}
|
||||
@@ -314,12 +314,12 @@ class Statistics extends BaseController
|
||||
$watch = $this->mdSyliveActivityKpidata->count($where_sort);
|
||||
}
|
||||
if ($sort == 'order') {
|
||||
$order = $v['total'];
|
||||
$orderTotal = $v['total'];
|
||||
} else {
|
||||
$where_order['kpi'] = 'order';
|
||||
$where_order['bizId'] = $bizId;
|
||||
$itemId && $where_order['itemId'] = $itemId;
|
||||
$order = $this->mdSyliveActivityKpidata->count($where_order);
|
||||
$orderTotal = $this->mdSyliveActivityKpidata->count($where_order);
|
||||
}
|
||||
$consultant = $this->mdSyliveActivityUser->count(['bizId' => $bizId, 'activityId' => $activityId, 'organizationId>' => 0, 'userId>' => 0]);
|
||||
$consultants = [];
|
||||
@@ -343,14 +343,23 @@ class Statistics extends BaseController
|
||||
}
|
||||
$list[] = [
|
||||
'bizName' => $bizName, 'consultant' => $consultant . '/' . $allConsultant, 'browse' => $browse, 'subscribe' => $subscribe
|
||||
, 'watch' => $watch, 'order' => $order, 'livePV' => $livePV, 'watchDuration' => $watchDuration];
|
||||
, 'watch' => $watch, 'order' => $orderTotal, 'livePV' => $livePV, 'watchDuration' => $watchDuration];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$where = ['activityId' => $activityId, 'status>=' => 0, 'bizId>' => 0];
|
||||
$count = $this->mdSyliveActivityBiz->count($where);
|
||||
if ($sort == 'order' && $itemId) {//有订单排序与商品id,区分订单搜索
|
||||
$where = ['activityId' => $activityId, 'type' => $type, 'itemId' => $itemId, 'bizId>' => 0, 'kpi' => $sort];
|
||||
$count = $this->mdSyliveActivityKpidata->count($where, 'bizId');
|
||||
} else {
|
||||
$where = ['activityId' => $activityId, 'status>=' => 0, 'bizId>' => 0];
|
||||
$count = $this->mdSyliveActivityBiz->count($where);
|
||||
}
|
||||
if ($count) {
|
||||
$res = $this->mdSyliveActivityBiz->select($where, "{$sort_order},id desc", $page, $limit);
|
||||
if ($sort == 'order' && $itemId) {//有订单排序与商品id,区分订单搜索
|
||||
$res = $this->mdSyliveActivityKpidata->select_groupby('bizId', $where, "orderTotal {$order},id desc", $page, $limit, "bizId,count(id) as orderTotal");
|
||||
} else {
|
||||
$res = $this->mdSyliveActivityBiz->select($where, "{$sort_order},id desc", $page, $limit);
|
||||
}
|
||||
foreach ($res as $v) {
|
||||
$bizId = intval($v['bizId']);
|
||||
$re_biz = $this->mdSyliveOrganization->get(['organizationId' => $bizId, 'status>=' => 0]);
|
||||
@@ -375,11 +384,17 @@ class Statistics extends BaseController
|
||||
$watchDuration = round($playDuration / $livePV);
|
||||
}
|
||||
}
|
||||
if ($itemId) {
|
||||
if ($sort != 'order' && $itemId) {//有商品id,区分订单
|
||||
$order = $this->mdSyliveActivityKpidata->count(['kpi' => 'order', 'bizId' => $bizId, 'type' => $type, 'itemId' => $itemId, 'activityId' => $activityId]);
|
||||
} else {
|
||||
$order = $v['orderTotal'];
|
||||
}
|
||||
if ($sort == 'order' && $itemId) {//只改变订单数值,其它不变
|
||||
$re = $this->mdSyliveActivityBiz->get(['bizId' => $bizId, 'activityId' => $activityId, 'status>=' => 0], 'browse,subscribe,watch');
|
||||
$v['browse'] = intval($re['browse']);
|
||||
$v['subscribe'] = intval($re['subscribe']);
|
||||
$v['watch'] = intval($re['watch']);
|
||||
}
|
||||
$list[] = [
|
||||
'bizName' => $bizName, 'consultant' => $consultant . '/' . $allConsultant, 'browse' => $v['browse'], 'subscribe' => $v['subscribe']
|
||||
, 'watch' => $v['watch'], 'order' => $order, 'livePV' => $livePV, 'watchDuration' => $watchDuration];
|
||||
@@ -480,11 +495,20 @@ class Statistics extends BaseController
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$where = ['activityId' => $activityId, 'organizationId>' => 0];
|
||||
$count = $this->mdSyliveActivityUser->count($where, 'userId');
|
||||
if ($sort == 'order' && $itemId) {//有订单排序与商品id,区分订单搜索
|
||||
$where = ['activityId' => $activityId, 'type' => $type, 'itemId' => $itemId, 'cfUserId>' => 0, 'kpi' => $sort];
|
||||
$count = $this->mdSyliveActivityKpidata->count($where, 'cfUserId');
|
||||
} else {
|
||||
$where = ['activityId' => $activityId, 'organizationId>' => 0];
|
||||
$count = $this->mdSyliveActivityUser->count($where, 'userId');
|
||||
}
|
||||
if ($count) {
|
||||
$filed = 'userId,bizId,browse,subscribe,orderTotal,watch';
|
||||
$res = $this->mdSyliveActivityUser->select_groupby('userId', $where, "{$sort_order},id desc", $page, $limit, $filed);
|
||||
if ($sort == 'order' && $itemId) {//有订单排序与商品id,区分订单搜索
|
||||
$res = $this->mdSyliveActivityKpidata->select_groupby('cfUserId', $where, "orderTotal {$order},id desc", $page, $limit, "cfUserId as userId,bizId,count(id) as orderTotal");
|
||||
} else {
|
||||
$res = $this->mdSyliveActivityUser->select_groupby('userId', $where, "{$sort_order},id desc", $page
|
||||
, $limit, 'userId,bizId,browse,subscribe,orderTotal,watch');
|
||||
}
|
||||
foreach ($res as $v) {
|
||||
$userId = intval($v['userId']);
|
||||
$re_org = $this->mdSyliveOrganization->get(['organizationId' => $v['bizId'], 'status>=' => 0]);
|
||||
@@ -501,11 +525,17 @@ class Statistics extends BaseController
|
||||
$watchDuration = round($playDuration / $livePV);
|
||||
}
|
||||
}
|
||||
if ($itemId) {
|
||||
if ($sort != 'order' && $itemId) {//有商品id,区分订单
|
||||
$order = $this->mdSyliveActivityKpidata->count(['kpi' => 'order', 'cfUserId' => $userId, 'type' => $type, 'itemId' => $itemId, 'activityId' => $activityId]);
|
||||
} else {
|
||||
$order = $v['orderTotal'];
|
||||
}
|
||||
if ($sort == 'order' && $itemId) {//只改变订单数值,其它不变
|
||||
$re = $this->mdSyliveActivityUser->get(['userId' => $userId, 'activityId' => $activityId], 'browse,subscribe,watch');
|
||||
$v['browse'] = intval($re['browse']);
|
||||
$v['subscribe'] = intval($re['subscribe']);
|
||||
$v['watch'] = intval($re['watch']);
|
||||
}
|
||||
$list[] = ['consultantName' => $consultantName, 'browse' => $v['browse'], 'subscribe' => $v['subscribe'], 'watch' => $v['watch']
|
||||
, 'order' => $order, 'livePV' => $livePV, 'watchDuration' => $watchDuration];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user