+
- 长按识别二维码领福利
+ diff --git a/api/controllers/plan/Syt.php b/api/controllers/plan/Syt.php
index 0cbe2652..52795e90 100644
--- a/api/controllers/plan/Syt.php
+++ b/api/controllers/plan/Syt.php
@@ -408,4 +408,28 @@ class Syt extends CI_Controller
}
}
}
-}
\ No newline at end of file
+ //临时更新kpi时间
+ public function tmp_day(){
+ $this->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData');
+ $page = $this->input->get('page');
+ $size = $this->input->get('size');
+ !$page && $page = 1;
+ !$size && $size = 100;
+ $where = [
+ 'createTime>' => 0,
+ 'day' => '0000-00-00',
+ ];
+ $total = $this->mdSytActivityKpiData->count($where);
+ echo '总数:'.$total.'
';
+ if($total){
+ $rows = $this->mdSytActivityKpiData->select($where,'id asc',$page,$size,'id,createTime');
+ foreach ($rows as $item) {
+ $update = [
+ 'day' => date('Y-m-d',$item['createTime']),
+ ];
+ $this->mdSytActivityKpiData->update($update,['id'=>$item['id']]);
+ }
+ }
+ echo '更新完成';
+ }
+}
diff --git a/common/libraries/market/Sylive_data_entity.php b/common/libraries/market/Sylive_data_entity.php
index 67863450..b5a9562e 100644
--- a/common/libraries/market/Sylive_data_entity.php
+++ b/common/libraries/market/Sylive_data_entity.php
@@ -4,6 +4,8 @@
*/
class Sylive_data_entity{
+ const DF_IMG = 'https://qs.haodian.cn/web/images/project/H5-ShiYu/goodslogo.jpg'; //东风图标
+
private $ci;
private $map_kpi_biz = [
'browse' => 'browse', 'subscribe' => 'subscribe', 'order' => 'orderTotal','watch' => 'watch'
@@ -27,7 +29,7 @@ class Sylive_data_entity{
/**
* 根据kpi排名
* @param $params ['activityId','kpi','createTime']
- * @param $gtype 分组类型(biz 店铺 area 大区 gw 顾问)
+ * @param $gtype 分组类型(biz 店铺 gw 顾问)
* @param $page
* @param $size
* @param $biz_id
@@ -43,15 +45,10 @@ class Sylive_data_entity{
"{$t2}.activityId={$t1}.activityId",
"{$t2}.kpi='{$params['kpi']}'"
];
- if($gtype=='area'){ //大区
- $where["{$t1}.status"] = 0;
- $j_where[] = "{$t2}.areaId={$t1}.areaId";
- $fileds = "{$t1}.areaId as organizationId,count({$t2}.id) as t";
- $group_by = "{$t1}.areaId";
- }elseif($gtype=='gw'){//顾问
+ if($gtype=='gw'){//顾问
$where["{$t1}.organizationId>"] = 0;
$j_where[] = "{$t2}.cfUserId={$t1}.userId";
- $fileds = "{$t1}.userId,count({$t2}.id) as t";
+ $fileds = "{$t1}.userId,{$t1}.bizId as organizationId,count({$t2}.id) as t";
$group_by = "{$t1}.userId";
}else{ //门店
$where["{$t1}.status"] = 0;
@@ -60,8 +57,7 @@ class Sylive_data_entity{
$group_by = "{$t1}.bizId";
}
if($params['createTime']){
- $j_where[] = "{$t2}.createTime>=".strtotime($params['createTime'].' 00:00:00');
- $j_where[] = "{$t2}.createTime<=".strtotime($params['createTime'].' 23:59:59');
+ $j_where[] = "{$t2}.day='".date('Y-m-d',strtotime($params['createTime']))."'";
}
$j_where = implode(' and ',$j_where);
if($page) {
@@ -85,19 +81,20 @@ class Sylive_data_entity{
if($userIds){
$user_rows = $this->ci->user_model->map('userId','',["userId in ($userIds)"=>null],'','','','userId,uname');
}
- }else{
- $biz_ids = implode(',',array_column($rows,'organizationId'));
- $org_rows = [];
- if($biz_ids){
- $org_rows = $this->ci->market_sylive_organization_model->map('organizationId','',["organizationId in ($biz_ids)"=>null],'','','','organizationId,organizationName');
- }
+ }
+ $biz_ids = implode(',',array_column($rows,'organizationId'));
+ $org_rows = [];
+ if($biz_ids){
+ $org_rows = $this->ci->market_sylive_organization_model->map('organizationId','',["organizationId in ($biz_ids)"=>null],'','','','organizationId,organizationName');
}
$start = $page>1 ? ($page-1)*$size : 0;
foreach ($rows as $key=>$val) {
$name = $tip = '';
if($gtype=='gw'){
$user = $user_rows[$val['userId']] ? $user_rows[$val['userId']][0] : [];
+ $org = $org_rows[$val['organizationId']] ? $org_rows[$val['organizationId']][0] : [];
$name = $user['uname'];
+ $org['organizationName'] && $name.="({$org['organizationName']})";
if($biz_id>0 && $biz_id==$val['userId']){
$tip = '本人';
}
@@ -181,7 +178,7 @@ class Sylive_data_entity{
$area_ids = implode(',',array_column($rows,'areaId'));
$org_rows = [];
if($area_ids){
- $org_rows = $this->ci->market_sylive_organization_model->map('organizationId','organizationName',["organizationId in ($area_ids)"],'','','','organizationId,organizationName');
+ $org_rows = $this->ci->market_sylive_organization_model->map('organizationId','organizationName',["organizationId in ($area_ids)"=>null],'','','','organizationId,organizationName');
}
$start = $page>1 ? ($page-1)*$size : 0;
foreach ($rows as $key=>$val) {
@@ -199,6 +196,54 @@ class Sylive_data_entity{
];
return $data;
}
+ /**
+ * 根据kpi排名
+ * @param $params ['activityId','kpi','createTime']
+ * @param $page
+ * @param $size
+ * @return array
+ */
+ public function top_area_kpidata($params, $page=1, $size=20){
+ $lists = [];
+ $where = [
+ 'activityId' => $params['activityId'],
+ 'status' => 0,
+ 'areaId>' => 0,
+ ];
+ $select = "distinct(areaId)";
+ $rows = $this->ci->mdSytActivityBiz->select($where,"",$page,$size,$select);
+ if($rows){
+ $area_ids = implode(',',array_column($rows,'areaId'));
+ $org_rows = $this->ci->market_sylive_organization_model->map('organizationId','',["organizationId in ($area_ids)"=>null],'','','','organizationId,organizationName');
+ $start = $page>1 ? ($page-1)*$size : 0;
+ foreach ($rows as $key=>$val) {
+ $where = [
+ 'areaId' => $val['areaId'],
+ 'activityId' => $params['activityId'],
+ ];
+ if($params['createTime']){
+ $where['day='] = date('Y-m-d',strtotime($params['createTime']));
+ }
+ $params['kpi'] = $where['kpi'] = $params['kpi'];
+ $total = $this->ci->mdSytActivityKpiData->count($where);
+ $org = $org_rows[$val['areaId']] ? $org_rows[$val['areaId']][0] : [];
+ $lists[] = [
+ 'ranking' => $start+$key+1,
+ 'name' => $org ? $org['organizationName'] : '',
+ 'total' => $total,
+ 'num' => $total.'人',
+ 'tip' => '',
+ ];
+ }
+ $edit = array_column($lists,'total');
+ array_multisort($edit,SORT_DESC,$lists);
+ }
+ $data = [
+ 'total' => 0,
+ 'lists' => $lists
+ ];
+ return $data;
+ }
/**
* 顾问排行
@@ -219,6 +264,60 @@ class Sylive_data_entity{
'organizationId>' => 0
];
$other_where && $where = array_merge($where,$other_where);
+ $select = "bizId,userId,{$filed} as t";
+ $total = $this->ci->act_user_model->count($where);
+ if($total){
+ $rows = $this->ci->act_user_model->select($where,"t desc",$page,$size,$select);
+ $user_ids = implode(',',array_column($rows,'userId'));
+ $user_rows = [];
+ if($user_ids){
+ $user_rows = $this->ci->user_model->map('userId','',["userId in ($user_ids)"],'','','','userId,uname,nickname,headimg');
+ }
+ $biz_ids = implode(',',array_column($rows,'bizId'));
+ $biz_rows = [];
+ if($biz_ids){
+ $biz_rows = $this->ci->market_sylive_organization_model->map('organizationId','',["organizationId in ($biz_ids)"=>null],'','','','organizationId,organizationName');
+ }
+ $start = $page>1 ? ($page-1)*$size : 0;
+ foreach ($rows as $key=>$val) {
+ $user = $user_rows[$val['userId']] ? $user_rows[$val['userId']][0] : [];
+ $biz = $biz_rows[$val['bizId']] ? $biz_rows[$val['bizId']][0] : [];
+ $biz_name = $biz['organizationName'] ? "({$biz['organizationName']})" : '';
+ $lists[] = [
+ 'ranking' => $start+$key+1,
+ 'name' => $user['uname'].$biz_name,
+ 'num' => $val['t'].'人',
+ 'tip' => $userId==$val['userId'] ? '本人' : '',
+ 'headimg' => $user['headimg']
+ ];
+ }
+ }
+ $data = [
+ 'total' => $total,
+ 'lists' => $lists
+ ];
+ return $data;
+ }
+
+ /**
+ * 顾问排行
+ * @param $a_id
+ * @param $type
+ * @param $page
+ * @param $size
+ * @return array
+ */
+ public function top_team_lists($a_id,$type='',$other_where=[], $page=1, $size=20,$userId=0){
+ $lists = [];
+ $filed = $this->map_kpi_biz[$type];
+ if(!$filed){
+ return ['lists' => $lists,'total' => 0];
+ }
+ $where = [
+ 'activityId' => $a_id,
+ 'teamId>' => 0
+ ];
+ $other_where && $where = array_merge($where,$other_where);
$select = "userId,{$filed} as t";
$total = $this->ci->act_user_model->count($where);
if($total){
@@ -228,15 +327,16 @@ class Sylive_data_entity{
if($user_ids){
$user_rows = $this->ci->user_model->map('userId','',["userId in ($user_ids)"],'','','','userId,uname,nickname,headimg');
}
- $start = $page>1 ? ($page-1)*$size : 0;
foreach ($rows as $key=>$val) {
$user = $user_rows[$val['userId']] ? $user_rows[$val['userId']][0] : [];
+ $name =$user['uname'] ? $user['uname'] : $user['nickname'];
$lists[] = [
- 'ranking' => $start+$key+1,
- 'name' => $user['uname'],
+ 'uid' => $val['userId'],
+ 'name' => name_asterisk($name),
+ 'headimg' => self::DF_IMG,
+ 'total' => $total,
'num' => $val['t'].'人',
'tip' => $userId==$val['userId'] ? '本人' : '',
- 'headimg' => $user['headimg']
];
}
}
diff --git a/common/libraries/market/Sylive_entity.php b/common/libraries/market/Sylive_entity.php
index cee33303..565b2fe5 100644
--- a/common/libraries/market/Sylive_entity.php
+++ b/common/libraries/market/Sylive_entity.php
@@ -197,7 +197,8 @@ class Sylive_entity{
'cfUserId' => $params['cf_uid'],
'kpi' => $params['kpi'],
'type' => $type,
- 'createTime' => time()
+ 'createTime' => time(),
+ 'day' => date('Y-m-d')
];
$area_id && $addData['areaId'] = $area_id;
$biz_id && $addData['bizId'] = $biz_id;
@@ -451,61 +452,6 @@ class Sylive_entity{
return $data;
}
- //团队用户排行数据
- public function top_team_user($aid,$teamId,$uid,$type='browse',$page=1,$size=50){
- if(!$teamId){
- return ['total' => 0, 'lists' => []];
- }
- $where = [
- 'parentId' => $teamId
- ];
- $orgs = $this->ci->market_sylive_team_model->select($where,'',0,0,'teamId');
- $orgs && $org_arr_ids = array_column($orgs,'teamId');
- $org_arr_ids[] = $teamId;
- $org_ids = implode($org_arr_ids,',');
- $where = [
- "teamId>" => 0,
- "teamId in ({$org_ids})" => null
- ];
- $total = $this->ci->user_model->count($where);
- $lists = [];
- if($total){
- $rows = $this->ci->user_model->select($where,'userId desc',$page,$size,'userId,uname,nickname,headimg');
- $where = [
- 'activityId' => $aid,
- 'kpi' => $type,
- 'bizId' => $teamId,
- 'type' => 1,
- ];
- $t_rows = $this->ci->mdSytActivityKpiData->select_groupby('cfUserId',$where,'total desc',$page,$size,'cfUserId,count(id) as total');
- $map = [];
- if($t_rows){
- foreach($t_rows as $item) {
- $map[$item['cf_uid']] = null !== $item['total'] ? $item['total'] : $item;
- }
- }
- foreach ($rows as $item) {
- $total = $map[$item['userId']] ? $map[$item['userId']] : '0';
- $name = $item['uname'] ? $item['uname'] : $item['nickname'];
- $lists[] = [
- 'uid' => $item['userId'],
- 'name' => name_asterisk($name),
- 'headimg' => self::DF_IMG,
- 'total' => $total,
- 'num' => "{$total}人",
- 'tip' => $uid == $item['userId'] ? '本人' : '',
- ];
- }
- $edit = array_column($lists,'total');
- array_multisort($edit,SORT_DESC,$lists);
- }
- $data = [
- 'total' => $total,
- 'lists' => $lists
- ];
- return $data;
- }
-
//用户用户观看次数排行
public function top_team_view_num($where,$page=1,$size=10){
$total = $this->ci->market_sylive_viewlog_model->count($where);
diff --git a/home/controllers/h5/market/sylive/Login.php b/home/controllers/h5/market/sylive/Login.php
index 27b55f42..bc02a2ea 100644
--- a/home/controllers/h5/market/sylive/Login.php
+++ b/home/controllers/h5/market/sylive/Login.php
@@ -86,7 +86,7 @@ class Login extends CI_Controller{
}
$area_id && $update['areaId'] = $area_id;
$biz_id && $update['bizId'] = $biz_id;
- $this->act_user_model->update($update,['openid'=>$wx_info['openid'],'status'=>0]);
+ $this->act_user_model->update($update,['userId'=>$wx_info['userId'],'status'=>0,'organizationId'=>0,'teamId'=>0]);
return ['code' => 1,'msg' => '绑定成功'];
}
//获取验证码
diff --git a/home/controllers/h5/market/sylive/Stic.php b/home/controllers/h5/market/sylive/Stic.php
index 80f016ab..b23c651c 100644
--- a/home/controllers/h5/market/sylive/Stic.php
+++ b/home/controllers/h5/market/sylive/Stic.php
@@ -93,13 +93,8 @@ class Stic extends Admin{
$area_count = $this->mdSytActivityBiz->db->query($sql)->row_array();
$sql = "select count(distinct bizId) as total from lc_market_sylive_activity_biz where `activityId`={$a_id}";
$biz_count = $this->mdSytActivityBiz->db->query($sql)->row_array();
- $where = [
- 'status' => 0,
- "organizationId in (select organizationId from lc_market_sylive_organization where
- parentId in (select bizId from lc_market_sylive_activity_biz where activityId={$a_id} and status=0)
- )" => null
- ];
- $gw_count = $this->user_model->count($where); //顾问
+ $where = ['activityId' => $a_id, 'organizationId>' => 0];
+ $gw_count = $this->act_user_model->count($where, 'userId');
$join = [
['title' => '参与大区', 'num' => "{$area_count['total']}个"],
['title' => '参与门店', 'num' => "{$biz_count['total']}家"],
@@ -244,13 +239,8 @@ class Stic extends Admin{
$area_count = $this->mdSytActivityBiz->db->query($sql)->row_array();
$sql = "select count(distinct bizId) as total from lc_market_sylive_activity_biz where `activityId`={$a_id}";
$biz_count = $this->mdSytActivityBiz->db->query($sql)->row_array();
- $where = [
- 'status' => 0,
- "organizationId in (select organizationId from lc_market_sylive_organization where
- parentId in (select bizId from lc_market_sylive_activity_biz where activityId={$a_id} and status=0)
- )" => null
- ];
- $gw_count = $this->user_model->count($where); //顾问
+ $where = ['activityId' => $a_id, 'organizationId>' => 0];
+ $gw_count = $this->act_user_model->count($where, 'userId');
$join = [
['title' => '参与大区', 'num' => "{$area_count['total']}个"],
['title' => '参与门店', 'num' => "{$biz_count['total']}家"],
@@ -421,20 +411,24 @@ class Stic extends Admin{
$a_id = intval($info['a_id']);//活动id
$type = $params['type'] ? $params['type'] : 'browse';
if(strtotime($params['day'])){//根据日期排行
- $biz_id = '';
+ $biz_id = '';
$where = [
'activityId' => $a_id,
'kpi' => $type,
'createTime' => $params['day'],
];
- if($params['gtype']=='gw'){
- $biz_id = $this->uid;
+ if($params['gtype']=='area'){
+ $data = $this->sylive_data_entity->top_area_kpidata($where,$page,$size);
+ }else{
+ if($params['gtype']=='gw'){
+ $biz_id = $this->uid;
+ }
+ if($params['gtype']=='biz'){
+ $biz_id = $this->sylive_entity->get_biz_id($this->session['org_id'],$this->group_id);
+ }
+ $gtype = $params['gtype'] ? $params['gtype'] : 'biz';
+ $data = $this->sylive_data_entity->top_biz_kpidata($where,$gtype,$page,$size,$biz_id);
}
- if($params['gtype']=='biz'){
- $biz_id = $this->sylive_entity->get_biz_id($this->session['org_id'],$this->group_id);
- }
- $gtype = $params['gtype'] ? $params['gtype'] : 'biz';
- $data = $this->sylive_data_entity->top_biz_kpidata($where,$gtype,$page,$size,$biz_id);
}else{
if($params['gtype']=='area'){
$data = $this->sylive_data_entity->top_area_lists($a_id,$type,1,50);
@@ -522,6 +516,26 @@ class Stic extends Admin{
];
$biz_id = $this->sylive_entity->get_biz_id($this->session['org_id'],$this->group_id);
if($type==1){
+ $biz_b_rows = $this->sylive_data_entity->top_lists($a_id,'browse',1,10,0);
+ $data['biz_browse'] = [
+ 'title' => '门店观看排行',
+ 'list' => $biz_b_rows['lists']
+ ];
+ $biz_sub_rows = $this->sylive_data_entity->top_lists($a_id,'subscribe',1,10,0);
+ $data['biz_book'] = [
+ 'title' => '门店订单排行',
+ 'list' => $biz_sub_rows['lists']
+ ];
+ $gw_b_rows = $this->sylive_data_entity->top_gw_lists($a_id,'browse',[],1,10,$this->uid);
+ $data['gw_browse'] = [
+ 'title' => '顾问浏览排行',
+ 'list' => $gw_b_rows['lists']
+ ];
+ $gw_sub_rows = $this->sylive_data_entity->top_gw_lists($a_id,'subscribe',[],1,10,$this->uid);
+ $data['gw_book'] = [
+ 'title' => '顾问预约排行',
+ 'list' => $gw_sub_rows['lists']
+ ];
$b_rows = $this->sylive_data_entity->top_gw_lists($a_id,'browse',['bizId'=>$biz_id],1,30,$this->uid);
$data['browse'] = [
'title' => '本店浏览排行',
@@ -533,6 +547,26 @@ class Stic extends Admin{
'list' => $sub_rows['lists']
];
}else{
+ $biz_view_rows = $this->sylive_data_entity->top_lists($a_id,'watch',1,10,0);
+ $data['biz_view'] = [
+ 'title' => '门店观看排行',
+ 'list' => $biz_view_rows['lists']
+ ];
+ $biz_order_rows = $this->sylive_data_entity->top_lists($a_id,'order',1,10,0);
+ $data['biz_order'] = [
+ 'title' => '门店订单排行',
+ 'list' => $biz_order_rows['lists']
+ ];
+ $gw_view_rows = $this->sylive_data_entity->top_gw_lists($a_id,'watch',[],1,10,$this->uid);
+ $data['gw_view'] = [
+ 'title' => '顾问观看排行',
+ 'list' => $gw_view_rows['lists']
+ ];
+ $gw_order_rows = $this->sylive_data_entity->top_gw_lists($a_id,'order',[],1,10,$this->uid);
+ $data['gw_order'] = [
+ 'title' => '顾问订单排行',
+ 'list' => $gw_order_rows['lists']
+ ];
$view_rows = $this->sylive_data_entity->top_gw_lists($a_id,'watch',['bizId'=>$biz_id],1,30,$this->uid);
$data['view'] = [
'title' => '本店观看排行',
@@ -663,7 +697,6 @@ class Stic extends Admin{
$biz_id = $params['type_id'];
$o_where = ['bizId'=>$biz_id];
}
- $o_where = [];
$res = $this->sylive_data_entity->top_gw_lists($params['a_id'],$params['kpi'],$o_where,$page,$size,$this->uid);
$lists = [];
if($res['lists']){
diff --git a/home/controllers/h5/market/sylive/Tstic.php b/home/controllers/h5/market/sylive/Tstic.php
index d92d7832..0c04c6f8 100644
--- a/home/controllers/h5/market/sylive/Tstic.php
+++ b/home/controllers/h5/market/sylive/Tstic.php
@@ -15,6 +15,7 @@ class Tstic extends Admin{
$this->load->model('live/Live_polyv_session_model', 'mdPolyvSession');
$this->load->library('market/sylive_entity');
+ $this->load->library('market/sylive_data_entity');
$this->teamLevel = $this->sylive_entity->get_team_level($this->session['teamId']);
$this->data['skey'] = $this->input->get('skey');
}
@@ -345,24 +346,26 @@ class Tstic extends Admin{
}else{//大团长
$teamId = 0;
}
+ $o_where = [];
+ $teamId && $o_where['bizId'] = $teamId;
if($type==1){
- $b_rows = $this->sylive_entity->top_team_user($a_id,$teamId,$this->uid,'browse');
+ $b_rows = $this->sylive_data_entity->top_team_lists($a_id,'browse',$o_where,1,10,$this->uid);
$data['browse'] = [
'title' => '团队浏览排行',
'list' => $b_rows['lists']
];
- $sub_rows = $this->sylive_entity->top_team_user($a_id,$teamId,$this->uid,'subscribe');
+ $sub_rows = $this->sylive_data_entity->top_team_lists($a_id,'subscribe',$o_where,1,10,$this->uid);
$data['book'] = [
'title' => '团队预约排行',
'list' => $sub_rows['lists']
];
}else{
- $view_rows = $this->sylive_entity->top_team_user($a_id,$teamId,$this->uid,'watch');
+ $view_rows = $this->sylive_data_entity->top_team_lists($a_id,'watch',$o_where,1,10,$this->uid);
$data['view'] = [
'title' => '团队观看排行',
'list' => $view_rows['lists']
];
- $order_rows = $this->sylive_entity->top_team_user($a_id,$teamId,$this->uid,'order');
+ $order_rows = $this->sylive_data_entity->top_team_lists($a_id,'watch',$o_where,1,10,$this->uid);
$data['order'] = [
'title' => '团队订单排行',
'list' => $order_rows['lists']
@@ -478,6 +481,8 @@ class Tstic extends Admin{
public function gw_lists(){
$params = $this->input->get();
+ $page = $params['page'] ? $params['page'] : 1;
+ $size = $params['size'] ? $params['size'] : 20;
if($this->teamLevel==2){ //团员
$t_row = $this->market_sylive_team_model->get(['teamId'=>$this->session['teamId']],'parentId');
$teamId = $t_row['parentId'];
@@ -486,7 +491,8 @@ class Tstic extends Admin{
}else{//大团长
$teamId = 0;
}
- $res = $this->sylive_entity->top_team_user($params['a_id'],$teamId,$this->uid,$params['kpi']);
+ $teamId && $o_where['bizId'] = $teamId;
+ $res = $this->sylive_data_entity->top_team_lists($params['a_id'],$params['kpi'],$o_where,$page,$size,$this->uid);
$lists = [];
if($res['lists']){
foreach ($res['lists'] as $item) {
diff --git a/home/views/h5/market/sylive/act/index.php b/home/views/h5/market/sylive/act/index.php
index 16fba697..57cefbad 100644
--- a/home/views/h5/market/sylive/act/index.php
+++ b/home/views/h5/market/sylive/act/index.php
@@ -29,12 +29,12 @@
+
- 长按识别二维码领福利
+