|
|
@@ -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);
|