From 954b393843caa61d95cfbcfec8594eafcde0c34f Mon Sep 17 00:00:00 2001 From: dengbw Date: Fri, 11 Mar 2022 17:05:53 +0800 Subject: [PATCH] admin_customer_tag_311 --- admin/controllers/receiver/Tag.php | 177 ++++++++++++++ admin/views/receiver/tag/edit.php | 20 ++ admin/views/receiver/tag/lists.php | 222 ++++++++++++++++++ api/controllers/plan/Temp.php | 26 +- api/controllers/wxapp/licheb/Customers.php | 33 ++- api/controllers/wxapp/material/Biz.php | 9 +- common/libraries/entity/Syt_entity.php | 4 +- .../receiver/Receiver_customer_tag_model.php | 30 +++ .../receiver/Receiver_customers_model.php | 4 +- 9 files changed, 490 insertions(+), 35 deletions(-) create mode 100644 admin/controllers/receiver/Tag.php create mode 100644 admin/views/receiver/tag/edit.php create mode 100644 admin/views/receiver/tag/lists.php create mode 100644 common/models/receiver/Receiver_customer_tag_model.php diff --git a/admin/controllers/receiver/Tag.php b/admin/controllers/receiver/Tag.php new file mode 100644 index 00000000..713bcec4 --- /dev/null +++ b/admin/controllers/receiver/Tag.php @@ -0,0 +1,177 @@ +load->model('receiver/receiver_customer_tag_model', 'mdCustomerTag'); + } + + //首页信息 + public function index() + { + return $this->lists(); + } + + //数据列表 + public function lists() + { + $params = $this->input->get(); + $params['page'] = $params['page'] ? intval($params['page']) : 1; + $params['size'] = $params['size'] ? intval($params['size']) : 20; + $statusAry = $this->mdCustomerTag->statusAry(); + $lists = array(); + $where = ["status<>-1" => null, 'pid' => 0]; + if (strlen($params['status'])) { + $where['status'] = $params['status']; + } + $count = $this->mdCustomerTag->count($where); + if ($count) { + $res = $this->mdCustomerTag->select($where, "sort desc,id desc", $params['page'], $params['size']); + foreach ($res as $key => $value) { + $setValue = array(); + $setValue['id'] = $value['id']; + $setValue['name'] = $value['name']; + $setValue['sort'] = $value['sort']; + $setValue['status'] = $value['status']; + $setValue['status_name'] = $statusAry[$value['status']]; + $options = ''; + $res_tag = $this->mdCustomerTag->select(["status" => 1, 'pid' => $value['id']], "sort desc,id desc", 0, 0, 'id,name,sort'); + $res_tag && $options = implode(',', array_column($res_tag, 'name')); + $setValue['options'] = $options; + $lists[] = $setValue; + } + } + $this->data['lists'] = $lists; + $this->data['params'] = $params; + $this->data['showInfo'] = ['statusAry' => $statusAry]; + $this->data['_title'] = '客户标签列表'; + $this->data['pager'] = array('count' => ceil($count / $params['size']), 'curr' => $params['page'], 'totle' => $count); + return $this->show_view('/receiver/tag/lists', true); + } + + public function get_options() + { + $id = intval($this->input->post('id')); + if (!$id) { + return $this->show_json(SYS_CODE_FAIL, '参数错误!'); + } + $res_tag = $this->mdCustomerTag->select(["status" => 1, 'pid' => $id], "sort desc,id desc", 0, 0, 'id,name,sort,status'); + $this->data['lists'] = $res_tag; + return $this->show_json(SYS_CODE_SUCCESS); + } + + //展示单条数据 + public function get() + { + $id = intval($this->input->get('id')); + if ($id) { + $url = "/receiver/tag/edit"; + $re = $this->mdCustomerTag->get(['id' => $id]); + if (!$re) { + return $this->show_json(SYS_CODE_FAIL, '客户标签不存在!'); + } + $name = $re['name']; + $sort = $re['sort']; + } else { + $url = "/receiver/tag/add"; + $name = ''; + $sort = 0; + } + $this->data['showInfo'] = ['id' => $id, 'name' => $name, 'sort' => $sort, 'url' => $url]; + return $this->show_view('/receiver/tag/edit'); + } + + //添加单条数据 + public function add() + { + $params = $this->input->post(); + if (!$params['name']) { + return $this->show_json(SYS_CODE_FAIL, '标签名称不能为空!'); + } + $re = $this->mdCustomerTag->get(array('name' => $params['name'])); + if ($re) { + return $this->show_json(SYS_CODE_FAIL, '标签名称已存在了!'); + } + $this->mdCustomerTag->add(['name' => $params['name'], 'sort' => $params['sort']]); + return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); + } + + //编辑单条数据 + public function edit() + { + $params = $this->input->post(); + if (!$params['id']) { + return $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + if (!$params['name']) { + return $this->show_json(SYS_CODE_FAIL, '请输入标签名称'); + } + $re = $this->mdCustomerTag->get(array('name' => $params['name'])); + if ($re && $re['id'] != $params['id']) { + return $this->show_json(SYS_CODE_FAIL, '标签名称已存在了!'); + } + $this->mdCustomerTag->update(['name' => $params['name'], 'sort' => $params['sort']], ['id' => $params['id']]); + return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); + } + + //修改标签选项 + function edit_options() + { + $id = $this->input->post('id'); + $options = $this->input->post('options'); + if (!$id || !$options) { + return $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + foreach ($options as $key => $value) { + $data = ['name' => $value['name'], 'status' => $value['status'], 'sort' => intval($value['sort'])]; + if ($value['name']) { + if ($value['id']) {//修改 + $this->mdCustomerTag->update($data, ['id' => $value['id']]); + } else {//新增 + $data['pid'] = $id; + $this->mdCustomerTag->add($data); + } + } + } + return $this->show_json(SYS_CODE_SUCCESS, '保存成功'); + } + + function edit_status() + { + $id = $this->input->post('id'); + $stauts = intval($this->input->post('status')); + if (!$id) { + $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + $this->mdCustomerTag->update(['status' => $stauts], ['id' => $id]); + return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); + } + + //删除单条数据 + public function del() + { + $id = $this->input->post('id'); + if (!$id) { + $this->show_json(SYS_CODE_FAIL, '参数错误'); + } + $this->mdCustomerTag->update(['status' => '-1'], ['id' => $id]); + return $this->show_json(SYS_CODE_SUCCESS, '操作成功'); + } + + //批量操作(默认修改状态) + public function batch() + { + + } + + //导出数据列表 + public function export() + { + + } +} \ No newline at end of file diff --git a/admin/views/receiver/tag/edit.php b/admin/views/receiver/tag/edit.php new file mode 100644 index 00000000..e0b3b28a --- /dev/null +++ b/admin/views/receiver/tag/edit.php @@ -0,0 +1,20 @@ +
+ +
+ +
+ +
+
+
+ +
+ + 越大越靠前 +
+
+
+ +
+
\ No newline at end of file diff --git a/admin/views/receiver/tag/lists.php b/admin/views/receiver/tag/lists.php new file mode 100644 index 00000000..3a7463c8 --- /dev/null +++ b/admin/views/receiver/tag/lists.php @@ -0,0 +1,222 @@ +
+ +
+
共有条数据
+ + + + + + + + + + + + + + + + + + + + + + +
名称标签选项排序状态
+ 编辑选项 + 编辑标签 + + 关闭 + + + 开启 + + 删除 +
+ +
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/api/controllers/plan/Temp.php b/api/controllers/plan/Temp.php index 0b92bbec..ac8e267d 100644 --- a/api/controllers/plan/Temp.php +++ b/api/controllers/plan/Temp.php @@ -33,34 +33,20 @@ class Temp extends HD_Controller !$param['page'] && $param['page'] = 1; $counts = intval($param['counts']); ob_start(); //打开缓冲区 - $where = array("cf_clues !=''" => null); - $res = $this->mdCustomers->select($where, 'id ASC', $param['page'], $param['size'], 'id,cf_clues'); + $where = array("cf_title" => '素材推广'); + $res = $this->mdCustomers->select($where, 'id ASC', $param['page'], $param['size'], 'id,cf_title'); if (!$res) { echo '
本次更新客户线下来源完成了:'; echo '

成功更新 ' . $counts . ' 条'; echo '

点击将再次更新客户线下来源>>>'; + $this->mdCustomers->update(['cf_title' => '自有资源', 'of_id' => 5, 'of2_id' => 53], ['id' => 2873]); exit; } $log = array(); foreach ($res as $key => $value) { - $of_id = 0; - $cf_clues = $value['cf_clues']; - if ($cf_clues == '自然进店') { - $of_id = 1; - } else if ($cf_clues == '外展' || $cf_clues == 'DM' || $cf_clues == '外展外拓') { - $of_id = 4; - } else if ($cf_clues == '转介绍') { - $of_id = 2; - } else if ($cf_clues == '网站' || $cf_clues == '垂直媒体') { - $of_id = 3; - } else if ($cf_clues == '自媒体' || $cf_clues == '其他') { - $of_id = 5; - } - if ($of_id) { - $this->mdCustomers->update(['of_id' => $of_id], ['id' => $value['id']]); - $log[] = array('id' => $value['id'], 'of_id' => $of_id); - $counts++; - } + $this->mdCustomers->update(['cf_title' => '自有资源', 'of_id' => 5, 'of2_id' => 53], ['id' => $value['id']]); + $log[] = array('id' => $value['id'], 'of_id' => 5); + $counts++; } echo '
成功更新:'; $log && print_r($log); diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index 10009181..444894d5 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -55,9 +55,10 @@ class Customers extends Wxapp '品牌车型' => $brand['name'] . $series['name'], '颜色型号' => $color . '-' . $version, '建卡时间' => date('Y-m-d', $row['c_time']), - '客户来源' => $row['cf_title'], + '客户来源' => $this->get_cfTitle($row), '销售顾问' => isset($admin) ? $admin['uname'] : '', ]; + $other_data['销售顾问'] = isset($admin) ? $admin['uname'] : ''; $row['cont_time'] != '0000-00-00 00:00:00' && $other_data['上次联系'] = date('Y-m-d', strtotime($row['cont_time'])); $data = [ 'id' => $row['id'], @@ -88,12 +89,7 @@ class Customers extends Wxapp throw new Exception('数据不存在', ERR_PARAMS_ERROR); } $car_json = json_decode($row['car_json'], true); - $of_title = ''; - if ($row['of_id']) { - $of_ary = $this->customers_model->offlineSources()[$row['of_id']]; - $of_title = $of_ary['name']; - $row['of2_id'] && $of_title .= '-' . $of_ary['list'][$row['of2_id']]; - } + $of_title = $row['of_id'] ? $this->get_cfTitle($row) : ''; $data['baseinfo'] = [ 'name' => ['value' => $row['name'], 'cn' => '客户姓名'], 'mobile' => ['value' => $this->get_mobile(['mobile' => $row['mobile'], 'cf_title' => $row['cf_title']]), 'cn' => '客户电话'], @@ -496,7 +492,8 @@ class Customers extends Wxapp $count = $this->customers_model->count($where); $lists = []; if ($count) { - $fileds = 'id,name,admin_id,mobile,level,car_json,is_top,cf_title,brand_id,s_id,cont_time,c_time,defeat_time'; + $fileds = 'id,name,admin_id,mobile,level,car_json,is_top,cf_title,brand_id,s_id,cont_time,c_time,defeat_time + ,of_id,of2_id'; $rows = $this->customers_model->select($where, $orderby, $page, $size, $fileds); //获取管理员 $admin_arr = array_unique(array_column($rows, 'admin_id')); @@ -527,7 +524,7 @@ class Customers extends Wxapp '品牌车型' => $brand_name . $serie_name, '颜色型号' => $color . '-' . $version, '建卡时间' => date('Y-m-d', $val['c_time']), - '客户来源' => $val['cf_title'], + '客户来源' => $this->get_cfTitle($val), '销售顾问' => isset($admins[$val['admin_id']]) ? $admins[$val['admin_id']][0]['uname'] : '', ]; $val['cont_time'] != '0000-00-00 00:00:00' && $other_data['上次联系'] = date('Y-m-d', strtotime($val['cont_time'])); @@ -756,6 +753,24 @@ class Customers extends Wxapp throw new Exception('操作失败', ERR_PARAMS_ERROR); } + /** + * Notes:来源title + * Created on: 2022/3/11 15:53 + * Created by: dengbw + * @param $params + * @return string + */ + private function get_cfTitle($params) + { + $title = $params['cf_title'] ? $params['cf_title'] : ''; + if ($title == '自有资源' && $params['of_id']) {//自有资源 取线下来源 + $of_ary = $this->customers_model->offlineSources()[$params['of_id']]; + $title = $of_ary['name']; + $params['of2_id'] && $title .= '-' . $of_ary['list'][$params['of2_id']]; + } + return $title; + } + /** * Notes:显示电话格式 * Created on: 2022/3/9 14:38 diff --git a/api/controllers/wxapp/material/Biz.php b/api/controllers/wxapp/material/Biz.php index da70409b..5a11d031 100644 --- a/api/controllers/wxapp/material/Biz.php +++ b/api/controllers/wxapp/material/Biz.php @@ -196,12 +196,13 @@ class Biz extends Wxapp if (!$re_biz) { return $this->Hd_exception(SYS_CODE_FAIL, '预约的门店不存在!'); } + $of_id = $of2_id = 0; if ($type == 'biz') { $cf_id = 29; - $cf_title = '自有资源'; } else { $cf_id = $this->cf_id; - $cf_title = '素材推广'; + $of_id = 5; + $of2_id = 53;//狸车素材 } $add_data = [ 'name' => $this->session['uname'] ? $this->session['uname'] : '', @@ -209,12 +210,14 @@ class Biz extends Wxapp 'biz_id' => $biz_id, 'city_id' => $re_biz['city_id'], 'county_id' => $re_biz['county_id'], - 'cf_title' => $cf_title, + 'cf_title' => '自有资源', 'cf_id' => $cf_id, 't_id' => $t_id, 'p_time' => date('Y-m-d H:i:s'), 'c_time' => time() ]; + $of_id && $add_data['of_id'] = $of_id; + $of2_id && $add_data['of2_id'] = $of2_id; $where = ['biz_id' => $biz_id, 'mobile' => $add_data['mobile']]; $re_cus = $this->mdCustomers->get($where); if ($re_cus) { diff --git a/common/libraries/entity/Syt_entity.php b/common/libraries/entity/Syt_entity.php index de2507e8..cef09acb 100644 --- a/common/libraries/entity/Syt_entity.php +++ b/common/libraries/entity/Syt_entity.php @@ -103,7 +103,9 @@ class Syt_entity 'brand_id' => $brand_id, 'city_id' => $re_biz['city_id'], 'county_id' => $re_biz['county_id'], - 'cf_title' => '私域活动', + 'cf_title' => '自有资源', + 'of_id' => 5, + 'of2_id' => 53,//狸车素材 'cf_id' => $cf_id, 't_id' => $params['a_id'], 'p_time' => date('Y-m-d H:i:s'), diff --git a/common/models/receiver/Receiver_customer_tag_model.php b/common/models/receiver/Receiver_customer_tag_model.php new file mode 100644 index 00000000..2f0e866d --- /dev/null +++ b/common/models/receiver/Receiver_customer_tag_model.php @@ -0,0 +1,30 @@ +table_name, 'default'); + } + + /** + * Notes:类型 + * Created on: 2021/7/27 10:31 + * Created by: dengbw + * @return array + */ + public function statusAry() + { + return array(1 => '正常', 0 => '禁用'); + } + +} diff --git a/common/models/receiver/Receiver_customers_model.php b/common/models/receiver/Receiver_customers_model.php index f3c29c08..3520f577 100644 --- a/common/models/receiver/Receiver_customers_model.php +++ b/common/models/receiver/Receiver_customers_model.php @@ -14,7 +14,7 @@ class Receiver_customers_model extends HD_Model private $status_arr = [-1 => '删除', 0 => '未见客户', 1 => '到店客户', 2 => '订单客户', 3 => '战败客户']; private $level = ['H', 'A', 'B', 'C', 'D']; - private $cfrom_arr = ['自有资源', '平台分配', '素材推广', '私域活动']; + private $cfrom_arr = ['自有资源', '平台分配']; private $cfrom_clues_arr = ['自然进店', '外展', 'DM', '转介绍', '其它', '网站', '外展外拓', '垂直媒体', '自媒体']; private $buy_time = [3 => '3天(H级)', 7 => '7天(A级)', 15 => '15天(B级)', 30 => '30天 (C级)']; @@ -82,7 +82,7 @@ class Receiver_customers_model extends HD_Model $arr[2] = ['name' => '转介绍', 'list' => [20 => '其他4S店', 21 => '其他二网', 22 => '汽车美容', 23 => '二手车', 24 => '修车厂', 25 => '驾校', 26 => '老车主']]; $arr[3] = ['name' => '网络推广', 'list' => [30 => '抖音', 31 => '区域媒体', 32 => '懂车帝', 33 => '易车', 34 => '汽车之家', 35 => '网红']]; $arr[4] = ['name' => '外展外拓', 'list' => [40 => '巡展', 41 => '车展', 42 => '静展', 43 => '大客户']]; - $arr[5] = ['name' => '自媒体', 'list' => [50 => '小红书号', 51 => '咸鱼号', 52 => '抖音号', 53 => '狸车素材']]; + $arr[5] = ['name' => '自媒体', 'list' => [50 => '小红书号', 51 => '咸鱼号', 52 => '抖音号', 53 => '狸车素材', 54 => '知乎号']]; if ($id) { return $arr[$id]; } else {