shish 4 lat temu
rodzic
commit
08c17d21c1

+ 12 - 15
app-ghs/controllers/ShopController.php

@@ -343,27 +343,24 @@ class ShopController extends BaseController
     //切换门店 ssh 20220624
     public function actionSwitchGhsShop()
     {
-        $shopAdmin = $this->shopAdmin;
-        $adminId = $shopAdmin->adminId ?? 0;
-        $admin = $this->admin;
         $shopId = Yii::$app->request->get('shopId', 0);
         $shop = ShopClass::getById($shopId, true);
         if (empty($shop)) {
             util::fail('没有找到门店');
         }
-        $mainId = $shop->mainId ?? 0;
-        $staff = ShopAdminClass::getByCondition(['mainId' => $mainId, 'adminId' => $adminId], true);
-        if (empty($staff)) {
-            util::fail('没有权限哦...');
-        }
-        $delStatus = $staff->delStatus ?? 0;
-        if ($delStatus == 1) {
-            util::fail('你不是员工');
-        }
-        $status = $staff->status ?? 0;
-        if ($status == 0) {
-            util::fail('无法登录,请联系店长');
+        $shopAdmin = $this->shopAdmin;
+        $admin = $this->admin;
+        $adminId = $this->adminId ?? 0;
+        if (getenv('YII_ENV') == 'production') {
+            if (in_array($adminId, [4]) == false) {
+                util::fail('没有权限切换,请联系管理员');
+            }
+        } else {
+            if (in_array($adminId, [919]) == false) {
+                util::fail('没有权限切换,请联系管理员');
+            }
         }
+        ShopAdminClass::changeShopAddRelate($shopAdmin, $shop, 1);
         $admin->currentGhsShopId = $shopId;
         $lsShopId = $shop->lsShopId ?? 0;
         $admin->currentShopId = $lsShopId;

+ 2 - 1
biz/shop/classes/ShopAdminClass.php

@@ -104,7 +104,7 @@ class ShopAdminClass extends BaseClass
     }
 
     //切换门店时增加员工关系 ssh 2021.3.1
-    public static function changeShopAddRelate($originShopAdmin, $newShop)
+    public static function changeShopAddRelate($originShopAdmin, $newShop, $isPt = 0)
     {
         $newMainId = $newShop->mainId ?? 0;
         $name = $originShopAdmin->name ?? '';
@@ -129,6 +129,7 @@ class ShopAdminClass extends BaseClass
             'sjId' => $sjId,
             'super' => $super,
             'mainId' => $newMainId,
+            'isPt' => $isPt,
         ];
         $return = self::addShopAdmin($data, true);
         return $return;