diff --git a/admin/controllers/Common.php b/admin/controllers/Common.php index 43c337e4..2fa8a025 100644 --- a/admin/controllers/Common.php +++ b/admin/controllers/Common.php @@ -414,6 +414,7 @@ class Common extends CI_Controller $size = $this->input->post('size') ? intval($this->input->post('size')) : 10; $type = intval($this->input->post('type')); $brand_id = intval($this->input->post('brand_id')); + $province_id = intval($this->input->post('province_id')); $city_id = intval($this->input->post('city_id')); $county_id = intval($this->input->post('county_id')); @@ -431,6 +432,7 @@ class Common extends CI_Controller $sys_cate_id && $where['cate_id'] = $sys_cate_id; $biz_name && $where['biz_name like "%' . $biz_name . '%"'] = null; $brand_id && $where['brand_id'] = $brand_id; + $province_id && $where['province_id'] = $province_id; $city_id && $where['city_id'] = $city_id; $county_id && $where['county_id'] = $county_id; $type && $where['type'] = $type; @@ -440,21 +442,25 @@ class Common extends CI_Controller $typeAry = $this->mdBiz->type_ary(); $type_ids = implode(',',array_keys($typeAry)); $type_ids && $where["type in ($type_ids)"] = null; - $count = $this->mdBiz->count($where); - if ($count) { - $resBiz = $this->mdBiz->select($where, 'id desc', $page, $size); - foreach ($resBiz as $key => $value) { - $setValue = array(); - $setValue['id'] = $value['id']; - $setValue['name'] = $value['biz_name']; - $img = $value['headimg'] ? $value['headimg'] : $value['cover']; - $setValue['img'] = $img ? build_qiniu_image_url($img) : ''; - $setValue['sort'] = $key; - $setValue['is_checked'] = $shopChecked[$value['id']] ? 1 : 0; - $setValue['brand_id'] = $value['brand_id']; - $shopList[] = $setValue; + + if($province_id && $city_id){ + $count = $this->mdBiz->count($where); + if ($count) { + $resBiz = $this->mdBiz->select($where, 'id desc', $page, $size); + foreach ($resBiz as $key => $value) { + $setValue = array(); + $setValue['id'] = $value['id']; + $setValue['name'] = $value['biz_name']; + $img = $value['headimg'] ? $value['headimg'] : $value['cover']; + $setValue['img'] = $img ? build_qiniu_image_url($img) : ''; + $setValue['sort'] = $key; + $setValue['is_checked'] = $shopChecked[$value['id']] ? 1 : 0; + $setValue['brand_id'] = $value['brand_id']; + $shopList[] = $setValue; + } } } + $this->data['shopList'] = $shopList; $hasNext = ceil($count / $size) > $page ? 1 : 0; $this->data['shopPage'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext); @@ -781,7 +787,7 @@ class Common extends CI_Controller if (mb_strlen($content) > 300) { return $this->show_json(SYS_CODE_FAIL, '短信最多300个字'); } - $content = '【狸车】' . $content; + $content = '【理车】' . $content; $plaintext = ''; if (strstr($mobile, ',')) { //多个手机号 $mobiles = explode(',', $mobile); diff --git a/admin/controllers/app/licheb/Channel.php b/admin/controllers/app/licheb/Channel.php index f0e2ebd9..132888ba 100644 --- a/admin/controllers/app/licheb/Channel.php +++ b/admin/controllers/app/licheb/Channel.php @@ -209,7 +209,7 @@ class Channel extends HD_Controller "orders" => "订单数", "days" => "创建时间", ]; - !$params['uid'] && $indexs['uname'] = "渠道经理"; + !$params['uid'] && $indexs['uname'] = "客户成功经理"; array_unshift($data, $indexs); $this->load->library('excel'); $this->excel->out_csv($data, $indexs, $fileName . "_" . date('YmdHis')); diff --git a/admin/controllers/app/licheb/Main.php b/admin/controllers/app/licheb/Main.php index e0144864..2d017b97 100644 --- a/admin/controllers/app/licheb/Main.php +++ b/admin/controllers/app/licheb/Main.php @@ -26,15 +26,15 @@ class Main extends HD_Controller $list = []; $value = $this->userM->count([]); $list[] = array( - 'title' => '用户(人)', + 'title' => '系统用户(人)', 'value' => $value, 'btns' => array( array('name' => '查看详情', 'url' => '/app/licheb/member/index?status=1'), ), ); - $value = $this->userM->count(['group_id' => 4, 'status' => 1]); + $value = $this->userM->count(['group_id' => 4,'biz_id !=' => 0, 'status' => 1]); $list[] = array( - 'title' => '渠道列表(人)', + 'title' => '客户成功经理(人)', 'value' => $value, 'btns' => array( array('name' => '查看详情', 'url' => '/app/licheb/channel'), @@ -44,7 +44,7 @@ class Main extends HD_Controller $this->data['conditions'] = $conditions; - $this->data['_title'] = '狸车'; + $this->data['_title'] = '理车'; return $this->show_view('/app/main', true); } diff --git a/admin/controllers/app/licheb/Member.php b/admin/controllers/app/licheb/Member.php index 8481b1cf..7646fb0f 100644 --- a/admin/controllers/app/licheb/Member.php +++ b/admin/controllers/app/licheb/Member.php @@ -44,13 +44,16 @@ class Member extends HD_Controller if ($params['biz_id']) { $where['biz_id'] = $params['biz_id']; } else { - $params['city_id'] = ''; - $params['county_id'] = ''; $params['biz_id'] = ''; + $params['province_id'] ? $where['province_id'] = $params['province_id'] : $params['province_id'] = ''; + $params['city_id'] ? $where['city_id'] = $params['city_id'] : $params['city_id'] = ''; + !$params['county_id'] && $params['county_id'] = ''; } + if (strlen($params['status'])) { $where['status'] = $params['status']; } + $count = $this->userM->count($where); $lists = $this->userM->select($where, 'id desc', $page, $size); foreach ($lists as $key => $val) { @@ -83,6 +86,8 @@ class Member extends HD_Controller $lists[$key]['umajia'] = $majia; } } + + $this->data['provinces'] = $this->province_ary(); $this->data['app_id'] = 2; $this->data['params'] = $params; $this->data['lists'] = $lists; @@ -156,16 +161,8 @@ class Member extends HD_Controller $action = '/app/licheb/member/add'; $_title = '添加用户'; } - $type_ary = $this->biz_model->type_ary(); - $typeStr = '1,2,3';//品牌 合伙 代理 - $typeAry = []; - foreach ($type_ary as $k => $v) { - if (strstr($typeStr . ',', $k . ',')) { - $typeAry[$k] = $v; - } - } - $show_info['typeAry'] = $typeAry; - #$show_info['typeAry'] = $this->biz_model->type_ary(); + + $this->data['provinces'] = $this->province_ary(); $show_info['cityList'] = $this->mdSysCity->select(['status' => 1], 'id desc', 0, 0, 'city_id,name'); $this->data['selectedBrands'] = $selectedBrands; $this->data['selectedBrands1'] = $selectedBrands1; @@ -185,10 +182,12 @@ class Member extends HD_Controller $mobile = $info['mobile']; $group_id = $info['group_id']; $bizs = $info['bizs']; + $province_id = $info['province_id']; $city_id = $info['city_id']; - $biz_id_arr = array_column($bizs, 'biz_id'); + $bizs && $biz_id_arr = array_column($bizs, 'biz_id'); $group_id1 = $info['group_id1']; $bizs1 = $info['bizs1']; + $province_id1 = $info['province_id1']; $city_id1 = $info['city_id1']; $biz_id_arr1 = is_array($bizs1) ? array_column($bizs1, 'biz_id') : ''; @@ -207,6 +206,8 @@ class Member extends HD_Controller $add = array( 'mobile' => $mobile, 'uname' => $uname, + 'province_id' => $province_id, + 'province_id1' => $province_id1, 'city_id' => $city_id, 'city_id1' => $city_id1, 'status' => 1, @@ -218,10 +219,10 @@ class Member extends HD_Controller $biz_id_arr1 && $add['biz_id1'] = implode(',', $biz_id_arr1); $id = $this->userM->add($add); - if ($id && $group_id == 4 && $biz_id_arr) {//加狸车宝渠道门店 + if ($id && $group_id == 4 && $biz_id_arr) {//加理车宝渠道门店 $this->channel_biz(["uid" => $id, 'biz_id_arr' => $biz_id_arr]); } - if ($id && $group_id1 == 4 && $biz_id_arr1) {//加狸车宝渠道门店 group_id1 + if ($id && $group_id1 == 4 && $biz_id_arr1) {//加理车宝渠道门店 group_id1 $this->channel_biz(["uid" => $id, 'biz_id_arr' => $biz_id_arr1, 'edit' => 1, 'group_id1' => true]); } return $this->show_json(SYS_CODE_SUCCESS, '操作成功', '/app/licheb/member'); @@ -237,6 +238,8 @@ class Member extends HD_Controller $mobile = $info['mobile']; $group_id = $info['group_id']; $bizs = $info['bizs']; + $province_id = $info['province_id']; + $province_id1 = $info['province_id1']; $city_id = $info['city_id']; $biz_id_arr = is_array($bizs) ? array_column($bizs, 'biz_id') : ''; $group_id1 = $info['group_id1']; @@ -258,6 +261,8 @@ class Member extends HD_Controller $upd = array( 'mobile' => $mobile, + 'province_id' => $province_id, + 'province_id1' => $province_id1, 'city_id' => $city_id, 'city_id1' => $city_id1, ); @@ -271,10 +276,10 @@ class Member extends HD_Controller $uname && $upd['uname'] = $uname; $this->userM->update($upd, array('id' => $id)); - if ($id && $group_id == 4) {//加狸车宝渠道门店 + if ($id && $group_id == 4) {//加理车宝渠道门店 $this->channel_biz(["uid" => $id, 'biz_id_arr' => $biz_id_arr, 'edit' => 1]); } - if ($id && $group_id1 == 4) {//加狸车宝渠道门店 group_id1 + if ($id && $group_id1 == 4) {//加理车宝渠道门店 group_id1 $this->channel_biz(["uid" => $id, 'biz_id_arr' => $biz_id_arr1, 'edit' => 1, 'group_id1' => true]); } return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); @@ -347,7 +352,7 @@ class Member extends HD_Controller ); } } - if ($type == 1) {//查找渠道经理 + if ($type == 1) {//查找客户成功经理 $where2 = ['status' => 1, 'group_id' => 4]; $where2["id in(select uid from lc_app_licheb_channel_biz where biz_id = {$biz_id})"] = null; $total2 = $this->userM->count($where2); @@ -369,7 +374,7 @@ class Member extends HD_Controller } /** - * Notes:加狸车宝渠道门店 + * Notes:加理车宝渠道门店 * Created on: 2021/11/12 14:54 * Created by: dengbw * @param array $json @@ -401,7 +406,7 @@ class Member extends HD_Controller } /** - * Notes:获取门店渠道经理 + * Notes:获取门店客户成功经理 * Created on: 2021/11/15 11:31 * Created by: dengbw * @return bool diff --git a/admin/controllers/biz/store/Store.php b/admin/controllers/biz/store/Store.php index 519a1d63..1bccbff8 100644 --- a/admin/controllers/biz/store/Store.php +++ b/admin/controllers/biz/store/Store.php @@ -281,20 +281,14 @@ class Store extends HD_Controller $page = $this->input->get('page'); $size = $this->input->get('size'); $title = $this->input->get('title'); - $type = $this->input->get('type'); $where = array(); - $typeAry = $this->biz_model->type_ary(); - $type_ids = implode(',', array_keys($typeAry)); - $type_ids && $where["type in ($type_ids)"] = null; if (strlen($status) > 0) { $where['status'] = $status; } else { $where['status > -1'] = null; } - if ($type) { - $where["type in({$type})"] = null; - } + $province_id && $where['province_id'] = $province_id; $city_id && $where['city_id'] = $city_id; $county_id && $where['county_id'] = $county_id; diff --git a/admin/controllers/receiver/Clues.php b/admin/controllers/receiver/Clues.php index 329a2bbc..33bfa226 100644 --- a/admin/controllers/receiver/Clues.php +++ b/admin/controllers/receiver/Clues.php @@ -66,11 +66,13 @@ class Clues extends HD_Controller $where["en_time <="] = $en_time[1] . ' 23:59:59'; } } + strlen($params['status']) && $where["status"] = $params['status']; strlen($params['status2']) && $where["status2"] = $params['status2']; $province_id && $where['province_id'] = $province_id; $city_id && $where['city_id'] = $city_id; $county_id && $where['county_id'] = $county_id; + if ($params['cfrom_id'] || $params['cfrom_id2']) { if ($params['cfrom_id2']) { $where['cf_id'] = $params['cfrom_id2']; @@ -82,14 +84,32 @@ class Clues extends HD_Controller $cf_str_ids && $where["cf_id in ({$cf_str_ids})"] = null; } } + + //门店筛选 + if ($params['biz_id_admin']) { + $where['biz_id'] = $params['biz_id_admin']; + } else if ($params['county_id_admin']) { + $where["biz_id in(select id from lc_biz where county_id={$params['county_id_admin']})"] = null; + } else if ($params['city_id_admin']) { + $where["biz_id in(select id from lc_biz where city_id={$params['city_id_admin']})"] = null; + }else if ($params['province_id_admin']) { + $where["biz_id in(select id from lc_biz where province_id={$params['province_id_admin']})"] = null; + } + + !$params['province_id_admin'] && $params['province_id_admin'] = ''; + !$params['city_id_admin'] && $params['city_id_admin'] = ''; + !$params['county_id_admin'] && $params['county_id_admin'] = ''; + !$params['biz_id_admin'] && $params['biz_id_admin'] = ''; + $count = $this->clues_model->count($where); $lists = []; if ($count) { - $fileds = 'id,name,mobile,cf_id,c_time,admin_id,status,status2,en_time,county_id'; + $fileds = 'id,name,mobile,cf_id,cf2_id,c_time,admin_id,status,status2,en_time,province_id,city_id,county_id,biz_id'; $rows = $this->clues_model->select($where, 'en_time desc,id desc', $page, $size, $fileds); $map_admin = $map_cf_pid = $cf_title_arr = []; - //获取来源 - $cf_id_arr = array_unique(array_column($rows, 'cf_id')); + + //获取来源二 + $cf_id_arr = array_unique(array_column($rows, 'cf2_id')); if ($cf_id_arr) { $cf_id_str = implode(',', $cf_id_arr); $res_cfrom = $this->clues_cfrom_model->select(["id in({$cf_id_str})" => null], 'id desc', 0, 0, 'id,title,pid'); @@ -106,6 +126,7 @@ class Clues extends HD_Controller $cf_title_arr[$val['id']] = $title; } } + //获取管理员 $this->load->model('sys/sys_admin_model', 'admin_model'); $admin_id_arr = array_unique(array_column($rows, 'admin_id')); @@ -113,26 +134,62 @@ class Clues extends HD_Controller $str_ids = implode(',', $admin_id_arr); $map_admin = $this->admin_model->map('id', 'username', ["id in ({$str_ids})" => null]); } - $county_id_arr = array_unique(array_column($rows, 'county_id')); + + //门店 + $biz_id_arr = array_unique(array_column($rows, 'biz_id')); + $str_ids = implode(',', $biz_id_arr); + $biz_id_arr && $biz_rows = $this->biz_model->map('id', 'id,biz_name,county_id', ["id in ({$str_ids})" => null], '', '', '', 'id,biz_name,county_id'); + + //门店位置 + $county_id_bizarr = array_filter(array_unique(array_column($biz_rows, 'county_id'))); + if ($county_id_bizarr) { + $str_ids = implode(',', $county_id_bizarr); + $map_area_biz = $this->area_model->map('county_id', '', ["county_id in ({$str_ids})" => null], '', 0, $size, 'county_id,province_name,city_name,county_name'); + } + + $county_id_arr = array_filter(array_unique(array_column($rows, 'county_id'))); if ($county_id_arr) { $str_ids = implode(',', $county_id_arr); - $map_area = $this->area_model->map('county_id', '', ["county_id in ({$str_ids})" => null], '', 0, $size, 'county_id,province_name,city_name,county_name'); + $map_area_county = $this->area_model->map('county_id', '', ["county_id in ({$str_ids})" => null], '', 0, $size, 'county_id,province_name,city_name,county_name'); } + + $city_id_arr = array_filter(array_unique(array_column($rows, 'city_id'))); + if ($city_id_arr) { + $str_ids = implode(',', $city_id_arr); + $map_area_city = $this->area_model->map('city_id', '', ["city_id in ({$str_ids})" => null], '', 0, $size, 'city_id,province_name,city_name'); + } + + $province_id_arr = array_filter(array_unique(array_column($rows, 'province_id'))); + if ($province_id_arr) { + $str_ids = implode(',', $province_id_arr); + $map_area_province = $this->area_model->map('province_id', '', ["province_id in ({$str_ids})" => null], '', 0, $size, 'province_id,province_name'); + } + foreach ($rows as $key => $val) { - $val['cf_title'] = $cf_title_arr[$val['cf_id']] ? $cf_title_arr[$val['cf_id']] : ''; + $val['cf_title'] = $cf_title_arr[$val['cf2_id']] ? $cf_title_arr[$val['cf2_id']] : $cf_title_arr[$val['cf_id']]; + $status_name = $statusAry[$val['status']]['name']; $val['status2'] && $status_name .= '‒' . $statusAry[$val['status']]['list'][$val['status2']]; $val['status_name'] = $status_name; $val['admin_name'] = $map_admin[$val['admin_id']] ? $map_admin[$val['admin_id']] : ''; - if (SUPER_ADMIN == $this->role) { - $val['mobile_sub'] = $val['mobile']; - } else { - $val['mobile_sub'] = $val['mobile'] ? substr_replace($val['mobile'], '*****', 0, 5) : ''; - } - $area = $map_area[$val['county_id']][0]; - if ($area) { + $val['mobile_sub'] = $val['mobile']; + + if ($val['county_id']) { + $area = $map_area_county[$val['county_id']][0]; $val['poi'] = "{$area['province_name']}-{$area['city_name']}-{$area['county_name']}"; + }elseif ($val['city_id']) { + $area = $map_area_city[$val['city_id']][0]; + $val['poi'] = "{$area['province_name']}-{$area['city_name']}"; + }elseif ($val['province_id']) { + $area = $map_area_province[$val['province_id']][0]; + $val['poi'] = "{$area['province_name']}"; } + + $val['biz_name'] = isset($biz_rows[$val['biz_id']]) ? $biz_rows[$val['biz_id']]['biz_name'] : ''; + + $bizarea = $map_area_biz[$biz_rows[$val['biz_id']]['county_id']][0]; + $val['biz_poi'] = "{$bizarea['province_name']}-{$bizarea['city_name']}-{$bizarea['county_name']}"; + $lists[] = $val; } } @@ -151,9 +208,10 @@ class Clues extends HD_Controller $statusList[] = array("id" => $key, "name" => $value['name'], "cate" => $cate, "count" => $count1); } - $map_cfrom = $this->clues_cfrom_model->map('id', 'title', array('status' => 1, 'pid' => 0), '', 0, 0, 'id, title'); + $map_cfrom = $this->clues_cfrom_model->map('id', 'title', array('status' => 1, 'pid' => 0, 'type' => 0), '', 0, 0, 'id, title'); $map_cfrom2 = $this->clues_cfrom_model->map('id', 'title', array('status' => 1, 'pid' => $params['cfrom_id']), '', 0, 0, 'id, title'); + $this->data['provinces'] = $this->province_ary(); $this->data['lists'] = $lists; $this->data['pager'] = array('count' => ceil($count / $size), 'curr' => $page, 'totle' => $count); $this->data['searchTpAry'] = $this->searchTpAry; @@ -239,7 +297,7 @@ class Clues extends HD_Controller $dataInfo['county_id'] = $re['county_id']; $dataInfo['v_id'] = intval($jsondata['car']['version']['id']); $dataInfo['cor_id'] = intval($jsondata['car']['color']['id']); - //获取已分配店铺 + //获取已分配门店 $cus = $this->customers_model->select(['rid' => $re['id']], '', '', '', 'biz_id'); $biz_arr = []; if ($cus) { @@ -293,7 +351,7 @@ class Clues extends HD_Controller } $cf_id1 = ''; - $cf_id2 = ''; + $c2_id2 = ''; if ($row['cf_id']) { $row_cfrom = $this->clues_cfrom_model->get(array('id' => $row['cf_id'])); if ($row_cfrom['pid']) { @@ -332,7 +390,7 @@ class Clues extends HD_Controller $action = "add"; } - $where = array('status' => 1, 'pid' => 0); + $where = array('status' => 1, 'pid' => 0, 'type' => 0); $select = 'id, title'; $map_cfrom = $this->clues_cfrom_model->map('id', 'title', $where, '', 0, 0, $select); $this->data['provinces'] = $this->province_ary(); @@ -355,20 +413,20 @@ class Clues extends HD_Controller if (!mobile_valid($info['mobile'])) { return $this->show_json(SYS_CODE_FAIL, '手机号码不准确'); } + if ($this->clues_model->get(['mobile' => $info['mobile']])) { return $this->show_json(SYS_CODE_FAIL, '手机号已存在'); } - $cf_id = 0; - if ($info['cf_id2']) { - $cf_id = $info['cf_id2']; - } else if ($info['cf_id1']) { - $cf_id = $info['cf_id1']; + + if (!$info['cf_id'] || !$info['cf_id2']) { + return $this->show_json(SYS_CODE_FAIL, '来源需填写完整'); } $add = array( 'name' => $info['name'], 'mobile' => $info['mobile'], - 'cf_id' => $cf_id, + 'cf_id' => $info['cf_id'], + 'cf2_id' => $info['cf_id2'], 'admin_id' => $this->uid, 'c_time' => time(), ); @@ -751,11 +809,15 @@ class Clues extends HD_Controller function json_map_cfrom() { $pid = $this->input->post('pid'); + $type = $this->input->post('type'); $status = $this->input->post('status'); $where = array(); if (strlen($pid) > 0) { $where['pid'] = $pid; + }else{ + !$type && $type = 0; + $where['type'] = $type; } if (strlen($status) > 0) { diff --git a/admin/controllers/receiver/CluesCfrom.php b/admin/controllers/receiver/CluesCfrom.php index 539fdc2a..4e649530 100644 --- a/admin/controllers/receiver/CluesCfrom.php +++ b/admin/controllers/receiver/CluesCfrom.php @@ -37,9 +37,10 @@ class CluesCfrom extends HD_Controller $setValue = []; $setValue['id'] = $value['id']; $setValue['name'] = $value['title']; + $setValue['type'] = $value['type'] ? '门店' : '中台'; $setValue['sort'] = $value['sort']; $setValue['status'] = $value['status']; - $setValue['status_name'] = $value['status'] == 1 ? '正常' : '禁用'; + $setValue['status_name'] = $value['status'] == 1 ? '开启' : '禁用'; $options = ''; $res_cfrom = $this->mdCluesCfrom->select(["status<>" => -1, 'pid' => $value['id']], "sort desc,id desc", 1, 10, 'title'); $res_cfrom && $options = implode(',', array_column($res_cfrom, 'title')); @@ -76,13 +77,15 @@ class CluesCfrom extends HD_Controller return $this->show_json(SYS_CODE_FAIL, '数据不存在!'); } $name = $re['title']; + $type = $re['type']; $sort = $re['sort']; } else { $url = "receiver/CluesCfrom/add"; $sort = 50; + $type = 0; $name = ''; } - $this->data['showInfo'] = ['id' => $id, 'name' => $name, 'sort' => $sort, 'url' => $url]; + $this->data['showInfo'] = ['id' => $id, 'name' => $name, 'type' => $type, 'sort' => $sort, 'url' => $url]; return $this->show_view('receiver/cluescfrom/edit'); } @@ -97,7 +100,13 @@ class CluesCfrom extends HD_Controller if ($re) { return $this->show_json(SYS_CODE_FAIL, '名称已存在了!'); } - $id = $this->mdCluesCfrom->add(['title' => $params['name'], 'sort' => $params['sort'], 'c_time' => time()]); + + $re = $this->mdCluesCfrom->get(array('type' => 1, 'pid' => 0, "status" => 1)); + if ($re && $re['id'] != $params['id']) { + return $this->show_json(SYS_CODE_FAIL, '门店分类最多存在一个!'); + } + + $id = $this->mdCluesCfrom->add(['title' => $params['name'], 'type' => $params['type'], 'sort' => $params['sort'], 'c_time' => time()]); if (!$id) { return $this->show_json(SYS_CODE_FAIL, '保存失败'); } @@ -118,7 +127,12 @@ class CluesCfrom extends HD_Controller if ($re && $re['id'] != $params['id']) { return $this->show_json(SYS_CODE_FAIL, '名称已存在了!'); } - $this->mdCluesCfrom->update(['title' => $params['name'], 'sort' => $params['sort']], ['id' => $params['id']]); + + $re = $this->mdCluesCfrom->get(array('type' => 1, 'pid' => 0, "status" => 1)); + if ($re && $re['id'] != $params['id']) { + return $this->show_json(SYS_CODE_FAIL, '门店分类最多存在一个!'); + } + $this->mdCluesCfrom->update(['title' => $params['name'], 'type' => $params['type'],'sort' => $params['sort']], ['id' => $params['id']]); return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); } diff --git a/admin/controllers/receiver/Customer.php b/admin/controllers/receiver/Customer.php index fc28f42b..ac1a8a3d 100644 --- a/admin/controllers/receiver/Customer.php +++ b/admin/controllers/receiver/Customer.php @@ -10,8 +10,7 @@ defined('BASEPATH') or exit('No direct script access allowed'); class Customer extends HD_Controller { private $searchTpAry = array('mobile' => '客户手机号', 'name' => '客户姓名'); - private $searchTimeAry = array('c_time' => '创建时间', 'p_time' => '分配时间', 'cont_time' => '最后联系时间', 'u_time' => '最后操作时间' - , 'dt_time' => '首次到店时间', 'order_time' => '下单时间', 'def_time' => '战败时间'); + private $searchTimeAry = array('c_time' => '创建时间', 'p_time' => '派单时间', 'cont_time' => '最后联系时间', 'dt_time' => '首次到店时间', 'order_time' => '下定时间', 'def_time' => '战败时间'); protected $log_dir; @@ -29,8 +28,9 @@ class Customer extends HD_Controller // $this->load->model('receiver/Receiver_customer_stat_data_log_model', 'statdatalog'); $this->load->model('app/licheb/app_licheb_users_model'); $this->load->model("biz/biz_model"); - + $this->load->model('area_model'); $this->load->model('auto/auto_brand_model'); + $this->log_dir = 'receiver_' . get_class($this); } @@ -50,30 +50,37 @@ class Customer extends HD_Controller $where = $this->get_where($params); $count = $this->customers_model->count($where); $lists = []; - $offlineSources = $this->customers_model->offlineSources(); - $wxqyAry = $this->customers_model->wxqyAry(); + + //$wxqyAry = $this->customers_model->wxqyAry(); $wxgrAry = $this->customers_model->wxgrAry(); if ($count) { - $fileds = 'id,name,mobile,cf_title,cont_time,admin_id,status,biz_id,cs_biz_id,level,of_id,of2_id,wxqy,wxgr'; + $fileds = 'id,name,mobile,cf_title,cont_time,admin_id,status,biz_id,level,of_id,of2_id,wxgr,c_time,county_id'; $rows = $this->customers_model->select($where, 'id desc', $page, $size, $fileds); - //获取销售员 + //获取车管家 $admin_id_arr = array_unique(array_column($rows, 'admin_id')); $admin_id_arr && $admin_rows = $this->app_licheb_users_model->get_map_by_ids($admin_id_arr, 'id,uname'); //获取门店 $biz_id_arr = array_unique(array_column($rows, 'biz_id')); $biz_id_arr && $biz_rows = $this->biz_model->get_map_by_ids($biz_id_arr, 'id,biz_name'); foreach ($rows as $key => $val) { - if (SUPER_ADMIN == $this->role) { - $mobile_sub = $val['mobile']; - } else { - $mobile_sub = $val['mobile'] ? substr_replace($val['mobile'], '*****', 0, 5) : ''; - } + $mobile_sub = $val['mobile']; $of_title = ''; if ($val['of_id']) { - $of_ary = $offlineSources[$val['of_id']]; - $of_title = $of_ary['name']; - $val['of2_id'] && $of_title .= '-' . $of_ary['list'][$val['of2_id']]; + $of = $this->clues_cfrom_model->get(array('id' => $val['of_id'])); + $of_title = $of['title']; + if($val['of2_id']){ + $of = $this->clues_cfrom_model->get(array('id' => $val['of2_id'])); + $of_title .= '-' . $of['title']; + } } + + $county_id_arr = array_unique(array_column($rows, 'county_id')); + if ($county_id_arr) { + $str_ids = implode(',', $county_id_arr); + $map_area = $this->area_model->map('county_id', '', ["county_id in ({$str_ids})" => null], '', 0, $size, 'county_id,province_name,city_name,county_name'); + $area = $map_area[$val['county_id']][0]; + } + $lists[] = array( 'id' => $val['id'], 'name' => $val['name'], @@ -83,11 +90,13 @@ class Customer extends HD_Controller 'of_title' => $of_title, 'of2_id' => $val['of2_id'], 'status_name' => $status_arr[$val['status']], - 'wxqy_name' => $wxqyAry[$val['wxqy']], + //'wxqy_name' => $wxqyAry[$val['wxqy']], 'wxgr_name' => $wxgrAry[$val['wxgr']], - 'to_send' => $this->customers_model->csbizidAry($val['cs_biz_id'] ? $val['cs_biz_id'] : 0), + //'to_send' => $this->customers_model->csbizidAry($val['cs_biz_id'] ? $val['cs_biz_id'] : 0), 'admin_name' => isset($admin_rows[$val['admin_id']]) ? $admin_rows[$val['admin_id']][0]['uname'] : '', + 'area' => $area ? "{$area['province_name']}-{$area['city_name']}-{$area['county_name']}" : '', 'biz_name' => isset($biz_rows[$val['biz_id']]) ? $biz_rows[$val['biz_id']][0]['biz_name'] : '', + 'c_time' => $val['c_time'] != '0' ? date('Y-m-d H:i:s', $val['c_time']) : '', 'cont_time' => $val['cont_time'] != '0000-00-00 00:00:00' ? $val['cont_time'] : '', ); } @@ -98,12 +107,11 @@ class Customer extends HD_Controller $show_info['tagsIntention'] = $this->get_tag(0, 2, $tag_data); $tag_data = $params['tagsDefeat'] ? explode(',', $params['tagsDefeat']) : ''; $show_info['tagsDefeat'] = $this->get_tag(0, 1, $tag_data); - //渠道经理 + //客户成功经理 $qdjl_lists = $this->app_licheb_users_model->select(array('group_id' => 4, 'status' => 1, 'biz_id<>' => '0'), 'id desc', 0, 0, 'id,uname as name'); $show_info['levelAry'] = $this->customers_model->get_sdata('level'); - #$show_info['offlineSourcesAry'] = $offlineSources; - $show_info['offlineSourcesAry'] = $this->customers_model->offlineSources_search(); - $show_info['wxqyAry'] = $wxqyAry; + $show_info['cfroms'] = $this->clues_cfrom_model->map('id', 'title', array('status' => 1, 'pid' => 0), '', 0, 0, 'id, title'); + $show_info['cfroms2'] = $this->clues_cfrom_model->map('id', 'title', array('status' => 1, 'pid' => $params['of_id']), '', 0, 0, 'id, title'); $show_info['wxgrAry'] = $wxgrAry; $show_info['csbizidAry'] = $this->customers_model->csbizidAry(); $show_info['cbrandAry'] = $this->customers_model->cbrandAry(); @@ -400,6 +408,7 @@ class Customer extends HD_Controller !is_numeric($params['c_brand']) && $params['c_brand'] = ''; !$params['of_id'] && $params['of_id'] = ''; !$params['of2_id'] && $params['of2_id'] = ''; + !$params['province_id'] && $params['province_id'] = ''; !$params['city_id'] && $params['city_id'] = ''; !$params['county_id'] && $params['county_id'] = ''; !$params['biz_type'] && $params['biz_type'] = ''; @@ -432,6 +441,9 @@ class Customer extends HD_Controller if ($params['of2_id']) { $where['of2_id'] = $params['of2_id']; } + if ($params['province_id']) { + $where['province_id'] = $params['province_id']; + } if ($params['city_id']) { $where['city_id'] = $params['city_id']; } @@ -462,8 +474,12 @@ class Customer extends HD_Controller $where["biz_id in(select id from lc_biz where county_id={$params['county_id_admin']})"] = null; } else if ($params['city_id_admin']) { $where["biz_id in(select id from lc_biz where city_id={$params['city_id_admin']})"] = null; + }else if ($params['province_id_admin']) { + $where["biz_id in(select id from lc_biz where province_id={$params['province_id_admin']})"] = null; } + $where[$this->customers_model->csbizidWhere($params['cs_biz_id'])] = null; + !$params['province_id_admin'] && $params['province_id_admin'] = ''; !$params['city_id_admin'] && $params['city_id_admin'] = ''; !$params['county_id_admin'] && $params['county_id_admin'] = ''; !$params['biz_id_admin'] && $params['biz_id_admin'] = ''; @@ -503,22 +519,7 @@ class Customer extends HD_Controller $order_time[0] && $where["def_time >="] = $order_time[0] . ' 00:00:00'; $order_time[1] && $where["def_time <="] = $order_time[1] . ' 23:59:59'; } - if ($params['cfrom_id'] || $params['cfrom_id2']) { - if ($params['cfrom_id'] == 24) { - $where['cf_id'] = 24; - $params['cfrom_id2'] && $where['t_id'] = $params['cfrom_id2']; - } else { - if ($params['cfrom_id2']) { - $where['cf_id'] = $params['cfrom_id2']; - } else { - $cf_rows = $this->clues_cfrom_model->select(['pid' => $params['cfrom_id']], '', '', '', 'id'); - $cf_ids = array_column($cf_rows, 'id'); - $cf_ids[] = $params['cfrom_id']; - $cf_str_ids = implode(',', array_filter($cf_ids)); - $cf_str_ids && $where["cf_id in ({$cf_str_ids})"] = null; - } - } - } + if ($params['tags']) { $where = $this->tagWhere($where, $params['tags']); } else if ($params['tagsIntention']) { @@ -926,7 +927,9 @@ class Customer extends HD_Controller $count = $this->customers_model->count($where); $data = []; - $offlineSources = $this->customers_model->offlineSources(); + + + $onlineSources = $this->customers_model->offlineSources(); $status_arr = $this->customers_model->get_status(); unset($status_arr['-1']); if ($count) { diff --git a/admin/core/HD_Controller.php b/admin/core/HD_Controller.php index caf7af96..bef02680 100644 --- a/admin/core/HD_Controller.php +++ b/admin/core/HD_Controller.php @@ -14,7 +14,11 @@ abstract class HD_Controller extends CI_Controller public $data = array(), $if_ajax = false; - public $city_lists = [430, 350]; //开发城省份 湖南 福建 + //开发城省份 湖南 福建 + public $city_lists = array( + '430000' => ['id' => '430000', 'name' => '湖南省'], + '350000' => ['id' => '350000', 'name' => '福建省'], + ); public function __construct() { @@ -132,8 +136,10 @@ abstract class HD_Controller extends CI_Controller protected function province_ary() { $area_where = []; - if ($this->city_lists) { - $area_where["province_id in (" . implode(",", $this->city_lists) . ")"] = null; + $citys = array_column($this->city_lists, 'id'); + if ($citys) { + $this->load->model("sys/area_model", 'area_model'); + $area_where["province_id in (" . implode(",", $citys) . ")"] = null; } return $this->area_model->select($area_where, '', 0, 0, 'distinct(province_id), province_name'); } diff --git a/admin/views/app/licheb/member/get.php b/admin/views/app/licheb/member/get.php index 180f57a7..9545a93f 100644 --- a/admin/views/app/licheb/member/get.php +++ b/admin/views/app/licheb/member/get.php @@ -15,7 +15,7 @@
-
+
@@ -86,7 +86,15 @@