From 7172a6e47a9df79aada5e805c50b757f9855ccc1 Mon Sep 17 00:00:00 2001 From: lccsw <1127794702@qq.com> Date: Tue, 19 Oct 2021 11:13:16 +0800 Subject: [PATCH] add-admin-biz_limit --- admin/controllers/biz/store/Store.php | 4 + admin/controllers/receiver/Customer.php | 4 + admin/controllers/sys/admin/Admin.php | 18 ++++- admin/libraries/OrdersList.php | 28 +++++++ admin/views/sys/admin/edit.php | 102 ++++++++++++++++++++++++ sql/sys.sql | 2 +- 6 files changed, 155 insertions(+), 3 deletions(-) diff --git a/admin/controllers/biz/store/Store.php b/admin/controllers/biz/store/Store.php index f5958e06..d3770d70 100755 --- a/admin/controllers/biz/store/Store.php +++ b/admin/controllers/biz/store/Store.php @@ -869,6 +869,10 @@ class Store extends HD_Controller } else { $whre['status > -1'] = null; } + if($_SESSION['admin_info']['biz_id']){ + $biz_ids = implode(',',$_SESSION['admin_info']['biz_id']); + $where["id in ($biz_ids)"] = 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/Customer.php b/admin/controllers/receiver/Customer.php index 754ba625..e63fe225 100644 --- a/admin/controllers/receiver/Customer.php +++ b/admin/controllers/receiver/Customer.php @@ -44,6 +44,10 @@ class Customer extends HD_Controller $size = $params['size'] = $params['size'] ? intval($params['size']) : 20; $where = array('status>=0' => null); + if($_SESSION['admin_info']['biz_id']){ + $biz_ids = implode(',',$_SESSION['admin_info']['biz_id']); + $where["biz_id in ($biz_ids)"] = null; + } if (false == strpos($_SERVER['HTTP_HOST'], 'dev')) {//dev时不限制 $where['biz_id<>'] = 1; } diff --git a/admin/controllers/sys/admin/Admin.php b/admin/controllers/sys/admin/Admin.php index 64e20b25..2aaf65a4 100755 --- a/admin/controllers/sys/admin/Admin.php +++ b/admin/controllers/sys/admin/Admin.php @@ -11,6 +11,7 @@ class Admin extends HD_Controller { $this->load->model('sys/Sys_category_model','sysCate'); $this->load->model('sys/Sys_city_model','sysCity'); $this->load->model('app/app_model'); + $this->load->model('biz/biz_model'); } public function index() @@ -83,6 +84,14 @@ class Admin extends HD_Controller { $this->data = $this->_get_info(); $data = $this->sysAdmin->get(['id' => $id]); $json = (array)json_decode($data['other_json']); + //获取已选门店 + if($json['biz_id']){ + $ids = implode(',',$json['biz_id']); + $where = [ + "id in ($ids)" => null + ]; + $this->data['selectBiz'] = $this->biz_model->select($where,'','','','id,biz_name as title'); + } $this->data['username'] = $data['username']; $this->data['role_id'] = $data['role_id']; $this->data['mobile'] = $data['mobile']; @@ -127,11 +136,13 @@ class Admin extends HD_Controller { } //输入流数据获取 $input = $this->_get_input(); + $other_json = []; + $input['biz_id'] && $other_json['biz_id'] = $input['biz_id']; $insert = [ 'username' => $input['username'], 'mobile' => $input['mobile'], 'role_id' => $input['role'], - 'other_json' => json_encode([]), + 'other_json' => json_encode($other_json,JSON_UNESCAPED_UNICODE), 'password' => password_hash($input['password1'],PASSWORD_BCRYPT), 'c_time' => time(), ]; @@ -148,11 +159,13 @@ class Admin extends HD_Controller { } //输入流数据获取 $input = $this->_get_input(); + $other_json = []; + $input['biz_id'] && $other_json['biz_id'] = $input['biz_id']; $upd = [ 'username' => $input['username'], 'mobile' => $input['mobile'], 'role_id' => $input['role'], - 'other_json' => json_encode([]), + 'other_json' => json_encode($other_json,JSON_UNESCAPED_UNICODE), ]; if($this->sysAdmin->update($upd,['id' => $input['id']])) { return $this->show_json(SYS_CODE_SUCCESS,'修改成功!'); @@ -242,6 +255,7 @@ class Admin extends HD_Controller { 'role' => $this->input->post('role'), 'password1' => trim($this->input->post('password1')), 'password2' => trim($this->input->post('password2')), + 'biz_id' => $this->input->post('biz_id'), ]; return $data; } diff --git a/admin/libraries/OrdersList.php b/admin/libraries/OrdersList.php index b73d4ad6..fa66ec4d 100644 --- a/admin/libraries/OrdersList.php +++ b/admin/libraries/OrdersList.php @@ -86,6 +86,10 @@ class OrdersList $view = 'receiver/orders/lists'; } $where['biz_id!='] = 1; + if($_SESSION['admin_info']['biz_id']){ + $biz_ids = implode(',',$_SESSION['admin_info']['biz_id']); + $where["biz_id in ($biz_ids)"] = null; + } if ($params['cf_title']) { $where['rid in (select id from lc_receiver_customers where cf_title = "' . $params['cf_title'] . '")'] = null; } @@ -242,6 +246,10 @@ class OrdersList "$t2.status>=" => 0, "$t2.biz_id!=" => 1, ]; + if($_SESSION['admin_info']['biz_id']){ + $biz_ids = implode(',',$_SESSION['admin_info']['biz_id']); + $where["$t2.biz_id in ($biz_ids)"] = null; + } if ($params['cf_title']) { $where[$t2.'.rid in (select id from lc_receiver_customers where cf_title = "' . $params['cf_title'] . '")'] = null; } @@ -437,6 +445,10 @@ class OrdersList "$t2.status>=" => 0, "$t2.biz_id!=" => 1, ]; + if($_SESSION['admin_info']['biz_id']){ + $biz_ids = implode(',',$_SESSION['admin_info']['biz_id']); + $where["$t2.biz_id in ($biz_ids)"] = null; + } if ($params['cf_title']) { $where[$t2.'.rid in (select id from lc_receiver_customers where cf_title = "' . $params['cf_title'] . '")'] = null; } @@ -586,6 +598,10 @@ class OrdersList "$t2.status>=" => 0, "$t2.biz_id!=" => 1, ]; + if($_SESSION['admin_info']['biz_id']){ + $biz_ids = implode(',',$_SESSION['admin_info']['biz_id']); + $where["$t2.biz_id in ($biz_ids)"] = null; + } if ($params['cf_title']) { $where[$t2.'.rid in (select id from lc_receiver_customers where cf_title = "' . $params['cf_title'] . '")'] = null; } @@ -753,6 +769,10 @@ class OrdersList "$t2.status>=" => 0, "$t2.biz_id!=" => 1, ]; + if($_SESSION['admin_info']['biz_id']){ + $biz_ids = implode(',',$_SESSION['admin_info']['biz_id']); + $where["$t2.biz_id in ($biz_ids)"] = null; + } if ($params['cf_title']) { $where[$t2.'.rid in (select id from lc_receiver_customers where cf_title = "' . $params['cf_title'] . '")'] = null; } @@ -920,6 +940,10 @@ class OrdersList "$t2.status>=" => 0, "$t2.biz_id!=" => 1, ]; + if($_SESSION['admin_info']['biz_id']){ + $biz_ids = implode(',',$_SESSION['admin_info']['biz_id']); + $where["$t2.biz_id in ($biz_ids)"] = null; + } if ($params['cf_title']) { $where[$t2.'.rid in (select id from lc_receiver_customers where cf_title = "' . $params['cf_title'] . '")'] = null; } @@ -1087,6 +1111,10 @@ class OrdersList "$t2.status>=" => 0, "$t2.biz_id!=" => 1, ]; + if($_SESSION['admin_info']['biz_id']){ + $biz_ids = implode(',',$_SESSION['admin_info']['biz_id']); + $where["$t2.biz_id in ($biz_ids)"] = null; + } if ($params['cf_title']) { $where[$t2.'.rid in (select id from lc_receiver_customers where cf_title = "' . $params['cf_title'] . '")'] = null; } diff --git a/admin/views/sys/admin/edit.php b/admin/views/sys/admin/edit.php index d94b4dca..730f5e27 100755 --- a/admin/views/sys/admin/edit.php +++ b/admin/views/sys/admin/edit.php @@ -53,6 +53,33 @@ +