From 80e68892565e4098142b7d11514b9880452d14c2 Mon Sep 17 00:00:00 2001 From: lccsw <805383944@qq.com> Date: Wed, 2 Nov 2022 15:46:21 +0800 Subject: [PATCH] edit-sql-fields --- api/controllers/plan/Syt.php | 24 +++--- common/libraries/market/Sylive_entity.php | 42 +++++++---- home/controllers/h5/market/sylive/Act.php | 52 ++++++------- home/controllers/h5/market/sylive/Biz.php | 4 +- home/controllers/h5/market/sylive/Common.php | 4 +- home/controllers/h5/market/sylive/Notify.php | 8 +- home/controllers/h5/market/sylive/Stic.php | 68 ++++++++--------- home/controllers/h5/market/sylive/Tstic.php | 78 ++++++++++---------- 8 files changed, 146 insertions(+), 134 deletions(-) diff --git a/api/controllers/plan/Syt.php b/api/controllers/plan/Syt.php index 32144c8b..63efa81d 100644 --- a/api/controllers/plan/Syt.php +++ b/api/controllers/plan/Syt.php @@ -40,7 +40,7 @@ class Syt extends CI_Controller { $this->load->model('market/market_sylive_subscribemsg_model', 'mdSytSubscribemsg'); $date = date('Y-m-d H:i:s', strtotime('+10 minute'));//提前10分钟发送 - $where['s_time<='] = $date; + $where['timeStart<='] = $date; $where['status'] = 0; $res = $this->mdSytSubscribemsg->select($where, 'id asc', 1, 200); $log = array(); @@ -53,8 +53,8 @@ class Syt extends CI_Controller if ($re_a) { $content = '您预约“' . $re_a['title'] . '”直播已经开始啦!赶紧进入直播间观看直播领取福利吧~'; $temp_arr = array( - 'touser' => $value['openid'], - 'template_id' => $value['template_id'], + 'touser' => $value['openId'], + 'template_id' => $value['templateId'], 'url' => $value['url'], 'scene' => $value['scene'], 'title' => '开播提醒', @@ -270,7 +270,7 @@ class Syt extends CI_Controller $up_data = [ 'stock = stock+1' => null ]; - $this->market_sylive_activity_model->update($up_data,['activityId'=>$val['item_id']]); + $this->market_sylive_activity_model->update($up_data,['activityId'=>$val['itemId']]); } } } @@ -293,7 +293,7 @@ class Syt extends CI_Controller $fileds = "{$t1}.*,{$t2}.activityId"; $rows = $this->db->select($fileds)->from("$t1") ->join("$t2", "{$t2}.channelId={$t1}.channelId", 'left') - ->join("$t3", "{$t3}.vlog_id={$t1}.id", 'left') + ->join("$t3", "{$t3}.vlogId={$t1}.id", 'left') ->where($where)->order_by("{$t1}.id asc")->limit($size, 0) ->get()->result_array(); if (!$rows) { @@ -302,12 +302,12 @@ class Syt extends CI_Controller foreach ($rows as $key => $value) { $ac_user = $p_user = ''; $addData = [ - 'vlog_id' => $value['id'], - 'a_id' => $value['activityId'], + 'vlogId' => $value['id'], + 'activityId' => $value['activityId'], 'playId' => $value['playId'], 'playDuration' => $value['playDuration'], 'stayDuration' => $value['stayDuration'], - 'c_time' => time() + 'createTime' => time() ]; $user = $this->user_model->get(['unionid'=>$value['param1']]); $user && $ac_user = $this->act_user_model->get(['activityId'=>$value['activityId'],'userId'=>$user['userId']]); @@ -319,17 +319,17 @@ class Syt extends CI_Controller $team_lists = $this->sylive_entity->get_team_lists($p_user['teamId']); $area_id = $team_lists[0]['teamId']; //大团长id $biz_id = $team_lists[1]['teamId']; //团长id - $addData['cf_uid'] = $p_user['userId']; + $addData['cfUserId'] = $p_user['userId']; } if($p_user['organizationId']){ $addData['type'] = 0; $team_lists = $this->sylive_entity->get_level_lists($p_user['organizationId']); $area_id = $team_lists[0]['teamId']; //大团长id $biz_id = $team_lists[1]['teamId']; //团长id - $addData['cf_uid'] = $p_user['userId']; + $addData['cfUserId'] = $p_user['userId']; } - $area_id && $addData['area_id'] = $area_id; - $biz_id && $addData['biz_id'] = $biz_id; + $area_id && $addData['areaId'] = $area_id; + $biz_id && $addData['bizId'] = $biz_id; $user && $addData['userId'] = $user['userId']; $this->market_sylive_viewlog_model->add($addData); } diff --git a/common/libraries/market/Sylive_entity.php b/common/libraries/market/Sylive_entity.php index 6addd5e2..d09a44ad 100644 --- a/common/libraries/market/Sylive_entity.php +++ b/common/libraries/market/Sylive_entity.php @@ -14,6 +14,7 @@ class Sylive_entity{ 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_activity_model'); $this->ci->load->model('market/market_sylive_activity_biz_model','mdSytActivityBiz'); $this->ci->load->model('market/market_sylive_activity_team_model','mdSytActivityTeam'); @@ -170,7 +171,7 @@ class Sylive_entity{ } } $type = $user['organizationId'] > 0 ? 0 : 1; //0门店 1团队 - $re_kpi = $this->ci->mdSytActivityKpiData->get(array("a_id" => $params['a_id'], 'uid' => $params['uid'], 'kpi' => $params['kpi'],'type'=>$type)); + $re_kpi = $this->ci->mdSytActivityKpiData->get(array("activityId" => $params['a_id'], 'userId' => $params['uid'], 'kpi' => $params['kpi'],'type'=>$type)); if ($re_kpi) {//已添加过活动kpi(访活动只记录一次用户kpi记录) return array('code' => 0, 'msg' => '已添加过' . $params['kpi'] . '记录'); } @@ -191,15 +192,15 @@ class Sylive_entity{ } //增加记录 $addData = [ - 'a_id' => $params['a_id'], - 'uid' => $params['uid'], - 'cf_uid' => $params['cf_uid'], + 'activityId' => $params['a_id'], + 'userId' => $params['uid'], + 'cfUserId' => $params['cf_uid'], 'kpi' => $params['kpi'], 'type' => $type, - 'c_time' => time() + 'createTime' => time() ]; - $area_id && $addData['area_id'] = $area_id; - $biz_id && $addData['biz_id'] = $biz_id; + $area_id && $addData['areaId'] = $area_id; + $biz_id && $addData['bizId'] = $biz_id; $jsondata = $params['jsondata'] ? $params['jsondata'] : []; $jsondata && $addData['jsondata'] = json_encode($jsondata, JSON_UNESCAPED_UNICODE); $id = $this->ci->mdSytActivityKpiData->add($addData); @@ -208,14 +209,25 @@ class Sylive_entity{ } if($this->map_kpi_biz[$params['kpi']] && $biz_id && !$addData['type']){//更新门店统计数据 $up_key = $this->map_kpi_biz[$params['kpi']]; - $update[$up_key] = $this->ci->mdSytActivityKpiData->count(['a_id'=>$params['a_id'],'biz_id'=>$biz_id,'kpi'=>$params['kpi'],'type'=>0]); + $update = [ + $up_key => $this->ci->mdSytActivityKpiData->count(['activityId'=>$params['a_id'],'bizId'=>$biz_id,'kpi'=>$params['kpi'],'type'=>0]) + ]; $this->ci->mdSytActivityBiz->update($update,['activityId'=>$params['a_id'],'bizId'=>$biz_id]); } if($this->map_kpi_biz[$params['kpi']] && $biz_id && $addData['type']) {//更新团队统计数据 $up_key = $this->map_kpi_biz[$params['kpi']]; - $update[$up_key] = $this->ci->mdSytActivityKpiData->count(['a_id'=>$params['a_id'],'biz_id'=>$biz_id,'kpi'=>$params['kpi'],'type'=>1]); + $update = [ + $up_key => $this->ci->mdSytActivityKpiData->count(['activityId'=>$params['a_id'],'bizId'=>$biz_id,'kpi'=>$params['kpi'],'type'=>1]) + ]; $this->ci->mdSytActivityTeam->update($update,['activityId'=>$params['a_id'],'teamId2'=>$biz_id]); } + if($this->map_kpi_biz[$params['kpi']] && $params['cf_uid']){ //更新活动用户表统计数据 + $up_key = $this->map_kpi_biz[$params['kpi']]; + $update = [ + $up_key => $this->ci->mdSytActivityKpiData->count(['activityId'=>$params['a_id'],'cfUserId'=>$params['cf_uid'],'kpi'=>$params['kpi'],'type'=>$type]) + ]; + $this->ci->act_user_model->update($update,['activityId'=>$params['a_id'],'userId'=>$params['cf_uid']]); + } return array('code' => 1, 'msg' => '添加记录成功'); } else { return array('code' => 0, 'msg' => '参数错误'); @@ -275,12 +287,12 @@ class Sylive_entity{ if($total){ $rows = $this->ci->user_model->select($where,'userId desc',$page,$size,'userId,uname,nickname,headimg'); $where = [ - 'a_id' => $aid, + 'activityId' => $aid, 'kpi' => $type, - 'biz_id' => $biz_id, + 'bizId' => $biz_id, 'type' => 0, ]; - $t_rows = $this->ci->mdSytActivityKpiData->select_groupby('cf_uid',$where,'total desc',$page,$size,'cf_uid,count(id) as total'); + $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) { @@ -493,12 +505,12 @@ class Sylive_entity{ if($total){ $rows = $this->ci->user_model->select($where,'userId desc',$page,$size,'userId,uname,nickname,headimg'); $where = [ - 'a_id' => $aid, + 'activityId' => $aid, 'kpi' => $type, - 'biz_id' => $teamId, + 'bizId' => $teamId, 'type' => 1, ]; - $t_rows = $this->ci->mdSytActivityKpiData->select_groupby('cf_uid',$where,'total desc',$page,$size,'cf_uid,count(id) as total'); + $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) { diff --git a/home/controllers/h5/market/sylive/Act.php b/home/controllers/h5/market/sylive/Act.php index ae765dc8..f72d7c40 100644 --- a/home/controllers/h5/market/sylive/Act.php +++ b/home/controllers/h5/market/sylive/Act.php @@ -60,7 +60,7 @@ class Act extends Wx { $info['content'] = $row['introduction']; $act_user = $this->act_user_model->get(['userId'=>$this->uid,'activityId'=>$a_id]); //一次性订阅 - $re_s = $this->mdSytSubscribemsg->get(array('a_id' => $a_id, 'uid' => $this->uid)); + $re_s = $this->mdSytSubscribemsg->get(array('activityId' => $a_id, 'userId' => $this->uid)); $is_show_code = false; //是否显示二维码 if ($re_s) { $subscribemsg = '已订阅直播'; @@ -116,7 +116,7 @@ class Act extends Wx { $info['live_url'] = "https://live.haodian.cn/watch/{$row['channelId']}?userid={$userid}&ts={$ts}&sign={$sign}"; } //判断是否支付商品 - $is_pay = $this->market_sylive_order_model->count(['item_id'=>$a_id,'status'=>1,'uid'=>$this->uid]); + $is_pay = $this->market_sylive_order_model->count(['itemId'=>$a_id,'status'=>1,'userId'=>$this->uid]); //微信分享 $wx_info = $this->share_info($row); $info['is_pay'] = $is_pay ? 1 : 0; @@ -136,10 +136,10 @@ class Act extends Wx { ]; $a_id = $this->input->get('a_id'); $live_status = $this->input->get('live_status'); - $field = 'uid,c_time,kpi'; + $field = 'userId,createTime,kpi'; $lists = []; $where = [ - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'subscribe' ]; if($live_status){ @@ -148,7 +148,7 @@ class Act extends Wx { $rows = $this->mdSytActivityKpiData->select($where,'id desc',1,30,$field); if($rows){ $users = []; - $uids = implode(',',array_unique(array_column($rows,'uid'))); + $uids = implode(',',array_unique(array_column($rows,'userId'))); if($uids){ $where = [ "userId in ($uids)" => null, @@ -156,7 +156,7 @@ class Act extends Wx { $users = $this->user_model->map('userId','nickname',$where,'','','','userId,nickname'); } foreach ($rows as $item) { - $nickname = $users[$item['uid']] ? $users[$item['uid']] : "用户{$item['uid']}"; + $nickname = $users[$item['userId']] ? $users[$item['userId']] : "用户{$item['userId']}"; $lists[] = [ 'name' => $nickname, 'tip' => $map_kpi_name[$item['kpi']], @@ -181,16 +181,16 @@ class Act extends Wx { $action = $this->input->get('action'); $show_code = 0; if ($s_time && $action == "confirm") { - $add_data['a_id'] = $a_id; - $add_data['openid'] = $this->input->get('openid'); + $add_data['activityId'] = $a_id; + $add_data['openId'] = $this->input->get('openid'); $add_data['scene'] = $this->input->get('scene'); $re_s = $this->mdSytSubscribemsg->get($add_data); if (!$re_s) { - $add_data['uid'] = $this->uid; - $add_data['template_id'] = $this->input->get('template_id'); + $add_data['userId'] = $this->uid; + $add_data['templateId'] = $this->input->get('template_id'); $add_data['url'] = http_host_com('home') . "/h5/market/sylive/act?skey=" . $this->myencryption->base64url_encode("a_id=" . $a_id);; - $add_data['s_time'] = $s_time; - $add_data['c_time'] = time(); + $add_data['timeStart'] = $s_time; + $add_data['createTime'] = time(); $add_data['status'] = 0; $id = $this->mdSytSubscribemsg->add($add_data); if ($id) { @@ -293,7 +293,7 @@ class Act extends Wx { } $jsondata = json_decode($row['jsondata'],true); $item = $jsondata['item'] ? $jsondata['item'] : []; - $is_pay = $this->market_sylive_order_model->count(['item_id'=>$a_id,'status'=>1,'uid'=>$this->uid]); + $is_pay = $this->market_sylive_order_model->count(['itemId'=>$a_id,'status'=>1,'userId'=>$this->uid]); if($is_pay){ $url = http_host_com('home').'/h5/market/sylive/act/ucenter?skey='.$skey; redirect($url);exit; @@ -346,7 +346,7 @@ class Act extends Wx { $jsondata = json_decode($row['jsondata'],true); $item = $jsondata['item'] ? $jsondata['item'] : []; //判断是否已支付 - $o_row = $this->market_sylive_order_model->get(['item_id'=>$a_id,'status'=>1,'uid'=>$this->uid]); + $o_row = $this->market_sylive_order_model->get(['itemId'=>$a_id,'status'=>1,'userId'=>$this->uid]); if($o_row){ $this->show_json('',400,'已支付,请勿重复支付'); } @@ -357,7 +357,7 @@ class Act extends Wx { if($row['stock']<=0){ $this->show_json('',400,'已售罄'); } - $unpay = $this->market_sylive_order_model->get(['item_id'=>$a_id,'status'=>0,'uid'=>$this->uid,'expire_time>'=>time()]); + $unpay = $this->market_sylive_order_model->get(['itemId'=>$a_id,'status'=>0,'userId'=>$this->uid,'expireTime>'=>time()]); if(!$unpay){ $mb_count = $redis_obj->sCard($mb_key); //获取集合中用户数量 if($mb_count && $mb_count>$row['stock']+10){ @@ -365,27 +365,27 @@ class Act extends Wx { $this->show_json('',400,'已售罄:'.json_encode($mb,JSON_UNESCAPED_UNICODE)); } try { + $act_user = $this->act_user_model->get(['userId'=>$this->uid,'activityId'=>$a_id]); + $p_user = []; + $act_user['channelId'] && $p_user = $this->user_model->get(['userId'=>$act_user['channelId']]); $this->market_sylive_order_model->db->trans_begin(); //限购一件 - $u_row = $this->market_sylive_order_model->get(['item_id'=>$a_id,'status>='=>0,'uid'=>$this->uid]); + $u_row = $this->market_sylive_order_model->get(['itemId'=>$a_id,'status>='=>0,'userId'=>$this->uid]); if($u_row){ throw new Exception('限购一件'); } $this->load->helper('order'); $unpay = [ 'sid' => create_order_no('350200','market'), - 'uid' => $this->uid, - 'item_id' => $a_id, - 'item_title' => $item['title'], - 'total_price' => $pay_price, - 'expire_time' => time()+5*60,//订单过期时间 + 'userId' => $this->uid, + 'itemId' => $a_id, + 'itemTitle' => $item['title'], + 'totalPrice' => $pay_price, + 'expireTime' => time()+5*60,//订单过期时间 'createTime' => date('Y-m-d H:i:s') ]; $name && $unpay['uname'] = $name; $mobile && $unpay['mobile'] = $mobile; - $act_user = $this->act_user_model->get(['userId'=>$this->uid,'activityId'=>$a_id]); - $p_user = []; - $act_user['channelId'] && $p_user = $this->user_model->get(['userId'=>$act_user['channelId']]); $p_user['teamId'] && $unpay['cfrom'] = 1; $oid = $this->market_sylive_order_model->add($unpay); if(!is_numeric($oid)){ @@ -407,7 +407,7 @@ class Act extends Wx { } $user = $this->user_model->get(['userId'=>$this->uid]); $notify_url = http_host_com('home').'/h5/market/sylive/notify'; - $result = $this->unorder($unpay['sid'],$unpay['total_price'],$user['openid'],$unpay['item_title'],$notify_url,$unpay['expire_time'],['wx_type'=>'dc']); + $result = $this->unorder($unpay['sid'],$unpay['totalPrice'],$user['openid'],$unpay['itemTitle'],$notify_url,$unpay['expireTime'],['wx_type'=>'dc']); if(!$result['code']){ $this->show_json('',400,$result['msg']); } @@ -421,7 +421,7 @@ class Act extends Wx { if(!$row){ throw new Hd_exception('参数错误',400); } - $order = $this->market_sylive_order_model->get(['uid'=>$this->uid,'status'=>1,'item_id'=>$a_id]); + $order = $this->market_sylive_order_model->get(['userId'=>$this->uid,'status'=>1,'itemId'=>$a_id]); if(!$order){ $url = http_host_com('home').'/h5/market/sylive/act/item?skey='.$skey; redirect($url);exit; diff --git a/home/controllers/h5/market/sylive/Biz.php b/home/controllers/h5/market/sylive/Biz.php index e781641b..860f115e 100644 --- a/home/controllers/h5/market/sylive/Biz.php +++ b/home/controllers/h5/market/sylive/Biz.php @@ -105,7 +105,7 @@ class Biz extends Admin { $count_live = $this->market_sylive_activity_model->count($where); $where = [ 'kpi' => 'order', - "area_id" => $area_id, + "areaId" => $area_id, 'type' => 0 ]; $count_order = $this->mdSytActivityKpiData->count($where); @@ -136,7 +136,7 @@ class Biz extends Admin { $where = [ 'type' => 0, 'kpi' => 'order', - " area_id in (select organizationId from lc_market_sylive_organization where parentId={$this->session['org_id']} and status=0)" => null + " areaId in (select organizationId from lc_market_sylive_organization where parentId={$this->session['org_id']} and status=0)" => null ]; $count_order = $this->mdSytActivityKpiData->count($where); $count = [ diff --git a/home/controllers/h5/market/sylive/Common.php b/home/controllers/h5/market/sylive/Common.php index 11f4077c..ea06d96d 100644 --- a/home/controllers/h5/market/sylive/Common.php +++ b/home/controllers/h5/market/sylive/Common.php @@ -207,7 +207,7 @@ class Wx extends Common{ public function _remap($method){ try{ - if($this->act_uid){ + if(!$this->act_uid){ $this->session = $this->uid = ''; } if(!in_array($method,$this->white_login_method) && !$this->uid){ @@ -254,7 +254,7 @@ class Wx extends Common{ } $act_user['id'] = $this->act_user_model->add($act_data); } - $_SESSION[self::SESSION_KEY] = ['uid' => $this->uid,'org_id'=>$row_wechat['organizationId'],'teamId'=>$row_wechat['teamId'],'act_id'=>$act_user['id']]; + $_SESSION[self::SESSION_KEY] = ['uid' => $this->uid,'org_id'=>$row_wechat['organizationId'],'teamId'=>$row_wechat['teamId'],'act_uid'=>$act_user['id']]; echo ("");exit; } return $this->$method(); diff --git a/home/controllers/h5/market/sylive/Notify.php b/home/controllers/h5/market/sylive/Notify.php index 3c1cd8c9..3f1c31b3 100644 --- a/home/controllers/h5/market/sylive/Notify.php +++ b/home/controllers/h5/market/sylive/Notify.php @@ -52,12 +52,12 @@ class Notify extends CI_Controller { if($this->notify['result_code'] != 'SUCCESS'){ //支付失败 throw new Exception("支付失败,sid={$sid}"); }else{ //支付成功 - $res = $this->order_model->update(['status'=>1,'pay_time'=>date('Y-m-d H:i:s')],['id'=>$order['id']]); + $res = $this->order_model->update(['status'=>1,'payTime'=>date('Y-m-d H:i:s')],['id'=>$order['id']]); if($res){ - $act_user = $this->act_user_model->get(['userId'=>$order['uid'],'activityId'=>$order['item_id']]); + $act_user = $this->act_user_model->get(['userId'=>$order['uid'],'activityId'=>$order['itemId']]); $params = [ - 'a_id' => $order['item_id'], - 'uid' => $order['uid'], + 'a_id' => $order['itemId'], + 'uid' => $order['userId'], 'cf_uid' => $act_user['channelId'], 'kpi' => 'order', 'jsondata'=> ['order_id'=>$order['id'],'sid'=>$sid] diff --git a/home/controllers/h5/market/sylive/Stic.php b/home/controllers/h5/market/sylive/Stic.php index 4b551a6a..404b7698 100644 --- a/home/controllers/h5/market/sylive/Stic.php +++ b/home/controllers/h5/market/sylive/Stic.php @@ -34,15 +34,15 @@ class Stic extends Admin{ $this->data['sign_package'] = $wx_info['sign_package']; $this->data['share'] = $wx_info['share']; if($this->group_id==3){ //顾问 - $browse_count = $this->mdSytActivityKpiData->count(['a_id'=>$a_id,'kpi'=>'browse','cf_uid'=>$this->uid,'type'=>0]); - $subscribe_count = $this->mdSytActivityKpiData->count(['a_id'=>$a_id,'kpi'=>'subscribe','cf_uid'=>$this->uid,'type'=>0]); + $browse_count = $this->mdSytActivityKpiData->count(['activityId'=>$a_id,'kpi'=>'browse','cfUserId'=>$this->uid,'type'=>0]); + $subscribe_count = $this->mdSytActivityKpiData->count(['activityId'=>$a_id,'kpi'=>'subscribe','cfUserId'=>$this->uid,'type'=>0]); $info['begin'] = [ ['title' => '访问用户', 'num' => "{$browse_count}人",'url'=>'/h5/market/sylive/stic/users?type=owner&kpi=browse&a_id='.$a_id], ['title' => '预约用户', 'num' => "{$subscribe_count}人",'url'=>'/h5/market/sylive/stic/users?type=owner&kpi=subscribe&a_id='.$a_id], ['title' => '预约率', 'num' => $browse_count ? round($subscribe_count/$browse_count*100,2)."%" : 0], ]; - $watch_count = $this->mdSytActivityKpiData->count(['a_id'=>$a_id,'kpi'=>'watch','cf_uid'=>$this->uid,'type'=>0]); - $order_count = $this->mdSytActivityKpiData->count(['a_id'=>$a_id,'kpi'=>'order','cf_uid'=>$this->uid,'type'=>0]); + $watch_count = $this->mdSytActivityKpiData->count(['activityId'=>$a_id,'kpi'=>'watch','cfUserId'=>$this->uid,'type'=>0]); + $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], @@ -101,7 +101,7 @@ class Stic extends Admin{ ]; $where = [ 'type' => 0, - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'browse', ]; $all_browse_count = $this->mdSytActivityKpiData->count($where); //浏览数据 @@ -118,10 +118,10 @@ class Stic extends Admin{ if($area_id){ $where = [ 'type' => 0, - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'browse', ]; - $where['area_id'] = $area_id; + $where['areaId'] = $area_id; $a_browse_count = $this->mdSytActivityKpiData->count($where); //浏览数据 $where['kpi'] = 'subscribe'; $a_subscribe_count = $this->mdSytActivityKpiData->count($where); //订阅数据 @@ -135,9 +135,9 @@ class Stic extends Admin{ $biz_id = $this->session['org_id']; } $where = [ - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'browse', - 'cf_uid' => $this->uid, + 'cfUserId' => $this->uid, 'type' => 0 ]; $owner_browse_count = $this->mdSytActivityKpiData->count($where); //浏览数据 @@ -151,9 +151,9 @@ class Stic extends Admin{ if($biz_id){ $where = [ 'type' => 0, - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'browse', - 'biz_id' => $biz_id + 'bizId' => $biz_id ]; $b_browse_count = $this->mdSytActivityKpiData->count($where); //浏览数据 $where['kpi'] = 'subscribe'; @@ -223,7 +223,7 @@ class Stic extends Admin{ ]; $where = [ 'type' => 0, - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'watch', ]; $all_view_count = $this->mdSytActivityKpiData->count($where); //观看数据 @@ -240,10 +240,10 @@ class Stic extends Admin{ if($area_id){ $where = [ 'type' => 0, - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'watch', ]; - $where['area_id'] = $area_id; + $where['areaId'] = $area_id; $a_view_count = $this->mdSytActivityKpiData->count($where); //观看数据 $where['kpi'] = 'order'; $a_order_count = $this->mdSytActivityKpiData->count($where); //下单数据 @@ -270,9 +270,9 @@ class Stic extends Admin{ } $where = [ 'type' => 0, - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'watch', - 'cf_uid' => $this->uid, + 'cfUserId' => $this->uid, ]; $m_view_count = $this->mdSytActivityKpiData->count($where); //观看数据 $where['kpi'] = 'order'; @@ -285,9 +285,9 @@ class Stic extends Admin{ if($biz_id){ $where = [ 'type' => 0, - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'watch', - 'biz_id' => $biz_id + 'bizId' => $biz_id ]; $b_view_count = $this->mdSytActivityKpiData->count($where); //观看数据 $where['kpi'] = 'order'; @@ -385,8 +385,8 @@ class Stic extends Admin{ $a_id = intval($param['a_id']);//活动id $row = $this->market_sylive_activity_model->get(['activityId'=>$a_id]); $where = [ - 'a_id'=>$a_id, - 'cf_uid'=>$this->uid, + 'activityId'=>$a_id, + 'cfUserId'=>$this->uid, 'type' => 0, ]; if($type==1){ //预热 @@ -397,9 +397,9 @@ class Stic extends Admin{ $total = $this->mdSytActivityKpiData->count($where); $lists = []; if($total){ - $rows = $this->mdSytActivityKpiData->select($where,'id desc',$page,10,'uid,kpi,c_time'); + $rows = $this->mdSytActivityKpiData->select($where,'id desc',$page,10,'userId,kpi,createTime'); $users = []; - $uids = implode(',',array_unique(array_column($rows,'uid'))); + $uids = implode(',',array_unique(array_column($rows,'userId'))); if($uids){ $where = [ "userId in ($uids)" => null, @@ -407,11 +407,11 @@ class Stic extends Admin{ $users = $this->user_model->map('userId','nickname',$where,'','','','userId,nickname'); } foreach ($rows as $key => $val) { - $nickname = $users[$val['uid']] ? $users[$val['uid']] : "用户{$val['uid']}"; + $nickname = $users[$val['userId']] ? $users[$val['userId']] : "用户{$val['userId']}"; $lists[] = [ 'nickname' => $nickname, 'action' => $map_kpi_name[$val['kpi']], - 'time' => friendly_date($val['c_time']), + 'time' => friendly_date($val['createTime']), ]; } } @@ -492,25 +492,25 @@ class Stic extends Admin{ $page = $params['page'] ? intval($params['page']) : 1; $where = [ 'type' => 0, - 'a_id' => $params['a_id'], + 'activityId' => $params['a_id'], 'kpi' => $params['kpi'], ]; if($params['type']=='all'){ }elseif($params['type']=='area'){ - $where['area_id'] = $params['type_id']; + $where['areaId'] = $params['type_id']; }elseif($params['type']=='biz'){ - $where['biz_id'] = $params['type_id']; + $where['bizId'] = $params['type_id']; }else{ - $where['cf_uid'] = $this->uid; + $where['cfUserId'] = $this->uid; } $total = $this->mdSytActivityKpiData->count($where); $lists = []; if($total){ - $rows = $this->mdSytActivityKpiData->select($where,'id desc',$page,20,'uid,cf_uid,c_time,jsondata'); - $uids_arr = array_column($rows,'uid'); + $rows = $this->mdSytActivityKpiData->select($where,'id desc',$page,20,'userId,cfUserId,createTime,jsondata'); + $uids_arr = array_column($rows,'userId'); if($this->group_id==2){ - $gw_uids_arr = array_column($rows,'cf_uid'); + $gw_uids_arr = array_column($rows,'cfUserId'); $uids_arr = array_merge($uids_arr,$gw_uids_arr); } $uids = implode(',',array_unique($uids_arr)); @@ -523,12 +523,12 @@ class Stic extends Admin{ } foreach ($rows as $key => $item) { $jsondata = json_decode($item['jsondata'],true); - $user = $users[$item['uid']] ? $users[$item['uid']][0] : []; + $user = $users[$item['userId']] ? $users[$item['userId']][0] : []; $nickname = $user['nickname'] ? $user['nickname'] : '用户'.$user['userId']; $headimg = $user['headimg'] ? $user['headimg'] : 'https://thirdwx.qlogo.cn/mmopen/vi_32/Q3auHgzwzM483tlYWFg5RWQ1Xat94ib82prnDSicm2GHuxI49swU08N2I1aHb7B1gmicyxXF8R1BsVWahU9SiaPEzA/132'; $cf_uname = ''; if($this->group_id==2){ //店长 - $cf_user = $users[$item['cf_uid']] ? $users[$item['cf_uid']][0] : []; + $cf_user = $users[$item['cfUserId']] ? $users[$item['cfUserId']][0] : []; $cf_uname = $cf_user['uname'] ? $cf_user['uname'] : ""; } $mobile = $name = ''; @@ -543,7 +543,7 @@ class Stic extends Admin{ 'mobile' => $mobile, 'headimg' => $headimg, 'cf_uname' => $cf_uname, - 'time' => friendly_date($item['c_time'],'normal',1) + 'time' => friendly_date($item['createTime'],'normal',1) ]; } } diff --git a/home/controllers/h5/market/sylive/Tstic.php b/home/controllers/h5/market/sylive/Tstic.php index a0dd5df0..7d7e777b 100644 --- a/home/controllers/h5/market/sylive/Tstic.php +++ b/home/controllers/h5/market/sylive/Tstic.php @@ -35,15 +35,15 @@ class Tstic extends Admin{ $this->data['sign_package'] = $wx_info['sign_package']; $this->data['share'] = $wx_info['share']; if($this->teamLevel==2){ //团员 - $browse_count = $this->mdSytActivityKpiData->count(['a_id'=>$a_id,'kpi'=>'browse','cf_uid'=>$this->uid,'type'=>1]); - $subscribe_count = $this->mdSytActivityKpiData->count(['a_id'=>$a_id,'kpi'=>'subscribe','cf_uid'=>$this->uid,'type'=>1]); + $browse_count = $this->mdSytActivityKpiData->count(['activityId'=>$a_id,'kpi'=>'browse','cfUserId'=>$this->uid,'type'=>1]); + $subscribe_count = $this->mdSytActivityKpiData->count(['activityId'=>$a_id,'kpi'=>'subscribe','cfUserId'=>$this->uid,'type'=>1]); $info['begin'] = [ ['title' => '访问用户', 'num' => "{$browse_count}人",'url'=>'/h5/market/sylive/tstic/users?type=owner&kpi=browse&a_id='.$a_id], ['title' => '预约用户', 'num' => "{$subscribe_count}人",'url'=>'/h5/market/sylive/tstic/users?type=owner&kpi=subscribe&a_id='.$a_id], ['title' => '预约率', 'num' => $browse_count ? round($subscribe_count/$browse_count*100,2)."%" : 0], ]; - $watch_count = $this->mdSytActivityKpiData->count(['a_id'=>$a_id,'kpi'=>'watch','cf_uid'=>$this->uid,'type'=>1]); - $order_count = $this->mdSytActivityKpiData->count(['a_id'=>$a_id,'kpi'=>'order','cf_uid'=>$this->uid,'type'=>1]); + $watch_count = $this->mdSytActivityKpiData->count(['activityId'=>$a_id,'kpi'=>'watch','cfUserId'=>$this->uid,'type'=>1]); + $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], @@ -69,18 +69,18 @@ class Tstic extends Admin{ if(!$this->teamLevel){ //大团长 $where = [ 'type' => 1, - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'browse', - 'area_id' => $this->session['teamId'] + 'areaId' => $this->session['teamId'] ]; $browse_count = $this->mdSytActivityKpiData->count($where); //浏览数据 $where['kpi'] = 'subscribe'; $subscribe_count = $this->mdSytActivityKpiData->count($where); //预约用户 $where = [ 'type' => 1, - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'browse', - 'biz_id' => $this->uid + 'bizId' => $this->uid ]; $owner_browse_count = $this->mdSytActivityKpiData->count($where); //浏览数据 $where['kpi'] = 'subscribe'; @@ -93,17 +93,17 @@ class Tstic extends Admin{ }else{ //团长 $where = [ 'type' => 1, - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'browse', - 'biz_id' => $this->session['teamId'], + 'bizId' => $this->session['teamId'], ]; $browse_count = $this->mdSytActivityKpiData->count($where); //浏览数据 $where['kpi'] = 'subscribe'; $subscribe_count = $this->mdSytActivityKpiData->count($where); //浏览数据 $where = [ - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'browse', - 'cf_uid' => $this->uid, + 'cfUserId' => $this->uid, 'type' => 1 ]; $owner_browse_count = $this->mdSytActivityKpiData->count($where); //浏览数据 @@ -161,9 +161,9 @@ class Tstic extends Admin{ if(!$this->teamLevel){ //大团长 $where = [ 'type' => 1, - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'watch', - 'area_id' => $this->session['teamId'] + 'areaId' => $this->session['teamId'] ]; $view_count = $this->mdSytActivityKpiData->count($where); //浏览数据 $where['kpi'] = 'order'; @@ -171,17 +171,17 @@ class Tstic extends Admin{ }else{ //团长 $where = [ 'type' => 1, - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'watch', - 'biz_id' => $this->session['teamId'], + 'bizId' => $this->session['teamId'], ]; $view_count = $this->mdSytActivityKpiData->count($where); //观看数据 $where['kpi'] = 'order'; $order_count = $this->mdSytActivityKpiData->count($where); //下单数据 // $where = [ // 'type' => 1, -// 'a_id' => $a_id, -// 'biz_id' => $this->session['teamId'], +// 'activityId' => $a_id, +// 'bizId' => $this->session['teamId'], // ]; // $view_num_lists = $this->sylive_entity->top_team_view_num($where,1,10); // $view_num = [ @@ -197,9 +197,9 @@ class Tstic extends Admin{ // ]; $where = [ 'type' => 1, - 'a_id' => $a_id, + 'activityId' => $a_id, 'kpi' => 'watch', - 'cf_uid' => $this->uid + 'cfUserId' => $this->uid ]; $owner_view_count = $this->mdSytActivityKpiData->count($where); //观看数据 $where['kpi'] = 'order'; @@ -304,8 +304,8 @@ class Tstic extends Admin{ $row = $this->market_sylive_activity_model->get(['activityId'=>$a_id]); $where = [ 'type' => 1, - 'a_id'=>$a_id, - 'cf_uid'=>$this->uid + 'activityId'=>$a_id, + 'cfUserId'=>$this->uid ]; if($type==1){ //预热 $where['c_time<='] = strtotime($row['timeStart']); @@ -315,9 +315,9 @@ class Tstic extends Admin{ $total = $this->mdSytActivityKpiData->count($where); $lists = []; if($total){ - $rows = $this->mdSytActivityKpiData->select($where,'id desc',$page,10,'uid,kpi,c_time'); + $rows = $this->mdSytActivityKpiData->select($where,'id desc',$page,10,'userId,kpi,createTime'); $users = []; - $uids = implode(',',array_unique(array_column($rows,'uid'))); + $uids = implode(',',array_unique(array_column($rows,'userId'))); if($uids){ $where = [ "userId in ($uids)" => null, @@ -325,11 +325,11 @@ class Tstic extends Admin{ $users = $this->user_model->map('userId','nickname',$where,'','','','userId,nickname'); } foreach ($rows as $key => $val) { - $nickname = $users[$val['uid']] ? $users[$val['uid']] : "用户{$val['uid']}"; + $nickname = $users[$val['userId']] ? $users[$val['userId']] : "用户{$val['userId']}"; $lists[] = [ 'nickname' => $nickname, 'action' => $map_kpi_name[$val['kpi']], - 'time' => friendly_date($val['c_time']), + 'time' => friendly_date($val['createTime']), ]; } } @@ -368,9 +368,9 @@ class Tstic extends Admin{ 'list' => $order_rows['lists'] ]; // $where = [ -// 'a_id' => $a_id, +// 'activityId' => $a_id, // 'type' => 1, -// 'biz_id' => $teamId, +// 'bizId' => $teamId, // ]; // $view_num_lists = $this->sylive_entity->top_team_view_num($where,1,10); // $data['view_num'] = [ @@ -422,27 +422,27 @@ class Tstic extends Admin{ $page = $params['page'] ? intval($params['page']) : 1; $where = [ 'type' => 1, - 'a_id' => $params['a_id'], + 'activityId' => $params['a_id'], 'kpi' => $params['kpi'], ]; if($params['type']=='all' && $this->teamLevel<2){ //所有 if(!$this->teamLevel){ //大团长 - $where["area_id"] = $this->session['teamId']; + $where["areaId"] = $this->session['teamId']; }elseif($this->teamLevel==1){ //团长 - $where["biz_id"] = $this->session['teamId']; + $where["bizId"] = $this->session['teamId']; }else{ //团员 - $where['cf_uid'] = $this->uid; + $where['cfUserId'] = $this->uid; } }else{ //只显示个人 - $where['cf_uid'] = $this->uid; + $where['cfUserId'] = $this->uid; } $total = $this->mdSytActivityKpiData->count($where); $lists = []; if($total){ - $rows = $this->mdSytActivityKpiData->select($where,'id desc',$page,20,'uid,cf_uid,c_time'); - $uids_arr = array_column($rows,'uid'); + $rows = $this->mdSytActivityKpiData->select($where,'id desc',$page,20,'userId,cfUserId,createTime'); + $uids_arr = array_column($rows,'userId'); if($this->teamLevel==1){ - $gw_uids_arr = array_column($rows,'cf_uid'); + $gw_uids_arr = array_column($rows,'cfUserId'); $uids_arr = array_merge($uids_arr,$gw_uids_arr); } $uids = implode(',',array_unique($uids_arr)); @@ -454,18 +454,18 @@ class Tstic extends Admin{ $users = $this->user_model->map('userId','',$where,'','','','userId,uname,nickname,headimg'); } foreach ($rows as $key => $item) { - $user = $users[$item['uid']] ? $users[$item['uid']][0] : []; + $user = $users[$item['userId']] ? $users[$item['userId']][0] : []; $nickname = $user['nickname'] ? $user['nickname'] : '用户'.$user['userId']; $headimg = $user['headimg'] ? $user['headimg'] : 'https://thirdwx.qlogo.cn/mmopen/vi_32/Q3auHgzwzM483tlYWFg5RWQ1Xat94ib82prnDSicm2GHuxI49swU08N2I1aHb7B1gmicyxXF8R1BsVWahU9SiaPEzA/132'; $cf_uname = ''; if($this->teamLevel==1){ //团长 - $cf_user = $users[$item['cf_uid']] ? $users[$item['cf_uid']][0] : []; + $cf_user = $users[$item['cfUserId']] ? $users[$item['cfUserId']][0] : []; $cf_user['uname'] && '('.name_asterisk($cf_user['uname']).')'; } $lists[] = [ 'nickname' => $nickname, 'headimg' => $headimg, - 'time' => $cf_uname.friendly_date($item['c_time'],'normal',1) + 'time' => $cf_uname.friendly_date($item['createTime'],'normal',1) ]; } }