From 851b4c22ed22acb96a3e64385be8cebdea5f3d57 Mon Sep 17 00:00:00 2001 From: dengbw Date: Fri, 2 Sep 2022 14:51:50 +0800 Subject: [PATCH] owners_902 --- admin/controllers/app/licheb/Main.php | 2 +- admin/controllers/live/Polyv.php | 2 +- admin/controllers/receiver/Owners.php | 200 ++++++++++++++++++-------- admin/views/receiver/owners/get.php | 8 +- admin/views/receiver/owners/lists.php | 162 +++++++++++++++++++-- 5 files changed, 304 insertions(+), 70 deletions(-) diff --git a/admin/controllers/app/licheb/Main.php b/admin/controllers/app/licheb/Main.php index 54322a98..70b38f84 100644 --- a/admin/controllers/app/licheb/Main.php +++ b/admin/controllers/app/licheb/Main.php @@ -93,7 +93,7 @@ class Main extends HD_Controller ); $value = $this->mdPolyvSession->count(); $list[] = array( - 'title' => '保利威直播-场次报表', + 'title' => '直播-场次报表', 'value' => $value, 'btns' => array( array('name' => '查看详情', 'url' => '/live/polyv'), diff --git a/admin/controllers/live/Polyv.php b/admin/controllers/live/Polyv.php index a8c70a27..e8c47e0c 100644 --- a/admin/controllers/live/Polyv.php +++ b/admin/controllers/live/Polyv.php @@ -55,7 +55,7 @@ class Polyv extends HD_Controller $this->data['pager'] = array('count' => ceil($total / $params['size']), 'curr' => $params['page'], 'totle' => $total); $this->data['lists'] = $lists; $this->data['params'] = $params; - $this->data['_title'] = "保利威频道({$this->channelId})_场次报表"; + $this->data['_title'] = "频道({$this->channelId})_场次报表"; $this->show_view('live/polyv/lists', true); } diff --git a/admin/controllers/receiver/Owners.php b/admin/controllers/receiver/Owners.php index c9a98b66..9e58a2f0 100644 --- a/admin/controllers/receiver/Owners.php +++ b/admin/controllers/receiver/Owners.php @@ -18,7 +18,14 @@ class Owners extends HD_Controller $this->load->model('receiver/receiver_owners_oplogs_model', 'mdOwnersOplogs'); $this->load->model('receiver/receiver_owners_tag_model', 'mdOwnersTag'); $this->load->model('receiver/receiver_owners_tagdata_model', 'mdOwnersTagdata'); - $this->load->model('receiver/receiver_xz_model'); + $this->load->model("biz/biz_model", 'mdBiz'); + $this->load->model('receiver/order/receiver_orders_v2_model', 'mdOrders'); + $this->load->model('app/licheb/app_licheb_users_model', 'mdLichebUsers'); + $this->load->model('receiver/receiver_xz_model', 'mdXz'); + $this->load->model('auto/auto_brand_model', 'mdBrand'); + $this->load->model('auto/auto_series_model', 'mdSeries'); + $this->load->model('auto/auto_attr_model', 'mdAttr'); + $this->load->model('area_model', 'mdArea'); } public function index() @@ -29,83 +36,103 @@ class Owners extends HD_Controller public function lists() { $params = $this->input->get(); + $this->data = $this->dataSelect($params); + return $this->show_view('receiver/owners/lists', true); + } + + private function dataSelect($params) + { $page = $params['page'] = $params['page'] ? intval($params['page']) : 1; $size = $params['size'] = $params['size'] ? intval($params['size']) : 20; + !$params['city_id_admin'] && $params['city_id_admin'] = ''; + !$params['county_id_admin'] && $params['county_id_admin'] = ''; + !$params['biz_id_admin'] && $params['biz_id_admin'] = ''; + !$params['admin_id'] && $params['admin_id'] = ''; + !$params['city_id'] && $params['city_id'] = ''; + !$params['county_id'] && $params['county_id'] = ''; + !$params['sex'] && $params['sex'] = ''; + !$params['brand_id'] && $params['brand_id'] = ''; + !$params['s_id'] && $params['s_id'] = ''; + !$params['v_id'] && $params['v_id'] = ''; if (strlen($params['status'])) { - $where["status"] = $params['status']; + $where["a.status"] = $params['status']; } else { - $where["status>=0"] = null; + $where["a.status>=0"] = null; } if ($params['title']) { - $where["{$params['search_tp']} like '%{$params['title']}%'"] = null; + $where["a.{$params['search_tp']} like '%{$params['title']}%'"] = null; } !$params['search_tp'] && $params['search_tp'] = 'mobile'; if ($params['c_time']) { $c_time = explode(' ~ ', $params['c_time']); - $c_time[0] && $where["c_time >="] = strtotime($c_time[0] . ' 00:00:00'); - $c_time[1] && $where["c_time <="] = strtotime($c_time[1] . ' 23:59:59'); + $c_time[0] && $where["a.c_time >="] = strtotime($c_time[0] . ' 00:00:00'); + $c_time[1] && $where["a.c_time <="] = strtotime($c_time[1] . ' 23:59:59'); } if ($params['order_time']) { $order_time = explode(' ~ ', $params['order_time']); - $order_time[0] && $where["order_time >="] = $order_time[0] . ' 00:00:00'; - $order_time[1] && $where["order_time <="] = $order_time[1] . ' 23:59:59'; + $order_time[0] && $where["a.order_time >="] = $order_time[0] . ' 00:00:00'; + $order_time[1] && $where["a.order_time <="] = $order_time[1] . ' 23:59:59'; } if ($params['ck_time']) { $ck_time = explode(' ~ ', $params['ck_time']); - $ck_time[0] && $where["ck_time >="] = $ck_time[0] . ' 00:00:00'; - $ck_time[1] && $where["ck_time <="] = $ck_time[1] . ' 23:59:59'; + $ck_time[0] && $where["a.ck_time >="] = $ck_time[0] . ' 00:00:00'; + $ck_time[1] && $where["a.ck_time <="] = $ck_time[1] . ' 23:59:59'; } if ($params['u_time']) { $u_time = explode(' ~ ', $params['u_time']); - $u_time[0] && $where["u_time >="] = $u_time[0] . ' 00:00:00'; - $u_time[1] && $where["u_time <="] = $u_time[1] . ' 23:59:59'; + $u_time[0] && $where["a.u_time >="] = $u_time[0] . ' 00:00:00'; + $u_time[1] && $where["a.u_time <="] = $u_time[1] . ' 23:59:59'; } if (strlen($params['wxqy'])) { - $where["wxqy"] = $params['wxqy']; + $where["a.wxqy"] = $params['wxqy']; } else { $params['wxqy'] = ''; } if ($params['city_id']) { - $where["city_id"] = $params['city_id']; - } else { - $params['city_id'] = ''; + $where["a.city_id"] = $params['city_id']; } if ($params['county_id']) { - $where["county_id"] = $params['county_id']; - } else { - $params['county_id'] = ''; + $where["a.county_id"] = $params['county_id']; } if ($params['sex']) { - $where["sex"] = $params['sex']; - } else { - $params['sex'] = ''; + $where["a.sex"] = $params['sex']; } if ($params['brand_id']) { - $where["brand_id"] = $params['brand_id']; - } else { - $params['brand_id'] = ''; + $where["a.brand_id"] = $params['brand_id']; } if ($params['s_id']) { - $where["s_id"] = $params['s_id']; - } else { - $params['s_id'] = ''; + $where["a.s_id"] = $params['s_id']; } if ($params['v_id']) { - $where["v_id"] = $params['v_id']; - } else { - $params['v_id'] = ''; + $where["a.v_id"] = $params['v_id']; + } + //销售员筛选 + if ($params['admin_id']) { + $where['b.admin_id'] = $params['admin_id']; + } else if ($params['biz_id_admin']) { + $where['b.biz_id'] = $params['biz_id_admin']; + } else if ($params['county_id_admin']) { + $where["b.biz_id in(select id from lc_biz where county_id={$params['county_id_admin']})"] = null; + } else if ($params['city_id_admin']) { + $where["b.biz_id in(select id from lc_biz where city_id={$params['city_id_admin']})"] = null; } - $count = $this->mdOwners->count($where); $lists = []; $wxqyAry = $this->mdOwners->wxqyAry(); $statusAry = $this->mdOwners->statusAry(); + $count = $this->db->select('a.id') + ->from('lc_receiver_owners as a') + ->join('lc_receiver_orders_v2 as b', "b.id=a.o_id", 'left') + ->where($where) + ->count_all_results(); if ($count) { - $this->load->model('auto/auto_brand_model', 'mdBrand'); - $this->load->model('auto/auto_series_model', 'mdSeries'); - $this->load->model('auto/auto_attr_model', 'mdAttr'); - $this->load->model('area_model', 'mdArea'); - $res = $this->mdOwners->select($where, 'id desc', $page, $size); - + $offset = ($page - 1) * $size; + $res = $this->db->select('a.*,b.admin_id,b.biz_id') + ->from('lc_receiver_owners as a') + ->join('lc_receiver_orders_v2 as b', "b.id=a.o_id", 'left') + ->where($where) + ->order_by('a.id Desc') + ->limit($size, $offset) + ->get()->result_array(); $str_brand_ids = implode(',', array_unique(array_column($res, 'brand_id'))); $map_brands = $this->mdBrand->map('id', 'name', ["id in({$str_brand_ids})" => null]); $str_s_ids = implode(',', array_unique(array_column($res, 's_id'))); @@ -114,17 +141,13 @@ class Owners extends HD_Controller $map_attrs = $this->mdAttr->map('id', 'title', ["id in({$str_v_ids})" => null]); $str_county_ids = implode(',', array_unique(array_column($res, 'county_id'))); $map_countys = $this->mdArea->map('county_id', 'city_name,county_name', ["county_id in({$str_county_ids})" => null]); + $str_biz_ids = implode(',', array_unique(array_column($res, 'biz_id'))); + $map_bizs = $this->mdBiz->map('id', 'biz_name', ["id in({$str_biz_ids})" => null]); + $str_admin_ids = implode(',', array_unique(array_column($res, 'admin_id'))); + $map_admins = $this->mdLichebUsers->map('id', 'uname', ["id in({$str_admin_ids})" => null]); foreach ($res as $key => $val) { -// if (SUPER_ADMIN == $this->role || $this->role == 35) { -// $mobile_sub = $val['mobile']; -// } else { -// $mobile_sub = $val['mobile'] ? substr_replace($val['mobile'], '*****', 0, 5) : ''; -// } $mobile_sub = $val['mobile']; $sex = $car_name = $city_name = ''; - if ($val['sex']) { - $sex = $val['sex'] == 1 ? '男' : '女'; - } $map_brands[$val['brand_id']] && $car_name = $map_brands[$val['brand_id']]; $map_series[$val['s_id']] && $car_name = $car_name ? $car_name . '-' . $map_series[$val['s_id']] : $map_series[$val['s_id']]; $map_attrs[$val['v_id']] && $car_name = $car_name ? $car_name . '-' . $map_attrs[$val['v_id']] : $map_attrs[$val['v_id']]; @@ -133,7 +156,10 @@ class Owners extends HD_Controller $re_are = $this->mdArea->get(['city_id' => $val['city_id']]); $re_are && $city_name = $re_are['city_name']; } - $lists[] = array( + $val['sex'] && $sex = $val['sex'] == 1 ? '男' : '女'; + $biz_name = $map_bizs[$val['biz_id']] ? $map_bizs[$val['biz_id']] : ''; + $admin_name = $map_admins[$val['admin_id']] ? $map_admins[$val['admin_id']] : ''; + $lists[] = [ 'id' => $val['id'], 'name' => $val['name'], 'mobile' => $val['mobile'], @@ -142,25 +168,27 @@ class Owners extends HD_Controller 'age' => $this->getAgeByBirth($val['birth_day']), 'car_name' => $car_name, 'city_name' => $city_name, + 'biz_name' => $biz_name, + 'admin_name' => $admin_name, 'wxqy' => $wxqyAry[$val['wxqy']], 'car_num' => $val['car_num'], 'order_time' => $val['order_time'] != '0000-00-00 00:00:00' ? $val['order_time'] : '', 'ck_time' => $val['ck_time'] != '0000-00-00 00:00:00' ? $val['ck_time'] : '', 'u_time' => $val['u_time'], - 'status_name' => $statusAry[$val['status']], - ); + 'status_name' => $statusAry[$val['status']] + ]; } } $show_info['searchTpAry'] = $this->searchTpAry; $show_info['wxqyAry'] = $wxqyAry; $show_info['statusAry'] = $statusAry; - $this->data['show_info'] = $show_info; - $this->data['lists'] = $lists; - $this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count); - $this->data['searchTimeAry'] = $this->searchTimeAry; - $this->data['params'] = $params; - $this->data['_title'] = '车主列表'; - return $this->show_view('receiver/owners/lists', true); + $data['show_info'] = $show_info; + $data['lists'] = $lists; + $data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count); + $data['searchTimeAry'] = $this->searchTimeAry; + $data['params'] = $params; + $data['_title'] = '车主列表'; + return $data; } public function get() @@ -185,6 +213,20 @@ class Owners extends HD_Controller $info['c_time'] = date('Y-m-d H:i:s', $row['c_time']); $info['birth_day'] = $row['birth_day'] != '0000-00-00' ? $row['birth_day'] : ''; $info['tag'] = $this->get_tag($row['id']); + $biz_name = $admin_name = ''; + if ($row['o_id']) { + $re_o = $this->mdOrders->get(array('id' => $row['o_id']), 'biz_id,admin_id'); + if ($re_o['biz_id']) { + $re_b = $this->mdBiz->get(array('id' => $re_o['biz_id']), 'biz_name'); + $re_b && $biz_name = $re_b['biz_name']; + } + if ($re_o['admin_id']) { + $re_u = $this->mdLichebUsers->get(array('id' => $re_o['admin_id']), 'uname'); + $re_u && $admin_name = $re_u['uname']; + } + } + $info['biz_name'] = $biz_name; + $info['admin_name'] = $admin_name; //操作日志 $rows_log = $this->mdOwnersOplogs->select(['own_id' => $id], 'id desc', 0, 0); $logs = []; @@ -192,7 +234,7 @@ class Owners extends HD_Controller foreach ($rows_log as $key => $value) { $rec_text = $rec_url = ''; if ($value['type'] == 2) { - $rec_row = $this->receiver_xz_model->get(['id' => $value['log']], 'rec_url,duration'); + $rec_row = $this->mdXz->get(['id' => $value['log']], 'rec_url,duration'); if ($rec_row['duration']) { $rec_row['rec_url'] && $rec_url = $rec_row['rec_url']; !$rec_row['rec_url'] && $rec_text = '录音暂未生成'; @@ -361,7 +403,49 @@ class Owners extends HD_Controller public function export() { - // TODO: Implement export() method. + $params = $this->input->get(); + $params['page'] = 1; + $params['size'] = 10000; + $data = $indexs = array(); + $res = $this->dataSelect($params); + $fileName = $res['_title']; + foreach ($res['lists'] as $key => $value) { + $temp['name'] = $value['name']; + $temp['mobile'] = $value['mobile']; + $temp['car_name'] = $value['car_name']; + $temp['city_name'] = $value['city_name']; + $temp['car_num'] = $value['car_num']; + $temp['sex'] = $value['sex']; + $temp['age'] = $value['age']; + $temp['wxqy'] = $value['wxqy']; + $temp['status_name'] = $value['status_name']; + $temp['order_time'] = $value['order_time']; + $temp['ck_time'] = $value['ck_time']; + $temp['city_name'] = $value['city_name']; + $temp['biz_name'] = $value['biz_name']; + $temp['admin_name'] = $value['admin_name']; + $temp['u_time'] = $value['u_time']; + $data[] = $value; + } + $indexs = [ + 'name' => '车主', + 'mobile' => '手机号', + 'car_name' => '车辆', + 'city_name' => '所在城市', + 'car_num' => '车牌号', + "sex" => "性别", + "age" => "年龄", + "wxqy" => "企微好友", + "status_name" => "状态", + "order_time" => "购车时间", + "ck_time" => "交付时间", + "biz_name" => "所属门店", + "admin_name" => "销售员", + "u_time" => "最后操作时间", + ]; + array_unshift($data, $indexs); + $this->load->library('excel'); + $this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis')); } /** diff --git a/admin/views/receiver/owners/get.php b/admin/views/receiver/owners/get.php index 374c7791..9ac66902 100644 --- a/admin/views/receiver/owners/get.php +++ b/admin/views/receiver/owners/get.php @@ -175,8 +175,12 @@ - - + + + + 所属门店:{{info.biz_name}} + 销售人员:{{info.admin_name}} + diff --git a/admin/views/receiver/owners/lists.php b/admin/views/receiver/owners/lists.php index 3cee9f8c..0d1fc356 100644 --- a/admin/views/receiver/owners/lists.php +++ b/admin/views/receiver/owners/lists.php @@ -87,6 +87,37 @@ +
+ +
+ +
+
+ +
+
+ +
+
+ +
+
$value) { ?>
@@ -108,15 +139,18 @@
-
- -
+
+ +
+
+ +
@@ -129,15 +163,17 @@ ID - 车主 + 车主 车辆 - 车牌号 - 性别 - 年龄 + 车牌号 + 性别 + 年龄 企微好友 状态 购车时间 交付时间 + 所属门店 + 销售员 最后操作时间 @@ -154,10 +190,12 @@ {{v.status_name}} {{v.order_time}} {{v.ck_time}} + {{v.biz_name}} + {{v.admin_name}} {{v.u_time}} - +
@@ -246,6 +284,7 @@ cityAry: [], countyAry: [], show_info: {searchTpAry: [], wxqyAry: []}, + admins: {cityAry: [], countyAry: [], bizAry: [], list: []}, }, mounted: function () { var vm = this; @@ -261,6 +300,7 @@ $.get('common/area', {id: '350', key: 'city', type: 1}, function (response) { if (response.code == 1) { vm.cityAry = response.data; + vm.admins.cityAry = JSON.parse(JSON.stringify(response.data)); } }); if (vm.params.city_id) { @@ -319,6 +359,10 @@ that.params.search_tp = 'mobile'; that.params.title = ''; that.params.sex = ''; + that.params.city_id_admin = ''; + that.params.brand_id = ''; + that.params.wxqy = ''; + that.params.city_id = ''; $(".order-times").map(function () { var id = this.value; this.checked = false; @@ -410,8 +454,110 @@ vm.params.v_id = ''; } }, + 'params.city_id_admin': function (nv, ov) { + var that = this; + if (nv == '') { + that.admins.countyAry = []; + that.params.county_id_admin = ''; + } else { + if (nv.substring(0, 4) != that.params.county_id_admin.substring(0, 4)) { + that.params.county_id_admin = ''; + } + $.ajax({ + type: 'get', + url: '/common/area', + dataType: 'json', + data: { + id: nv, + key: 'county', + type: 1 + }, + success: function (response) { + if (response.code == 1) { + that.admins.countyAry = response.data; + } + } + }); + } + }, + 'params.county_id_admin': function (nv, ov) { + var that = this; + if (nv == '') { + that.admins.bizAry = []; + that.params.biz_id_admin = ''; + } else { + $.ajax({ + type: 'post', + url: '/biz/store/store/json_lists', + dataType: 'json', + data: { + city_id: that.params.city_id_admin, + county_id: that.params.county_id_admin, + status: 1 + }, + success: function (response) { + if (response.code == 1) { + that.admins.bizAry = response.data.list; + if (that.params.biz_id_admin > 0) { + var biz_id = ''; + for (var i in that.admins.bizAry) { + if (that.params.biz_id_admin == that.admins.bizAry[i].id) { + biz_id = that.params.biz_id_admin; + break; + } + } + that.params.biz_id_admin = biz_id; + } + } + } + }); + } + }, + 'params.biz_id_admin': function (nv, ov) { + var that = this; + if (nv == '') { + that.admins.list = []; + that.params.admin_id = ''; + } else { + $.ajax({ + type: 'post', + url: '/app/licheb/member/json_lists', + dataType: 'json', + data: { + biz_id: nv, + status: 1 + }, + success: function (response) { + if (response.code == 1) { + that.admins.list = response.data.list; + if (that.params.admin_id > 0) { + var admin_id = ''; + for (var i in that.admins.list) { + if (that.params.admin_id == that.admins.list[i].id) { + admin_id = that.params.admin_id; + break; + } + } + that.params.admin_id = admin_id; + } + } + } + }); + } + } } }); + $('#export').click(function () { + var count = ; + if (count > 10000) { + layer.msg('单次导出数据不能超过10000'); + return false; + } + var href = $.menu.parseUri(window.location.href); + var arr = href.split('?'); + href = '/receiver/owners/export?' + arr[1]; + window.location.href = href; + }); });