From cf16ca4e255ac177bbefd3087809c66edf125a0e Mon Sep 17 00:00:00 2001 From: dengbw Date: Fri, 18 Mar 2022 17:51:18 +0800 Subject: [PATCH] customer_318 --- admin/controllers/Common.php | 27 ++ admin/controllers/auto/Introduce.php | 170 +++++++++++ admin/views/auto/introduce/edit.php | 305 ++++++++++++++++++++ admin/views/auto/introduce/lists.php | 215 ++++++++++++++ api/controllers/wxapp/licheb/Customers.php | 35 ++- api/controllers/wxapp/material/Biz.php | 12 +- common/models/auto/Auto_introduce_model.php | 29 ++ 7 files changed, 779 insertions(+), 14 deletions(-) create mode 100644 admin/controllers/auto/Introduce.php create mode 100644 admin/views/auto/introduce/edit.php create mode 100644 admin/views/auto/introduce/lists.php create mode 100644 common/models/auto/Auto_introduce_model.php diff --git a/admin/controllers/Common.php b/admin/controllers/Common.php index 450c9955..7c37c963 100644 --- a/admin/controllers/Common.php +++ b/admin/controllers/Common.php @@ -16,6 +16,33 @@ class Common extends CI_Controller public $data = array(); + /** + * Notes:获取车系 + * Created on: 2022/3/18 17:09 + * Created by: dengbw + * @return bool + */ + public function auto_series() + { + $this->load->model('auto/auto_series_model', 'mdAutoSeries'); + $page = $this->input->post('page') ? intval($this->input->post('page')) : 1; + $size = $this->input->post('size') ? intval($this->input->post('size')) : 10; + $brand_id = intval($this->input->post('brand_id')); + $name = $this->input->post('name'); + $where['status'] = 1; + $brand_id && $where['brand_id'] = $brand_id; + $name && $where['name like "%' . $name . '%"'] = null; + $list = []; + $count = $this->mdAutoSeries->count($where); + if ($count) { + $list = $this->mdAutoSeries->select($where, "id desc", $page, $size, 'id, name'); + } + $this->data['list'] = $list; + $hasNext = ceil($count / $size) > $page ? 1 : 0; + $this->data['page'] = array('page' => $page, 'pageLimit' => $size, 'pageCount' => $count, 'hasNext' => $hasNext); + return $this->show_json(SYS_CODE_SUCCESS); + } + //获取素材模版 public function material() { diff --git a/admin/controllers/auto/Introduce.php b/admin/controllers/auto/Introduce.php new file mode 100644 index 00000000..7dd0fdb6 --- /dev/null +++ b/admin/controllers/auto/Introduce.php @@ -0,0 +1,170 @@ +load->model('auto/auto_introduce_model', 'mdAutoIntroduce'); + $this->load->model('auto/auto_brand_model', 'mdAutoBrand'); + $this->load->model('auto/auto_series_model', 'mdAutoSeries'); + } + + //首页信息 + 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->mdAutoIntroduce->statusAry(); + $lists = array(); + $where = ["status<>-1" => null]; + if (strlen($params['status'])) { + $where['status'] = $params['status']; + } + $count = $this->mdAutoIntroduce->count($where); + if ($count) { + $res = $this->mdAutoIntroduce->select($where, "id desc", $params['page'], $params['size']); + $map_brand = $map_series = []; + $brand_ids = array_unique(array_column($res, 'brand_id')); + if ($brand_ids) { + $str_ids = implode(',', $brand_ids); + $map_brand = $this->mdAutoBrand->map('id', 'name', ["id in ({$str_ids})" => null]); + } + $s_ids = array_unique(array_column($res, 's_id')); + if ($s_ids) { + $str_ids = implode(',', $s_ids); + $map_series = $this->mdAutoSeries->map('id', 'name', ["id in ({$str_ids})" => null]); + } + foreach ($res as $key => $value) { + $brand_name = $map_brand[$value['brand_id']]; + $s_name = $map_series[$value['s_id']]; + $lists[] = [ + 'id' => $value['id'], + 'title' => "{$brand_name}-{$s_name}", + 'status' => $value['status'], + 'status_name' => $statusAry[$value['status']], + 'c_time' => date('Y-m-d', $value['c_time']), + ]; + } + } + $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('/auto/introduce/lists', true); + } + + + //展示单条数据 + public function get() + { + $id = intval($this->input->get('id')); + $info = []; + if ($id) { + $re = $this->mdAutoIntroduce->get(['id' => $id]); + if (!$re) { + return $this->show_json(SYS_CODE_FAIL, '车型不存在!'); + } + $_title = '编辑车型介绍'; + $showInfo = ['title' => '请选择车型', 'url' => '/auto/introduce/edit']; + } else { + $_title = '新增车型介绍'; + $info = array( + 'brand_id' => 0, + 's_id' => 0, + 'video' => '', + 'video_cover' => '', + 'content' => '', + ); + $showInfo = ['title' => '请选择车型', 'url' => '/auto/introduce/add']; + } + $showInfo['brandList'] = $this->mdAutoBrand->select(["status<>-1" => null], 'id desc', 0, 0, 'id, name'); + $this->data['_title'] = $_title; + $this->data['info'] = $info; + $this->data['showInfo'] = $showInfo; + return $this->show_view('/auto/introduce/edit',true); + } + + //添加单条数据 + 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'], 'type' => $params['type']]); + 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'], 'type' => $params['type']] + , ['id' => $params['id']]); + 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->mdAutoIntroduce->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->mdAutoIntroduce->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/auto/introduce/edit.php b/admin/views/auto/introduce/edit.php new file mode 100644 index 00000000..3e4d971d --- /dev/null +++ b/admin/views/auto/introduce/edit.php @@ -0,0 +1,305 @@ +
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+
+ + +
+
+
+
+
+ +
+ +
+
+
+ +
+ + +
+ \ No newline at end of file diff --git a/admin/views/auto/introduce/lists.php b/admin/views/auto/introduce/lists.php new file mode 100644 index 00000000..a7d46233 --- /dev/null +++ b/admin/views/auto/introduce/lists.php @@ -0,0 +1,215 @@ +
+ +
+
共有条数据
+ + + + + + + + + + + + + + + + + + + +
车型创建时间状态操作
+ 关闭 + + + 开启 + + 删除
+ +
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/api/controllers/wxapp/licheb/Customers.php b/api/controllers/wxapp/licheb/Customers.php index 9f9dd3fd..9450d9bf 100644 --- a/api/controllers/wxapp/licheb/Customers.php +++ b/api/controllers/wxapp/licheb/Customers.php @@ -574,10 +574,7 @@ class Customers extends Wxapp //车系车型 //$series_arr = array_unique(array_column($rows, 's_id')); //$series = $this->auto_series_model->get_map_by_ids($series_arr, 'id,name'); - $allot = 0; - if ($group_id == 2 || $group_id == 3) {//店长和老板可再分配用户 - $allot = 1; - } + $allot = $this->get_allot(); foreach ($rows as $key => $val) { //$car_json = json_decode($val['car_json'], true); //$color = isset($car_json['color']) ? $car_json['color']['title'] : ''; @@ -609,6 +606,7 @@ class Customers extends Wxapp 'other_data' => $other_data, 'tags' => $tags, 'defeat' => $defeat, + 'group_id' => $group_id, 'allot' => $allot ]; } @@ -627,6 +625,10 @@ class Customers extends Wxapp $uid = $this->session['uid']; $id_arr = $this->input_param('ids'); $admin_id = $this->input_param('admin_id'); + $allot = $this->get_allot(); + if ($allot == 0) { + throw new Hd_exception('无权限分配', API_CODE_INVILD_PARAM); + } $admin = $this->app_user_model->get(['id' => $admin_id, 'status' => 1]); if (!$id_arr || !$admin) { throw new Hd_exception('参数错误', API_CODE_INVILD_PARAM); @@ -685,11 +687,11 @@ class Customers extends Wxapp $admins = $this->app_user_model->map('id', '', ["id in ({$admin_ids})" => null], '', '', '', 'id,uname'); } //品牌车型 - $brand_arr = array_unique(array_column($rows, 'brand_id')); - $brands = $this->auto_brand_model->get_map_by_ids($brand_arr, 'id,name'); + //$brand_arr = array_unique(array_column($rows, 'brand_id')); + //$brands = $this->auto_brand_model->get_map_by_ids($brand_arr, 'id,name'); //车系车型 - $series_arr = array_unique(array_column($rows, 's_id')); - $series = $this->auto_series_model->get_map_by_ids($series_arr, 'id,name'); + //$series_arr = array_unique(array_column($rows, 's_id')); + //$series = $this->auto_series_model->get_map_by_ids($series_arr, 'id,name'); foreach ($rows as $key => $val) { //$car_json = json_decode($val['car_json'], true); //$color = isset($car_json['color']) ? $car_json['color']['title'] : ''; @@ -861,4 +863,21 @@ class Customers extends Wxapp } return $mobile; } + + /** + * Notes:判断分配客户权限 + * Created on: 2022/3/18 10:02 + * Created by: dengbw + * @return int + */ + private function get_allot() + { + $allot = 0; + $group_id = $this->session['group_id']; + if ($group_id == 2 || $group_id == 3) {//店长和老板可再分配用户 + $allot = 1; + } + return $allot; + } + } diff --git a/api/controllers/wxapp/material/Biz.php b/api/controllers/wxapp/material/Biz.php index 5a11d031..6e60a689 100644 --- a/api/controllers/wxapp/material/Biz.php +++ b/api/controllers/wxapp/material/Biz.php @@ -64,18 +64,18 @@ class Biz extends Wxapp $lists = [ [ 'brand_id' => 1, 'cms_id' => 0, 'sort' => 0, - 'title' => '东风EX1', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '45700 ~ 52700'], + 'title' => '东风 EX1 Pro', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '50700 ~ 57700'], 'img' => 'https://img.liche.cn/EX1.png' ], [ - 'brand_id' => 2, 'cms_id' => 0, 'sort' => 0, - 'title' => '雷丁芒果', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '29800 ~ 54900'], - 'img' => 'https://img.liche.cn/LDMG.png' + 'brand_id' => 4, 'cms_id' => 0, 'sort' => 0, + 'title' => '哪吒V', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '68900 ~ 77900'], + 'img' => 'https://img.liche.cn/NZV.png' ], [ 'brand_id' => 4, 'cms_id' => 0, 'sort' => 0, - 'title' => '哪吒V', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '65900 ~ 74900'], - 'img' => 'https://img.liche.cn/NZV.png' + 'title' => '哪吒U', 'ori_price' => ['title' => '厂商指导价¥', 'value' => '105800 ~ 167800'], + 'img' => 'https://img.liche.cn/NZU.png' ], [ 'brand_id' => 5, 'cms_id' => 0, 'sort' => 0, diff --git a/common/models/auto/Auto_introduce_model.php b/common/models/auto/Auto_introduce_model.php new file mode 100644 index 00000000..c048a567 --- /dev/null +++ b/common/models/auto/Auto_introduce_model.php @@ -0,0 +1,29 @@ +table_name, 'default'); + } + + /** + * Notes:状态 + * Created on: 2022/3/18 10:31 + * Created by: dengbw + * @return array + */ + public function statusAry() + { + return array(1 => '正常', 0 => '禁用'); + } +}