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