From 33fb06bd4511fde88bb09dc2c58b7448bbd42dbe Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Mon, 22 Jan 2024 11:43:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=EF=BC=9A=E6=8C=87=E5=AE=9A?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=98=AF=E5=90=A6=E4=B8=BA=E6=9C=89=E6=95=88?= =?UTF-8?q?=E5=91=98=E5=B7=A5=E5=88=A4=E6=96=AD=E6=9D=A1=E4=BB=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E5=85=BC=E5=AE=B9=E6=80=BB=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/service/StoreServiceRepository.php | 20 ++++++++++++------- .../user/UserMerchantRepository.php | 2 +- .../api/store/merchant/MerchantIntention.php | 4 ++-- .../merchant/store/service/StoreService.php | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/app/common/repositories/store/service/StoreServiceRepository.php b/app/common/repositories/store/service/StoreServiceRepository.php index 0a69a90..b5a00be 100644 --- a/app/common/repositories/store/service/StoreServiceRepository.php +++ b/app/common/repositories/store/service/StoreServiceRepository.php @@ -248,25 +248,31 @@ class StoreServiceRepository extends BaseRepository return $key; } - /** * Common: 判断:指定用户是否为有效员工 * Author: wu-hui - * Time: 2024/01/19 15:56 + * Time: 2024/01/22 11:35 * @param int $uid * @param int $id + * @param int $merId * @return bool */ - public function isService(int $uid,int $id = 0):bool{ + public function isService(int $uid,int $id = 0,int $merId = 0):bool{ $count = $this->dao->getSearch([]) ->hasWhere('merchant',function($query){ $query->where('is_del', 0); }) ->where('StoreService.uid',$uid) ->where('StoreService.is_del', 0) - ->when($id > 0,function($query) use ($id){ + ->when((int)$id > 0,function($query) use ($id){ $query->where('StoreService.service_id','<>',$id); - })->count(); + }) + ->when((int)$merId > 0,function($query) use ($merId){ + $query->where('StoreService.mer_id','>',$merId); + },function($query){ + $query->where('StoreService.mer_id', 0); + }) + ->count(); return $count > 0; } @@ -279,7 +285,7 @@ class StoreServiceRepository extends BaseRepository */ public function createInfo($data){ // 内容校验 - if($this->isService($data['uid'])) throw new ValidateException('该用户已绑定商户!'); + if($this->isService($data['uid'], 0, $data['mer_id'])) throw new ValidateException('该用户已绑定商户!'); if($this->dao->fieldExists('account', $data['account'])) throw new ValidateException('账号已存在!'); // 数据添加 $data['pwd'] = password_hash($data['pwd'], PASSWORD_BCRYPT); @@ -297,7 +303,7 @@ class StoreServiceRepository extends BaseRepository public function updateInfo($id,$data){ // 内容校验 if (!$this->dao->merExists($data['mer_id'], $id)) throw new ValidateException('数据不存在!'); - if($this->isService($data['uid'], $id)) throw new ValidateException('该用户已绑定商户!'); + if($this->isService($data['uid'], $id, $data['mer_id'])) throw new ValidateException('该用户已绑定商户!'); if($this->dao->fieldExists('account', $data['account'], $id)) throw new ValidateException('账号已存在!'); // 数据修改 if ($data['pwd']) $data['pwd'] = password_hash($data['pwd'], PASSWORD_BCRYPT); diff --git a/app/common/repositories/user/UserMerchantRepository.php b/app/common/repositories/user/UserMerchantRepository.php index 7235d91..751c573 100644 --- a/app/common/repositories/user/UserMerchantRepository.php +++ b/app/common/repositories/user/UserMerchantRepository.php @@ -43,7 +43,7 @@ class UserMerchantRepository extends BaseRepository $item->svip_endtime = date('Y-m-d H:i:s', strtotime("+100 year")); $item->merchant_integral = $integralMake->getMerIntegral((int)$item->uid,(int)$where['mer_id']); // 当前用户是否已经绑定店员身份 - $item->is_store_service = (int)app()->make(StoreServiceRepository::class)->isService((int)$item->uid); + $item->is_store_service = (int)app()->make(StoreServiceRepository::class)->isService((int)$item->uid, 0, 1); return $item; }); diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index 5305bc5..61621a7 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -107,7 +107,7 @@ class MerchantIntention extends BaseController $typeIsHas = app()->make(MerchantTypeRepository::class)->exists($data['mer_type_id']); if($data['mer_type_id'] && !$typeIsHas) throw new ValidateException('店铺类型不存在'); // 判断:当前管理员身份是否有效 - $isService = app()->make(StoreServiceRepository::class)->isService($data['manage_uid'], $id);// 是否存在店员信息 + $isService = app()->make(StoreServiceRepository::class)->isService($data['manage_uid'], $id, 1);// 是否存在店员信息 if($isService) throw new ValidateException('管理员身份无效,已成为其他商户管理员或店员!'); $isManage = app()->make(repository::class)->isManage($data['manage_uid'], $id);// 是否存在审核中店长信息 if($isManage) throw new ValidateException('管理员身份无效,已成为其他商户管理员!'); @@ -148,7 +148,7 @@ class MerchantIntention extends BaseController 'msg' => '有效' ]; // 判断:当前管理员身份是否有效 - $isService = app()->make(StoreServiceRepository::class)->isService((int)$data['manage_uid'], (int)$data['service_id']);// 是否存在店员信息 + $isService = app()->make(StoreServiceRepository::class)->isService((int)$data['manage_uid'], (int)$data['service_id'], 1);// 是否存在店员信息 if($isService){ $returnData = [ 'is_eligible' => false, diff --git a/app/controller/merchant/store/service/StoreService.php b/app/controller/merchant/store/service/StoreService.php index d459f8c..5f8d1f8 100644 --- a/app/controller/merchant/store/service/StoreService.php +++ b/app/controller/merchant/store/service/StoreService.php @@ -98,7 +98,7 @@ class StoreService extends BaseController 'pwd', 'confirm_pwd', 'is_open', - 'status', + ['status',0], 'customer', 'is_verify', 'is_goods',