shish 6 месяцев назад
Родитель
Сommit
7168328a35

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

@@ -352,7 +352,7 @@ class ShopAdminController extends BaseController
         $id = Yii::$app->request->get('id');
 
         $shopAdmin = $this->shopAdmin;
-        if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
+        if (!isset($shopAdmin->super) || $shopAdmin->super != 1) {
             util::fail('没有权限');
         }
 

+ 1 - 1
app-hd/controllers/AdminController.php

@@ -63,7 +63,7 @@ class AdminController extends BaseController
         $transaction = $connection->beginTransaction();
 
         try {
-            // 执行离职操作
+            // 执行离职操作,多处使用,关键词 staff_lz
             $respond = StaffClass::executeStaffResignation($admin, $staff);
             $transaction->commit();
             util::success($respond);

+ 4 - 16
biz-hd/staff/classes/StaffClass.php

@@ -21,36 +21,24 @@ class StaffClass extends BaseClass
     {
         $id = $relation->id ?? 0;
         if ($relation->founder == 2) {
-            util::fail("超管不能删除");
+            util::fail("不能删老板");
         }
         if ($id == $thisShopAdminId) {
             util::fail("不能删自己");
         }
         self::valid($relation, $mainId);
         $adminId = $relation->adminId ?? 0;
-        $currentShopId = $relation->shopId ?? 0;
         $admin = AdminClass::getById($adminId, true);
         if (empty($admin)) {
             util::fail('没有找到员工信息');
         }
-        $admin->currentShopId = 0;
-        $admin->save();
-        $relation->delStatus = 1;
-        $relation->save();
-        //删除员工关系后,再找出这个员工还有没其它门店员工身份补上
-        if (!empty($admin) && isset($admin->currentShopId) && $admin->currentShopId == $currentShopId) {
-            $has = self::getByCondition(['adminId' => $adminId, 'delStatus' => 0, 'status' => 1], true);
-            $hasCurrentShopId = $has->shopId ?? 0;
-            $admin->currentShopId = $hasCurrentShopId;
-            $admin->save();
-        }
-        // 员工数-1
-        AdminRoleClass::counters(['num' => -1], ['id' => $relation->roleId]);
+        //员工离职,多处使用,关键词 staff_lz
+        StaffClass::executeStaffResignation($admin, $relation);
     }
 
     public static function valid($relation, $mainId)
     {
-        if (isset($relation->mainId) == false || $relation->mainId != $mainId) {
+        if (!isset($relation->mainId) || $relation->mainId != $mainId) {
             util::fail('没有权限');
         }
     }

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

@@ -5,6 +5,7 @@ namespace biz\shop\classes;
 use biz\admin\classes\AdminClass;
 use biz\admin\classes\AdminRoleClass;
 use bizGhs\ws\services\WsService;
+use bizHd\staff\classes\StaffClass;
 use bizHd\user\classes\UserClass;
 use common\components\util;
 use Yii;
@@ -180,31 +181,19 @@ class ShopAdminClass extends BaseClass
     {
         $id = $relation->id ?? 0;
         if ($relation->founder == 2) {
-            util::fail("创始人不能删除");
+            util::fail("不能删老板");
         }
         if ($id == $thisShopAdminId) {
             util::fail("不能删自己");
         }
         ShopAdminClass::valid($relation, $mainId);
         $adminId = $relation->adminId ?? 0;
-        $currentShopId = $relation->shopId ?? 0;
         $admin = AdminClass::getById($adminId, true);
         if (empty($admin)) {
             util::fail('没有找到员工信息');
         }
-        $admin->currentGhsShopId = 0;
-        $admin->save();
-        $relation->delStatus = 1;
-        $relation->save();
-        //删除员工关系后,再找出这个员工还有没其它门店员工身份补上
-        if (!empty($admin) && isset($admin->currentShopId) && $admin->currentShopId == $currentShopId) {
-            $has = self::getByCondition(['adminId' => $adminId, 'delStatus' => 0, 'status' => 1], true);
-            $hasCurrentShopId = $has->shopId ?? 0;
-            $admin->currentGhsShopId = $hasCurrentShopId;
-            $admin->save();
-        }
-        // 员工数-1
-        AdminRoleClass::counters(['num' => -1], ['id' => $relation->roleId]);
+        //员工离职,多处使用,关键词 staff_lz
+        StaffClass::executeStaffResignation($admin, $relation);
     }
 
     //根据shopId 获取 员工的shopAdminId