diff --git a/common/libraries/market/Sylive2_entity.php b/common/libraries/market/Sylive2_entity.php index 663f295e..87695af4 100644 --- a/common/libraries/market/Sylive2_entity.php +++ b/common/libraries/market/Sylive2_entity.php @@ -1,22 +1,25 @@ 'browse', 'subscribe' => 'subscribe', 'order' => 'orderTotal','watch' => 'watch','beforeOrder' => 'beforeOrderTotal' + 'browse' => 'browse', 'subscribe' => 'subscribe', 'order' => 'orderTotal', 'watch' => 'watch', 'beforeOrder' => 'beforeOrderTotal' ]; - public function __construct(){ + public function __construct() + { $this->ci = &get_instance(); $this->ci->load->model('market/market_sylive_user_model', 'user_model'); $this->ci->load->model('market/market_sylive_activity_user_model', 'act_user_model'); $this->ci->load->model('market/market_sylive_groups_model', 'groups_model'); $this->ci->load->model('market/market_sylive_groups_user_model', 'groups_user_model'); $this->ci->load->model('market/market_sys_dictionary_data_model'); - $this->ci->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData'); + $this->ci->load->model('market/market_sylive_activity_kpidata_model', 'mdSytActivityKpiData'); } /** @@ -25,15 +28,16 @@ class Sylive2_entity{ * @param $data * @return int */ - public function get_group_lists($groupsId,$a_id,$data=[]){ - $row = $this->ci->groups_model->get(['groupsId'=>$groupsId,'activityId'=>$a_id],'groupsId,parentId,groupsName'); - if(!$row){ + public function get_group_lists($groupsId, $a_id, $data = []) + { + $row = $this->ci->groups_model->get(['groupsId' => $groupsId, 'activityId' => $a_id], 'groupsId,parentId,groupsName'); + if (!$row) { return $data; - }else{ - array_unshift($data,$row); - if($row['parentId']){ - return $this->get_group_lists($row['parentId'],$a_id,$data); - }else{ + } else { + array_unshift($data, $row); + if ($row['parentId']) { + return $this->get_group_lists($row['parentId'], $a_id, $data); + } else { return $data; } } @@ -46,19 +50,32 @@ class Sylive2_entity{ */ public function kpi_log($params) { + $mkKpiData = new Market_sylive_activity_kpidata_model(); if ($params['a_id'] && $params['uid'] && $params['cf_uid']) { - $user = $this->user_model->get(['userId'=>$params['uid']]); - $act_user = $this->act_user_model->get(['activityId'=>$params['a_id'],'userId'=>$params['cf_uid']]); - if(!$user || !$act_user){ - debug_log("[info]# " .'uid:'.$params['uid'].' cf_uid:'.$params['cf_uid'].'顾问不存在', 'market/sylive','kpi.log'); + $user = $this->user_model->get(['userId' => $params['uid']]); + $act_user = $this->act_user_model->get(['activityId' => $params['a_id'], 'userId' => $params['cf_uid']]); + if (!$user || !$act_user) { + debug_log("[info]# " . 'uid:' . $params['uid'] . ' cf_uid:' . $params['cf_uid'] . '顾问不存在', 'market/sylive', 'kpi.log'); return array('code' => 0, 'msg' => '顾问不存在'); } - if(!in_array($params['kpi'],['order']) || $params["itemId"]==19){ //订单可添加多条kpi 商品id=19也只能加一次 + if (!in_array($params['kpi'], ['order', $mkKpiData::KYP_SHARE]) || $params["itemId"] == 19) { //订单可添加多条kpi 商品id=19也只能加一次 $re_kpi = $this->ci->mdSytActivityKpiData->get(array("activityId" => $params['a_id'], 'userId' => $params['uid'], 'kpi' => $params['kpi'])); if ($re_kpi) {//已添加过活动kpi(访活动只记录一次用户kpi记录) return array('code' => 0, 'msg' => '已添加过' . $params['kpi'] . '记录'); } } + if ($params['kpi'] == $mkKpiData::KYP_SHARE) { + $where = [ + "activityId" => $params['a_id'], + 'userId' => $params['uid'], + 'kpi' => $params['kpi'], + 'cfShare' => $params['cfShare'] + ]; + $re_kpi = $this->ci->mdSytActivityKpiData->get($where); + if ($re_kpi) { + return ['code' => 0, 'msg' => '已添加过' . $params['kpi'] . '记录']; + } + } //增加记录 $addData = [ 'activityId' => $params['a_id'], @@ -68,10 +85,10 @@ class Sylive2_entity{ 'createTime' => time(), 'day' => date('Y-m-d') ]; - if($params['c_time']){ //指定创建时间 - $addData['updateTime'] = date('Y-m-d H:i:s',$params['c_time']); + if ($params['c_time']) { //指定创建时间 + $addData['updateTime'] = date('Y-m-d H:i:s', $params['c_time']); $addData['createTime'] = $params['c_time']; - $addData['day'] = date('Y-m-d',$params['c_time']); + $addData['day'] = date('Y-m-d', $params['c_time']); } $act_user['bizId'] && $addData['bizId'] = $act_user['bizId']; $act_user['levelId1'] && $addData['levelId1'] = $act_user['levelId1']; @@ -81,11 +98,12 @@ class Sylive2_entity{ $params['itemId'] && $addData['itemId'] = $params['itemId']; $jsondata = $params['jsondata'] ? $params['jsondata'] : []; $jsondata && $addData['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE); + $params['cfShare'] && $addData['cfShare'] = $params['cfShare']; $id = $this->ci->mdSytActivityKpiData->add($addData); if (!$id) { return array('code' => 0, 'msg' => '添加记录失败'); } - $this->kpi_count($params['a_id'],$params['kpi'],$params['cf_uid']); + $this->kpi_count($params['a_id'], $params['kpi'], $params['cf_uid']); return array('code' => 1, 'msg' => '添加记录成功'); } else { return array('code' => 0, 'msg' => '参数错误'); @@ -99,51 +117,52 @@ class Sylive2_entity{ * @param $cf_uid * @return array */ - public function kpi_count($a_id,$kpi,$cf_uid){ - if($this->map_kpi_biz[$kpi] && $cf_uid && $a_id){ + public function kpi_count($a_id, $kpi, $cf_uid) + { + if ($this->map_kpi_biz[$kpi] && $cf_uid && $a_id) { $up_key = $this->map_kpi_biz[$kpi]; - $total = $this->ci->mdSytActivityKpiData->count(['activityId'=>$a_id,'cfUserId'=>$cf_uid,'kpi'=>$kpi]); + $total = $this->ci->mdSytActivityKpiData->count(['activityId' => $a_id, 'cfUserId' => $cf_uid, 'kpi' => $kpi]); $update = [ $up_key => $total ]; //更新活动用户表统计数据 - $this->ci->act_user_model->update($update,['activityId'=>$a_id,'userId'=>$cf_uid]); + $this->ci->act_user_model->update($update, ['activityId' => $a_id, 'userId' => $cf_uid]); //更新分组用户统计 - $this->ci->groups_user_model->update($update,['activityId'=>$a_id,'userId'=>$cf_uid]); + $this->ci->groups_user_model->update($update, ['activityId' => $a_id, 'userId' => $cf_uid]); //更新分组统计 - $group_user = $this->groups_user_model->get(['activityId'=>$a_id,'userId'=>$cf_uid]); - if($group_user['levelId1']){ - $total = $this->ci->mdSytActivityKpiData->count(['activityId'=>$a_id,'levelId1'=>$group_user['levelId1'],'kpi'=>$kpi]); + $group_user = $this->groups_user_model->get(['activityId' => $a_id, 'userId' => $cf_uid]); + if ($group_user['levelId1']) { + $total = $this->ci->mdSytActivityKpiData->count(['activityId' => $a_id, 'levelId1' => $group_user['levelId1'], 'kpi' => $kpi]); $update = [ $up_key => $total ]; - $this->ci->groups_model->update($update,['activityId'=>$a_id,'groupsId'=>$group_user['levelId1']]); + $this->ci->groups_model->update($update, ['activityId' => $a_id, 'groupsId' => $group_user['levelId1']]); } - if($group_user['levelId2']){ - $total = $this->ci->mdSytActivityKpiData->count(['activityId'=>$a_id,'levelId2'=>$group_user['levelId2'],'kpi'=>$kpi]); + if ($group_user['levelId2']) { + $total = $this->ci->mdSytActivityKpiData->count(['activityId' => $a_id, 'levelId2' => $group_user['levelId2'], 'kpi' => $kpi]); $update = [ $up_key => $total ]; - $this->ci->groups_model->update($update,['activityId'=>$a_id,'groupsId'=>$group_user['levelId2']]); + $this->ci->groups_model->update($update, ['activityId' => $a_id, 'groupsId' => $group_user['levelId2']]); } - if($group_user['levelId3']){ - $total = $this->ci->mdSytActivityKpiData->count(['activityId'=>$a_id,'levelId3'=>$group_user['levelId3'],'kpi'=>$kpi]); + if ($group_user['levelId3']) { + $total = $this->ci->mdSytActivityKpiData->count(['activityId' => $a_id, 'levelId3' => $group_user['levelId3'], 'kpi' => $kpi]); $update = [ $up_key => $total ]; - $this->ci->groups_model->update($update,['activityId'=>$a_id,'groupsId'=>$group_user['levelId3']]); + $this->ci->groups_model->update($update, ['activityId' => $a_id, 'groupsId' => $group_user['levelId3']]); } //更新门店 - if($group_user['bizId']){ - $total = $this->ci->mdSytActivityKpiData->count(['activityId'=>$a_id,'bizId'=>$group_user['bizId'],'kpi'=>$kpi]); + if ($group_user['bizId']) { + $total = $this->ci->mdSytActivityKpiData->count(['activityId' => $a_id, 'bizId' => $group_user['bizId'], 'kpi' => $kpi]); $update = [ $up_key => $total ]; - $this->ci->groups_model->update($update,['activityId'=>$a_id,'groupsId'=>$group_user['bizId']]); + $this->ci->groups_model->update($update, ['activityId' => $a_id, 'groupsId' => $group_user['bizId']]); } - return ['code'=>1,'msg'=>'更新成功']; - }else{ - return ['code'=>0,'msg'=>'参数错误']; + return ['code' => 1, 'msg' => '更新成功']; + } else { + return ['code' => 0, 'msg' => '参数错误']; } } @@ -152,13 +171,14 @@ class Sylive2_entity{ * @param $a_id * @return array */ - public function level_disk($a_id,$groupsLevel=0){ - $top_group = $this->ci->groups_model->get(['activityId'=>$a_id,'parentId'=>0],'statisticsType'); + public function level_disk($a_id, $groupsLevel = 0) + { + $top_group = $this->ci->groups_model->get(['activityId' => $a_id, 'parentId' => 0], 'statisticsType'); $disk = []; - if($top_group['statisticsType']){ - $where = ['dictId'=>$top_group['statisticsType']]; + if ($top_group['statisticsType']) { + $where = ['dictId' => $top_group['statisticsType']]; $groupsLevel && $where["dictDataCode>"] = $groupsLevel; - $disk = $this->ci->market_sys_dictionary_data_model->map('dictDataCode','dictDataName',$where,'','','','dictDataName,dictDataCode'); + $disk = $this->ci->market_sys_dictionary_data_model->map('dictDataCode', 'dictDataName', $where, '', '', '', 'dictDataName,dictDataCode'); } return $disk; } @@ -168,12 +188,13 @@ class Sylive2_entity{ * @param $a_id * @return array */ - public function level_disk_lists($a_id){ - $top_group = $this->ci->groups_model->get(['activityId'=>$a_id,'parentId'=>0],'statisticsType'); + public function level_disk_lists($a_id) + { + $top_group = $this->ci->groups_model->get(['activityId' => $a_id, 'parentId' => 0], 'statisticsType'); $disk = []; - if($top_group['statisticsType']){ - $where = ['dictId'=>$top_group['statisticsType']]; - $disk = $this->ci->market_sys_dictionary_data_model->select($where,'','','','dictDataName,dictDataCode'); + if ($top_group['statisticsType']) { + $where = ['dictId' => $top_group['statisticsType']]; + $disk = $this->ci->market_sys_dictionary_data_model->select($where, '', '', '', 'dictDataName,dictDataCode'); } return $disk; } diff --git a/common/models/market/Market_sylive_activity_kpidata_model.php b/common/models/market/Market_sylive_activity_kpidata_model.php index 7d8bf35b..dfca9ff9 100644 --- a/common/models/market/Market_sylive_activity_kpidata_model.php +++ b/common/models/market/Market_sylive_activity_kpidata_model.php @@ -1,10 +1,12 @@ table_name, 'default'); diff --git a/common/models/market/Market_sylive_activity_model.php b/common/models/market/Market_sylive_activity_model.php index 60cf3492..a10a5116 100644 --- a/common/models/market/Market_sylive_activity_model.php +++ b/common/models/market/Market_sylive_activity_model.php @@ -1,5 +1,5 @@ table_name, 'default'); diff --git a/home/controllers/h5/market/sylive2/Act.php b/home/controllers/h5/market/sylive2/Act.php index 4a4b73fc..2f72ce09 100644 --- a/home/controllers/h5/market/sylive2/Act.php +++ b/home/controllers/h5/market/sylive2/Act.php @@ -134,7 +134,7 @@ class Act extends Wx $appoint = $this->market_sylive_customer_model->get($where); $info['is_appoint'] = $appoint ? true : false; - if($jsondata['bottoms']){ + if ($jsondata['bottoms']) { foreach ($jsondata['bottoms'] as $v) { if ($v['urlType'] == 'enroll') { $enroll = 1; @@ -190,7 +190,7 @@ class Act extends Wx if ($rows) { $act_row = $this->market_sylive_activity_model->get(['activityId' => $a_id]); $jsondata = json_decode($act_row['jsondata'], true); - if($jsondata['bottoms']){ + if ($jsondata['bottoms']) { foreach ($jsondata['bottoms'] as $v) { if ($v['urlType'] == 'enroll') { $enroll = 1; @@ -323,6 +323,7 @@ class Act extends Wx $this->data['fillStyle'] = $jsondata['barrage']['color'] ? '#fff' : '#333'; $this->data['lists'] = $lists; $this->data['shareTitle'] = $shareTitle; + $this->data['a_id'] = $this->a_id; //微信分享 $wx_info = $this->share_info($row); $this->data['sign_package'] = $wx_info['sign_package']; @@ -583,9 +584,9 @@ class Act extends Wx $ac_row = $this->market_sylive_activity_model->get(['activityId' => $a_id], 'jsondata,orderType'); $jsondata = json_decode($ac_row['jsondata'], true); $act_user_row = $this->act_user_model->get(['id' => $this->act_uid]); - if($ac_row['orderType'] && $act_user_row['pid']){ + if ($ac_row['orderType'] && $act_user_row['pid']) { $cf_uid = $act_user_row['pid']; - }else{ + } else { $cf_uid = $act_user_row['channelId']; } $p_user = $this->act_user_model->get(['userId' => $cf_uid, 'activityId' => $a_id]); @@ -715,4 +716,26 @@ class Act extends Wx $redis->delete($key); $this->show_json(array('ukey' => $ukey), 200, '预约成功'); } + + public function addShareKpi() + { + $a_id = (int)$this->input->post('a_id'); + $index = (int)$this->input->post('index'); + $row = $this->market_sylive_activity_model->get(['activityId' => $a_id]); + if (!$row) { + throw new Hd_exception('参数错误', 400); + } + $shareImg = json_decode($row['shareImg'], true); + $img = $shareImg[$index]; + $cfShare = md5($img); + $mkKpiData = new Market_sylive_activity_kpidata_model(); + //添加kpi + $params = ['a_id' => $a_id, 'uid' => $this->uid, 'cf_uid' => $this->uid, 'kpi' => $mkKpiData::KYP_SHARE, 'cfShare' => $cfShare]; + $params['jsondata'] = [ + 'img' => $img, + ]; + $res = $this->sylive2_entity->kpi_log($params); + var_dump($res); + $this->show_json([], 200, '保存成功'); + } } diff --git a/home/controllers/h5/market/sylive2/Stic.php b/home/controllers/h5/market/sylive2/Stic.php index 5d854061..7e008b4c 100644 --- a/home/controllers/h5/market/sylive2/Stic.php +++ b/home/controllers/h5/market/sylive2/Stic.php @@ -106,10 +106,19 @@ class Stic extends Admin 'status' => 0, ]; $gw_total = $this->groups_user_model->count($where); - $where = [ - 'activityId' => $this->a_id, - //"cfUserId in (SELECT userId FROM lc_market_sylive_groups_user WHERE activityId = {$this->a_id} and bizId > 0 and status = 0)" => null - ]; + $mdSyliveActivity = new Market_sylive_activity_model(); + $mdData = new Market_sylive_activity_kpidata_model(); + if ($mdSyliveActivity::KPI_SHARE_ID < $this->a_id) { + $where = [ + 'activityId' => $this->a_id, + 'kpi' => $mdData::KYP_SHARE, + ]; + } else { + $where = [ + 'activityId' => $this->a_id, + //"cfUserId in (SELECT userId FROM lc_market_sylive_groups_user WHERE activityId = {$this->a_id} and bizId > 0 and status = 0)" => null + ]; + } $kgw_total = $this->mdSytActivityKpiData->count($where, "cfUserId"); $h_lists[] = ['title' => '参与团队', 'num' => "{$biz_total}个"]; $h_lists[] = ['title' => '参与团员', 'num' => "{$gw_total}人"]; @@ -166,10 +175,19 @@ class Stic extends Admin 'status' => 0, ]; $gw_total = $this->groups_user_model->count($kg_where); - $kgw_where = [ - 'activityId' => $this->a_id, - "cfUserId in (SELECT userId FROM lc_market_sylive_groups_user WHERE activityId = {$this->a_id} and bizId =".$group_user['bizId']." and status = 0)" => null - ]; + + if ($mdSyliveActivity::KPI_SHARE_ID < $this->a_id) { + $kgw_where = [ + 'activityId' => $this->a_id, + 'kpi' => $mdData::KYP_SHARE, + "cfUserId in (SELECT userId FROM lc_market_sylive_groups_user WHERE activityId = {$this->a_id} and bizId =" . $group_user['bizId'] . " and status = 0)" => null + ]; + } else { + $kgw_where = [ + 'activityId' => $this->a_id, + "cfUserId in (SELECT userId FROM lc_market_sylive_groups_user WHERE activityId = {$this->a_id} and bizId =" . $group_user['bizId'] . " and status = 0)" => null + ]; + } $kgw_total = $this->mdSytActivityKpiData->count($kgw_where, 'cfUserId'); $biz = [ @@ -390,7 +408,7 @@ class Stic extends Admin 'order' => '下单数', 'watch' => '观看用户', 'beforeOrder' => '留资客户', - ]; + ]; $params = $this->input->get(); $row = $this->market_sylive_activity_model->get(['activityId' => $this->a_id]); if (!$row) { @@ -514,7 +532,8 @@ class Stic extends Admin $this->show_view('h5/market/sylive2/stic/work'); } - public function work_lists(){ + public function work_lists() + { $params = $this->input->get(); $where = [ @@ -525,11 +544,16 @@ class Stic extends Admin $lists = []; $total_user = $this->groups_user_model->select($where); - $user_ids = implode(',',array_column($total_user,'userId')); - $users = $this->market_sylive_user_model->map('userId','',["userId in ($user_ids)"=>null],'','','','userId,uname as name,headimg'); - - foreach ($users as $k => $v){ - $work = $this->market_sylive_activity_kpidata_model->count(['activityId' => $this->a_id, 'cfUserId' => $k]); + $user_ids = implode(',', array_column($total_user, 'userId')); + $users = $this->market_sylive_user_model->map('userId', '', ["userId in ($user_ids)" => null], '', '', '', 'userId,uname as name,headimg'); + $mdSyliveActivity = new Market_sylive_activity_model(); + $mdData = new Market_sylive_activity_kpidata_model(); + foreach ($users as $k => $v) { + if ($mdSyliveActivity::KPI_SHARE_ID < $this->a_id) { + $work = $this->market_sylive_activity_kpidata_model->count(['activityId' => $this->a_id, 'cfUserId' => $k, 'kpi' => $mdData::KYP_SHARE]); + } else { + $work = $this->market_sylive_activity_kpidata_model->count(['activityId' => $this->a_id, 'cfUserId' => $k]); + } $v[0]['work'] = $work ? '已开工' : '尚未开工'; $lists[] = $v[0]; } diff --git a/home/views/h5/market/sylive2/act/share.php b/home/views/h5/market/sylive2/act/share.php index 2b738adb..208de9df 100644 --- a/home/views/h5/market/sylive2/act/share.php +++ b/home/views/h5/market/sylive2/act/share.php @@ -109,6 +109,10 @@ methods: { showPoster: function () { this.posterSrc = '' + //保存kpi + $.post('/h5/market/sylive2/act/addShareKpi', {'a_id': '','index':this.activeIndex}, function (res) { + console.log(res) + }, 'json') this.draw() }, closePoster: function () { diff --git a/market/controllers/api/sylive/GroupsStatistics.php b/market/controllers/api/sylive/GroupsStatistics.php index 203b3047..5d04cf03 100644 --- a/market/controllers/api/sylive/GroupsStatistics.php +++ b/market/controllers/api/sylive/GroupsStatistics.php @@ -1,5 +1,5 @@ '全部日期', 'value' => '']; - + $mdSyliveActivity = new Market_sylive_activity_model(); + $mdData = new Market_sylive_activity_kpidata_model(); $goods = []; $re = $this->mdSyliveActivity->get(['activityId' => $activityId]); if ($re) { @@ -88,12 +89,19 @@ class GroupsStatistics extends BaseController $pvDuration = round($livePV / $liveUV, 1); } } - $consultant = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId], 'cfUserId'); $allConsultant = $this->mdSyliveGroupsUser->count(['activityId' => $activityId, 'status' => 0, 'bizId >' => 0]); - $consultant > $allConsultant && $allConsultant = $consultant; + $bizs = $this->mdSyliveGroups->count(['activityId' => $activityId, 'ifBiz' => 1, 'status>=' => 0]); + if ($activityId > $mdSyliveActivity::KPI_SHARE_ID) { + $activityData1Name = '开工/全部 顾问数'; + $consultant = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId, 'kpi' => $mdData::KYP_SHARE], 'cfUserId'); + } else { + $activityData1Name = '参与/全部 顾问数'; + $consultant = $this->mdSyliveActivityKpidata->count(['activityId' => $activityId], 'cfUserId'); + } + $consultant > $allConsultant && $allConsultant = $consultant; $activityData1 = [['name' => '参与门店数', 'value' => $bizs] - , ['name' => '参与/全部 顾问数', 'value' => $consultant . ' / ' . $allConsultant]]; + , ['name' => $activityData1Name, 'value' => $consultant . ' / ' . $allConsultant]]; $watch_un = 0; if ($liveUV) { $watch_un = $watch - $liveUV; @@ -152,8 +160,8 @@ class GroupsStatistics extends BaseController if ($sort == 'order' && !$day) { $sort_order = 'orderTotal ' . $order; } else { - if($sort == 'beforeOrder'){ - $sort_order = 'beforeOrderTotal ' . $order; + if ($sort == 'beforeOrder') { + $sort_order = 'beforeOrderTotal ' . $order; } } @@ -245,8 +253,8 @@ class GroupsStatistics extends BaseController $res = $this->mdSyliveActivityKpidata->select_groupby($levelId, $where, "orderTotal {$order},id desc" , $page, $limit, "$levelId,count(id) as orderTotal"); } else { - if($sort == 'beforeOrder'){ - $sort_order = 'beforeOrderTotal ' . $order; + if ($sort == 'beforeOrder') { + $sort_order = 'beforeOrderTotal ' . $order; } $res = $this->mdSyliveGroups->select($where, "{$sort_order},groupsId desc", $page, $limit, 'groupsId,groupsName,browse,subscribe,beforeOrderTotal,orderTotal'); @@ -386,7 +394,7 @@ class GroupsStatistics extends BaseController if ($itemId) { $left_order = $this->mdSyliveOrder->count(['activityId' => $activityId, 'itemId' => $itemId, 'status' => 1, 'createTime <' => $re['timeStart']]); } else { - $left_order = $this->mdSyliveOrder->count(['activityId' => $activityId, 'itemId>' => 0, 'itemPrice >' => 0 , 'status' => 1, 'createTime <' => $re['timeStart']]); + $left_order = $this->mdSyliveOrder->count(['activityId' => $activityId, 'itemId>' => 0, 'itemPrice >' => 0, 'status' => 1, 'createTime <' => $re['timeStart']]); } $left_subscribe_per = number_format_com($left_subscribe / $left_browse * 100, 1, ''); @@ -413,7 +421,7 @@ class GroupsStatistics extends BaseController if ($itemId) { $right_order = $this->mdSyliveOrder->count(['activityId' => $activityId, 'itemId' => $itemId, 'status' => 1, 'createTime >=' => $re['timeStart']]); } else { - $right_order = $this->mdSyliveOrder->count(['activityId' => $activityId, 'itemId>' => 0, 'itemPrice >' => 0 , 'status' => 1, 'createTime >=' => $re['timeStart']]); + $right_order = $this->mdSyliveOrder->count(['activityId' => $activityId, 'itemId>' => 0, 'itemPrice >' => 0, 'status' => 1, 'createTime >=' => $re['timeStart']]); } $right_watch_per = number_format_com($right_watch / $right_browse * 100, 1, ''); $right_order_per = number_format_com($right_order / $right_watch * 100, 1, ''); @@ -450,7 +458,7 @@ class GroupsStatistics extends BaseController // $hour < 6 && $add_time = '+30 minute';//转分钟显示 $i = 0; while ($start_Time < $end_Time) { - if($i > 0){ + if ($i > 0) { $start_Time = $start_Time + 86400; } @@ -469,7 +477,7 @@ class GroupsStatistics extends BaseController $end = strtotime($v2['end']); $where = ['createTime >=' => $start, 'createTime <=' => $end, 'activityId' => $activityId]; if ($v['value'] == 'order') { - $counts[] = $this->mdSyliveOrder->count(['activityId' => $activityId, 'itemId>' => 0, 'itemPrice >' => 0 , 'status' => 1, 'createTime >=' => $v2['start'], 'createTime <=' => $v2['end'],]); + $counts[] = $this->mdSyliveOrder->count(['activityId' => $activityId, 'itemId>' => 0, 'itemPrice >' => 0, 'status' => 1, 'createTime >=' => $v2['start'], 'createTime <=' => $v2['end'],]); } else { $where['kpi'] = $v['value']; $counts[] = $this->mdSyliveActivityKpidata->count($where); @@ -504,6 +512,8 @@ class GroupsStatistics extends BaseController $levels[$k] = ['label' => $arr_unit[0], 'prop' => "levelName{$arr_unit[1]}", 'levelId' => "levelId{$arr_unit[1]}"]; } } + $mdSyliveActivity = new Market_sylive_activity_model(); + $mdData = new Market_sylive_activity_kpidata_model(); if ($re) { $channelId = intval($re['channelId']); !$sort && $sort = 'browse'; @@ -571,12 +581,12 @@ class GroupsStatistics extends BaseController $where_sort['kpi'] = 'beforeOrder'; $beforeOrderTotal = $this->mdSyliveActivityKpidata->count($where_sort); } -/* if ($sort == 'watch') { - $watch = $v['total']; - } else { - $where_sort['kpi'] = 'watch'; - $watch = $this->mdSyliveActivityKpidata->count($where_sort); - }*/ + /* if ($sort == 'watch') { + $watch = $v['total']; + } else { + $where_sort['kpi'] = 'watch'; + $watch = $this->mdSyliveActivityKpidata->count($where_sort); + }*/ if ($sort == 'order') { $orderTotal = $v['total']; } else { @@ -587,7 +597,11 @@ class GroupsStatistics extends BaseController } $orderTotal = $this->mdSyliveActivityKpidata->count($where_item); } - $consultant = $this->mdSyliveActivityKpidata->count(['bizId' => $bizId, 'activityId' => $activityId, "cfUserId in (SELECT userId FROM lc_market_sylive_groups_user WHERE activityId = {$activityId} and bizId > 0 and status = 0)" => null], 'cfUserId'); + if ($mdSyliveActivity::KPI_SHARE_ID < $activityId) { + $consultant = $this->mdSyliveActivityKpidata->count(['bizId' => $bizId, 'activityId' => $activityId, 'kpi' => $mdData::KYP_SHARE, "cfUserId in (SELECT userId FROM lc_market_sylive_groups_user WHERE activityId = {$activityId} and bizId > 0 and status = 0)" => null], 'cfUserId'); + } else { + $consultant = $this->mdSyliveActivityKpidata->count(['bizId' => $bizId, 'activityId' => $activityId, "cfUserId in (SELECT userId FROM lc_market_sylive_groups_user WHERE activityId = {$activityId} and bizId > 0 and status = 0)" => null], 'cfUserId'); + } $allConsultant = $this->mdSyliveGroupsUser->count(['bizId' => $bizId, 'activityId' => $activityId, 'status' => 0, 'bizId >' => 0]); $consultant > $allConsultant && $allConsultant = $consultant; // $livePV = $watchDuration = 0; @@ -608,7 +622,7 @@ class GroupsStatistics extends BaseController $list1[$v2['prop']] = $map_groups[$v[$levelId]] ? $map_groups[$v[$levelId]] : ''; } $list2 = ['bizName' => $bizName, 'consultant' => $consultant, 'allConsultant' => $allConsultant, 'consultantPer' => $consultantPer - , 'browse' => $browse, 'subscribe' => $subscribe,'beforeOrder' => $beforeOrderTotal, 'order' => $orderTotal]; + , 'browse' => $browse, 'subscribe' => $subscribe, 'beforeOrder' => $beforeOrderTotal, 'order' => $orderTotal]; $list[] = count($list1) ? array_merge($list1, $list2) : $list2; } } @@ -639,7 +653,7 @@ class GroupsStatistics extends BaseController } } } else { - if ($sort == 'beforeOrder'){ + if ($sort == 'beforeOrder') { $sort_order = 'beforeOrderTotal ' . $order; } $res = $this->mdSyliveGroups->select($where, "{$sort_order},groupsId desc", $page, $limit, @@ -674,7 +688,11 @@ class GroupsStatistics extends BaseController } else { $map_groups[$bizId] && $bizName = $map_groups[$bizId]; } - $consultant = $this->mdSyliveActivityKpidata->count(['bizId' => $bizId, 'activityId' => $activityId], 'cfUserId'); + if ($mdSyliveActivity::KPI_SHARE_ID < $activityId) { + $consultant = $this->mdSyliveActivityKpidata->count(['bizId' => $bizId, 'activityId' => $activityId, 'kpi' => $mdData::KYP_SHARE], 'cfUserId'); + } else { + $consultant = $this->mdSyliveActivityKpidata->count(['bizId' => $bizId, 'activityId' => $activityId], 'cfUserId'); + } $allConsultant = $this->mdSyliveGroupsUser->count(['bizId' => $bizId, 'activityId' => $activityId, 'status' => 0]); $consultant > $allConsultant && $allConsultant = $consultant; // $livePV = $watchDuration = 0; @@ -700,7 +718,7 @@ class GroupsStatistics extends BaseController } $consultantPer = number_format_com($consultant / $allConsultant * 100, 2, '') . '%'; $list1 = []; - if($levels){ + if ($levels) { foreach ($levels as $k2 => $v2) { $levelId = $v2['levelId']; $list1[$v2['prop']] = $map_groups[$v[$levelId]] ? $map_groups[$v[$levelId]] : ''; @@ -719,7 +737,7 @@ class GroupsStatistics extends BaseController $columns = ''; if ($page == 1) { $columns1 = []; - if($levels){ + if ($levels) { foreach ($levels as $k => $v) { $columns1[] = ['prop' => $v['prop'], 'label' => $v['label'], 'align' => 'center', 'showOverflowTooltip' => true, 'minWidth' => 80]; } @@ -764,6 +782,7 @@ class GroupsStatistics extends BaseController } } $re = $this->mdSyliveActivity->get(['activityId' => $activityId]); + $mdData = new Market_sylive_activity_kpidata_model(); if ($re) { $channelId = intval($re['channelId']); !$sort && $sort = 'browse'; @@ -865,8 +884,12 @@ class GroupsStatistics extends BaseController $levelId = $v2['levelId']; $list1[$v2['prop']] = $map_groups[$v[$levelId]] ? $map_groups[$v[$levelId]] : ''; } + $isStart = '否'; + if ($this->mdSyliveActivityKpidata->get(['activityId' => $activityId, 'userId' => $cfUserId, 'kpi' => $mdData::KYP_SHARE, 'day' => $day])) { + $isStart = '是'; + } $list2 = ['bizName' => $bizName, 'consultantName' => $consultantName, 'browse' => $browse, - 'subscribe' => $subscribe,'beforeOrder' => $beforeOrderTotal, 'order' => $order]; + 'subscribe' => $subscribe, 'beforeOrder' => $beforeOrderTotal, 'order' => $order, 'isStart' => $isStart]; $list[] = count($list1) ? array_merge($list1, $list2) : $list2; } } @@ -883,7 +906,7 @@ class GroupsStatistics extends BaseController $res = $this->mdSyliveActivityKpidata->select_groupby('cfUserId', $where, "orderTotal {$order},id desc" , $page, $limit, "cfUserId,levelId1,levelId2,levelId3,bizId,count(id) as orderTotal"); } else { - if ($sort == 'beforeOrder'){ + if ($sort == 'beforeOrder') { $sort_order = 'beforeOrderTotal ' . $order; } $res = $this->mdSyliveGroupsUser->select($where, "{$sort_order},groupsUserId desc", $page, $limit, @@ -942,14 +965,18 @@ class GroupsStatistics extends BaseController // } // } $list1 = []; - if($levels){ + if ($levels) { foreach ($levels as $k2 => $v2) { $levelId = $v2['levelId']; $list1[$v2['prop']] = $map_groups[$v[$levelId]] ? $map_groups[$v[$levelId]] : ''; } } + $isStart = '否'; + if ($this->mdSyliveActivityKpidata->get(['activityId' => $activityId, 'userId' => $cfUserId, 'kpi' => $mdData::KYP_SHARE])) { + $isStart = '是'; + } $list2 = ['bizName' => $bizName, 'consultantName' => $consultantName, 'browse' => $browse, - 'subscribe' => $subscribe, 'beforeOrder' => $beforeOrderTotal, 'order' => $order]; + 'subscribe' => $subscribe, 'beforeOrder' => $beforeOrderTotal, 'order' => $order, 'isStart' => $isStart]; $list[] = count($list1) ? array_merge($list1, $list2) : $list2; } } @@ -961,7 +988,7 @@ class GroupsStatistics extends BaseController $columns = ''; if ($page == 1) { $columns1 = []; - if($levels){ + if ($levels) { foreach ($levels as $k => $v) { $columns1[] = ['prop' => $v['prop'], 'label' => $v['label'], 'align' => 'center', 'showOverflowTooltip' => true, 'minWidth' => 80]; } @@ -976,6 +1003,7 @@ class GroupsStatistics extends BaseController // ['prop' => 'watch', 'label' => '观看人数', 'align' => 'center', 'showOverflowTooltip' => true, 'minWidth' => 120, 'sortable' => 'custom'], // ['prop' => 'livePV', 'label' => '观看人次', 'align' => 'center', 'showOverflowTooltip' => true, 'minWidth' => 100, 'sortable' => 'custom'], // ['prop' => 'watchDuration', 'label' => '人均观看(分)', 'align' => 'center', 'showOverflowTooltip' => true, 'minWidth' => 100, 'sortable' => 'custom'], + ['prop' => 'isStart', 'label' => '是否开工', 'align' => 'center', 'showOverflowTooltip' => true, 'minWidth' => 120, 'sortable' => 'custom'], ]; $columns = count($columns1) ? array_merge($columns1, $columns2) : $columns2; } @@ -1104,7 +1132,7 @@ class GroupsStatistics extends BaseController // $re_sum['playDuration'] && $playDuration = ceil($re_sum['playDuration'] / 60); // } $list1 = []; - if($levels){ + if ($levels) { foreach ($levels as $k2 => $v2) { $levelId = $v2['levelId']; $list1[$v2['prop']] = $map_groups[$v[$levelId]] ? $map_groups[$v[$levelId]] : ''; @@ -1122,7 +1150,7 @@ class GroupsStatistics extends BaseController $columns = ''; if ($page == 1) { $columns1 = []; - if($levels){ + if ($levels) { foreach ($levels as $k => $v) { $columns1[] = ['prop' => $v['prop'], 'label' => $v['label'], 'align' => 'center', 'showOverflowTooltip' => true, 'minWidth' => 80]; }