From e65014453f64b4b53233d041cb181eb865c20aed Mon Sep 17 00:00:00 2001 From: lqmac Date: Sat, 23 Mar 2024 15:14:06 +0800 Subject: [PATCH 1/2] 1 --- app/admin/controller/Category.php | 8 ++++++++ app/admin/model/Store.php | 8 ++++++++ app/api/controller/Controller.php | 7 +++++++ app/common/enum/user/UserTypeEnum.php | 4 ++-- app/common/model/User.php | 2 +- app/store/model/User.php | 2 +- 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/admin/controller/Category.php b/app/admin/controller/Category.php index 3e5ba392..ffd3b869 100644 --- a/app/admin/controller/Category.php +++ b/app/admin/controller/Category.php @@ -100,9 +100,11 @@ class Category extends Controller $value['create_time'] = time(); $value['update_time'] = time(); $value['image_id'] = $value['image_id'] ? $this->copyImage($value['image_id'], $new_store_id) : 0; + $value['rank_image_id'] = $value['rank_image_id'] ? $this->copyImage($value['rank_image_id'], $new_store_id) : 0; $temp = $value; unset($temp['children']); unset($temp['image']); + unset($temp['rankimage']); unset($temp['category_id']); $firstid = Db::table('yoshop_category')->insertGetId($temp); @@ -116,9 +118,11 @@ class Category extends Controller $value1['create_time'] = time(); $value1['update_time'] = time(); $value1['image_id'] = $value1['image_id'] ? $this->copyImage($value1['image_id'], $new_store_id) : 0; + $value1['rank_image_id'] = $value1['rank_image_id'] ? $this->copyImage($value1['rank_image_id'], $new_store_id) : 0; $temp1 = $value1; unset($temp1['children']); unset($temp1['image']); + unset($temp1['rankimage']); unset($temp1['category_id']); $secondid = Db::table('yoshop_category')->insertGetId($temp1); @@ -132,9 +136,11 @@ class Category extends Controller $value2['create_time'] = time(); $value2['update_time'] = time(); $value2['image_id'] = $value2['image_id'] ? $this->copyImage($value2['image_id'], $new_store_id) : 0; + $value2['rank_image_id'] = $value2['rank_image_id'] ? $this->copyImage($value2['rank_image_id'], $new_store_id) : 0; $temp2 = $value2; unset($temp2['children']); unset($temp2['image']); + unset($temp2['rankimage']); unset($temp2['category_id']); Db::table('yoshop_category')->insertGetId($temp2); @@ -148,9 +154,11 @@ class Category extends Controller $value3['create_time'] = time(); $value3['update_time'] = time(); $value3['image_id'] = $value3['image_id'] ? $this->copyImage($value3['image_id'], $new_store_id) : 0; + $value3['rank_image_id'] = $value3['rank_image_id'] ? $this->copyImage($value3['rank_image_id'], $new_store_id) : 0; $temp3 = $value3; unset($temp3['children']); unset($temp3['image']); + unset($temp3['rankimage']); unset($temp3['category_id']); Db::table('yoshop_category')->insertGetId($temp3); diff --git a/app/admin/model/Store.php b/app/admin/model/Store.php index 544e4858..2fdebc8e 100644 --- a/app/admin/model/Store.php +++ b/app/admin/model/Store.php @@ -87,8 +87,10 @@ class Store extends StoreModel $value['create_time'] = time(); $value['update_time'] = time(); $value['image_id'] = $value['image_id'] ? $this->copyImage($value['image_id'], $new_store_id) : 0; + $value['rank_image_id'] = $value['rank_image_id'] ? $this->copyImage($value['rank_image_id'], $new_store_id) : 0; $temp = $value; unset($temp['children']); + unset($temp['rankimage']); unset($temp['image']); unset($temp['category_id']); @@ -105,9 +107,11 @@ class Store extends StoreModel $value1['create_time'] = time(); $value1['update_time'] = time(); $value1['image_id'] = $value1['image_id'] ? $this->copyImage($value1['image_id'], $new_store_id) : 0; + $value1['rank_image_id'] = $value1['rank_image_id'] ? $this->copyImage($value1['rank_image_id'], $new_store_id) : 0; $temp1 = $value1; unset($temp1['children']); unset($temp1['image']); + unset($temp1['rankimage']); unset($temp1['category_id']); $secondid = Db::table('yoshop_category')->insertGetId($temp1); @@ -121,9 +125,11 @@ class Store extends StoreModel $value2['create_time'] = time(); $value2['update_time'] = time(); $value2['image_id'] = $value2['image_id'] ? $this->copyImage($value2['image_id'], $new_store_id) : 0; + $value2['rank_image_id'] = $value2['rank_image_id'] ? $this->copyImage($value2['rank_image_id'], $new_store_id) : 0; $temp2 = $value2; unset($temp2['children']); unset($temp2['image']); + unset($temp2['rankimage']); unset($temp2['category_id']); Db::table('yoshop_category')->insertGetId($temp2); @@ -137,9 +143,11 @@ class Store extends StoreModel $value3['create_time'] = time(); $value3['update_time'] = time(); $value3['image_id'] = $value3['image_id'] ? $this->copyImage($value3['image_id'], $new_store_id) : 0; + $value3['rank_image_id'] = $value3['rank_image_id'] ? $this->copyImage($value3['rank_image_id'], $new_store_id) : 0; $temp3 = $value3; unset($temp3['children']); unset($temp3['image']); + unset($temp3['rankimage']); unset($temp3['category_id']); Db::table('yoshop_category')->insertGetId($temp3); diff --git a/app/api/controller/Controller.php b/app/api/controller/Controller.php index 14cbff55..1bfe026c 100644 --- a/app/api/controller/Controller.php +++ b/app/api/controller/Controller.php @@ -47,6 +47,13 @@ class Controller extends BaseController $this->checkStore(); // 验证当前客户端状态 $this->checkClient(); + $user = $this->getLoginUser(); + if ($user) { + if ($user->user_type == 0) { + throwError('很抱歉,您没有权限进入系统'); + } + } + } /** diff --git a/app/common/enum/user/UserTypeEnum.php b/app/common/enum/user/UserTypeEnum.php index 3808b188..8a525a1b 100644 --- a/app/common/enum/user/UserTypeEnum.php +++ b/app/common/enum/user/UserTypeEnum.php @@ -26,11 +26,11 @@ class UserTypeEnum extends EnumBasics { return [ self::NORMAL => [ - 'name' => '普通会员', + 'name' => '游客', 'value' => self::NORMAL, ], self::MEMBER => [ - 'name' => 'PLUS会员', + 'name' => '会员', 'value' => self::MEMBER, ], self::DEALER => [ diff --git a/app/common/model/User.php b/app/common/model/User.php index 414aa9df..2f5a4662 100644 --- a/app/common/model/User.php +++ b/app/common/model/User.php @@ -58,7 +58,7 @@ class User extends BaseModel return $result[$data['user_type']]['name']; } } - return '未知'; + return '无身份'; } /** diff --git a/app/store/model/User.php b/app/store/model/User.php index 43a6b936..0920d073 100644 --- a/app/store/model/User.php +++ b/app/store/model/User.php @@ -111,7 +111,7 @@ class User extends UserModel $filter = []; // 会员昵称 !empty($params['search']) && $filter[] = ['nick_name|mobile', 'like', "%{$params['search']}%"]; - !empty($params['user_type']) && $filter[] = ['user_type', 'in', explode(",", $params['user_type'])]; + isset($params['user_type']) && ($params['user_type'] != "") && $filter[] = ['user_type', 'in', explode(",", $params['user_type'])]; // 用户性别 $params['gender'] > -1 && $filter[] = ['gender', '=', (int)$params['gender']]; // 用户等级 From 24eefa338500e0d1034bfd7502d796a034029d01 Mon Sep 17 00:00:00 2001 From: lqmac Date: Sat, 23 Mar 2024 15:21:02 +0800 Subject: [PATCH 2/2] 1 --- app/api/controller/User.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/api/controller/User.php b/app/api/controller/User.php index 2e7cae02..5d70a7f1 100644 --- a/app/api/controller/User.php +++ b/app/api/controller/User.php @@ -361,6 +361,9 @@ class User extends Controller $params = $this->request->param(); $user_id = $params['user_id'] ?? 0; unset($params['user_id']); + if (isset($params['status']) && $params['status']) { + $params['user_type'] = 0; + } UserModel::where('user_id', $user_id)->update($params); return $this->renderSuccess('ok'); }