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 @@ -