From f36c9d49ad23a9ad2fad06cb40c8b5565a39309c Mon Sep 17 00:00:00 2001 From: xucong <850806214@qq.com> Date: Mon, 12 Aug 2024 22:34:27 +0800 Subject: [PATCH] =?UTF-8?q?1.=E8=8E=B7=E5=8F=96=E8=B7=9D=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/LocalStore.php | 13 +++++-------- app/api/logic/LocalStoreLogic.php | 4 ---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/app/api/controller/LocalStore.php b/app/api/controller/LocalStore.php index fe274437..e3e30a41 100755 --- a/app/api/controller/LocalStore.php +++ b/app/api/controller/LocalStore.php @@ -49,13 +49,6 @@ class LocalStore extends Api $result = $model->getLocalUserOrderList($data); return JsonServer::success('查询成功',$result); } - // 查询距离 - public function getLocalDistance(){ - $model = new LocalStoreLogic; - $data = $this->request->param(); - $result = $model->getLocalDistance($data); - return JsonServer::success('查询成功',$result); - } public function addLocalStore() { $user_id = $this->user_id; @@ -222,11 +215,15 @@ class LocalStore extends Api public function getLocalShopById() { $id = $this->request->post('id'); + $latitude = $this->request->post('latitude'); + $longitude = $this->request->post('longitude'); $result = Db::name('local_store') ->where(['lstore_id' => $id, 'user_id' => $this->user_id, 'store_state' => 1]) ->order('create_time', 'desc') - ->field('lstore_id, store_state, header_image, store_nickname, pay_image,shopName,shopLogo') + ->field('latitude,longitude,lstore_id, store_state, header_image, store_nickname, pay_image,shopName,shopLogo') ->find(); + $model = new LocalStoreLogic; + $result['distance']=round($model->distance($result['latitude'],$result['longitude'],$latitude,$longitude)/1000,2)."公里"; if ($result) { $result['header_image'] = FileConfig::get('aliyunoss.domain') . 'local_life_shop/' . $result['header_image'] ; return JsonServer::success('成功获取', $result); diff --git a/app/api/logic/LocalStoreLogic.php b/app/api/logic/LocalStoreLogic.php index e9682df4..33b47cee 100644 --- a/app/api/logic/LocalStoreLogic.php +++ b/app/api/logic/LocalStoreLogic.php @@ -104,10 +104,6 @@ class LocalStoreLogic extends Logic ]; return $data; } - public function getLocalDistance($data){ - $result = Db::name("local_store")->where("lstore_id",$data['id'])->find(); - return round($this->distance($data['latitude'], $data['longitude'], $result['latitude'], $result['longitude'])/1000,2)."公里"; - } function distance($lat1, $lon1, $lat2, $lon2) { $earthRadius = 6371000; // 地球平均半径,单位为米