diff --git a/admin/controllers/app/licheb/Userslog.php b/admin/controllers/app/licheb/Userslog.php index 288c287f..975451e1 100644 --- a/admin/controllers/app/licheb/Userslog.php +++ b/admin/controllers/app/licheb/Userslog.php @@ -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')); diff --git a/admin/views/app/licheb/userslog/lists.php b/admin/views/app/licheb/userslog/lists.php index 3fa4e953..b7b36d8a 100644 --- a/admin/views/app/licheb/userslog/lists.php +++ b/admin/views/app/licheb/userslog/lists.php @@ -1,3 +1,15 @@ +
+ +
$value) { ?> @@ -10,6 +22,7 @@
+
@@ -54,7 +67,7 @@
-
+
diff --git a/admin/views/app/licheb/userslog/lists_visit.php b/admin/views/app/licheb/userslog/lists_visit.php new file mode 100644 index 00000000..7c69ae42 --- /dev/null +++ b/admin/views/app/licheb/userslog/lists_visit.php @@ -0,0 +1,298 @@ +
+ +
+
+ + $value) { ?> + + + +
+
+
+
+ + +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+ 昨日 + 本周 + 本月 +
+
+
+
+
+ +
+
+ +
+
+ +
+
+
+ +
+
+
共有条数据
+ + + + + + + + + + + + + + + + + + + + + + + +
门店顾问待跟进数已跟进数逾期未跟进数日期
+
+
+
+
+
+ +
+
+
+ +