From fc53744c6bcc890ed8b9911d4277894168e4151f Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Sun, 29 Sep 2024 15:14:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E6=8F=90=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/LocalStore.php | 11 +++++++++++ app/api/logic/LocalStoreLogic.php | 24 ++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/app/api/controller/LocalStore.php b/app/api/controller/LocalStore.php index d4241ecf..1ba10fd1 100755 --- a/app/api/controller/LocalStore.php +++ b/app/api/controller/LocalStore.php @@ -335,4 +335,15 @@ class LocalStore extends Api return JsonServer::error($e->getMessage()); } } + + // 设置自提站点 + public function setPostStation() + { + try { + $post = $this->request->post(); + $data = LocalStoreLogic::setPostStation($post, $this->user_id); + } catch(\Exception $e) { + return JsonServer::error($e->getMessage()); + } + } } \ No newline at end of file diff --git a/app/api/logic/LocalStoreLogic.php b/app/api/logic/LocalStoreLogic.php index b35c8638..eb35798a 100644 --- a/app/api/logic/LocalStoreLogic.php +++ b/app/api/logic/LocalStoreLogic.php @@ -352,4 +352,28 @@ class LocalStoreLogic extends Logic 'more' => $more, ]; } + + public static function setPostStation($post, $user_id) + { + throw new \Exception('未选择区域'); + + if (!$post['province'] && !$post['city'] && !$post['area'] && !$post['address']) { + throw new \Exception('未选择区域'); + } + + if (!$post['lat'] && !$post['lng']) { + throw new \Exception('经纬度不能为空'); + } + + $result = LocalStore::where('user_id', $user_id)->update([ + 'post_station' => json_encode($post, JSON_UNESCAPED_UNICODE), + 'update_time' => time() + ]); + + if ($result) { + return true; + } + + throw new \Exception('更新失败'); + } } \ No newline at end of file