diff --git a/admin/controllers/sys/Vlog.php b/admin/controllers/sys/Vlog.php new file mode 100644 index 00000000..c89beb7e --- /dev/null +++ b/admin/controllers/sys/Vlog.php @@ -0,0 +1,100 @@ +load->model('biz/biz_visit_log_model'); + $this->load->model('biz/biz_model'); + $this->load->model("sys/sys_admin_model"); + } + + public function index() + { + return $this->lists(); + } + + public function lists() + { + $params = $this->input->get(); + $page = $this->input->get('page'); + + !$page && $page = 1; + $pageSize = 20; + $where = []; + if ($params['user_name']) { + $uids = 0; + $userList = $this->sys_admin_model->select(["username like '%{$params['user_name']}%'" => null], '', '', '', 'id,username'); + if ($userList) { + $uids = implode(',', array_column($userList, 'id')); + } + $where["uid in ($uids)"] = null; + } + if ($params['biz_name']) { + $bizs = 0; + $bizList = $this->biz_model->select(["biz_name like '%{$params['biz_name']}%'" => null], '', '', '', 'id,biz_name'); + if ($bizList) { + $bizs = implode(',', array_column($bizList, 'id')); + } + $where["biz_id in ($bizs)"] = null; + } + if ($params['c_time']) { + $c_time = explode(' ~ ', $params['c_time']); + $c_time[0] && $where["createTime >="] = $c_time[0] . ' 00:00:00'; + $c_time[1] && $where["createTime <="] = $c_time[1] . ' 23:59:59'; + } + $rows = $this->biz_visit_log_model->select($where, 'id desc', $page, $pageSize); + $count = $this->biz_visit_log_model->count($where); + $list = []; + if ($rows) { + $bizIds = implode(',', array_unique(array_column($rows, 'biz_id'))); + !$bizIds && $bizIds = 0; + $bizs = $this->biz_model->map('id', 'biz_name', ["id in ({$bizIds})" => null]); + + $userIds = implode(',', array_unique(array_column($rows, 'uid'))); + !$userIds && $userIds = 0; + $users = $this->sys_admin_model->map('id', 'username', ["id in ({$userIds})" => null]); + foreach ($rows as $v) { + $v['url'] = explode('?', $v['url'])[0]; + $v['biz_name'] = $bizs[$v['biz_id']] ?: ''; + $v['username'] = $users[$v['uid']] ?: ''; + $list[] = $v; + } + } + $this->data['params'] = $params; + $this->data['lists'] = $list; + $this->data['_title'] = '小程序访问日志'; + $this->data['pager'] = array('count' => ceil($count / $pageSize), 'curr' => $page, 'totle' => $count); + $this->show_view('sys/vlog/lists', true); + } + + public function add() + { + } + + public function get() + { + + } + + public function edit() + { + } + + public function batch() + { + + } + + public function export() + { + + } + + public function del() + { + + } +} diff --git a/admin/views/sys/vlog/lists.php b/admin/views/sys/vlog/lists.php new file mode 100644 index 00000000..e0d9c964 --- /dev/null +++ b/admin/views/sys/vlog/lists.php @@ -0,0 +1,135 @@ + +
+ + +
+
共有条数据
+ + + + + + + + + + + + + +
门店用户名称访问接口访问时间
+
+
+
+
+
+ +
+
+ +
+ diff --git a/api/controllers/plan/Licheb.php b/api/controllers/plan/Licheb.php index f89e89bd..049b12b8 100644 --- a/api/controllers/plan/Licheb.php +++ b/api/controllers/plan/Licheb.php @@ -15,6 +15,7 @@ class Licheb extends HD_Controller $this->log_file = 'licheb.log'; $this->load->model('receiver/receiver_customers_model', 'mdCustomers'); $this->load->model("biz/biz_model", 'mdBiz'); + $this->load->model('biz/biz_visit_log_model'); } /** @@ -232,7 +233,7 @@ class Licheb extends HD_Controller if ($visit_count) {//发送短信 // b2m_send_sms($value['mobile'], '【好店云】您好,今天共有 '.$visit_count.' 个客户需要回访,客户线索来之不易,请及时跟进~'); - ems_sms($value['mobile'], '您好,今天共有 '.$visit_count.' 个客户需要回访,客户线索来之不易,请及时跟进~ '); + ems_sms($value['mobile'], '您好,今天共有 ' . $visit_count . ' 个客户需要回访,客户线索来之不易,请及时跟进~ '); $log[] = array('id' => $id, 'mobile' => $value['mobile'], 'count' => $visit_count); } } @@ -295,16 +296,16 @@ class Licheb extends HD_Controller if ($biz_id == '1') { continue; } - $bizRow = $this->mdBiz->get(['id'=>$biz_id]); + $bizRow = $this->mdBiz->get(['id' => $biz_id]); $where_c = array("biz_id in ($biz_id)" => null, 'status' => 0, 'admin_id' => 0); - if($bizRow['type']==Biz_model::BIZ_TYPE_4s){ + if ($bizRow['type'] == Biz_model::BIZ_TYPE_4s) { $where_c['un_lock'] = 1; } $Customers_count = $this->mdCustomers->count($where_c); if ($Customers_count) { //发送短信 // b2m_send_sms($value['mobile'], '【好店云】您好,门店有 '.$Customers_count.' 个客户线索尚未分配。请及时到小程序"理车宝-待分配客户”分配给销售顾问跟进。祝您生活愉快!'); - ems_sms($value['mobile'], '您好,门店有 '.$Customers_count.' 个客户线索尚未分配。请及时到小程序"理车宝-待分配客户”分配给销售顾问跟进。祝您生活愉快!'); + ems_sms($value['mobile'], '您好,门店有 ' . $Customers_count . ' 个客户线索尚未分配。请及时到小程序"理车宝-待分配客户”分配给销售顾问跟进。祝您生活愉快!'); $log[] = array('id' => $id, 'mobile' => $value['mobile'], 'count' => $Customers_count); } } @@ -320,4 +321,13 @@ class Licheb extends HD_Controller echo json_encode($res_u, JSON_UNESCAPED_UNICODE); } } + + /** + * 访问日志入库 + * @return void + */ + public function log_add() + { + $this->biz_visit_log_model->popQueue(); + } } \ No newline at end of file diff --git a/api/controllers/plan/Plan.php b/api/controllers/plan/Plan.php index 54ef78a0..88b3bf37 100644 --- a/api/controllers/plan/Plan.php +++ b/api/controllers/plan/Plan.php @@ -28,6 +28,7 @@ class Plan extends CI_Controller $plan[] = array('url' => base_url(array('plan', 'licheb', 'visit_sales')), 'interval' => 3);//客户回访顾问统计 $plan[] = array('url' => base_url(array('plan', 'licheb', 'visit_sales_sms')), 'interval' => 2);//给销售发送待回访短信 $plan[] = array('url' => base_url(array('plan', 'licheb', 'customer_manager_sms')), 'interval' => 2);//给店长发送待分配短信 + $plan[] = array('url' => base_url(array('plan', 'licheb', 'log_add')), 'interval' => 1);//小程序访问日志 $plan[] = array('url' => base_url(array('plan', 'yxcall', 'down_video')), 'interval' => 5); //下载录音文件 //$plan[] = array('url' => base_url(array('plan', 'licheb', 'users_log')), 'interval' => 2);//顾问日志 //$plan[] = array('url' => base_url(array('plan', 'licheb', 'bizs_log')), 'interval' => 2);//门店日志 diff --git a/api/controllers/wxapp/licheb/Cusorder.php b/api/controllers/wxapp/licheb/Cusorder.php index 53ec7567..f6838561 100644 --- a/api/controllers/wxapp/licheb/Cusorder.php +++ b/api/controllers/wxapp/licheb/Cusorder.php @@ -30,6 +30,7 @@ class Cusorder extends Wxapp $this->load->model('app/licheb/app_licheb_users_model', 'app_user_model'); $this->load->model("biz/biz_model"); + $this->load->model('biz/biz_visit_log_model'); $this->load->library('receiver/customers_entity'); $this->load->library('receiver/orders_entity'); @@ -541,6 +542,13 @@ class Cusorder extends Wxapp 'list' => $lists, 'total' => $count ]; + //增加埋点 + $logData = [ + 'uid' => $this->session['uid'], + 'biz_id' => $this->biz_id, + 'title' => '订单列表' + ]; + $this->biz_visit_log_model->addDataPushQueue($logData); return $data; } @@ -620,6 +628,13 @@ class Cusorder extends Wxapp $admin_row = $this->app_user_model->get(['id' => $row['admin_id']], 'uname'); $data['admin_name'] = $admin_row['uname']; } + //增加埋点 + $logData = [ + 'uid' => $this->session['uid'], + 'biz_id' => $this->biz_id, + 'title' => '订单详情' + ]; + $this->biz_visit_log_model->addDataPushQueue($logData); return $data; } diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index 24d5991e..d7ee6e1e 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -35,6 +35,7 @@ class Customers extends Wxapp $this->load->library('receiver/customers_entity'); $this->load->library('receiver/clues_entity'); $this->load->model('app/paic/app_paic_users_model'); + $this->load->model('biz/biz_visit_log_model'); $this->biz_id = $this->get_biz_id(); } @@ -142,6 +143,13 @@ class Customers extends Wxapp 'cf_pid' => $row['cf_pid'], 'cf_name' => $paic_user ? $paic_user['name'] : '', ]; + //增加埋点 + $logData = [ + 'uid' => $this->session['uid'], + 'biz_id' => $this->biz_id, + 'title' => '客户详情' + ]; + $this->biz_visit_log_model->addDataPushQueue($logData); return $data; } @@ -829,7 +837,13 @@ class Customers extends Wxapp $tag_ids = $this->input_param('tag_ids');//多选客户画像 $city_id = $this->input_param('city_id'); $county_id = $this->input_param('county_id'); - + //增加埋点 + $logData = [ + 'uid' => $this->session['uid'], + 'biz_id' => $this->biz_id, + 'title' => '客户列表' + ]; + $this->biz_visit_log_model->addDataPushQueue($logData); !$page && $page = 1; !$size && $size = 10; $show_log = false; //是否获取日志 diff --git a/common/models/biz/Biz_visit_log_model.php b/common/models/biz/Biz_visit_log_model.php new file mode 100644 index 00000000..47510e0a --- /dev/null +++ b/common/models/biz/Biz_visit_log_model.php @@ -0,0 +1,66 @@ +table_name, 'default'); + } + + /** + * 添加数据到队列 + * @param $data + * @return false + */ + public function addDataPushQueue($data) + { + if (!$data) { + return false; + } + $data['ip'] = $_SERVER['REMOTE_ADDR']; + $data['url'] = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; + $data['day'] = date('Y-m-d'); + $data['createTime'] = date('Y-m-d H:i:s'); + $redis = load_cache(); + return $redis->push(self::QUEUE_NAME, $data); + } + + /** + * 出队列 + * @param $limit + * @return false|mixed + */ + public function popQueue($limit = 50) + { + $redis = load_cache(); + $i = 0; + $addData = []; + for ($i; $i < $limit; $i++) { + $data = $redis->pop(self::QUEUE_NAME, $limit); + if (!$data) { + break; + } + $addData[] = [ + 'biz_id' => $data->biz_id ?: 0, + 'uid' => $data->uid ?: 0, + 'title' => $data->title ?: '', + 'taskName' => $data->taskName ?: '', + 'params' => $data->params ? $data->params : json_encode([]), + 'url' => $data->url ?: '', + 'ip' => $data->ip ?: '', + 'day' => $data->day ?: date('Y-m-d'), + 'createTime' => $data->createTime ?: date('Y-m-d H:i:s'), + ]; + } + if ($addData) { + $req = $this->add_batch($addData); + return $req; + } + return false; + } +}