小程序增加访问日志
This commit is contained in:
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Vlog extends HD_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
<link rel="stylesheet" type="text/css" href="/static/css/font-awesome.min.css?v=1581252500">
|
||||
<div class="coms-table-wrap mt10" id="vue-app">
|
||||
<form class="form-search coms-table-hd clearfix no-border" onsubmit="return false"
|
||||
action="/sys/vlog/index" id="search_form">
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w100">用户:</label>
|
||||
<div class="am-form-group fl">
|
||||
<div class="am-para-inline w300">
|
||||
<input name="user_name" type="text" value="<?= $params['user_name'] ?>"
|
||||
placeholder="用户" autocomplete="off"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group">
|
||||
<label class="am-para-label w100">门店:</label>
|
||||
<div class="am-form-group fl">
|
||||
<div class="am-para-inline w300">
|
||||
<input name="biz_name" type="text" value="<?= $params['biz_name'] ?>"
|
||||
placeholder="门店" autocomplete="off"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<div class="am-form-group" style="margin-bottom: 0px;"></div>
|
||||
<label class="am-para-label w100">访问时间:</label>
|
||||
<div class="am-form-group fl">
|
||||
<div class="am-para-inline w300">
|
||||
<input id="id-create-time" name="c_time" type="text" value="<?= $params['c_time'] ?>"
|
||||
placeholder="访问时间" autocomplete="off"/>
|
||||
</div>
|
||||
<div class="am-para-inline" style="padding-top: 5px;">
|
||||
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="today">今天</a>
|
||||
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="yesterday">昨日</a>
|
||||
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="weeks">本周</a>
|
||||
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="month">本月</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="am-form-group" style="margin-bottom: 0px;">
|
||||
<div class="am-form-group fl ml30">
|
||||
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="coms-table-bd">
|
||||
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
|
||||
<table class="am-table am-table-bordered table-hover fixed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="15%"><span>门店</span></th>
|
||||
<th width="10%"><span>用户</span></th>
|
||||
<th width="12%"><span>名称</span></th>
|
||||
<th width=""><span>访问接口</span></th>
|
||||
<th width="15%"><span>访问时间</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template v-for="(item, index) in lists" :key="item.id">
|
||||
<tr>
|
||||
<td style="vertical-align: middle;">{{ item.biz_name }}</td>
|
||||
<td style="vertical-align: middle;">{{ item.username }}</td>
|
||||
<td style="vertical-align: middle;">{{ item.title }}</td>
|
||||
<td style="vertical-align: middle;overflow: hidden;text-overflow: ellipsis;">{{ item.url }}
|
||||
</td>
|
||||
<td style="vertical-align: middle;">{{ item.createTime}}</td>
|
||||
</tr>
|
||||
</template>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="coms-table-ft clearfix">
|
||||
<div class="hander am-form">
|
||||
</div>
|
||||
<div class="coms-pagination fr mr20">
|
||||
<? page_view($pager) ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
$(function () {
|
||||
vue_obj = new Vue({
|
||||
el: '#vue-app',
|
||||
data: {
|
||||
lists: []
|
||||
},
|
||||
mounted: function () {
|
||||
this.lists = <?= json_encode($lists, JSON_UNESCAPED_UNICODE) ?>;
|
||||
},
|
||||
methods: {
|
||||
// reset() {
|
||||
//
|
||||
// }
|
||||
},
|
||||
watch: {}
|
||||
});
|
||||
<?php page_script($pager) ?>
|
||||
});
|
||||
require(['laydate', 'autocomplete'], function (laydate) {
|
||||
laydate.render({
|
||||
elem: '#id-create-time', range: '~'
|
||||
});
|
||||
$('.id-day-btn').click(function () {
|
||||
var type = $(this).data('date'), date = '', nowDate = new Date();
|
||||
var beginDate = '', endDate = '';
|
||||
switch (type) {
|
||||
case 'today':
|
||||
beginDate = endDate = nowDate.Format('yyyy-MM-dd');
|
||||
break;
|
||||
case 'yesterday':
|
||||
beginDate = endDate = (new Date(nowDate.getTime() - 86400000)).Format('yyyy-MM-dd');
|
||||
break;
|
||||
case 'weeks':
|
||||
nowDate.setDate(nowDate.getDate() - nowDate.getDay() + 1);
|
||||
beginDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + nowDate.getDate();
|
||||
nowDate.setDate(nowDate.getDate() + 6);
|
||||
endDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + nowDate.getDate();
|
||||
break;
|
||||
case 'month':
|
||||
beginDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-01";
|
||||
var day = new Date(nowDate.getFullYear(), nowDate.getMonth() + 1, 0);
|
||||
endDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + "-" + day.getDate();
|
||||
break;
|
||||
}
|
||||
date = beginDate + ' ~ ' + endDate;
|
||||
$('#id-create-time').val(date);
|
||||
});
|
||||
$('.selectpicker').selectpicker();
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);//门店日志
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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; //是否获取日志
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Biz_visit_log_model extends HD_Model
|
||||
{
|
||||
private $table_name = 'lc_biz_visit_log';
|
||||
const QUEUE_NAME = 'biz:visit:log'; // 队列名称
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct($this->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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user