From ea2bd4aaad0309f4e325c7064d66856097fe8954 Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Mon, 8 Apr 2024 11:43:22 +0800 Subject: [PATCH] 1 --- app/api/controller/dealer/Apply.php | 37 +++++++++++++++++++++++++++++ app/api/model/dealer/Apply.php | 35 +++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/app/api/controller/dealer/Apply.php b/app/api/controller/dealer/Apply.php index 0f3c3fb0..00b4251d 100644 --- a/app/api/controller/dealer/Apply.php +++ b/app/api/controller/dealer/Apply.php @@ -102,4 +102,41 @@ class Apply extends Controller } return $this->renderError($model->getError() ?: '提交失败'); } + + /** + * @notes:更新申请服务商 + * @return Json + * @throws BaseException + * @author: wanghousheng + */ + public function editApplyProviders(): Json + { + $real_name = $this->request->post('real_name'); + if (!$real_name) { + return $this->renderError('联系人不能为空'); + } + $mobile = $this->request->post('mobile'); + if (empty($mobile)) { + return $this->renderError('联系电话不能为空'); + } + $shop_type = intval($this->request->post('shop_type', 10)); + $shop_name = $this->request->post('shop_name'); + if (empty($shop_name)) { + return $this->renderError('店铺名称不能为空'); + } + $business = $this->request->post('business'); + if (empty($business)) { + return $this->renderError('经营类型不能为空'); + } + $city = $this->request->post('city'); + if (empty($city)) { + return $this->renderError('所在城市不能为空'); + } + $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->renderError($model->getError() ?: '提交失败'); + } } \ No newline at end of file diff --git a/app/api/model/dealer/Apply.php b/app/api/model/dealer/Apply.php index a91d853a..7896c728 100644 --- a/app/api/model/dealer/Apply.php +++ b/app/api/model/dealer/Apply.php @@ -123,6 +123,41 @@ class Apply extends ApplyModel return $this->add($data); } + /** + * @notes:更新服务商申请 + * @param $data + * @return bool + * @throws BaseException + * @author: wanghousheng + */ + public function editApplyServiceProviders($data): bool + { + // 当前用户ID + $userId = UserService::getCurrentLoginUserId(); + $info = self::get(['user_id' => $userId]); + if ($info->isEmpty()) { + throwError('申请记录不存在'); + } + $info = $info->toArray(); + if ($info['apply_status'] == ApplyStatusEnum::PASS) { + throwError('您已通过申请,请勿重复提交'); + } + // 数据整理 + $data = [ + 'real_name' => trim($data['real_name']), + 'mobile' => trim($data['mobile']), + 'shop_type' => $data['shop_type'], + 'shop_name' => $data['shop_name'], + 'business' => $data['business'], + 'city' => $data['city'], + ]; + $res = $this->where(['user_id' => $userId])->update($data); + if ($res->getError()) { + return false; + } + return true; + } + /** * 更新分销商申请信息 * @param array $data