shish 5 lat temu
rodzic
commit
6814159a53

+ 22 - 13
biz-ghs/shop/services/ShopAdminService.php

@@ -40,11 +40,21 @@ class ShopAdminService extends BaseService
         $adminId = $data['adminId'] ?? 0;
         $shopId = $data['shopId'] ?? 0;
 
+        $admin = AdminClass::getById($adminId);
+        if (empty($admin)) {
+            util::fail('没有找到员工信息');
+        }
+        if (isset($admin['subscribe']) == false || $admin['subscribe'] != 1) {
+            //util::fail("请关注公众号");
+        }
+        $name = $admin['name'] ?? '未命名';
+        $avatar = $admin['avatar'] ?? '';
+
         $bindData = ShopAdminClass::getBindAdminData($shopId, $recommendAdminId);
         if (empty($bindData)) {
             util::fail('小程序码已失效,请重新创建');
         }
-        $name = isset($bindData['name']) ? $bindData['name'] : '';
+
         $password = isset($bindData['password']) ? password_hash($bindData['password'], PASSWORD_BCRYPT) : '';
         $remark = isset($bindData['remark']) ? $bindData['remark'] : '';
         $status = 1;
@@ -68,9 +78,14 @@ class ShopAdminService extends BaseService
                 $shopAdmin->roleId = $roleId;
                 $shopAdmin->remind = $remind;
                 $shopAdmin->status = $status;
+                $shopAdmin->remark = $remark;
+                $shopAdmin->name = $name;
                 $shopAdmin->save();
 
-                $update = ['name' => $name, 'mobile' => $mobile, 'password' => $password, 'remark' => $remark, 'currentShopId' => $shopId];
+                $update = [
+                    'password' => $password,
+                    'currentShopId' => $shopId
+                ];
                 AdminClass::updateById($adminId, $update);
                 // 员工数+1
                 AdminRoleClass::counters(['num' => 1], ['id' => $roleId]);
@@ -79,16 +94,10 @@ class ShopAdminService extends BaseService
             }
             util::fail('您已经是员工');
         }
-
-        $admin = AdminClass::getById($adminId);
-        if (empty($admin)) {
-            util::fail('员工信息无效');
-        }
-        if (isset($admin['subscribe']) == false || $admin['subscribe'] != 1) {
-            //util::fail("请关注公众号");
-        }
-
-        $update = ['name' => $name, 'mobile' => $mobile, 'password' => $password, 'remark' => $remark, 'currentShopId' => $shopId];
+        $update = [
+            'password' => $password,
+            'currentShopId' => $shopId
+        ];
         AdminClass::updateById($adminId, $update);
         $addData = [
             'adminId' => $adminId,
@@ -99,7 +108,7 @@ class ShopAdminService extends BaseService
             'merchantId' => $sjId,
             'name' => $name,
             'mobile' => $mobile,
-            'name' => $name,
+            'avatar' => $avatar,
         ];
         ShopAdminClass::delBindAdminData($shopId, $recommendAdminId);
         $result = ShopAdminClass::add($addData);

+ 15 - 11
biz-hd/admin/services/ShopAdminService.php

@@ -50,9 +50,18 @@ class ShopAdminService extends BaseService
             util::fail('小程序码已失效,请重新创建员工');
         }
 
+        $admin = AdminClass::getById($adminId);
+        if (empty($admin)) {
+            util::fail('没有找到管理员信息');
+        }
+        if (isset($admin['subscribe']) == false || $admin['subscribe'] != 1) {
+            //util::fail("请关注公众号");
+        }
+        $name = $admin['name'] ?? '未命名';
+        $avatar = $admin['avatar'] ?? '';
+
         $password = isset($bindData['password']) ? password_hash($bindData['password'], PASSWORD_BCRYPT) : '';
         $remark = isset($bindData['remark']) ? $bindData['remark'] : '';
-        $name = isset($bindData['name']) ? $bindData['name'] : '';
         $remind = isset($bindData['remind']) ? $bindData['remind'] : 0;
         $status = 1;
 
@@ -69,10 +78,7 @@ class ShopAdminService extends BaseService
         // 添加员工方法
         $addShopAdminFunc = function () use ($name, $mobile, $password, $remark, $shopId, $adminId, $roleId) {
             $update = [
-                'name' => $name,
-                'mobile' => $mobile,
                 'password' => $password,
-                'remark' => $remark,
                 'currentShopId' => $shopId
             ];
             AdminClass::updateById($adminId, $update);
@@ -90,6 +96,8 @@ class ShopAdminService extends BaseService
                 $shopAdmin->remind = $remind;
                 $shopAdmin->status = $status;
                 $shopAdmin->avatar = $avatar;
+                $shopAdmin->remark = $remark;
+                $shopAdmin->name = $name;
                 $shopAdmin->save();
                 // 添加员工方法
                 $addShopAdminFunc();
@@ -102,13 +110,7 @@ class ShopAdminService extends BaseService
         if (isset($bindData['roleId']) == false || empty($bindData['roleId'])) {
             util::fail('添加管理员时请选择角色');
         }
-        $admin = AdminClass::getById($adminId);
-        if (empty($admin)) {
-            util::fail('没有找到管理员信息');
-        }
-        if (isset($admin['subscribe']) == false || $admin['subscribe'] != 1) {
-            //util::fail("请关注公众号");
-        }
+
         $addData = [
             'adminId' => $adminId,
             'shopId' => $shopId,
@@ -119,10 +121,12 @@ class ShopAdminService extends BaseService
             'name' => $name,
             'mobile' => $mobile,
             'avatar' => $avatar,
+            'remark' => $remark,
         ];
         ShopAdminClass::delBindAdminData($shopId, $recommendAdminId);
 
         $result = ShopAdminClass::add($addData);
+
         // 添加员工方法
         $addShopAdminFunc();
 

+ 1 - 0
sql.sql

@@ -2504,6 +2504,7 @@ ALTER TABLE xhShop ADD cgSending INT NOT NULL DEFAULT 0 COMMENT '采购配送中
 ALTER TABLE xhShop ADD cgFinish INT NOT NULL DEFAULT 0 COMMENT '采购完成订单数' AFTER `cgSending`;
 ALTER TABLE xhShop ADD cgCancel INT NOT NULL DEFAULT 0 COMMENT '采购取消订单数' AFTER `cgFinish`;
 ALTER TABLE xhShopCoupon MODIFY `status` TINYINT(4) NOT NULL DEFAULT '0' COMMENT '状态 1未使用 2使用 3过期';
+ALTER TABLE xhShopAdmin ADD remark VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '' AFTER `lastLogin`;
 
 -----linqh 2021.5.14  监控ws定时任务
 */1 * * * * sh /root/new_monitor_shell/ws_monitor.sh >> /dev/null 2>&1