From cd1452004d74eb70237460c9c9c66af8349ba7be Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Mon, 8 Apr 2024 12:00:43 +0800 Subject: [PATCH] 1 --- app/api/controller/dealer/Apply.php | 18 ++++++++++++++++-- app/api/model/dealer/Apply.php | 25 +++++++++++++++++++------ 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/app/api/controller/dealer/Apply.php b/app/api/controller/dealer/Apply.php index 00b4251d..251d6e91 100644 --- a/app/api/controller/dealer/Apply.php +++ b/app/api/controller/dealer/Apply.php @@ -103,6 +103,7 @@ class Apply extends Controller return $this->renderError($model->getError() ?: '提交失败'); } + /** * @notes:更新申请服务商 * @return Json @@ -135,8 +136,21 @@ class Apply extends Controller $data = compact('business', 'city', 'real_name', 'mobile', 'shop_type', 'shop_name', 'business', 'city'); $model = new DealerApplyModel; if ($model->editApplyServiceProviders($data)) { - return $this->renderSuccess('提交成功'); + return $this->renderSuccess('更新成功'); } - return $this->renderError($model->getError() ?: '提交失败'); + return $this->renderError($model->getError() ?: '更新失败'); + } + + /** + * @notes:申请记录详情 + * @return Json + * @throws BaseException + * @author: wanghousheng + */ + public function getApplyInfo(): Json + { + $model = new DealerApplyModel; + $info = $model->getApplyInfo(); + return $this->renderSuccess(compact('info')); } } \ No newline at end of file diff --git a/app/api/model/dealer/Apply.php b/app/api/model/dealer/Apply.php index 7896c728..231a49ff 100644 --- a/app/api/model/dealer/Apply.php +++ b/app/api/model/dealer/Apply.php @@ -98,7 +98,8 @@ class Apply extends ApplyModel $userId = UserService::getCurrentLoginUserId(); // 成为分销商条件 $config = Setting::getItem('condition'); - if ($this->where(['user_id' => $userId])->exists()) { + $info = self::get(['user_id' => $userId]); + if (!empty($info)) { throwError('您已申请服务商,请勿重复提交'); } // 数据整理 @@ -135,7 +136,7 @@ class Apply extends ApplyModel // 当前用户ID $userId = UserService::getCurrentLoginUserId(); $info = self::get(['user_id' => $userId]); - if ($info->isEmpty()) { + if (empty($info)) { throwError('申请记录不存在'); } $info = $info->toArray(); @@ -151,11 +152,23 @@ class Apply extends ApplyModel 'business' => $data['business'], 'city' => $data['city'], ]; - $res = $this->where(['user_id' => $userId])->update($data); - if ($res->getError()) { - return false; + if ($this->update($data, ['user_id' => $userId])) { + return true; } - return true; + return false; + } + + /** + * @notes:申请记录详情 + * @return Apply|array|null + * @throws BaseException + * @author: wanghousheng + */ + public function getApplyInfo() + { + // 当前用户ID + $userId = UserService::getCurrentLoginUserId(); + return self::get(['user_id' => $userId]); } /**