userslog_607
This commit is contained in:
@@ -8,12 +8,14 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*/
|
||||
class Userslog extends HD_Controller
|
||||
{
|
||||
private $tabAry = [1 => '客户统计', 2 => '回访统计'];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('app/licheb/app_licheb_users_model', 'mdUsers');
|
||||
$this->load->model('app/licheb/app_licheb_users_log_model', 'mdUsersLog');
|
||||
$this->load->model('receiver/receiver_customers_visit_sales_model', 'mdCustomerVisitSales');
|
||||
$this->load->model('receiver/receiver_customers_model', 'mdCustomers');
|
||||
$this->load->model("biz/biz_model", 'mdBiz');
|
||||
$this->load->model('area_model', 'mdArea');
|
||||
@@ -29,10 +31,18 @@ class Userslog extends HD_Controller
|
||||
$params = $this->input->get();
|
||||
$params['page'] = $params['page'] ? intval($params['page']) : 1;
|
||||
$params['size'] = $params['size'] ? intval($params['size']) : 20;
|
||||
$data = $this->dataSelect($params);
|
||||
$params['tab'] = $params['tab'] ? intval($params['tab']) : 1;
|
||||
if ($params['tab'] == 2) {
|
||||
$view = 'app/licheb/userslog/lists_visit';
|
||||
$data = $this->visitSelect($params);
|
||||
} else {
|
||||
$view = 'app/licheb/userslog/lists';
|
||||
$data = $this->dataSelect($params);
|
||||
}
|
||||
$data['typeAry'] = $this->mdBiz->type_ary();
|
||||
$data['tabAry'] = $this->tabAry;
|
||||
$this->data = $data;
|
||||
$this->show_view('app/licheb/userslog/lists', true);
|
||||
$this->show_view($view, true);
|
||||
}
|
||||
|
||||
private function dataSelect($params)
|
||||
@@ -151,6 +161,81 @@ class Userslog extends HD_Controller
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function visitSelect($params)
|
||||
{
|
||||
$lists = $where = [];
|
||||
if ($params['uname']) {
|
||||
$where["sales_id in(select id from lc_app_licheb_users where uname like '%{$params['uname']}%')"] = null;
|
||||
}
|
||||
if ($params['biz_id']) {
|
||||
$where['biz_id'] = $params['biz_id'];
|
||||
} else if ($params['city_id'] || $params['type']) {
|
||||
$where_biz['status'] = 1;
|
||||
$params['type'] && $where_biz['type'] = $params['type'];
|
||||
$params['city_id'] && $where_biz['city_id'] = $params['city_id'];
|
||||
$params['county_id'] && $where_biz['county_id'] = $params['county_id'];
|
||||
$res_biz = $this->mdBiz->select($where_biz, 'id desc', 0, 0, 'id');
|
||||
if ($res_biz) {
|
||||
$str_ids = implode(',', array_column($res_biz, 'id'));
|
||||
$where["biz_id in ({$str_ids})"] = null;
|
||||
} else {
|
||||
$where['biz_id'] = -2;
|
||||
}
|
||||
} else {
|
||||
$params['city_id'] = '';
|
||||
$params['county_id'] = '';
|
||||
$params['biz_id'] = '';
|
||||
$params['type'] = '';
|
||||
}
|
||||
if ($params['time']) {
|
||||
$time = explode(' ~ ', $params['time']);
|
||||
$time[0] && $where["t_day>="] = $time[0];
|
||||
$time[1] && $where["t_day<="] = $time[1];
|
||||
}
|
||||
$total = $this->mdCustomerVisitSales->count($where);
|
||||
if ($total) {
|
||||
$res = $this->mdCustomerVisitSales->select($where, "id desc", $params['page'], $params['size']);
|
||||
$sales_ids = $biz_ids = [];
|
||||
foreach ($res as $v) {
|
||||
$v['sales_id'] && !in_array($v['sales_id'], $sales_ids) && $sales_ids[] = $v['sales_id'];
|
||||
$v['biz_id'] && !in_array($v['biz_id'], $biz_ids) && $biz_ids[] = $v['biz_id'];
|
||||
}
|
||||
$map_sale = $map_biz = $map_city = [];
|
||||
if ($sales_ids) {
|
||||
$str_ids = implode(',', $sales_ids);
|
||||
$map_sale = $this->mdUsers->map('id', 'uname', ["id in ({$str_ids})" => null]);
|
||||
}
|
||||
if ($biz_ids) {
|
||||
$str_ids = implode(',', $biz_ids);
|
||||
$map_biz = $this->mdBiz->map('id', 'biz_name,type', ["id in ({$str_ids})" => null]);
|
||||
}
|
||||
$typeAry = $this->mdBiz->type_ary();
|
||||
foreach ($res as $v) {
|
||||
$uname = $biz_name = $biz_type = '';
|
||||
$map_sale[$v['sales_id']] && $uname = $map_sale[$v['sales_id']];
|
||||
$map_biz[$v['biz_id']]['biz_name'] && $biz_name = $map_biz[$v['biz_id']]['biz_name'];
|
||||
$map_biz[$v['biz_id']]['type'] && $biz_type = $typeAry[$map_biz[$v['biz_id']]['type']];
|
||||
$temp = ['uname' => $uname, 'biz_type' => $biz_type, 'biz_name' => $biz_name, 't_follows' => $v['t_follows']
|
||||
, 'h_follows' => $v['h_follows'], 'w_follows' => $v['w_follows'], 't_day' => $v['t_day']];
|
||||
$lists[] = $temp;
|
||||
}
|
||||
}
|
||||
if ($params['size'] != 10000) {
|
||||
$sum = $this->mdCustomerVisitSales->sum('t_follows', $where);
|
||||
$menus[] = ['title' => "待跟进数", 'value' => intval($sum['t_follows']), 'tag' => '个'];
|
||||
$sum = $this->mdCustomerVisitSales->sum('h_follows', $where);
|
||||
$menus[] = ['title' => "已跟进数", 'value' => intval($sum['h_follows']), 'tag' => '个'];
|
||||
$sum = $this->mdCustomerVisitSales->sum('w_follows', $where);
|
||||
$menus[] = ['title' => "逾期未跟进数", 'value' => intval($sum['w_follows']), 'tag' => '个'];
|
||||
$data['menus'] = $menus;
|
||||
}
|
||||
$data['pager'] = array('count' => ceil($total / $params['size']), 'curr' => $params['page'], 'totle' => $total);
|
||||
$data['lists'] = $lists;
|
||||
$data['params'] = $params;
|
||||
$data['_title'] = "顾问日志";
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
}
|
||||
@@ -178,29 +263,35 @@ class Userslog extends HD_Controller
|
||||
$params['page'] = 1;
|
||||
$params['size'] = 10000;
|
||||
$data = $indexs = array();
|
||||
$res = $this->dataSelect($params);
|
||||
$fileName = $res['_title'];
|
||||
$offlineSources = $this->mdCustomers->offlineSources();
|
||||
if ($params['tab'] == 2) {
|
||||
$res = $this->visitSelect($params);
|
||||
$indexs = ['biz_name' => '门店', 'uname' => '顾问', 't_follows' => '待跟进数', 'h_follows' => '已跟进数'
|
||||
, 'w_follows' => '逾期未跟进数', 't_day' => '日期'];
|
||||
} else {
|
||||
$res = $this->dataSelect($params);
|
||||
$offlineSources = $this->mdCustomers->offlineSources();
|
||||
$indexs = ['biz_name' => '门店', 'uname' => '顾问', 'customers' => '客户数'];
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
$indexs['customer_' . $key1] = '【' . $value1['name'] . '】';
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$indexs['customer_' . $key2] = $value2;
|
||||
}
|
||||
}
|
||||
$indexs['c_num'] = '进店人数';
|
||||
$indexs['a_num'] = '进店次数';
|
||||
$indexs['t_num'] = '试驾数';
|
||||
$indexs['follows'] = '跟进数';
|
||||
$indexs['orders'] = '订单数';
|
||||
$indexs['defeats'] = '战败数';
|
||||
$indexs['bills'] = '开票数';
|
||||
$indexs['qy_adds'] = '新增企微';
|
||||
$indexs['qy_dels'] = '删除企微';
|
||||
$indexs['log_date'] = '日期';
|
||||
}
|
||||
$fileName = $res['_title'] . '_' . $this->tabAry[$params['tab']];
|
||||
foreach ($res['lists'] as $key => $value) {
|
||||
$data[] = $value;
|
||||
}
|
||||
$indexs = ['biz_name' => '门店', 'uname' => '顾问', 'customers' => '客户数'];
|
||||
foreach ($offlineSources as $key1 => $value1) {
|
||||
$indexs['customer_' . $key1] = '【' . $value1['name'] . '】';
|
||||
foreach ($value1['list'] as $key2 => $value2) {
|
||||
$indexs['customer_' . $key2] = $value2;
|
||||
}
|
||||
}
|
||||
$indexs['c_num'] = '进店人数';
|
||||
$indexs['a_num'] = '进店次数';
|
||||
$indexs['t_num'] = '试驾数';
|
||||
$indexs['follows'] = '跟进数';
|
||||
$indexs['orders'] = '订单数';
|
||||
$indexs['defeats'] = '战败数';
|
||||
$indexs['bills'] = '开票数';
|
||||
$indexs['qy_adds'] = '新增企微';
|
||||
$indexs['qy_dels'] = '删除企微';
|
||||
$indexs['log_date'] = '日期';
|
||||
array_unshift($data, $indexs);
|
||||
$this->load->library('excel');
|
||||
$this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis'));
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
<div class="bs-example bs-example-tabs" data-example-id="togglable-tabs" style="font-size:15px;margin-bottom: 20px;">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<? foreach ($tabAry as $key => $val) { ?>
|
||||
<li role="presentation"
|
||||
class="<?= strlen($params['tab']) && $params['tab'] == $key ? 'active' : '' ?>">
|
||||
<a href="javascript:void (0);" data-open="/app/licheb/userslog?tab=<?= $key ?>">
|
||||
<?= $val ?>
|
||||
</a>
|
||||
</li>
|
||||
<? } ?>
|
||||
</ul>
|
||||
</div>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<? foreach ($menus as $key => $value) { ?>
|
||||
@@ -10,6 +22,7 @@
|
||||
<div class="coms-table-wrap mt10">
|
||||
<form id="vue-app" class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
|
||||
action="app/licheb/userslog">
|
||||
<input type="hidden" name="tab" v-model="params.tab"/>
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">顾问名字:</label>
|
||||
@@ -54,7 +67,7 @@
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">日期:</label>
|
||||
<div class="am-form-group fl">
|
||||
<div class="am-para-inline w250">
|
||||
<div class="am-para-inline w200">
|
||||
<input id="id-time" name="time" type="text" value="<?= $params['time'] ?>"
|
||||
placeholder="开始时间 ~ 结束时间" autocomplete="off"/>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,298 @@
|
||||
<div class="bs-example bs-example-tabs" data-example-id="togglable-tabs" style="font-size:15px;margin-bottom: 20px;">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<? foreach ($tabAry as $key => $val) { ?>
|
||||
<li role="presentation"
|
||||
class="<?= strlen($params['tab']) && $params['tab'] == $key ? 'active' : '' ?>">
|
||||
<a href="javascript:void (0);" data-open="/app/licheb/userslog?tab=<?= $key ?>">
|
||||
<?= $val ?>
|
||||
</a>
|
||||
</li>
|
||||
<? } ?>
|
||||
</ul>
|
||||
</div>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<? foreach ($menus as $key => $value) { ?>
|
||||
<td class="my-panel text-center">
|
||||
<?= $value['title'] ?><br><?= $value['value'] ?><?= $value['tag'] ?>
|
||||
</td>
|
||||
<? } ?>
|
||||
</tr>
|
||||
</table>
|
||||
<div class="coms-table-wrap mt10">
|
||||
<form id="vue-app" class=" form-search coms-table-hd clearfix no-border" onsubmit="return false"
|
||||
action="app/licheb/userslog">
|
||||
<input type="hidden" name="tab" v-model="params.tab"/>
|
||||
<div class="am-form am-form-horizontal">
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">顾问名字:</label>
|
||||
<div class="am-para-inline w200">
|
||||
<input type="text" name="uname" placeholder="顾问名字关键字" v-model="params.uname"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">门店:</label>
|
||||
<div class="am-para-inline w120">
|
||||
<select title="类型" name="type" v-model="params.type">
|
||||
<option value="">选择类型</option>
|
||||
<option :value="i" v-for="(v,i) in typeAry">{{v}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<div class="am-para-inline w120">
|
||||
<select title="城市" name="city_id" v-model="params.city_id">
|
||||
<option value="">选择城市</option>
|
||||
<option :value="v.id" v-for="(v,i) in cityAry">{{v.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<div class="am-para-inline w120">
|
||||
<select title="行政区" name="county_id" v-model="params.county_id" @change="set_county">
|
||||
<option value="">选择行政区</option>
|
||||
<option :value="v.id" v-for="(v,i) in countyAry">{{v.name}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl">
|
||||
<div class="am-para-inline w200">
|
||||
<select title="门店" name="biz_id" v-model="params.biz_id">
|
||||
<option value="">选择门店</option>
|
||||
<option :value="v.id" v-for="(v,i) in bizAry">{{v.title}}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group" style="margin-bottom: 0px;"></div>
|
||||
<div class="am-form-group fl">
|
||||
<label class="am-para-label w80">日期:</label>
|
||||
<div class="am-form-group fl">
|
||||
<div class="am-para-inline w200">
|
||||
<input id="id-time" name="time" type="text" value="<?= $params['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="yesterday"
|
||||
data-source="id-time">昨日</a>
|
||||
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="weeks"
|
||||
data-source="id-time">本周</a>
|
||||
<a class="mr10 id-day-btn" href="javascript:void (0);" data-date="month"
|
||||
data-source="id-time">本月</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="am-form-group fl ml30">
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="submit" class="am-btn am-btn-success am-btn-sm w100">搜索</button>
|
||||
</div>
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="button" class="am-btn am-btn-success am-btn-sm w100" @click="reset">重置</button>
|
||||
</div>
|
||||
<div class="am-form-group fl ml10">
|
||||
<button type="button" id="export" class="am-btn am-btn-success am-btn-sm w100">导出</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="coms-table-bd">
|
||||
<div class="fl"></div>
|
||||
<div class="fr">共有<?= $pager['totle'] ?>条数据</div>
|
||||
<table class="am-table am-table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="17%"><span>门店</span></th>
|
||||
<th width="10%"><span>顾问</span></th>
|
||||
<th width="10%"><span>待跟进数</span></th>
|
||||
<th width="10%"><span>已跟进数</span></th>
|
||||
<th width="10%"><span>逾期未跟进数</span></th>
|
||||
<th width="10%"><span>日期</span></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? if ($lists) {
|
||||
foreach ($lists as $v) { ?>
|
||||
<tr>
|
||||
<td><?= $v['biz_name'] ?></td>
|
||||
<td><?= $v['uname'] ?></td>
|
||||
<td><?= $v['t_follows'] ?></td>
|
||||
<td><?= $v['h_follows'] ?></td>
|
||||
<td><?= $v['w_follows'] ?></td>
|
||||
<td><?= $v['t_day'] ?></td>
|
||||
</tr>
|
||||
<? }
|
||||
} ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="coms-table-ft clearfix">
|
||||
<div class="hander am-form">
|
||||
</div>
|
||||
<div class="coms-pagination fr mr20">
|
||||
<?php page_view($pager) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
require(['laydate', 'autocomplete'], function (laydate) {
|
||||
laydate.render({
|
||||
elem: '#id-time', range: '~'
|
||||
});
|
||||
$('.id-day-btn').click(function () {
|
||||
var type = $(this).data('date'), date = '', nowDate = new Date();
|
||||
var source_id = $(this).data('source') || 'id-time';
|
||||
var beginDate = '';
|
||||
var endDate = '';
|
||||
switch (type) {
|
||||
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;
|
||||
$('#' + source_id).val(date);
|
||||
});
|
||||
});
|
||||
$(function () {
|
||||
vue_obj = new Vue({
|
||||
el: '.coms-table-wrap',
|
||||
data: {
|
||||
params: {},
|
||||
typeAry: [],//城市
|
||||
cityAry: [],//城市
|
||||
countyAry: [],//行政区
|
||||
bizAry: [],//门店
|
||||
},
|
||||
mounted: function () {
|
||||
var vm = this;
|
||||
vm.params = <?=json_encode($params)?>;
|
||||
vm.typeAry = <?=json_encode($typeAry)?>;
|
||||
vm.init_citys();
|
||||
},
|
||||
methods: {
|
||||
init_citys: function () {
|
||||
var vm = this;
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '/common/area',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
id: '350',
|
||||
key: 'city',
|
||||
type: 1
|
||||
},
|
||||
success: function (response) {
|
||||
if (response.code == 1) {
|
||||
vm.cityAry = response.data;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
set_county: function () {
|
||||
var that = this;
|
||||
that.bizAry = [];
|
||||
that.params.biz_id = that.params.addr_id = '';
|
||||
},
|
||||
reset: function () {
|
||||
var that = this;
|
||||
that.params.city_id = '';
|
||||
that.params.uname = '';
|
||||
that.params.type = '';
|
||||
$('#id-time').val('');
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
'params.city_id': function (nv, ov) {
|
||||
var that = this;
|
||||
if (nv == '') {
|
||||
that.countyAry = [];
|
||||
that.params.county_id = '';
|
||||
} else {
|
||||
if (nv.substring(0, 4) != that.params.county_id.substring(0, 4)) {
|
||||
that.params.county_id = '';
|
||||
}
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
url: '/common/area',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
id: nv,
|
||||
key: 'county',
|
||||
type: 1
|
||||
},
|
||||
success: function (response) {
|
||||
if (response.code == 1) {
|
||||
that.countyAry = response.data;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
'params.county_id': function (nv, ov) {
|
||||
var that = this;
|
||||
if (nv == '') {
|
||||
that.bizAry = [];
|
||||
that.params.biz_id = that.params.addr_id = '';
|
||||
} else {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url: '/biz/store/store/json_lists',
|
||||
dataType: 'json',
|
||||
data: {
|
||||
city_id: that.params.city_id,
|
||||
county_id: that.params.county_id,
|
||||
status: 1
|
||||
},
|
||||
success: function (response) {
|
||||
if (response.code == 1) {
|
||||
that.bizAry = response.data.list;
|
||||
var biz_id = '';
|
||||
if (that.params.biz_id > 0 || that.params.biz_id == -1) {
|
||||
for (var i in that.bizAry) {
|
||||
if (that.params.biz_id == that.bizAry[i].id) {
|
||||
biz_id = that.params.biz_id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
that.params.biz_id = biz_id;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
<?php page_script($pager) ?>
|
||||
$('#export').click(function () {
|
||||
var count = <?=$pager['totle']?>;
|
||||
if (count > 10000) {
|
||||
layer.msg('单次导出数据不能超过10000');
|
||||
return false;
|
||||
}
|
||||
var href = $.menu.parseUri(window.location.href);
|
||||
var arr = href.split('?');
|
||||
href = '/app/licheb/userslog/export?' + arr[1];
|
||||
window.location.href = href;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<style>
|
||||
.my-panel {
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
.my-panel span {
|
||||
font-size: 20px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user