|
|
@@ -45,25 +45,42 @@ class ShopAdminService extends BaseService
|
|
|
$shopId = isset($data['shopId']) ? $data['shopId'] : 0;
|
|
|
$adminId = isset($data['adminId']) ? $data['adminId'] : 0;
|
|
|
$bindData = ShopAdminClass::getBindAdminData($shopId, $recommendAdminId);
|
|
|
- $shop = ShopClass::getById($shopId);
|
|
|
- if (empty($shop)) {
|
|
|
- util::fail('没有找到门店');
|
|
|
- }
|
|
|
- $merchantId = isset($shop['merchantId']) ? $shop['merchantId'] : 0;
|
|
|
if (empty($bindData)) {
|
|
|
util::fail('小程序码已失效,请重新创建员工');
|
|
|
}
|
|
|
+
|
|
|
+ $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;
|
|
|
+ $merchantId = $bindData['merchantId'] ?? 0;
|
|
|
+ $status = 1;
|
|
|
+
|
|
|
+ $roleId = $bindData['roleId'] ?? 0;
|
|
|
+ $role = AdminRoleClass::getById($roleId);
|
|
|
+ AdminRoleClass::valid($role, $merchantId);
|
|
|
+
|
|
|
+ $shop = ShopClass::getById($shopId);
|
|
|
+ Yii::info('merchantId:' . $merchantId . ' shopInfo:' . json_encode($shop));
|
|
|
+ ShopClass::valid($shop, $merchantId);
|
|
|
+
|
|
|
$shopAdmin = ShopAdminClass::getByCondition(['adminId' => $adminId, 'shopId' => $shopId]);
|
|
|
if (!empty($shopAdmin)) {
|
|
|
//员工已经删除的补回
|
|
|
if (isset($shopAdmin->delStatus) && $shopAdmin->delStatus == 1) {
|
|
|
$shopAdmin->delStatus = 0;
|
|
|
+ $shopAdmin->roleId = $roleId;
|
|
|
+ $shopAdmin->remind = $remind;
|
|
|
+ $shopAdmin->status = $status;
|
|
|
$shopAdmin->save();
|
|
|
+ $update = ['name' => $name, 'mobile' => $mobile, 'password' => $password, 'remark' => $remark, 'currentShopId' => $shopId];
|
|
|
+ AdminClass::updateById($adminId, $update);
|
|
|
+
|
|
|
return $shopAdmin->attributes;
|
|
|
}
|
|
|
util::fail('您已经是员工');
|
|
|
}
|
|
|
- $name = isset($bindData['name']) ? $bindData['name'] : '';
|
|
|
+
|
|
|
if (isset($bindData['roleId']) == false || empty($bindData['roleId'])) {
|
|
|
util::fail('添加管理员时请选择角色');
|
|
|
}
|
|
|
@@ -74,11 +91,6 @@ class ShopAdminService extends BaseService
|
|
|
if (isset($admin['subscribe']) == false || $admin['subscribe'] != 1) {
|
|
|
//util::fail("请关注公众号");
|
|
|
}
|
|
|
- $roleId = $bindData['roleId'];
|
|
|
- $remind = isset($bindData['remind']) ? $bindData['remind'] : 0;
|
|
|
- $status = 1;
|
|
|
- $password = isset($bindData['password']) ? password_hash($bindData['password'], PASSWORD_BCRYPT) : '';
|
|
|
- $remark = isset($bindData['remark']) ? $bindData['remark'] : '';
|
|
|
$update = ['name' => $name, 'mobile' => $mobile, 'password' => $password, 'remark' => $remark, 'currentShopId' => $shopId];
|
|
|
AdminClass::updateById($adminId, $update);
|
|
|
$addData = [
|