From 1550d8bf6e850b1df724874ab535690c9cc0d617 Mon Sep 17 00:00:00 2001 From: wuhui_zzw <1760308791@qq.com> Date: Mon, 22 Jan 2024 11:02:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=E5=95=86=E6=88=B7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=90=8E=E5=8F=B0=E6=B7=BB=E5=8A=A0=E3=80=81?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=91=98=E5=B7=A5=E6=97=B6=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=98=AF=E5=90=A6=E5=B7=B2=E7=BB=8F=E6=88=90?= =?UTF-8?q?=E4=B8=BA=E5=91=98=E5=B7=A5=20=E6=B7=BB=E5=8A=A0=EF=BC=9A?= =?UTF-8?q?=E5=95=86=E6=88=B7=E7=94=A8=E6=88=B7=E8=BE=93=E5=87=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=B7=BB=E5=8A=A0=E8=AF=A5=E7=94=A8=E6=88=B7=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E4=B8=BA=E5=91=98=E5=B7=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/service/StoreServiceRepository.php | 26 +++++++++++++---- .../user/UserMerchantRepository.php | 4 +++ .../merchant/store/service/StoreService.php | 28 ++++--------------- 3 files changed, 30 insertions(+), 28 deletions(-) diff --git a/app/common/repositories/store/service/StoreServiceRepository.php b/app/common/repositories/store/service/StoreServiceRepository.php index 4b16f58..0a69a90 100644 --- a/app/common/repositories/store/service/StoreServiceRepository.php +++ b/app/common/repositories/store/service/StoreServiceRepository.php @@ -267,7 +267,7 @@ class StoreServiceRepository extends BaseRepository ->when($id > 0,function($query) use ($id){ $query->where('StoreService.service_id','<>',$id); })->count(); - + return $count > 0; } /** @@ -278,17 +278,33 @@ class StoreServiceRepository extends BaseRepository * @return \app\common\dao\BaseDao|\think\Model */ public function createInfo($data){ - // 判断当前用户是否已经成为员工 + // 内容校验 if($this->isService($data['uid'])) throw new ValidateException('该用户已绑定商户!'); if($this->dao->fieldExists('account', $data['account'])) throw new ValidateException('账号已存在!'); // 数据添加 $data['pwd'] = password_hash($data['pwd'], PASSWORD_BCRYPT); return $this->dao->create($data); } + /** + * Common: 修改信息 + * Author: wu-hui + * Time: 2024/01/22 10:43 + * @param $id + * @param $data + * @return int + * @throws DbException + */ + 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->dao->fieldExists('account', $data['account'], $id)) throw new ValidateException('账号已存在!'); + // 数据修改 + if ($data['pwd']) $data['pwd'] = password_hash($data['pwd'], PASSWORD_BCRYPT); + else unset($data['pwd']); - - - + return $this->dao->update($id, $data); + } } diff --git a/app/common/repositories/user/UserMerchantRepository.php b/app/common/repositories/user/UserMerchantRepository.php index 6bb78d8..7235d91 100644 --- a/app/common/repositories/user/UserMerchantRepository.php +++ b/app/common/repositories/user/UserMerchantRepository.php @@ -8,6 +8,7 @@ namespace app\common\repositories\user; use app\common\dao\user\UserMerchantDao; use app\common\repositories\BaseRepository; +use app\common\repositories\store\service\StoreServiceRepository; use FormBuilder\Factory\Elm; use think\facade\Db; use think\facade\Route; @@ -41,6 +42,9 @@ class UserMerchantRepository extends BaseRepository $item->label = count($item['label_id']) ? $make->labels($item['label_id'], $where['mer_id']) : []; $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); + return $item; }); diff --git a/app/controller/merchant/store/service/StoreService.php b/app/controller/merchant/store/service/StoreService.php index c1286a6..d459f8c 100644 --- a/app/controller/merchant/store/service/StoreService.php +++ b/app/controller/merchant/store/service/StoreService.php @@ -146,30 +146,12 @@ class StoreService extends BaseController return app('json')->success(formToData($this->repository->updateForm($id))); } - /** - * @param $id - * @param StoreServiceValidate $validate - * @return mixed - * @throws DbException - * @author xaboy - * @day 2020/5/29 - */ - public function update($id, StoreServiceValidate $validate) - { + // 修改信息 + public function update($id, StoreServiceValidate $validate){ $data = $this->checkParams($validate, true); - if (!$this->repository->merExists($merId = $this->request->merId(), $id)) - return app('json')->fail('数据不存在'); - if ($this->repository->issetService($merId, $data['uid'], $id)) - return app('json')->fail('该用户已绑定员工'); - if ($this->repository->fieldExists('account', $data['account'], $id)) { - return app('json')->fail('账号已存在'); - } - if ($data['pwd']) { - $data['pwd'] = password_hash($data['pwd'], PASSWORD_BCRYPT); - } else { - unset($data['pwd']); - } - $this->repository->update($id, $data); + $data['mer_id'] = $this->request->merId(); + $this->repository->updateInfo($id, $data); + return app('json')->success('修改成功'); }