From 65a16c6289255d4a1d746a5f929ffd8a77691e84 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Fri, 12 Jul 2024 15:08:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E7=A7=BB=E5=8A=A8?= =?UTF-8?q?=E7=AB=AF=E5=95=86=E6=88=B7=E7=99=BB=E5=BD=95=E6=97=B6=20?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E5=88=A4=E6=96=AD=E5=95=86=E6=88=B7=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=EF=BC=8C=E5=8F=96=E6=B6=88=E8=B7=A8=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/merchant/MerchantAdminRepository.php | 11 ++++++----- app/controller/api/store/merchant/Merchant.php | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/common/repositories/system/merchant/MerchantAdminRepository.php b/app/common/repositories/system/merchant/MerchantAdminRepository.php index ec509b4..0f48946 100644 --- a/app/common/repositories/system/merchant/MerchantAdminRepository.php +++ b/app/common/repositories/system/merchant/MerchantAdminRepository.php @@ -158,18 +158,18 @@ class MerchantAdminRepository extends BaseRepository { return password_hash($password, PASSWORD_BCRYPT); } - /** * @param string $account * @param string $password + * @param int $merchantType * @return array|Model|null * @throws DataNotFoundException * @throws DbException * @throws ModelNotFoundException * @author xaboy - * @day 2020-04-17 + * @day 2020-04-17 */ - public function login(string $account, string $password) + public function login(string $account, string $password,int $merchantType = -1) { event('admin.merLogin.before',compact('account', 'password')); $accountInfo = explode('@', $account, 2); @@ -195,8 +195,7 @@ class MerchantAdminRepository extends BaseRepository throw new ValidateException('账号或密码错误'); } - if ($adminInfo['status'] != 1) - throw new ValidateException('账号已关闭'); + if ($adminInfo['status'] != 1) throw new ValidateException('账号已关闭'); /** @@ -206,6 +205,8 @@ class MerchantAdminRepository extends BaseRepository $merchant = $merchantRepository->get($adminInfo->mer_id); if (!$merchant) throw new ValidateException('商户不存在'); if (!$merchant['status']) throw new ValidateException('商户已被锁定'); + // 判断:如果指定了登录的商户类别 则禁止跨类别登录 + if($merchantType >= 0 && $merchant->merchant_type != $merchantType) throw new ValidateException('账号或密码错误'); $adminInfo->last_time = date('Y-m-d H:i:s'); $adminInfo->last_ip = app('request')->ip(); diff --git a/app/controller/api/store/merchant/Merchant.php b/app/controller/api/store/merchant/Merchant.php index c2764f7..d1f59fd 100644 --- a/app/controller/api/store/merchant/Merchant.php +++ b/app/controller/api/store/merchant/Merchant.php @@ -160,12 +160,12 @@ class Merchant extends BaseController */ public function storeLogin(){ // 参数获取 - $params = $this->request->params(['account','password']); + $params = $this->request->params(['account','password','merchant_type']); if(empty($params['account'])) throw new ValidateException('请输入账号'); if(empty($params['password'])) throw new ValidateException('请输入密码'); // 判断登录是否成功 $repository = app()->make(MerchantAdminRepository::class); - $adminInfo = $repository->login($params['account'], $params['password']); + $adminInfo = $repository->login($params['account'], $params['password'], $params['merchant_type']); $tokenInfo = $repository->createToken($adminInfo); $admin = $adminInfo->toArray(); // 判断:这里仅允许酒道馆和普通商户登录