From 65bbacbaadf694f32460c2da2ab49c5bbb602e47 Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Fri, 18 Sep 2020 14:02:39 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E5=B8=82=E5=9C=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/v3/Implementations/LocationService.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/Service/v3/Implementations/LocationService.php b/app/Service/v3/Implementations/LocationService.php index cb5265d..0151b69 100644 --- a/app/Service/v3/Implementations/LocationService.php +++ b/app/Service/v3/Implementations/LocationService.php @@ -84,17 +84,11 @@ class LocationService implements LocationServiceInterface } } - $res = collect($res->toArray())->sortBy(function ($area, $key) { - return $area['distance_num']; + $res = collect($res->toArray())->sortBy(function ($res, $key) { + return $res['distance_num']; }); - $res = collect($res->all())->map(function ($area, $key) { - $markets = collect($area['markets'])->sortBy('distance_num'); - $area['markets'] = $markets->values()->all(); - return $area; - }); - - return $res->all(); + return $res; } public function getNearestMarket($lng,$lat) From 7dda3fbda8129ddbe3573fe8b3e57d0aeb9e23cd Mon Sep 17 00:00:00 2001 From: Lemon <15040771@qq.com> Date: Fri, 18 Sep 2020 14:08:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=B8=82=E5=9C=BA=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Service/v3/Implementations/LocationService.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Service/v3/Implementations/LocationService.php b/app/Service/v3/Implementations/LocationService.php index 0151b69..8db6f55 100644 --- a/app/Service/v3/Implementations/LocationService.php +++ b/app/Service/v3/Implementations/LocationService.php @@ -84,8 +84,9 @@ class LocationService implements LocationServiceInterface } } - $res = collect($res->toArray())->sortBy(function ($res, $key) { - return $res['distance_num']; + $res = collect($res->toArray())->map(function ($res, $key) { + $markets = collect($res)->sortBy('distance_num'); + return $markets; }); return $res;