Browse Source

已经删除员工补回

shish 5 years ago
parent
commit
28ba5263c6

+ 8 - 2
biz-ghs/shop/services/ShopAdminService.php

@@ -55,8 +55,14 @@ class ShopAdminService extends BaseService
         Yii::info('merchantId:' . $merchantId . ' shopInfo:' . json_encode($shop));
         ShopClass::valid($shop, $merchantId);
 
-        $shopAdmin = ShopAdminClass::getByCondition(['merchantId' => $merchantId, 'shopId' => $shopId, 'adminId' => $adminId]);
+        $shopAdmin = ShopAdminClass::getByCondition(['shopId' => $shopId, 'adminId' => $adminId], true);
         if (!empty($shopAdmin)) {
+            //员工已经删除的补回
+            if (isset($shopAdmin->delStatus) && $shopAdmin->delStatus == 1) {
+                $shopAdmin->delStatus = 0;
+                $shopAdmin->save();
+                return $shopAdmin->attributes;
+            }
             util::fail('您已经是员工');
         }
         $name = isset($bindData['name']) ? $bindData['name'] : '';
@@ -70,7 +76,7 @@ class ShopAdminService extends BaseService
             util::fail('员工信息无效');
         }
         if (isset($admin['subscribe']) == false || $admin['subscribe'] != 1) {
-            util::fail("请关注公众号");
+            //util::fail("请关注公众号");
         }
         $roleId = $bindData['roleId'];
         $remind = isset($bindData['remind']) ? $bindData['remind'] : 0;

+ 9 - 3
biz-hd/admin/services/ShopAdminService.php

@@ -51,11 +51,17 @@ class ShopAdminService extends BaseService
         }
         $merchantId = isset($shop['merchantId']) ? $shop['merchantId'] : 0;
         if (empty($bindData)) {
-            util::fail('小程序码已失效,请重新创建员工');
+            util::fail('小程序码已失效,请重新创建员工');
         }
         $shopAdmin = ShopAdminClass::getByCondition(['adminId' => $adminId, 'shopId' => $shopId]);
         if (!empty($shopAdmin)) {
-            util::fail('您已经是管理员了');
+            //员工已经删除的补回
+            if (isset($shopAdmin->delStatus) && $shopAdmin->delStatus == 1) {
+                $shopAdmin->delStatus = 0;
+                $shopAdmin->save();
+                return $shopAdmin->attributes;
+            }
+            util::fail('您已经是员工');
         }
         $name = isset($bindData['name']) ? $bindData['name'] : '';
         if (isset($bindData['roleId']) == false || empty($bindData['roleId'])) {
@@ -66,7 +72,7 @@ class ShopAdminService extends BaseService
             util::fail('没有找到管理员信息');
         }
         if (isset($admin['subscribe']) == false || $admin['subscribe'] != 1) {
-            util::fail("请关注公众号({$admin['id']})");
+            //util::fail("请关注公众号");
         }
         $roleId = $bindData['roleId'];
         $remind = isset($bindData['remind']) ? $bindData['remind'] : 0;

+ 1 - 1
sql.sql

@@ -2289,4 +2289,4 @@ ALTER TABLE `xhOrder` ADD `shopAdminId` INT(11) NOT NULL DEFAULT '0' COMMENT '
 ALTER TABLE xhAdmin DROP INDEX `admin`;
 ALTER TABLE `xhAdmin` ADD UNIQUE INDEX `admin`(`mobile`,`style`);
 ALTER TABLE xhAdmin DROP INDEX `admin`;
-ALTER TABLE `xhAdmin` ADD UNIQUE INDEX `admin`(`mobile`,`style`);
+ALTER TABLE `xhAdmin` ADD INDEX `admin`(`mobile`,`style`);