Pārlūkot izejas kodu

管理员权限

shish 4 gadi atpakaļ
vecāks
revīzija
54c37e54d7

+ 1 - 1
app-ghs/controllers/CustomController.php

@@ -171,7 +171,7 @@ class CustomController extends BaseController
         }
         $shopId = $info['shopId'] ?? 0;
         //超管的信息
-        $superInfo = ShopAdminClass::getSuper($shopId);
+        $superInfo = ShopAdminClass::getManager($shopId);
         $superName = $superInfo['name'] ?? '';
         $currentSuper = ['name' => $superName];
         $info['superInfo'] = $currentSuper;

+ 1 - 1
app-ghs/controllers/OrderController.php

@@ -869,7 +869,7 @@ class OrderController extends BaseController
 
         //店长信息
         $customShopId = $info['customShopId'] ?? 0;
-        $superInfo = ShopAdminClass::getSuper($customShopId);
+        $superInfo = ShopAdminClass::getManager($customShopId);
         $info['customSuper'] = $superInfo;
 
         $purchaseId = $info['purchaseId'] ?? 0;

+ 11 - 3
app-ghs/controllers/ShopAdminController.php

@@ -41,6 +41,12 @@ class ShopAdminController extends BaseController
     //添加员工
     public function actionAddStaff()
     {
+
+        $shopAdmin = $this->shopAdmin;
+        if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
+            util::fail('没有权限');
+        }
+
         $post = Yii::$app->request->post();
         $authCode = $post['authCode'] ?? '';
         $mobile = $post['mobile'] ?? '';
@@ -178,9 +184,9 @@ class ShopAdminController extends BaseController
         $post = Yii::$app->request->post();
         $id = $post['id'] ?? 0;
 
-        $shopAdmin = $this->shopAdmin->attributes;
-        if ($shopAdmin['super'] != 1) {
-            util::fail('超管才能操作');
+        $shopAdmin = $this->shopAdmin;
+        if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
+            util::fail('没有权限');
         }
 
         if (empty($id)) {
@@ -195,9 +201,11 @@ class ShopAdminController extends BaseController
         $roleId = $post['roleId'] ?? 0;
         $remind = $post['remind'] ?? 0;
         $status = $post['status'] ?? 1;
+        $super = $post['super'] ?? 0;
         $relation->roleId = $roleId;
         $relation->remind = $remind;
         $relation->status = $status;
+        $relation->super = $super;
         if (isset($post['name']) && !empty($post['name'])) {
             $relation->name = $post['name'];
         }

+ 1 - 2
biz-ghs/admin/classes/AdminClass.php

@@ -92,7 +92,6 @@ class AdminClass extends BaseClass
             'super' => 1,
             'founder' => 2,
             'mobile' => $mobile,
-            'founder' => 2,
         ];
         ShopAdminClass::add($shopData);
     }
@@ -413,7 +412,7 @@ class AdminClass extends BaseClass
     {
         $right = \biz\shop\classes\ShopAdminClass::hasSwitchShopRight($originShopAdmin);
         if (empty($right)) {
-            util::fail("没有权限");
+            util::fail("没有权限");
         }
         $adminId = $admin['id'];
         $sjShopList = ShopClass::getSjShopList($sjId);

+ 3 - 0
biz-ghs/shop/services/ShopAdminService.php

@@ -41,6 +41,7 @@ class ShopAdminService extends BaseService
         $name = $data['name'] ?? '未命名';
         $remark = isset($data['remark']) ? $data['remark'] : '';
         $status = 1;
+        $super = $data['super'] ?? 0;
         $remind = isset($data['remind']) ? $data['remind'] : 0;
         $roleId = $data['roleId'] ?? 0;
         $role = AdminRoleClass::getById($roleId);
@@ -69,6 +70,7 @@ class ShopAdminService extends BaseService
                 $shopAdmin->remark = $remark;
                 $shopAdmin->name = $name;
                 $shopAdmin->avatar = $avatar;
+                $shopAdmin->super = $super;
                 $shopAdmin->save();
                 AdminRoleClass::counters(['num' => 1], ['id' => $roleId]);
             }
@@ -86,6 +88,7 @@ class ShopAdminService extends BaseService
                 'name' => $name,
                 'mobile' => $mobile,
                 'avatar' => $avatar,
+                'super' => $super,
             ];
             $shopAdmin = ShopAdminClass::add($addData);
             AdminRoleClass::counters(['num' => 1], ['id' => $roleId]);

+ 3 - 15
biz/shop/classes/ShopAdminClass.php

@@ -83,8 +83,8 @@ class ShopAdminClass extends BaseClass
         }
     }
 
-    //取超管信息 ssh 2021.1.8
-    public static function getSuper($shopId)
+    //取店长信息 ssh 2021.1.8
+    public static function getManager($shopId)
     {
         $relate = self::getByCondition(['shopId' => $shopId, 'founder' => 2]);
         $adminId = isset($relate['adminId']) ? $relate['adminId'] : 0;
@@ -160,19 +160,7 @@ class ShopAdminClass extends BaseClass
     //是否有切换门店权限 0不是 1是
     public static function hasSwitchShopRight($shopAdmin)
     {
-        $super = 0;
-        if (isset($shopAdmin['super']) && $shopAdmin['super'] == 1) {
-            //超管
-            $super = 1;
-        } else {
-            //老板身份
-            $roleId = $shopAdmin['roleId'] ?? 0;
-            $role = AdminRoleClass::getById($roleId);
-            $authInfo = $role['auth'] ?? '';
-            if ($authInfo == '*') {
-                $super = 1;
-            }
-        }
+        $super = isset($shopAdmin['super']) && $shopAdmin['super'] == 1 ? 1 : 0;
         return $super;
     }