From bb76489c1c51d04ee812f9f99cfeb4f129288571 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Thu, 17 Sep 2020 16:46:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=A1=AE=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/v3/OrderOnlineController.php | 7 +++++-- app/Service/v3/Implementations/LocationService.php | 1 - app/Service/v3/Implementations/UserAddressService.php | 1 - 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Controller/v3/OrderOnlineController.php b/app/Controller/v3/OrderOnlineController.php index ce1f1b0..8c717c1 100644 --- a/app/Controller/v3/OrderOnlineController.php +++ b/app/Controller/v3/OrderOnlineController.php @@ -103,8 +103,11 @@ class OrderOnlineController extends BaseController ->orderByDesc('updated_at') ->first(); $market = Market::find($marketId); - $distance = $this->locationService->getDistanceByTencent($address->lng,$address->lat,$market->lng,$market->lat); - if($distance < 8000){ + if(!empty($address->lng) && !empty($address->lat)){ + $distance = $this->locationService->getDistanceByTencent($market->lng,$market->lat,$address->lng,$address->lat); + } + + if(isset($distance) && $distance > 8000){ $distributionPrice = $this->distributionPriceService->do($distance); $res['location'] = [ 'address' => $address, diff --git a/app/Service/v3/Implementations/LocationService.php b/app/Service/v3/Implementations/LocationService.php index e04818a..ad32232 100644 --- a/app/Service/v3/Implementations/LocationService.php +++ b/app/Service/v3/Implementations/LocationService.php @@ -162,7 +162,6 @@ class LocationService implements LocationServiceInterface { throw new ErrorCodeException(ErrorCode::LOCATION_ERROR,$resultArr['message']); } - var_dump($resultArr); $distance = $resultArr['result']['rows'][0]['elements'][0]['distance']; return $distance; } diff --git a/app/Service/v3/Implementations/UserAddressService.php b/app/Service/v3/Implementations/UserAddressService.php index ebfc46f..ed5cadc 100644 --- a/app/Service/v3/Implementations/UserAddressService.php +++ b/app/Service/v3/Implementations/UserAddressService.php @@ -87,7 +87,6 @@ class UserAddressService implements UserAddressServiceInterface $market = Market::query()->select('lng','lat')->find($marketId); $distance = $this->locationService->getDistanceByTencent($address['address']->lng,$address['address']->lat,$market->lng,$market->lat); $distributionPrice = $this->distributionPriceService->do($distance); - var_dump($distance); $res['address'] = $address; $res['delivery_distance'] = $distance; $res['distribution_price'] = $distributionPrice;