diff --git a/api/controllers/plan/Syt.php b/api/controllers/plan/Syt.php index 948e8e82..c5f85703 100644 --- a/api/controllers/plan/Syt.php +++ b/api/controllers/plan/Syt.php @@ -538,4 +538,56 @@ class Syt extends CI_Controller echo '更新完毕'; } } + + public function order_info(){ + $this->load->model('market/market_sylive_user_model', 'user_model'); + $this->load->model('market/market_sylive_activity_user_model', 'act_user_model'); + $this->load->model('market/market_sylive_order_model','order_model'); + $this->load->model('market/market_sylive_activity_model'); + $this->load->model('market/market_sylive_activity_orders_model','mdSytActivityOrders'); + $this->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData'); + $this->load->library('market/sylive_entity'); + $page = $this->input->get('page'); + $size = $this->input->get('size'); + !$page && $page = 1; + !$size && $size = 20; + $where = [ + 'activityId' => 4, + 'status' => 1, + 'bizId' => 0, + 'areaId' => 0, + ]; + $rows = $this->order_model->select($where,'id asc',$page,$size); + if($rows){ + foreach ($rows as $item) { + $user = $this->user_model->get(['userId'=>$item['userId']]); + $act_user = $this->act_user_model->get(['userId'=>$item['userId'],'activityId'=>$item['activityId']]); + $p_user = []; + $act_user['channelId'] && $p_user = $this->act_user_model->get(['userId'=>$act_user['channelId']]); + if(!$p_user){ + if($user['teamId']){ //团长 + $t_level_id = $this->sylive_entity->get_team_level($user['teamId']); + $p_user = $t_level_id<3 ? $act_user : []; + } + if($user['organizationId']){ //顾问 + $group_id = $this->sylive_entity->get_level($user['organizationId']); + $p_user = $group_id<4 ? $act_user : 0; + } + } + $update = []; + $p_user['teamId'] && $update['cfrom'] = 1; + $p_user['areaId'] && $update['areaId'] = $p_user['areaId']; + $p_user['bizId'] && $update['bizId'] = $p_user['bizId']; + $p_user['userId'] && $update['cfUserId'] = $p_user['userId']; + if($update){ + echo "订单id:{$item['id']},更新:".json_encode($update,JSON_UNESCAPED_UNICODE).'
'; + $this->order_model->update($update,['id'=>$item['id']]); + }else{ + echo "订单id:{$item['id']},不存在上级
"; + } + } + }else{ + echo '更新完毕'; + } + } } diff --git a/common/libraries/market/Sylive_data_entity.php b/common/libraries/market/Sylive_data_entity.php index 145921db..091e3332 100644 --- a/common/libraries/market/Sylive_data_entity.php +++ b/common/libraries/market/Sylive_data_entity.php @@ -88,6 +88,7 @@ class Sylive_data_entity{ if($biz_ids){ $org_rows = $this->ci->market_sylive_organization_model->map('organizationId','',["organizationId in ($biz_ids)"=>null],'','','','organizationId,organizationName'); } + $num_tip = $params['kpi'] == 'order' ? '单' : '人'; $start = $page>1 ? ($page-1)*$size : 0; foreach ($rows as $key=>$val) { $name = $tip = ''; @@ -109,7 +110,7 @@ class Sylive_data_entity{ $lists[] = [ 'ranking' => $start+$key+1, 'name' => $name, - 'num' => $val['t'].'人', + 'num' => $val['t'].$num_tip, 'tip' => $tip, ]; } @@ -138,11 +139,12 @@ class Sylive_data_entity{ $org_rows = $this->ci->market_sylive_organization_model->map('organizationId','organizationName',["organizationId in ($biz_ids)"],'','','','organizationId,organizationName'); } $start = $page>1 ? ($page-1)*$size : 0; + $num_tip = $type == 'order' ? '单' : '人'; foreach ($rows as $key=>$val) { $lists[] = [ 'ranking' => $start+$key+1, 'name' => $org_rows[$val['bizId']] ? $org_rows[$val['bizId']] : '', - 'num' => $val[$this->map_kpi_biz[$type]].'人', + 'num' => $val[$this->map_kpi_biz[$type]].$num_tip, 'tip' => $biz_id==$val['bizId'] ? '本店' : '', ]; } @@ -182,11 +184,12 @@ class Sylive_data_entity{ $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; + $num_tip = $type == 'order' ? '单' : '人'; foreach ($rows as $key=>$val) { $lists[] = [ 'ranking' => $start+$key+1, 'name' => $org_rows[$val['areaId']] ? $org_rows[$val['areaId']] : '', - 'num' => $val['t'].'人', + 'num' => $val['t'].$num_tip, 'tip' => '', ]; } @@ -217,6 +220,7 @@ class Sylive_data_entity{ $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; + $num_tip = $params['kpi'] == 'order' ? '单' : '人'; foreach ($rows as $key=>$val) { $where = [ 'areaId' => $val['areaId'], @@ -226,14 +230,14 @@ class Sylive_data_entity{ if($params['createTime']){ $where['day='] = date('Y-m-d',strtotime($params['createTime'])); } - $params['kpi'] = $where['kpi'] = $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.'人', + 'num' => $total.$num_tip, 'tip' => '', ]; } @@ -281,6 +285,7 @@ class Sylive_data_entity{ $biz_rows = $this->ci->market_sylive_organization_model->map('organizationId','',["organizationId in ($biz_ids)"=>null],'','','','organizationId,organizationName'); } $start = $page>1 ? ($page-1)*$size : 0; + $num_tip = $type == 'order' ? '单' : '人'; 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] : []; @@ -288,7 +293,7 @@ class Sylive_data_entity{ $lists[] = [ 'ranking' => $start+$key+1, 'name' => $user['uname'].$biz_name, - 'num' => $val['t'].'人', + 'num' => $val['t'].$num_tip, 'tip' => $userId==$val['userId'] ? '本人' : '', 'headimg' => $user['headimg'] ]; @@ -318,12 +323,13 @@ class Sylive_data_entity{ if($team_ids){ $org_rows = $this->ci->market_sylive_team_model->map('teamId','teamName',["teamId in ($team_ids)"=>null],'','','','teamId,teamName'); } + $num_tip = $type == 'order' ? '单' : '人'; $start = $page>1 ? ($page-1)*$size : 0; foreach ($rows as $key=>$val) { $lists[] = [ 'ranking' => $start+$key+1, 'name' => $org_rows[$val['teamId2']] ? $org_rows[$val['teamId2']] : '', - 'num' => $val[$this->map_kpi_biz[$type]].'人', + 'num' => $val[$this->map_kpi_biz[$type]].$num_tip, 'tip' => $teamId==$val['teamId2'] ? '我的团队' : '', ]; } @@ -363,6 +369,7 @@ class Sylive_data_entity{ if($user_ids){ $user_rows = $this->ci->user_model->map('userId','',["userId in ($user_ids)"=>null],'','','','userId,uname,nickname,headimg'); } + $num_tip = $type == 'order' ? '单' : '人'; $start = $page>1 ? ($page-1)*$size : 0; foreach ($rows as $key=>$val) { $user = $user_rows[$val['userId']] ? $user_rows[$val['userId']][0] : []; @@ -373,7 +380,7 @@ class Sylive_data_entity{ 'name' => name_asterisk($name), 'headimg' => self::DF_IMG, 'total' => $val['t'], - 'num' => $val['t'].'人', + 'num' => $val['t'].$num_tip, 'tip' => $userId==$val['userId'] ? '本人' : '', ]; } @@ -405,7 +412,7 @@ class Sylive_data_entity{ $org_rows = $this->ci->market_sylive_team_model->map('teamId','',["teamId in ($team_ids)"=>null],'','','','teamId,teamName as name'); } } - + $num_tip = $where['kpi'] == 'order' ? '单' : '人'; $start = $page>1 ? ($page-1)*$page_size : 0; foreach ($rows as $key=>$val) { if($groupby=='cfUserId'){ @@ -418,7 +425,7 @@ class Sylive_data_entity{ $lists[] = [ 'ranking' => $start+$key+1, 'name' => $org['name'], - 'num' => $val['t'].'人', + 'num' => $val['t'].$num_tip, 'tip' => $tip, ]; } diff --git a/common/libraries/market/Sylive_entity.php b/common/libraries/market/Sylive_entity.php index 15fbe2fa..36064b16 100644 --- a/common/libraries/market/Sylive_entity.php +++ b/common/libraries/market/Sylive_entity.php @@ -270,14 +270,15 @@ class Sylive_entity{ $map[$item['cf_uid']] = null !== $item['total'] ? $item['total'] : $item; } } + $num_tip = $type == 'order' ? '单' : '人'; foreach ($rows as $item) { $total = $map[$item['userId']] ? $map[$item['userId']] : '0'; $lists[] = [ 'uid' => $item['userId'], 'name' => $item['uname'] ? $item['uname'] : $item['nickname'], 'headimg' => $item['headimg'] ? $item['headimg'] : self::DEFAULT_HEAD, - 'total' => $total, - 'num' => "{$total}人", + 'total' => $num, + 'num' => "{$num}{$num_tip}", 'tip' => $uid == $item['userId'] ? '本人' : '', ]; } @@ -514,4 +515,4 @@ class Sylive_entity{ } return null; } -} \ No newline at end of file +} diff --git a/home/controllers/h5/market/sylive/Item.php b/home/controllers/h5/market/sylive/Item.php index 7d7cb54f..bb4cf389 100644 --- a/home/controllers/h5/market/sylive/Item.php +++ b/home/controllers/h5/market/sylive/Item.php @@ -141,9 +141,20 @@ class Item extends Wx{ if($row['stock']<=0){ $this->show_json('',400,'已售罄'); } + $user = $this->user_model->get(['userId'=>$this->uid]); $act_user = $this->act_user_model->get(['userId'=>$this->uid,'activityId'=>$a_id]); $p_user = []; $act_user['channelId'] && $p_user = $this->act_user_model->get(['userId'=>$act_user['channelId']]); + if(!$p_user){ + if($user['teamId']){ //团长 + $t_level_id = $this->sylive_entity->get_team_level($user['teamId']); + $p_user = $t_level_id<3 ? $act_user : []; + } + if($user['organizationId']){ //顾问 + $group_id = $this->sylive_entity->get_level($user['organizationId']); + $p_user = $group_id<4 ? $act_user : 0; + } + } $unpay = $this->market_sylive_order_model->get(['itemId'=>$itemId,'activityId'=>$a_id,'status'=>0,'userId'=>$this->uid,'expireTime>'=>time(),'type'=>0]); if(!$unpay){ $mb_count = $redis_obj->sCard($mb_key); //获取集合中用户数量 @@ -205,7 +216,6 @@ class Item extends Wx{ } $this->market_sylive_order_model->update($update,['id'=>$unpay['id']]); } - $user = $this->user_model->get(['userId'=>$this->uid]); $notify_url = http_host_com('home').'/h5/market/sylive/notify/item'; $result = $this->unorder($unpay['sid'],$unpay['totalPrice'],$user['openid'],$unpay['itemTitle'],$notify_url,$unpay['expireTime'],['wx_type'=>'dc']); if(!$result['code']){ diff --git a/home/controllers/h5/market/sylive/Stic.php b/home/controllers/h5/market/sylive/Stic.php index 1bbbb368..fcc174af 100644 --- a/home/controllers/h5/market/sylive/Stic.php +++ b/home/controllers/h5/market/sylive/Stic.php @@ -12,6 +12,7 @@ class Stic extends Admin{ $this->load->model('market/market_sylive_activity_biz_model','mdSytActivityBiz'); $this->load->model('market/market_sylive_activity_kpidata_model','mdSytActivityKpiData'); $this->load->model('market/market_sylive_order_model'); + $this->load->model('market/market_sylive_items_model'); $this->load->model('live/Live_polyv_session_model', 'mdPolyvSession'); $this->load->library('market/sylive_entity'); $this->load->library('market/sylive_data_entity'); @@ -46,7 +47,7 @@ class Stic extends Admin{ $order_count = $this->mdSytActivityKpiData->count(['activityId'=>$a_id,'kpi'=>'order','cfUserId'=>$this->uid,'type'=>0]); $info['live'] = [ ['title' => '观看用户', 'num' => "{$watch_count}人",'url' => '/h5/market/sylive/stic/users?type=owner&kpi=watch&a_id='.$a_id], - ['title' => '下单用户', 'num' => "{$order_count}人",'url' => '/h5/market/sylive/stic/users?type=owner&kpi=order&a_id='.$a_id], + ['title' => '下单数', 'num' => "{$order_count}单",'url' => '/h5/market/sylive/stic/users?type=owner&kpi=order&a_id='.$a_id], ['title' => '转化率', 'num' => $watch_count ? round($order_count/$watch_count*100,2)."%" : 0], ]; $this->data['info'] = $info; @@ -256,7 +257,7 @@ class Stic extends Admin{ $all_order_count = $this->mdSytActivityKpiData->count($where); //下单数据 $all = [ ['title' => '观看用户', 'num' => "{$all_view_count}人",'url'=>''], - ['title' => '下单用户', 'num' => "{$all_order_count}人",'url'=>''], + ['title' => '下单数', 'num' => "{$all_order_count}单",'url'=>''], ['title' => '转化率', 'num' => $all_view_count ? round($all_order_count/$all_view_count*100,2)."%" : 0], ]; }else{ @@ -274,7 +275,7 @@ class Stic extends Admin{ $a_order_count = $this->mdSytActivityKpiData->count($where); //下单数据 $area = [ ['title' => '观看用户', 'num' => "{$a_view_count}人",'url'=>""], - ['title' => '下单用户', 'num' => "{$a_order_count}人",'url'=>""], + ['title' => '下单数', 'num' => "{$a_order_count}单",'url'=>""], ['title' => '转化率', 'num' => $a_view_count ? round($a_order_count/$a_view_count*100,2)."%" : 0], ]; } @@ -317,7 +318,7 @@ class Stic extends Admin{ $m_order_count = $this->mdSytActivityKpiData->count($where); //下单数据 $mine = [ ['title' => '观看用户', 'num' => "{$m_view_count}人",'url'=>'/h5/market/sylive/stic/users?type=owner&kpi=watch&a_id='.$a_id], - ['title' => '下单用户', 'num' => "{$m_order_count}人",'url'=>'/h5/market/sylive/stic/users?type=owner&kpi=order&a_id='.$a_id], + ['title' => '下单数', 'num' => "{$m_order_count}单",'url'=>'/h5/market/sylive/stic/users?type=owner&kpi=order&a_id='.$a_id], ['title' => '转化率', 'num' => $m_view_count ? round($m_order_count/$m_view_count*100,2)."%" : 0], ]; if($biz_id){ @@ -332,7 +333,7 @@ class Stic extends Admin{ $b_order_count = $this->mdSytActivityKpiData->count($where); //下单数据 $biz = [ ['title' => '观看用户', 'num' => "{$b_view_count}人",'url'=>"/h5/market/sylive/stic/users?type=biz&type_id={$biz_id}&kpi=watch&a_id={$a_id}"], - ['title' => '下单用户', 'num' => "{$b_order_count}人",'url'=>"/h5/market/sylive/stic/users?type=biz&type_id={$biz_id}&kpi=order&a_id={$a_id}"], + ['title' => '下单数', 'num' => "{$b_order_count}单",'url'=>"/h5/market/sylive/stic/users?type=biz&type_id={$biz_id}&kpi=order&a_id={$a_id}"], ['title' => '转化率', 'num' => $b_view_count ? round($b_order_count/$b_view_count*100,2)."%" : 0], ]; } @@ -599,7 +600,7 @@ class Stic extends Admin{ public function users(){ $map_kpi_name = [ - 'browse' => '访问用户', 'subscribe' => '预约用户', 'order' => '下单用户','watch' => '观看用户' + 'browse' => '访问用户', 'subscribe' => '预约用户', 'order' => '下单数','watch' => '观看用户' ]; $params = $this->input->get(); $a_id = intval($params['a_id']);//活动id @@ -614,9 +615,18 @@ class Stic extends Admin{ if($this->group_id==2 || ($params['type']=='biz'&&$params['type_id'])){ //店长 $tab[] = ['id'=>2,'title'=>'顾问数据']; } + $goods = []; + if($params['kpi']=='order'){ + $where = [ + 'activityId' => $a_id, + 'status' => 0 + ]; + $goods = $this->market_sylive_items_model->select($where,'sort desc,itemId desc',0,0,'itemId,title'); + } $this->data['title'] = $title; $this->data['tab'] = $tab; $this->data['params'] = $params; + $this->data['goods'] = $goods; //微信分享 $wx_info = $this->share_info($row); $this->data['sign_package'] = $wx_info['sign_package']; @@ -644,6 +654,9 @@ class Stic extends Admin{ }else{ $where['cfUserId'] = $this->uid; } + if($params['kpi']=='order' && $params['itemId']){ + $where["tagId in (select id from lc_market_sylive_order where itemId={$params['itemId']} and activityId={$params['a_id']})"] = null; + } $total = $this->mdSytActivityKpiData->count($where); $lists = []; if($total){ diff --git a/home/controllers/h5/market/sylive/Tstic.php b/home/controllers/h5/market/sylive/Tstic.php index 5b7c47ec..0885894a 100644 --- a/home/controllers/h5/market/sylive/Tstic.php +++ b/home/controllers/h5/market/sylive/Tstic.php @@ -47,7 +47,7 @@ class Tstic extends Admin{ $order_count = $this->mdSytActivityKpiData->count(['activityId'=>$a_id,'kpi'=>'order','cfUserId'=>$this->uid,'type'=>1]); $info['live'] = [ ['title' => '观看用户', 'num' => "{$watch_count}人",'url' => '/h5/market/sylive/tstic/users?type=owner&kpi=watch&a_id='.$a_id], - ['title' => '下单用户', 'num' => "{$order_count}人",'url' => '/h5/market/sylive/tstic/users?type=owner&kpi=order&a_id='.$a_id], + ['title' => '下单数', 'num' => "{$order_count}单",'url' => '/h5/market/sylive/tstic/users?type=owner&kpi=order&a_id='.$a_id], ['title' => '转化率', 'num' => $watch_count ? round($order_count/$watch_count*100,2)."%" : 0], ]; $this->data['info'] = $info; @@ -229,13 +229,13 @@ class Tstic extends Admin{ $owner_order_count = $this->mdSytActivityKpiData->count($where); //下单数据 $cell4 = [ ['title' => '观看用户', 'num' => "{$owner_view_count}人",'url'=>'/h5/market/sylive/tstic/users?type=owner&kpi=watch&a_id='.$a_id], - ['title' => '下单用户', 'num' => "{$owner_order_count}人",'url'=>'/h5/market/sylive/tstic/users?type=owner&kpi=order&a_id='.$a_id], + ['title' => '下单数', 'num' => "{$owner_order_count}单",'url'=>'/h5/market/sylive/tstic/users?type=owner&kpi=order&a_id='.$a_id], ['title' => '转化率', 'num' => $owner_view_count ? round($owner_order_count/$owner_view_count*100,2)."%" : 0], ]; } $cell1 = [ ['title' => '观看用户', 'num' => "{$view_count}人",'url'=>'/h5/market/sylive/tstic/users?type=all&kpi=watch&a_id='.$a_id], - ['title' => '下单用户', 'num' => "{$order_count}人",'url'=>'/h5/market/sylive/tstic/users?type=all&kpi=order&a_id='.$a_id], + ['title' => '下单数', 'num' => "{$order_count}单",'url'=>'/h5/market/sylive/tstic/users?type=all&kpi=order&a_id='.$a_id], ['title' => '转化率', 'num' => $view_count ? round($order_count/$view_count*100,2)."%" : 0], ]; $poly_row = $this->mdPolyvSession->get(['channelId'=>$row['channelId']]); @@ -464,7 +464,7 @@ class Tstic extends Admin{ public function users(){ $map_kpi_name = [ - 'browse' => '访问用户', 'subscribe' => '预约用户', 'order' => '下单用户','watch' => '观看用户' + 'browse' => '访问用户', 'subscribe' => '预约用户', 'order' => '下单数','watch' => '观看用户' ]; $params = $this->input->get(); $a_id = intval($params['a_id']);//活动id diff --git a/home/views/h5/market/sylive/stic/users.php b/home/views/h5/market/sylive/stic/users.php index 2af02bb5..3f3870eb 100644 --- a/home/views/h5/market/sylive/stic/users.php +++ b/home/views/h5/market/sylive/stic/users.php @@ -17,6 +17,12 @@
{{item.title}}
+
+ +