瀏覽代碼

添加员工

shish 5 年之前
父節點
當前提交
b0f353b962

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

@@ -2,7 +2,7 @@
 
 namespace ghs\controllers;
 
-use bizGhs\admin\services\ShopAdminService;
+use bizGhs\shop\services\ShopAdminService;
 use biz\saas\services\ApplyService;
 use biz\wx\services\WxBaseService;
 use biz\wx\services\WxOpenService;

+ 187 - 187
app/ghs/controllers/AuthController.php

@@ -2,7 +2,7 @@
 
 namespace ghs\controllers;
 
-use bizGhs\admin\services\ShopAdminService;
+use bizGhs\shop\services\ShopAdminService;
 use bizGhs\admin\services\AdminService;
 use biz\auth\services\AuthService;
 use biz\user\classes\UserClass;
@@ -26,190 +26,190 @@ use yii\helpers\Json;
  */
 class AuthController extends PublicController
 {
-
-    //准备授权 shish 2019.11.19
-    public function actionPrepare()
-    {
-        $get = Yii::$app->request->get();
-        $url = isset($get['url']) && !empty($get['url']) ? $get['url'] : '';
-        if (empty($url)) {
-            util::fail('没有网址');
-        }
-        $account = httpUtil::getAccount($url);
-        if (empty($account)) {
-            util::fail('没有商家帐号');
-        }
-        $merchant = MerchantService::getById($account);
-        if (empty($merchant)) {
-            util::fail('商家无效');
-        }
-        /**
-         * authScope 参数的说明
-         * 1.用户通过公众号菜单打开网页,因为已经关注过了公众号,已经生成过用户信息,所以只要使用snsapi_base静默方式拿到openid就可以
-         * 2.为了保证付款页的访问速度,暂时只要通过snsapi_base静默方式拿到openid先生成可以用的用户信息即可
-         * 3.其它情况需要获取用户完整信息的,使用snsapi_userinfo让用户授权获取信息即可
-         * 4.snsapi_base静默方式使用的场景更多,所以参数authScope默认使用snsapi_base
-         */
-        $authScope = isset($get['authScope']) ? $get['authScope'] : 'snsapi_base';
-        $urlEncode = stringUtil::urlSafeB64Encode($url);
-        //微信授权获取code shish 2019.11.24
-        wxUtil::getCode($urlEncode, $merchant, $authScope);
-        util::end();
-    }
-
-    //微信授权获取用户信息 shish 2019.11.20
-    public function actionGetUserInfo()
-    {
-        $get = Yii::$app->request->get();
-        $code = isset($get['code']) ? $get['code'] : '';
-        if (empty($code)) {
-            util::fail('没有获取用户code');
-        }
-        if (isset($get['state']) && $get['state'] == 'authdeny') {
-            util::fail('auth fail');
-        }
-        $urlEncode = $get['url'];
-        $url = stringUtil::urlSafeBase64Decode($urlEncode);
-        $account = httpUtil::getAccount($url);
-        if (empty($account)) {
-            util::stop('商店ID无效!!');
-        }
-        $merchant = xhMerchantService::getByAccount($account);
-        if (empty($merchant)) {
-            util::stop('商店无效');
-        }
-        $merchantId = $merchant['id'];
-        $authScope = isset($get['authScope']) ? $get['authScope'] : '';
-        if (empty($authScope)) {
-            util::stop('没有授权类型');
-        }
-        $data = wxUtil::getOpenId($code, $merchant);
-        if ($data === false) {
-            //微信授权获取code shish 2019.11.24
-            wxUtil::getCode($urlEncode, $merchant, $authScope);
-            util::end();
-        }
-        $openId = $data['openid'];
-        $access_token = $data['access_token'];
-        $user = UserService::getByOpenId($openId, $merchantId);
-        //用户来源
-        $userSource = Yii::$app->dict->getValue('userSourceGetId', 'official');
-        $source = $userSource['name'];
-        if (empty($user)) {
-            //$authScope 默认是 snsapi_base 公众号菜单打开网页(已经关注公众号,有完整信息)、打开付款页(有些客户只付款,没有后续可以不用登记完整信息),只需要获取openid
-            $originalInfo = [];
-            $originalInfo['openId'] = $openId;
-            $originalInfo['merchantId'] = $merchantId;
-
-            //没有关注公众号,需要获取用户完整信息的情况,则通过弹框授权
-            if ($authScope == 'snsapi_userinfo') {
-                $baseInfo = wxUtil::authGetUserInfo($openId, $access_token);
-                $originalInfo = array_merge($baseInfo, $originalInfo);
-                $originalInfo['isFull'] = 1;
-                $originalInfo['unionId'] = $baseInfo['unionid'];
-                $originalInfo['headImgUrl'] = $baseInfo['headimgurl'];
-                $originalInfo['nickName'] = $baseInfo['nickName'];
-            }
-            $user = UserService::replaceUser($originalInfo, $source, $merchantId);
-        } else {
-            if ($user['isFull'] == 0) {
-                if ($authScope == 'snsapi_userinfo') {
-                    $baseInfo = wxUtil::authGetUserInfo($openId, $access_token);
-                    $originalInfo = $baseInfo;
-                    $originalInfo['isFull'] = 1;
-                    $originalInfo['unionId'] = $baseInfo['unionid'];
-                    $originalInfo['headImgUrl'] = $baseInfo['headimgurl'];
-                    $originalInfo['openId'] = $baseInfo['openid'];
-                    $originalInfo['nickName'] = $baseInfo['nickName'];
-                    $originalInfo['merchantId'] = $merchantId;
-                    $user = UserService::replaceUser($originalInfo, $source, $merchantId);
-                }
-            }
-        }
-        //这个的基类没有设置统一的全局变量,这里进行设置一次
-        $userId = $user['id'];
-        $admin = AdminService::getByCondition(['userId' => $userId]);
-        if (empty($admin)) {
-            util::fail('您没有权限访问');
-        }
-        $adminId = $admin['id'];
-        //获取token
-        $token = jwt::getNewToken($adminId);
-        $url = strpos($url, '?') === false ? $url . '?token=' . $token : $url . '&token=' . $token;
-        $this->redirect($url);
-    }
-
-    //登陆并拿到token shish 2019.11.23
-    public function actionLogin()
-    {
-        $get = Yii::$app->request->get();
-        $mobile = isset($get['mobile']) ? $get['mobile'] : 0;
-        if (stringUtil::isMobile($mobile) == false) {
-            util::fail('请填写正常的手机号');
-        }
-        $password = isset($get['password']) && !empty($get['password']) ? $get['password'] : '';
-        if (empty($password)) {
-            util::fail('请输入密码');
-        }
-        $admin = AdminService::getByCondition(['mobile' => $mobile]);
-        if (password_verify($password, $admin['password']) == false) {
-            util::fail('密码错误');
-        }
-        $adminId = $admin['id'];
-        $shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId]);
-        $merchantId = isset($shopAdmin['merchantId']) ? $shopAdmin['merchantId'] : 0;
-        $shopId = isset($shopAdmin['shopId']) ? $shopAdmin['shopId'] : 0;
-        if (empty($shopId)) {
-            util::fail('您不是管理员');
-        }
-        //管理员关联门店
-        Yii::$app->redis->executeCommand('SET', ['LOGIN_ADMIN_SHOP' . $adminId, $shopId]);
-        //获取token
-        $token = jwt::getNewToken($adminId);
-        util::success(['token' => $token, 'account' => $merchantId, 'shopId' => $shopId]);
-    }
-
-    //静默获取小程序用户信息
-    public function actionMiniInfo()
-    {
-        $code = Yii::$app->request->get('code', '');
-        if (empty($code)) {
-            util::fail('没有CODE信息');
-        }
-        $wxMiniBase = WxOpenClass::getGhsWxInfo();
-        $appId = $wxMiniBase['miniAppId'];
-        $appSecret = $wxMiniBase['miniAppSecret'];
-        if (empty($appSecret)) {
-            util::fail('没有找到小程序的密钥');
-        }
-        $url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
-        $curl = new curl\Curl();
-        $result = $curl->get($url);
-        $arr = Json::decode($result);
-        $sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';
-        $openid = isset($arr['openid']) ? $arr['openid'] : '';
-        if (empty($openid)) {
-            Yii::info(json_encode($arr));
-            util::fail('没有获取到小程序openId');
-        }
-        $cacheKey = 'GHS_SHOP_MINI_SESSION_KEY_' . $openid;
-        Yii::$app->redis->executeCommand('SET', [$cacheKey, $sessionKey]);
-        //用户来源
-        $userSource = UserClass::$userSourceId['mini']['name'];
-        $admin = AdminService::getByMiniOpenId($openid);
-        if (empty($admin)) {
-            $adminInfo = ['miniOpenId' => $openid];
-            $admin = AdminService::replaceAdmin($adminInfo, $userSource);
-        }
-        $adminId = $admin['id'];
-        $staff = ShopAdminService::getByCondition(['adminId' => $adminId]);
-        $shopId = isset($staff['shopId']) ? $staff['shopId'] : 0;
-        //头像
-        $admin['avatar'] = Yii::$app->params['imgHost'] . '/retail/default-img.png';
-        //管理员关联商家
-        //Yii::$app->redis->executeCommand('SET', ['LOGIN_ADMIN_SHOP' . $adminId, $shopId]);
-        $token = jwt::getNewToken($adminId);
-        util::success(['token' => $token, 'admin' => $admin, 'shopId' => $shopId]);
-    }
-
+	
+	//准备授权 shish 2019.11.19
+	public function actionPrepare()
+	{
+		$get = Yii::$app->request->get();
+		$url = isset($get['url']) && !empty($get['url']) ? $get['url'] : '';
+		if (empty($url)) {
+			util::fail('没有网址');
+		}
+		$account = httpUtil::getAccount($url);
+		if (empty($account)) {
+			util::fail('没有商家帐号');
+		}
+		$merchant = MerchantService::getById($account);
+		if (empty($merchant)) {
+			util::fail('商家无效');
+		}
+		/**
+		 * authScope 参数的说明
+		 * 1.用户通过公众号菜单打开网页,因为已经关注过了公众号,已经生成过用户信息,所以只要使用snsapi_base静默方式拿到openid就可以
+		 * 2.为了保证付款页的访问速度,暂时只要通过snsapi_base静默方式拿到openid先生成可以用的用户信息即可
+		 * 3.其它情况需要获取用户完整信息的,使用snsapi_userinfo让用户授权获取信息即可
+		 * 4.snsapi_base静默方式使用的场景更多,所以参数authScope默认使用snsapi_base
+		 */
+		$authScope = isset($get['authScope']) ? $get['authScope'] : 'snsapi_base';
+		$urlEncode = stringUtil::urlSafeB64Encode($url);
+		//微信授权获取code shish 2019.11.24
+		wxUtil::getCode($urlEncode, $merchant, $authScope);
+		util::end();
+	}
+	
+	//微信授权获取用户信息 shish 2019.11.20
+	public function actionGetUserInfo()
+	{
+		$get = Yii::$app->request->get();
+		$code = isset($get['code']) ? $get['code'] : '';
+		if (empty($code)) {
+			util::fail('没有获取用户code');
+		}
+		if (isset($get['state']) && $get['state'] == 'authdeny') {
+			util::fail('auth fail');
+		}
+		$urlEncode = $get['url'];
+		$url = stringUtil::urlSafeBase64Decode($urlEncode);
+		$account = httpUtil::getAccount($url);
+		if (empty($account)) {
+			util::stop('商店ID无效!!');
+		}
+		$merchant = xhMerchantService::getByAccount($account);
+		if (empty($merchant)) {
+			util::stop('商店无效');
+		}
+		$merchantId = $merchant['id'];
+		$authScope = isset($get['authScope']) ? $get['authScope'] : '';
+		if (empty($authScope)) {
+			util::stop('没有授权类型');
+		}
+		$data = wxUtil::getOpenId($code, $merchant);
+		if ($data === false) {
+			//微信授权获取code shish 2019.11.24
+			wxUtil::getCode($urlEncode, $merchant, $authScope);
+			util::end();
+		}
+		$openId = $data['openid'];
+		$access_token = $data['access_token'];
+		$user = UserService::getByOpenId($openId, $merchantId);
+		//用户来源
+		$userSource = Yii::$app->dict->getValue('userSourceGetId', 'official');
+		$source = $userSource['name'];
+		if (empty($user)) {
+			//$authScope 默认是 snsapi_base 公众号菜单打开网页(已经关注公众号,有完整信息)、打开付款页(有些客户只付款,没有后续可以不用登记完整信息),只需要获取openid
+			$originalInfo = [];
+			$originalInfo['openId'] = $openId;
+			$originalInfo['merchantId'] = $merchantId;
+			
+			//没有关注公众号,需要获取用户完整信息的情况,则通过弹框授权
+			if ($authScope == 'snsapi_userinfo') {
+				$baseInfo = wxUtil::authGetUserInfo($openId, $access_token);
+				$originalInfo = array_merge($baseInfo, $originalInfo);
+				$originalInfo['isFull'] = 1;
+				$originalInfo['unionId'] = $baseInfo['unionid'];
+				$originalInfo['headImgUrl'] = $baseInfo['headimgurl'];
+				$originalInfo['nickName'] = $baseInfo['nickName'];
+			}
+			$user = UserService::replaceUser($originalInfo, $source, $merchantId);
+		} else {
+			if ($user['isFull'] == 0) {
+				if ($authScope == 'snsapi_userinfo') {
+					$baseInfo = wxUtil::authGetUserInfo($openId, $access_token);
+					$originalInfo = $baseInfo;
+					$originalInfo['isFull'] = 1;
+					$originalInfo['unionId'] = $baseInfo['unionid'];
+					$originalInfo['headImgUrl'] = $baseInfo['headimgurl'];
+					$originalInfo['openId'] = $baseInfo['openid'];
+					$originalInfo['nickName'] = $baseInfo['nickName'];
+					$originalInfo['merchantId'] = $merchantId;
+					$user = UserService::replaceUser($originalInfo, $source, $merchantId);
+				}
+			}
+		}
+		//这个的基类没有设置统一的全局变量,这里进行设置一次
+		$userId = $user['id'];
+		$admin = AdminService::getByCondition(['userId' => $userId]);
+		if (empty($admin)) {
+			util::fail('您没有权限访问');
+		}
+		$adminId = $admin['id'];
+		//获取token
+		$token = jwt::getNewToken($adminId);
+		$url = strpos($url, '?') === false ? $url . '?token=' . $token : $url . '&token=' . $token;
+		$this->redirect($url);
+	}
+	
+	//登陆并拿到token shish 2019.11.23
+	public function actionLogin()
+	{
+		$get = Yii::$app->request->get();
+		$mobile = isset($get['mobile']) ? $get['mobile'] : 0;
+		if (stringUtil::isMobile($mobile) == false) {
+			util::fail('请填写正常的手机号');
+		}
+		$password = isset($get['password']) && !empty($get['password']) ? $get['password'] : '';
+		if (empty($password)) {
+			util::fail('请输入密码');
+		}
+		$admin = AdminService::getByCondition(['mobile' => $mobile]);
+		if (password_verify($password, $admin['password']) == false) {
+			util::fail('密码错误');
+		}
+		$adminId = $admin['id'];
+		$shopAdmin = ShopAdminService::getByCondition(['adminId' => $adminId]);
+		$merchantId = isset($shopAdmin['merchantId']) ? $shopAdmin['merchantId'] : 0;
+		$shopId = isset($shopAdmin['shopId']) ? $shopAdmin['shopId'] : 0;
+		if (empty($shopId)) {
+			util::fail('您不是管理员');
+		}
+		//管理员关联门店
+		Yii::$app->redis->executeCommand('SET', ['LOGIN_ADMIN_SHOP' . $adminId, $shopId]);
+		//获取token
+		$token = jwt::getNewToken($adminId);
+		util::success(['token' => $token, 'account' => $merchantId, 'shopId' => $shopId]);
+	}
+	
+	//静默获取小程序用户信息
+	public function actionMiniInfo()
+	{
+		$code = Yii::$app->request->get('code', '');
+		if (empty($code)) {
+			util::fail('没有CODE信息');
+		}
+		$wxMiniBase = WxOpenClass::getGhsWxInfo();
+		$appId = $wxMiniBase['miniAppId'];
+		$appSecret = $wxMiniBase['miniAppSecret'];
+		if (empty($appSecret)) {
+			util::fail('没有找到小程序的密钥');
+		}
+		$url = "https://api.weixin.qq.com/sns/jscode2session?appid={$appId}&secret={$appSecret}&js_code={$code}&grant_type=authorization_code";
+		$curl = new curl\Curl();
+		$result = $curl->get($url);
+		$arr = Json::decode($result);
+		$sessionKey = isset($arr['session_key']) ? $arr['session_key'] : '';
+		$openid = isset($arr['openid']) ? $arr['openid'] : '';
+		if (empty($openid)) {
+			Yii::info(json_encode($arr));
+			util::fail('没有获取到小程序openId');
+		}
+		$cacheKey = 'GHS_SHOP_MINI_SESSION_KEY_' . $openid;
+		Yii::$app->redis->executeCommand('SET', [$cacheKey, $sessionKey]);
+		//用户来源
+		$userSource = UserClass::$userSourceId['mini']['name'];
+		$admin = AdminService::getByMiniOpenId($openid);
+		if (empty($admin)) {
+			$adminInfo = ['miniOpenId' => $openid];
+			$admin = AdminService::replaceAdmin($adminInfo, $userSource);
+		}
+		$adminId = $admin['id'];
+		$staff = ShopAdminService::getByCondition(['adminId' => $adminId]);
+		$shopId = isset($staff['shopId']) ? $staff['shopId'] : 0;
+		//头像
+		$admin['avatar'] = Yii::$app->params['imgHost'] . '/retail/default-img.png';
+		//管理员关联商家
+		//Yii::$app->redis->executeCommand('SET', ['LOGIN_ADMIN_SHOP' . $adminId, $shopId]);
+		$token = jwt::getNewToken($adminId);
+		util::success(['token' => $token, 'admin' => $admin, 'shopId' => $shopId]);
+	}
+	
 }

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

@@ -7,7 +7,7 @@ use biz\merchant\services\MerchantService;
 use bizGhs\merchant\services\ShopService;
 use biz\wx\services\WxOpenService;
 use bizGhs\admin\services\AdminService;
-use bizGhs\admin\services\ShopAdminService;
+use bizGhs\shop\services\ShopAdminService;
 use common\components\jwt;
 use common\components\noticeUtil;
 use common\components\stringUtil;

+ 3 - 2
app/ghs/controllers/ShopAdminController.php

@@ -4,9 +4,9 @@ namespace ghs\controllers;
 
 use biz\wx\classes\WxOpenClass;
 use bizGhs\admin\classes\AdminClass;
-use bizGhs\admin\classes\ShopAdminClass;
+use bizGhs\shop\classes\ShopAdminClass;
 use bizGhs\admin\services\AdminRoleService;
-use bizGhs\admin\services\ShopAdminService;
+use bizGhs\shop\services\ShopAdminService;
 use biz\wx\services\WxOpenService;
 use common\components\jwt;
 use common\components\util;
@@ -28,6 +28,7 @@ class ShopAdminController extends BaseController
 		unset($post['userId']);
 		unset($post['status']);
 		$post['shopId'] = $this->shopId;
+		$post['ghsId'] = $this->ghsId;
 		$post['adminId'] = $this->adminId;
 		$merchant = WxOpenClass::getGhsWxInfo();
 		$post['merchant'] = $merchant;

+ 352 - 352
biz-ghs/admin/classes/AdminClass.php

@@ -6,359 +6,359 @@ use biz\user\classes\UserClass;
 use common\components\util;
 use common\services\ImageService;
 use Yii;
-use biz\base\classes\BaseClass;
+use bizGhs\base\classes\BaseClass;
 
 class AdminClass extends BaseClass
 {
-
-    public static $baseFile = '\bizGhs\admin\models\Admin';
-
-    //收益通知人
-    public static $noticeAdmin = [
-        //国兰
-        'wx193341a4a80f6ea3' => ['o4c8Vs54PQh32nkgG8R3m4VuGTvw', 'o4c8VszacQJyrzu651CAu0sCsfPc'],
-        //花美灵
-        'wx84d95afcb7b594eb' => ['oTFbYvsjwgVwXggwtlM2ESAKwuN8', 'oTFbYvqP6qwdCCkdFB9GYnlzDIUg'],
-    ];
-
-    //组合员工基本信息 shish 2019.12.9
-    public static function groupAdminBaseInfo($list, $sensitive = true)
-    {
-        $prefix = Yii::$app->params['imgHost'];
-        foreach ($list as $key => $val) {
-            $roleId = 0;
-            $list[$key]['roleName'] = '';
-            $list[$key]['avatarUrl'] = Yii::$app->params['imgHost'] . '/retail/default-avatar.png';
-            $list[$key]['addDate'] = date("Y-m-d H:i", $val['addTime']);
-            $list[$key]['lastLoginTime'] = date("Y-m-d H:i", $val['loginTime']);
-            //敏感信息
-            if ($sensitive) {
-                //这里需要输出值secret,否则修改密码那边会有问题
-                $list[$key]['openId'] = isset($val['openId']) && !empty($val['openId']) ? 'secret' : '';
-                $list[$key]['password'] = isset($val['password']) && !empty($val['password']) ? 'secret' : '';
-                $list[$key]['confirmPassword'] = isset($val['confirmPassword']) && !empty($val['confirmPassword']) ? 'secret' : '';
-            }
-        }
-        return $list;
-    }
-
-    //获取员工详情 shish 2019.12.9
-    public static function getDetail($id)
-    {
-        $detail = self::getById($id);
-        if (empty($detail)) {
-            util::fail('没有找到员工信息');
-        }
-        $list = self::groupAdminBaseInfo([$detail]);
-        return current($list);
-    }
-
-    //获取员工详情 shish 2019.12.9
-    public static function getAdminById($id)
-    {
-        $detail = AdminClass::getById($id);
-        if (empty($detail)) {
-            util::fail('没有找到员工信息!');
-        }
-        $list = self::groupAdminBaseInfo([$detail]);
-        return current($list);
-    }
-
-    //添加员工 shish 2019.12.9
-    public static function addAdmin($data)
-    {
-        $merchantId = $data['merchantId'];
-
-        //验证角色
-        $roleId = $data['roleId'];
-        $role = AdminRoleClass::getById($roleId);
-        AdminRoleClass::valid($role, $merchantId);
-
-        //验证关联的微信
-        $adminId = $data['admin'];
-        $admin = self::getById($adminId);
-        if (empty($admin)) {
-            util::fail('没有找到管理员信息');
-        }
-        $data['password'] = password_hash($data['password'], PASSWORD_BCRYPT);
-        $respond = self::add($data);
-        return $respond;
-    }
-
-    //获取商家的所有员工 shish 2019.12.9
-    public static function getAdminList($merchantId)
-    {
-        return self::getAllByCondition(['merchantId' => $merchantId, 'delStatus' => 0, 'status' => 1], null, '*');
-    }
-
-    //获取商家所有员工的名字 shish 2019.12.9
-    public static function getAdminNameList($merchantId)
-    {
-        $list = self::getAdminList($merchantId);
-        return !empty($list) ? array_column($list, 'adminName') : [];
-    }
-
-    //获取商家所有员工已经关联微信的userId
-    public static function getShopAdminUserId($merchantId)
-    {
-        $list = self::getAdminList($merchantId);
-        return !empty($list) ? array_column($list, 'userId') : [];
-    }
-
-    //验证权限
-    public static function valid($admin, $ghsId)
-    {
-        if (empty($admin)) {
-            util::fail('此员工无效');
-        }
-        $adminId = $admin['id'];
-        $staff = ShopAdminClass::getByCondition(['ghsId' => $ghsId, 'adminId' => $adminId]);
-        if (empty($staff)) {
-            util::fail('您没有权限操作此员工');
-        }
-    }
-
-    //删除员工,需要考虑权限 shish 2019.12.9
-    public static function deleteAdmin($admin, $adminId)
-    {
-        $id = $admin['id'];
-        if ($admin['super'] == 1) {
-            util::fail('超级管理员不能删除');
-        }
-        if ($id == $adminId) {
-            util::fail('不能删除自己');
-        }
-        self::updateById($id, ['delStatus' => 1]);
-    }
-
-    public static function getByMiniOpenId($miniOpenId)
-    {
-        return self::getByCondition(['miniOpenId' => $miniOpenId]);
-    }
-
-    public static function getByUnionId($unionId)
-    {
-        return self::getByCondition(['unionId' => $unionId]);
-    }
-
-    //创建以及更新用户 shish 2020.2.7
-    public static function replaceAdmin($adminInfo, $source)
-    {
-        $adminInfo = self::switchAdminInfo($adminInfo, $source);
-        $adminSource = UserClass::$userSourceId;
-        $unionId = isset($adminInfo['unionId']) && !empty($adminInfo['unionId']) ? $adminInfo['unionId'] : '';
-        $unionAdmin = [];
-        if (!empty($unionId)) {
-            $unionAdmin = self::getByUnionId($unionId);
-        }
-        switch ($source) {
-            case $adminSource['mini']['name']:
-                $sourceId = $adminSource['mini']['id'];
-                $miniOpenId = $adminInfo['miniOpenId'];
-                $admin = self::getByMiniOpenId($miniOpenId);
-                break;
-            case $adminSource['official']['name']:
-                $sourceId = $adminSource['official']['id'];
-                $openId = isset($adminInfo['openId']) ? $adminInfo['openId'] : '';
-                $admin = [];
-                if (!empty($openId)) {
-                    $admin = self::getByOpenId($openId);
-                }
-                break;
-            default:
-                throw new \Exception('未知来源的用户');
-        }
-        if (empty($admin)) {
-            if (!empty($unionAdmin)) {
-                //1、在小程序端已经授权用户信息和unionId之后,关注公众号时走这里
-                //2、关注了公众号或者H5已经授权时,并首次访问小程序
-                $admin = self::updateAdmin($unionAdmin, $adminInfo);
-            } else {
-                $adminInfo['sourceType'] = $sourceId;
-                $admin = self::generateAdmin($adminInfo);
-            }
-        } else {
-            if (!empty($unionAdmin)) {
-                if (isset($unionAdmin['id']) && isset($admin['id']) && $admin['id'] != $unionAdmin['id']) {
-                    //合并相同管理员,小程序管理保留,其它删除
-                    $admin = self::mergeAdmin($unionAdmin, $admin);
-                }
-            }
-            $admin = self::updateAdmin($admin, $adminInfo);
-        }
-        return $admin;
-    }
-
-    //更新员工信息 shish 2020.5.30
-    public static function updateAdmin($originalAdmin, $getAdminInfo)
-    {
-        $data = [];
-        $adminId = $originalAdmin['id'];
-        //替换掉微信不支持的图片
-        $nickName = isset($getAdminInfo['nickName']) ? preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $getAdminInfo['nickName']) : '';
-        if (!empty($nickName)) {
-            $data['nickName'] = $nickName;
-        }
-        if (isset($originalAdmin['adminName']) && empty($originalAdmin['adminName'])) {
-            $data['adminName'] = $nickName;
-        }
-        if (isset($getAdminInfo['openId']) && !empty($getAdminInfo['openId'])) {
-            $openId = $getAdminInfo['openId'];
-            $data['openId'] = $openId;
-        }
-        if (isset($getAdminInfo['miniOpenId']) && !empty($getAdminInfo['miniOpenId'])) {
-            $data['miniOpenId'] = $getAdminInfo['miniOpenId'];
-        }
-        if (isset($getAdminInfo['unionId']) && !empty($getAdminInfo['unionId'])) {
-            $data['unionId'] = $getAdminInfo['unionId'];
-        }
-        if (isset($getAdminInfo['sex'])) {
-            $data['sex'] = $getAdminInfo['sex'];
-        }
-        if (isset($getAdminInfo['subscribe'])) {
-            $data['subscribe'] = $getAdminInfo['subscribe'];
-        }
-        if (isset($getAdminInfo['subscribeTime'])) {
-            $data['subscribeTime'] = $getAdminInfo['subscribeTime'];
-        }
-        if (isset($getAdminInfo['isFull'])) {
-            $data['isFull'] = $getAdminInfo['isFull'];
-        }
-        if (isset($getAdminInfo['headImgUrl']) && !empty($getAdminInfo['headImgUrl'])) {
-            $data['isFull'] = 1;
-        }
-
-        //更新头像
-        $merchantId = 0;
-        if (isset($originalAdmin['avatar']) == false || empty($originalAdmin['avatar'])) {
-            if (isset($getAdminInfo['headImgUrl']) && !empty($getAdminInfo['headImgUrl'])) {
-                $imgUrl = $getAdminInfo['headImgUrl'];
-                $name = ImageService::generateAvatar($merchantId, $imgUrl);
-                if (!empty($name)) {
-                    $data['avatar'] = $name;
-                }
-            }
-        }
-
-        self::updateById($adminId, $data);
-        $admin = self::getById($adminId);
-        return $admin;
-    }
-
-    public static function generateAdmin($getAdminInfo)
-    {
-        $time = time();
-        //替换掉微信名称不支持的图片
-        $nickName = isset($getAdminInfo['nickName']) ? preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $getAdminInfo['nickName']) : '';
-        $getAdminInfo['nickName'] = $nickName;
-        $getAdminInfo['adminName'] = $nickName;
-        $subscribe = isset($getAdminInfo['subscribe']) ? $getAdminInfo['subscribe'] : 0;
-        $getAdminInfo['subscribe'] = $subscribe;
-        $getAdminInfo['avatar'] = '';
-        $getAdminInfo['password'] = '';
-        $getAdminInfo['payPassword'] = '';
-        $getAdminInfo['mobile'] = isset($getAdminInfo['mobile']) ? $getAdminInfo['mobile'] : '';
-        $getAdminInfo['addTime'] = $time;
-        $getAdminInfo['source'] = isset($getAdminInfo['source']) ? $getAdminInfo['source'] : 0;
-        $getAdminInfo['hasSubscribe'] = 0;
-
-        if (isset($getAdminInfo['headImgUrl']) && !empty($getAdminInfo['headImgUrl'])) {
-            $imgUrl = $getAdminInfo['headImgUrl'];
-            $name = ImageService::generateAvatar(0, $imgUrl);
-            if (!empty($name)) {
-                $getAdminInfo['avatar'] = $name;
-            }
-        }
-
-        $admin = self::add($getAdminInfo);
-        $adminId = $admin['id'];
-        if (empty($nickName)) {
-            self::updateById($adminId, ['adminName' => $adminId, 'nickName' => $adminId]);
-        }
-        return $admin;
-    }
-
-    //合并管理员
-    public static function mergeAdmin($delAdmin, $retainAdmin)
-    {
-        $connection = Yii::$app->db;//事务处理
-        $transaction = $connection->beginTransaction();
-        try {
-
-            $delAdminId = $delAdmin['id'];
-            $clearData = ['openId' => '', 'miniOpenId' => '', 'unionId' => ''];
-            self::updateById($delAdminId, $clearData);
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            return [];
-        }
-    }
-
-    //找出相同unionId的用户
-    public static function getSameUnionId($unionId)
-    {
-        return self::getAllByCondition(['unionId' => $unionId], 'addTime desc', '*');
-    }
-
-    public static function getByOpenId($openId)
-    {
-        return self::getByCondition(['openId' => $openId]);
-    }
-
-    //将微信和小程序获取的用户信息转成可以保存的用户信息
-    public static function switchAdminInfo($info, $source)
-    {
-        $openId = '';
-        if (isset($info['openid']) && !empty($info['openid'])) {
-            $openId = $info['openid'];
-            unset($info['openId']);
-        }
-        if (isset($info['openId']) && !empty($info['openId'])) {
-            $openId = $info['openId'];
-            unset($info['openId']);
-        }
-        if (!empty($openId)) {
-            $adminSource = UserClass::$userSourceId;
-            switch ($source) {
-                case $adminSource['mini']['name']:
-                    $info['miniOpenId'] = $openId;
-                    break;
-                case $adminSource['official']['name']:
-                    $info['openId'] = $openId;
-                    break;
-                default:
-            }
-        }
-        if (isset($info['nickName'])) {
-            $info['nickName'] = $info['nickName'];
-        }
-        if (isset($info['unionid'])) {
-            $info['unionId'] = $info['unionid'];
-        }
-        if (isset($info['unionId'])) {
-            $info['unionId'] = $info['unionId'];
-        }
-        if (isset($info['headimgurl'])) {
-            $info['headImgUrl'] = $info['headimgurl'];
-        }
-        if (isset($info['avatarUrl'])) {
-            $info['headImgUrl'] = $info['avatarUrl'];
-        }
-        if (isset($info['subscribe_time'])) {
-            $info['subscribeTime'] = $info['subscribe_time'];
-        }
-        if (isset($info['subscribe'])) {
-            $info['subscribe'] = $info['subscribe'];
-        }
-        return $info;
-    }
-
-    //取消关注 shish 2020.4.19
-    public static function unFocus($adminId)
-    {
-        self::updateById($adminId, ['subscribe' => 0, 'hasSubscribe' => 1]);
-    }
-
+	
+	public static $baseFile = '\bizGhs\admin\models\Admin';
+	
+	//收益通知人
+	public static $noticeAdmin = [
+		//国兰
+		'wx193341a4a80f6ea3' => ['o4c8Vs54PQh32nkgG8R3m4VuGTvw', 'o4c8VszacQJyrzu651CAu0sCsfPc'],
+		//花美灵
+		'wx84d95afcb7b594eb' => ['oTFbYvsjwgVwXggwtlM2ESAKwuN8', 'oTFbYvqP6qwdCCkdFB9GYnlzDIUg'],
+	];
+	
+	//组合员工基本信息 shish 2019.12.9
+	public static function groupAdminBaseInfo($list, $sensitive = true)
+	{
+		$prefix = Yii::$app->params['imgHost'];
+		foreach ($list as $key => $val) {
+			$roleId = 0;
+			$list[$key]['roleName'] = '';
+			$list[$key]['avatarUrl'] = Yii::$app->params['imgHost'] . '/retail/default-avatar.png';
+			$list[$key]['addDate'] = date("Y-m-d H:i", $val['addTime']);
+			$list[$key]['lastLoginTime'] = date("Y-m-d H:i", $val['loginTime']);
+			//敏感信息
+			if ($sensitive) {
+				//这里需要输出值secret,否则修改密码那边会有问题
+				$list[$key]['openId'] = isset($val['openId']) && !empty($val['openId']) ? 'secret' : '';
+				$list[$key]['password'] = isset($val['password']) && !empty($val['password']) ? 'secret' : '';
+				$list[$key]['confirmPassword'] = isset($val['confirmPassword']) && !empty($val['confirmPassword']) ? 'secret' : '';
+			}
+		}
+		return $list;
+	}
+	
+	//获取员工详情 shish 2019.12.9
+	public static function getDetail($id)
+	{
+		$detail = self::getById($id);
+		if (empty($detail)) {
+			util::fail('没有找到员工信息');
+		}
+		$list = self::groupAdminBaseInfo([$detail]);
+		return current($list);
+	}
+	
+	//获取员工详情 shish 2019.12.9
+	public static function getAdminById($id)
+	{
+		$detail = AdminClass::getById($id);
+		if (empty($detail)) {
+			util::fail('没有找到员工信息!');
+		}
+		$list = self::groupAdminBaseInfo([$detail]);
+		return current($list);
+	}
+	
+	//添加员工 shish 2019.12.9
+	public static function addAdmin($data)
+	{
+		$merchantId = $data['merchantId'];
+		
+		//验证角色
+		$roleId = $data['roleId'];
+		$role = AdminRoleClass::getById($roleId);
+		AdminRoleClass::valid($role, $merchantId);
+		
+		//验证关联的微信
+		$adminId = $data['admin'];
+		$admin = self::getById($adminId);
+		if (empty($admin)) {
+			util::fail('没有找到管理员信息');
+		}
+		$data['password'] = password_hash($data['password'], PASSWORD_BCRYPT);
+		$respond = self::add($data);
+		return $respond;
+	}
+	
+	//获取商家的所有员工 shish 2019.12.9
+	public static function getAdminList($merchantId)
+	{
+		return self::getAllByCondition(['merchantId' => $merchantId, 'delStatus' => 0, 'status' => 1], null, '*');
+	}
+	
+	//获取商家所有员工的名字 shish 2019.12.9
+	public static function getAdminNameList($merchantId)
+	{
+		$list = self::getAdminList($merchantId);
+		return !empty($list) ? array_column($list, 'adminName') : [];
+	}
+	
+	//获取商家所有员工已经关联微信的userId
+	public static function getShopAdminUserId($merchantId)
+	{
+		$list = self::getAdminList($merchantId);
+		return !empty($list) ? array_column($list, 'userId') : [];
+	}
+	
+	//验证权限
+	public static function valid($admin, $ghsId)
+	{
+		if (empty($admin)) {
+			util::fail('员工信息无效');
+		}
+		$adminId = $admin['id'];
+		$staff = ShopAdminClass::getByCondition(['ghsId' => $ghsId, 'adminId' => $adminId]);
+		if (empty($staff)) {
+			util::fail('您没有权限操作');
+		}
+	}
+
+	//删除员工,需要考虑权限 shish 2019.12.9
+	public static function deleteAdmin($admin, $adminId)
+	{
+		$id = $admin['id'];
+		if ($admin['super'] == 1) {
+			util::fail('超级管理员不能删除');
+		}
+		if ($id == $adminId) {
+			util::fail('不能删除自己');
+		}
+		self::updateById($id, ['delStatus' => 1]);
+	}
+	
+	public static function getByMiniOpenId($miniOpenId)
+	{
+		return self::getByCondition(['miniOpenId' => $miniOpenId]);
+	}
+	
+	public static function getByUnionId($unionId)
+	{
+		return self::getByCondition(['unionId' => $unionId]);
+	}
+	
+	//创建以及更新用户 shish 2020.2.7
+	public static function replaceAdmin($adminInfo, $source)
+	{
+		$adminInfo = self::switchAdminInfo($adminInfo, $source);
+		$adminSource = UserClass::$userSourceId;
+		$unionId = isset($adminInfo['unionId']) && !empty($adminInfo['unionId']) ? $adminInfo['unionId'] : '';
+		$unionAdmin = [];
+		if (!empty($unionId)) {
+			$unionAdmin = self::getByUnionId($unionId);
+		}
+		switch ($source) {
+			case $adminSource['mini']['name']:
+				$sourceId = $adminSource['mini']['id'];
+				$miniOpenId = $adminInfo['miniOpenId'];
+				$admin = self::getByMiniOpenId($miniOpenId);
+				break;
+			case $adminSource['official']['name']:
+				$sourceId = $adminSource['official']['id'];
+				$openId = isset($adminInfo['openId']) ? $adminInfo['openId'] : '';
+				$admin = [];
+				if (!empty($openId)) {
+					$admin = self::getByOpenId($openId);
+				}
+				break;
+			default:
+				throw new \Exception('未知来源的用户');
+		}
+		if (empty($admin)) {
+			if (!empty($unionAdmin)) {
+				//1、在小程序端已经授权用户信息和unionId之后,关注公众号时走这里
+				//2、关注了公众号或者H5已经授权时,并首次访问小程序
+				$admin = self::updateAdmin($unionAdmin, $adminInfo);
+			} else {
+				$adminInfo['sourceType'] = $sourceId;
+				$admin = self::generateAdmin($adminInfo);
+			}
+		} else {
+			if (!empty($unionAdmin)) {
+				if (isset($unionAdmin['id']) && isset($admin['id']) && $admin['id'] != $unionAdmin['id']) {
+					//合并相同管理员,小程序管理保留,其它删除
+					$admin = self::mergeAdmin($unionAdmin, $admin);
+				}
+			}
+			$admin = self::updateAdmin($admin, $adminInfo);
+		}
+		return $admin;
+	}
+	
+	//更新员工信息 shish 2020.5.30
+	public static function updateAdmin($originalAdmin, $getAdminInfo)
+	{
+		$data = [];
+		$adminId = $originalAdmin['id'];
+		//替换掉微信不支持的图片
+		$nickName = isset($getAdminInfo['nickName']) ? preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $getAdminInfo['nickName']) : '';
+		if (!empty($nickName)) {
+			$data['nickName'] = $nickName;
+		}
+		if (isset($originalAdmin['adminName']) && empty($originalAdmin['adminName'])) {
+			$data['adminName'] = $nickName;
+		}
+		if (isset($getAdminInfo['openId']) && !empty($getAdminInfo['openId'])) {
+			$openId = $getAdminInfo['openId'];
+			$data['openId'] = $openId;
+		}
+		if (isset($getAdminInfo['miniOpenId']) && !empty($getAdminInfo['miniOpenId'])) {
+			$data['miniOpenId'] = $getAdminInfo['miniOpenId'];
+		}
+		if (isset($getAdminInfo['unionId']) && !empty($getAdminInfo['unionId'])) {
+			$data['unionId'] = $getAdminInfo['unionId'];
+		}
+		if (isset($getAdminInfo['sex'])) {
+			$data['sex'] = $getAdminInfo['sex'];
+		}
+		if (isset($getAdminInfo['subscribe'])) {
+			$data['subscribe'] = $getAdminInfo['subscribe'];
+		}
+		if (isset($getAdminInfo['subscribeTime'])) {
+			$data['subscribeTime'] = $getAdminInfo['subscribeTime'];
+		}
+		if (isset($getAdminInfo['isFull'])) {
+			$data['isFull'] = $getAdminInfo['isFull'];
+		}
+		if (isset($getAdminInfo['headImgUrl']) && !empty($getAdminInfo['headImgUrl'])) {
+			$data['isFull'] = 1;
+		}
+		
+		//更新头像
+		$merchantId = 0;
+		if (isset($originalAdmin['avatar']) == false || empty($originalAdmin['avatar'])) {
+			if (isset($getAdminInfo['headImgUrl']) && !empty($getAdminInfo['headImgUrl'])) {
+				$imgUrl = $getAdminInfo['headImgUrl'];
+				$name = ImageService::generateAvatar($merchantId, $imgUrl);
+				if (!empty($name)) {
+					$data['avatar'] = $name;
+				}
+			}
+		}
+		
+		self::updateById($adminId, $data);
+		$admin = self::getById($adminId);
+		return $admin;
+	}
+	
+	public static function generateAdmin($getAdminInfo)
+	{
+		$time = time();
+		//替换掉微信名称不支持的图片
+		$nickName = isset($getAdminInfo['nickName']) ? preg_replace('/[\x{10000}-\x{10FFFF}]/u', '', $getAdminInfo['nickName']) : '';
+		$getAdminInfo['nickName'] = $nickName;
+		$getAdminInfo['adminName'] = $nickName;
+		$subscribe = isset($getAdminInfo['subscribe']) ? $getAdminInfo['subscribe'] : 0;
+		$getAdminInfo['subscribe'] = $subscribe;
+		$getAdminInfo['avatar'] = '';
+		$getAdminInfo['password'] = '';
+		$getAdminInfo['payPassword'] = '';
+		$getAdminInfo['mobile'] = isset($getAdminInfo['mobile']) ? $getAdminInfo['mobile'] : '';
+		$getAdminInfo['addTime'] = $time;
+		$getAdminInfo['source'] = isset($getAdminInfo['source']) ? $getAdminInfo['source'] : 0;
+		$getAdminInfo['hasSubscribe'] = 0;
+		
+		if (isset($getAdminInfo['headImgUrl']) && !empty($getAdminInfo['headImgUrl'])) {
+			$imgUrl = $getAdminInfo['headImgUrl'];
+			$name = ImageService::generateAvatar(0, $imgUrl);
+			if (!empty($name)) {
+				$getAdminInfo['avatar'] = $name;
+			}
+		}
+		
+		$admin = self::add($getAdminInfo);
+		$adminId = $admin['id'];
+		if (empty($nickName)) {
+			self::updateById($adminId, ['adminName' => $adminId, 'nickName' => $adminId]);
+		}
+		return $admin;
+	}
+	
+	//合并管理员
+	public static function mergeAdmin($delAdmin, $retainAdmin)
+	{
+		$connection = Yii::$app->db;//事务处理
+		$transaction = $connection->beginTransaction();
+		try {
+			
+			$delAdminId = $delAdmin['id'];
+			$clearData = ['openId' => '', 'miniOpenId' => '', 'unionId' => ''];
+			self::updateById($delAdminId, $clearData);
+			
+			$transaction->commit();
+		} catch (Exception $e) {
+			$transaction->rollBack();
+			return [];
+		}
+	}
+	
+	//找出相同unionId的用户
+	public static function getSameUnionId($unionId)
+	{
+		return self::getAllByCondition(['unionId' => $unionId], 'addTime desc', '*');
+	}
+	
+	public static function getByOpenId($openId)
+	{
+		return self::getByCondition(['openId' => $openId]);
+	}
+	
+	//将微信和小程序获取的用户信息转成可以保存的用户信息
+	public static function switchAdminInfo($info, $source)
+	{
+		$openId = '';
+		if (isset($info['openid']) && !empty($info['openid'])) {
+			$openId = $info['openid'];
+			unset($info['openId']);
+		}
+		if (isset($info['openId']) && !empty($info['openId'])) {
+			$openId = $info['openId'];
+			unset($info['openId']);
+		}
+		if (!empty($openId)) {
+			$adminSource = UserClass::$userSourceId;
+			switch ($source) {
+				case $adminSource['mini']['name']:
+					$info['miniOpenId'] = $openId;
+					break;
+				case $adminSource['official']['name']:
+					$info['openId'] = $openId;
+					break;
+				default:
+			}
+		}
+		if (isset($info['nickName'])) {
+			$info['nickName'] = $info['nickName'];
+		}
+		if (isset($info['unionid'])) {
+			$info['unionId'] = $info['unionid'];
+		}
+		if (isset($info['unionId'])) {
+			$info['unionId'] = $info['unionId'];
+		}
+		if (isset($info['headimgurl'])) {
+			$info['headImgUrl'] = $info['headimgurl'];
+		}
+		if (isset($info['avatarUrl'])) {
+			$info['headImgUrl'] = $info['avatarUrl'];
+		}
+		if (isset($info['subscribe_time'])) {
+			$info['subscribeTime'] = $info['subscribe_time'];
+		}
+		if (isset($info['subscribe'])) {
+			$info['subscribe'] = $info['subscribe'];
+		}
+		return $info;
+	}
+	
+	//取消关注 shish 2020.4.19
+	public static function unFocus($adminId)
+	{
+		self::updateById($adminId, ['subscribe' => 0, 'hasSubscribe' => 1]);
+	}
+	
 }

+ 1 - 1
biz-ghs/admin/classes/AdminLogClass.php

@@ -7,7 +7,7 @@ use biz\user\classes\UserClass;
 use bizGhs\user\services\UserService;
 use common\components\util;
 use Yii;
-use biz\base\classes\BaseClass;
+use bizGhs\base\classes\BaseClass;
 
 class AdminLogClass extends BaseClass
 {

+ 1 - 1
biz-ghs/admin/classes/AdminRoleAuthClass.php

@@ -3,7 +3,7 @@
 namespace bizGhs\admin\classes;
 
 use Yii;
-use biz\base\classes\BaseClass;
+use bizGhs\base\classes\BaseClass;
 
 class AdminRoleAuthClass extends BaseClass
 {

+ 7 - 7
biz-ghs/admin/classes/AdminRoleClass.php

@@ -4,7 +4,7 @@ namespace bizGhs\admin\classes;
 
 use common\components\util;
 use Yii;
-use biz\base\classes\BaseClass;
+use bizGhs\base\classes\BaseClass;
 
 class AdminRoleClass extends BaseClass
 {
@@ -12,16 +12,16 @@ class AdminRoleClass extends BaseClass
 	public static $baseFile = '\bizGhs\admin\models\AdminRole';
 	
 	//验证权限 shish 2019.12.9
-	public static function valid($role, $merchantId)
+	public static function valid($role, $ghsId)
 	{
 		if (empty($role)) {
 			util::fail('角色无效');
 		}
-		if ($role['merchantId'] != $merchantId) {
+		if ($role['ghsId'] != $ghsId) {
 			util::fail('没有权限操作');
 		}
 	}
-
+	
 	//添加角色 shish 2019.12.10
 	public static function addRole($data)
 	{
@@ -41,7 +41,7 @@ class AdminRoleClass extends BaseClass
 		$where = ['ghsId' => $ghsId, 'delStatus' => 0];
 		return self::getList('*', $where, 'addTime DESC');
 	}
-
+	
 	//获取商家所有的角色名称 shish 2019.12.10
 	public static function getNameList($ghsId)
 	{
@@ -52,10 +52,10 @@ class AdminRoleClass extends BaseClass
 	//更新角色 shish 2019.12.10
 	public static function updateRole($role, $data)
 	{
-		$merchantId = $role['merchantId'];
+		$ghsId = $role['ghsId'];
 		if ($role['roleName'] != $data['roleName']) {
 			$name = $data['roleName'];
-			$nameList = self::getNameList($merchantId);
+			$nameList = self::getNameList($ghsId);
 			if (in_array($name, $nameList)) {
 				util::fail('名称已经存在');
 			}

+ 1 - 1
biz-ghs/admin/models/Admin.php

@@ -1,6 +1,6 @@
 <?php
 namespace bizGhs\admin\models;
-use biz\base\models\Base;
+use bizGhs\base\models\Base;
 
 class Admin extends Base
 {

+ 1 - 1
biz-ghs/admin/models/AdminLog.php

@@ -1,6 +1,6 @@
 <?php
 namespace bizGhs\admin\models;
-use biz\base\models\Base;
+use bizGhs\base\models\Base;
 
 class AdminLog extends Base
 {

+ 1 - 1
biz-ghs/admin/models/AdminRole.php

@@ -1,6 +1,6 @@
 <?php
 namespace bizGhs\admin\models;
-use biz\base\models\Base;
+use bizGhs\base\models\Base;
 
 class AdminRole extends Base
 {

+ 1 - 1
biz-ghs/admin/models/AdminRoleAuth.php

@@ -1,6 +1,6 @@
 <?php
 namespace bizGhs\admin\models;
-use biz\base\models\Base;
+use bizGhs\base\models\Base;
 
 class AdminRoleAuth extends Base
 {

+ 1 - 1
biz-ghs/admin/services/AdminLogService.php

@@ -5,7 +5,7 @@ namespace bizGhs\admin\services;
 use bizGhs\admin\classes\AdminClass;
 use bizGhs\admin\classes\AdminLogClass;
 use bizGhs\auth\services\AuthService;
-use biz\base\services\BaseService;
+use bizGhs\base\services\BaseService;
 use bizGhs\merchant\services\MerchantService;
 use common\components\error;
 use common\components\stringUtil;

+ 1 - 1
biz-ghs/admin/services/AdminRoleAuthService.php

@@ -2,7 +2,7 @@
 
 namespace bizGhs\admin\services;
 
-use biz\base\services\BaseService;
+use bizGhs\base\services\BaseService;
 use common\components\util;
 use Yii;
 

+ 1 - 1
biz-ghs/admin/services/AdminRoleService.php

@@ -3,7 +3,7 @@
 namespace bizGhs\admin\services;
 
 use bizGhs\admin\classes\AdminRoleClass;
-use biz\base\services\BaseService;
+use bizGhs\base\services\BaseService;
 use Yii;
 
 class AdminRoleService extends BaseService

+ 1 - 1
biz-ghs/admin/services/AdminService.php

@@ -4,7 +4,7 @@ namespace bizGhs\admin\services;
 
 use bizGhs\admin\classes\AdminClass;
 use bizGhs\auth\services\AuthService;
-use biz\base\services\BaseService;
+use bizGhs\base\services\BaseService;
 use bizGhs\merchant\services\MerchantService;
 use bizGhs\user\services\UserService;
 use common\components\error;

+ 0 - 172
biz-ghs/admin/services/ShopAdminService.php

@@ -1,172 +0,0 @@
-<?php
-
-namespace bizGhs\admin\services;
-
-use bizGhs\admin\classes\AdminClass;
-use bizGhs\admin\classes\AdminRoleClass;
-use bizGhs\admin\classes\ShopAdminClass;
-use bizGhs\auth\services\AuthService;
-use biz\base\services\BaseService;
-use bizGhs\merchant\classes\ShopClass;
-use bizGhs\merchant\services\MerchantService;
-use bizGhs\user\services\UserService;
-use common\components\error;
-use common\components\miniUtil;
-use common\components\stringUtil;
-use common\components\util;
-use common\components\wxUtil;
-use common\services\xhTMessageService;
-use Yii;
-
-class ShopAdminService extends BaseService
-{
-
-    public static $baseFile = '\bizGhs\admin\classes\ShopAdminClass';
-
-    ///创建管理员生成小程序 shish 2020.4.17
-    public static function prepareBindAdmin($data)
-    {
-        ShopAdminClass::prepareBindAdmin($data);
-        $page = 'admin/shopAdmin/bind';
-        $isOpen = 2;
-        $adminId = $data['adminId'];
-        $shopId = $data['shopId'];
-        $scene = 'adminId=' . $adminId . '&shopId=' . $shopId;
-        $merchant = $data['merchant'];
-        $imgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $isOpen);
-        return ['miniCode' => $imgUrl];
-    }
-
-    public static function generateAdmin($data)
-    {
-        $recommendAdminId = isset($data['recommendAdminId']) ? $data['recommendAdminId'] : 0;
-        $mobile = isset($data['mobile']) ? $data['mobile'] : '';
-        $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('小程序码已失效,请重新生成');
-        }
-        $shopAdmin = ShopAdminClass::getByCondition(['adminId' => $adminId, 'shopId' => $shopId]);
-        if (!empty($shopAdmin)) {
-            util::fail('您已经是管理员了');
-        }
-        $adminName = isset($bindData['adminName']) ? $bindData['adminName'] : '';
-        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("请关注公众号");
-        }
-        $roleId = $bindData['roleId'];
-        $remind = isset($bindData['remind']) ? $bindData['remind'] : 0;
-        $status = isset($bindData['status']) ? $bindData['status'] : 0;
-        $password = isset($bindData['password']) ? password_hash($bindData['password'], PASSWORD_BCRYPT) : '';
-        $remark = isset($bindData['remark']) ? $bindData['remark'] : '';
-        $update = ['adminName' => $adminName, 'mobile' => $mobile, 'password' => $password, 'remark' => $remark];
-        AdminClass::updateById($adminId, $update);
-        $addData = [
-            'adminId' => $adminId,
-            'shopId' => $shopId,
-            'roleId' => $roleId,
-            'remind' => $remind,
-            'status' => $status,
-            'merchantId' => $merchantId,
-        ];
-        ShopAdminClass::delBindAdminData($shopId, $recommendAdminId);
-        return ShopAdminClass::add($addData);
-    }
-
-    //获取管理员 shish 2020.4.21
-    // $sensitive true 密码等敏感信息不显示
-    public static function getAdminList($where, $sensitive = true)
-    {
-        $data = ShopAdminClass::getList('*', $where, 'addTime DESC');
-        $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
-        if (empty($list)) {
-            return $data;
-        }
-
-        //管理员基础信息
-        $ids = array_column($list, 'adminId');
-        $adminInfo = AdminClass::getByIds($ids, null, 'id');
-        $adminBaseInfo = AdminClass::groupAdminBaseInfo($adminInfo, $sensitive);
-
-        $roleIds = array_column($list, 'roleId');
-        $roleIds = array_filter(array_unique($roleIds));
-        $roleList = AdminRoleClass::getByIds($roleIds, null, 'id');
-
-        foreach ($list as $key => $val) {
-            $adminId = $val['adminId'];
-            $roleId = $val['roleId'];
-            $roleName = isset($roleList[$roleId]['roleName']) ? $roleList[$roleId]['roleName'] : '';
-            $list[$key]['roleName'] = $roleName;
-            $currentAdmin = isset($adminBaseInfo[$adminId]) ? $adminBaseInfo[$adminId] : [];
-            $list[$key]['adminName'] = isset($currentAdmin['adminName']) ? $currentAdmin['adminName'] : '';
-            //帐号状态
-            $status = 1;
-            if (isset($currentAdmin['accountStatus']) && $currentAdmin['accountStatus'] == 0) {
-                $status = 0;
-            }
-            if (isset($val['status']) && $val['status'] == 0) {
-                $status = 0;
-            }
-            $list[$key]['status'] = $status;
-        }
-        $data['list'] = $list;
-        return $data;
-    }
-
-    //获取要通知的管理员 shish 2020.4.28
-    public static function getNoticeAdminList($shopId)
-    {
-        $where = ['shopId' => $shopId];
-        $respond = self::getAdminList($where, false);
-        $list = isset($respond['list']) ? $respond['list'] : [];
-        if (!empty($list)) {
-            foreach ($list as $key => $val) {
-                if (isset($val['remind']) && $val['remind'] == 0) {
-                    unset($list[$key]);
-                }
-            }
-        }
-        return $list;
-    }
-
-    public static function valid($shopAdmin, $shopId)
-    {
-        if (isset($shopAdmin['shopId']) == false || $shopAdmin['shopId'] != $shopId) {
-            util::fail('不是您的员工');
-        }
-    }
-
-    //根据id取员工信息,包括基本信息和角色 shish 2021.1.13
-    public static function getAdminInfo($id)
-    {
-        $relation = ShopAdminClass::getById($id);
-        if (empty($relation)) {
-            util::fail('没有找到员工信息');
-        }
-        $adminId = isset($relation['adminId']) ? $relation['adminId'] : 0;
-        if (empty($adminId)) {
-            util::fail('没有找到员工');
-        }
-        $adminInfo = AdminClass::getDetail($adminId);
-        $adminInfo['shopId'] = isset($relation['shopId']) ? $relation['shopId'] : 0;
-        $adminInfo['ghsId'] = isset($relation['ghsId']) ? $relation['ghsId'] : 0;
-        $adminInfo['adminId'] = isset($relation['adminId']) ? $relation['adminId'] : 0;
-        $adminInfo['roleId'] = isset($relation['roleId']) ? $relation['roleId'] : 0;
-        $adminInfo['remind'] = isset($relation['remind']) ? $relation['remind'] : 0;
-        return $adminInfo;
-    }
-
-}

+ 1 - 1
biz-ghs/custom/services/CustomService.php

@@ -4,7 +4,7 @@ namespace bizGhs\custom\services;
 
 use biz\base\services\BaseService;
 use biz\merchant\classes\ShopClass;
-use bizGhs\admin\classes\ShopAdminClass;
+use bizGhs\shop\classes\ShopAdminClass;
 use bizGhs\custom\classes\CustomClass;
 use Yii;
 

+ 1 - 1
biz-ghs/merchant/classes/MerchantClass.php

@@ -4,7 +4,7 @@ namespace bizGhs\merchant\classes;
 
 use biz\ad\classes\AdClass;
 use biz\admin\classes\AdminRoleClass;
-use biz\admin\classes\ShopAdminClass;
+use biz\shop\classes\ShopAdminClass;
 use biz\coupon\classes\CouponAssetClass;
 use biz\goods\classes\CategoryClass;
 use biz\goods\classes\GoodsSettingClass;

+ 2 - 2
biz-ghs/admin/classes/ShopAdminClass.php → biz-ghs/shop/classes/ShopAdminClass.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace bizGhs\admin\classes;
+namespace bizGhs\shop\classes;
 
 use biz\user\classes\UserClass;
 use common\components\util;
@@ -10,7 +10,7 @@ use biz\base\classes\BaseClass;
 class ShopAdminClass extends BaseClass
 {
 
-    public static $baseFile = '\bizGhs\admin\models\ShopAdmin';
+    public static $baseFile = '\bizGhs\shop\models\ShopAdmin';
 
     const GENERATE_ADMIN_DATA = 'generate_ghs_admin_data_';//创建管理员需要的数据
 

+ 1 - 1
biz-ghs/admin/models/ShopAdmin.php → biz-ghs/shop/models/ShopAdmin.php

@@ -1,6 +1,6 @@
 <?php
 
-namespace bizGhs\admin\models;
+namespace bizGhs\shop\models;
 
 use biz\base\models\Base;
 

+ 175 - 0
biz-ghs/shop/services/ShopAdminService.php

@@ -0,0 +1,175 @@
+<?php
+
+namespace bizGhs\shop\services;
+
+use bizGhs\admin\classes\AdminClass;
+use bizGhs\admin\classes\AdminRoleClass;
+use bizGhs\shop\classes\ShopAdminClass;
+use bizGhs\auth\services\AuthService;
+use biz\base\services\BaseService;
+use bizGhs\merchant\classes\ShopClass;
+use bizGhs\merchant\services\MerchantService;
+use bizGhs\user\services\UserService;
+use common\components\error;
+use common\components\miniUtil;
+use common\components\stringUtil;
+use common\components\util;
+use common\components\wxUtil;
+use common\services\xhTMessageService;
+use Yii;
+
+class ShopAdminService extends BaseService
+{
+	
+	public static $baseFile = '\bizGhs\shop\classes\ShopAdminClass';
+	
+	///创建管理员生成小程序 shish 2020.4.17
+	public static function prepareBindAdmin($data)
+	{
+		$merchant = $data['merchant'];
+		unset($data['merchant']);
+		ShopAdminClass::prepareBindAdmin($data);
+		$page = 'admin/shopAdmin/bind';
+		$isOpen = 2;
+		$adminId = $data['adminId'];
+		$shopId = $data['shopId'];
+		$scene = 'adminId=' . $adminId . '&shopId=' . $shopId;
+		$imgUrl = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $isOpen);
+		return ['miniCode' => $imgUrl];
+	}
+	
+	public static function generateAdmin($data)
+	{
+		$recommendAdminId = isset($data['recommendAdminId']) ? $data['recommendAdminId'] : 0;
+		$mobile = isset($data['mobile']) ? $data['mobile'] : '';
+		$shopId = isset($data['shopId']) ? $data['shopId'] : 0;
+		$adminId = isset($data['adminId']) ? $data['adminId'] : 0;
+		$ghsId = $data['ghsId'] ?? 0;
+		$shop = ShopClass::getById($shopId);
+		if (empty($shop)) {
+			util::fail('没有找到门店');
+		}
+		ShopClass::valid($shop, $ghsId);
+		$source = ShopAdminClass::getBindAdminData($shopId, $recommendAdminId);
+		if (empty($source)) {
+			util::fail('小程序码已失效,请重新创建');
+		}
+		$shopAdmin = ShopAdminClass::getByCondition(['ghsId' => $ghsId, 'shopId' => $shopId, 'adminId' => $adminId]);
+		if (!empty($shopAdmin)) {
+			util::fail('您已经是员工');
+		}
+		$adminName = isset($source['adminName']) ? $source['adminName'] : '';
+		
+		$roleId = $source['roleId'] ?? 0;
+		$role = AdminRoleClass::getById($roleId);
+		AdminRoleClass::valid($role, $ghsId);
+		
+		$admin = AdminClass::getById($adminId);
+		AdminClass::valid($admin,$ghsId);
+
+		if (isset($admin['subscribe']) == false || $admin['subscribe'] != 1) {
+			util::fail("请关注公众号");
+		}
+		$roleId = $source['roleId'];
+		$remind = isset($source['remind']) ? $source['remind'] : 0;
+		$status = isset($source['status']) ? $source['status'] : 0;
+		$password = isset($source['password']) ? password_hash($source['password'], PASSWORD_BCRYPT) : '';
+		$remark = isset($source['remark']) ? $source['remark'] : '';
+		$update = ['adminName' => $adminName, 'mobile' => $mobile, 'password' => $password, 'remark' => $remark];
+		AdminClass::updateById($adminId, $update);
+		$addData = [
+			'adminId' => $adminId,
+			'shopId' => $shopId,
+			'roleId' => $roleId,
+			'remind' => $remind,
+			'status' => $status,
+			'ghsId' => $ghsId,
+		];
+		ShopAdminClass::delBindAdminData($shopId, $recommendAdminId);
+		return ShopAdminClass::add($addData);
+	}
+
+	//获取管理员 shish 2020.4.21
+	// $sensitive true 密码等敏感信息不显示
+	public static function getAdminList($where, $sensitive = true)
+	{
+		$data = ShopAdminClass::getList('*', $where, 'addTime DESC');
+		$list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
+		if (empty($list)) {
+			return $data;
+		}
+		
+		//管理员基础信息
+		$ids = array_column($list, 'adminId');
+		$adminInfo = AdminClass::getByIds($ids, null, 'id');
+		$adminBaseInfo = AdminClass::groupAdminBaseInfo($adminInfo, $sensitive);
+		
+		$roleIds = array_column($list, 'roleId');
+		$roleIds = array_filter(array_unique($roleIds));
+		$roleList = AdminRoleClass::getByIds($roleIds, null, 'id');
+		
+		foreach ($list as $key => $val) {
+			$adminId = $val['adminId'];
+			$roleId = $val['roleId'];
+			$roleName = isset($roleList[$roleId]['roleName']) ? $roleList[$roleId]['roleName'] : '';
+			$list[$key]['roleName'] = $roleName;
+			$currentAdmin = isset($adminBaseInfo[$adminId]) ? $adminBaseInfo[$adminId] : [];
+			$list[$key]['adminName'] = isset($currentAdmin['adminName']) ? $currentAdmin['adminName'] : '';
+			//帐号状态
+			$status = 1;
+			if (isset($currentAdmin['accountStatus']) && $currentAdmin['accountStatus'] == 0) {
+				$status = 0;
+			}
+			if (isset($val['status']) && $val['status'] == 0) {
+				$status = 0;
+			}
+			$list[$key]['status'] = $status;
+		}
+		$data['list'] = $list;
+		return $data;
+	}
+	
+	//获取要通知的管理员 shish 2020.4.28
+	public static function getNoticeAdminList($shopId)
+	{
+		$where = ['shopId' => $shopId];
+		$respond = self::getAdminList($where, false);
+		$list = isset($respond['list']) ? $respond['list'] : [];
+		if (!empty($list)) {
+			foreach ($list as $key => $val) {
+				if (isset($val['remind']) && $val['remind'] == 0) {
+					unset($list[$key]);
+				}
+			}
+		}
+		return $list;
+	}
+	
+	public static function valid($shopAdmin, $shopId)
+	{
+		if (isset($shopAdmin['shopId']) == false || $shopAdmin['shopId'] != $shopId) {
+			util::fail('不是您的员工');
+		}
+	}
+	
+	//根据id取员工信息,包括基本信息和角色 shish 2021.1.13
+	public static function getAdminInfo($id)
+	{
+		$relation = ShopAdminClass::getById($id);
+		if (empty($relation)) {
+			util::fail('没有找到员工信息');
+		}
+		$adminId = isset($relation['adminId']) ? $relation['adminId'] : 0;
+		if (empty($adminId)) {
+			util::fail('没有找到员工');
+		}
+		$adminInfo = AdminClass::getDetail($adminId);
+		$adminInfo['shopId'] = isset($relation['shopId']) ? $relation['shopId'] : 0;
+		$adminInfo['ghsId'] = isset($relation['ghsId']) ? $relation['ghsId'] : 0;
+		$adminInfo['adminId'] = isset($relation['adminId']) ? $relation['adminId'] : 0;
+		$adminInfo['roleId'] = isset($relation['roleId']) ? $relation['roleId'] : 0;
+		$adminInfo['remind'] = isset($relation['remind']) ? $relation['remind'] : 0;
+		return $adminInfo;
+	}
+	
+}