From a35b04660e1abd1adcda626626d6702d98d90296 Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Tue, 22 Aug 2023 11:35:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AE=8C=E5=96=84=E5=95=86?= =?UTF-8?q?=E6=88=B7=E7=94=B3=E8=AF=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controller/admin/system/merchant/Merchant.php | 11 +++++++++++ .../api/store/merchant/MerchantIntention.php | 11 +++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/controller/admin/system/merchant/Merchant.php b/app/controller/admin/system/merchant/Merchant.php index 7ea929b2..4efab1d6 100644 --- a/app/controller/admin/system/merchant/Merchant.php +++ b/app/controller/admin/system/merchant/Merchant.php @@ -99,6 +99,12 @@ class Merchant extends BaseController public function create(MerchantValidate $validate) { $data = $this->checkParam($validate); + if (!empty($data['mer_phone'])) { + $newUid = Db::name('User')->where('account', $data['mer_phone'])->value('uid', 0); + if ($newUid) { + return app('json')->fail('该商家手机号已存在账户,请更换手机'); + } + } $this->repository->createMerchant($data); return app('json')->success('添加成功'); } @@ -143,6 +149,11 @@ class Merchant extends BaseController if (!$data['category_id'] || !$merchantCategoryRepository->exists($data['category_id'])) return app('json')->fail('商户分类不存在'); + $newUid = Db::name('User')->where('account', $data['mer_phone'])->value('uid', -1); + $merId = Db::name('Merchant')->where('uid', $newUid)->value('mer_id', 0); + if ($newUid != -1 && $id != $merId) { + return app('json')->fail('该商家手机号已存在账户,请更换手机'); + } unset($data['mer_account'], $data['mer_password']); $margin = $this->repository->checkMargin($id, $data['type_id']); $data['margin'] = $margin['margin']; diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index 6b0e5775..3805402d 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -45,10 +45,14 @@ class MerchantIntention extends BaseController return app('json')->fail('未开启商户入驻'); } if ($this->userInfo) $data['uid'] = $this->userInfo->uid; - $newUid = Db::name('User')->where('account', $data['phone'])->value('uid', 0); - if (!$newUid && ($this->userInfo->uid != $newUid)) { + $newUid = Db::name('User')->where('account', $data['phone'])->value('uid', -1); + if ($newUid != -1 && $this->userInfo->uid != $newUid) { throw new ValidateException('该申请手机已存在账户,不可申请'); } + $newMerid = Db::name('Merchant')->where('mer_phone', $data['phone'])->value('mer_id', -1); + if ($newMerid != -1) { + throw new ValidateException('该申请手机已存在商户,不可申请'); + } $make = app()->make(MerchantRepository::class); if ($make->fieldExists('mer_name', $data['mer_name'])) throw new ValidateException('商户名称已存在,不可申请'); @@ -77,6 +81,9 @@ class MerchantIntention extends BaseController if (!systemConfig('mer_intention_open')) { return app('json')->fail('未开启商户入驻'); } + if (!empty($data['mer_phone'])) { + unset($data['mer_phone']); + } $data['create_time'] = date('Y-m-d H:i:s', time()); $this->repository->updateIntention((int)$id, $data); SwooleTaskService::admin('notice', [