From ffcfe4102587ec48068707ccef924263d0c0ee0f Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Mon, 15 Dec 2025 18:39:41 +0800 Subject: [PATCH] 1 --- app/common/service/PostService.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/common/service/PostService.php b/app/common/service/PostService.php index cb2ce1c..3c4ca20 100644 --- a/app/common/service/PostService.php +++ b/app/common/service/PostService.php @@ -217,6 +217,7 @@ class PostService $lng = $request->get('lng'); $lat = $request->get('lat'); $status = $request->get('status', 1); + $keyword = $request->get('keyword', ''); if (!$lng || !$lat) { throw new BusinessException('经纬度必传'); @@ -245,7 +246,13 @@ class PostService SIN(RADIANS(?)) * SIN(RADIANS(latitude)) )) AS distance FROM post - WHERE $status + WHERE status = " . $status; + + if (!empty($keyword)) { + $sql = $sql." AND (content LIKE '%".$keyword."%' OR `model` LIKE '%".$keyword."%')"; + } + + $sql = $sql." HAVING distance <= ? ORDER BY distance LIMIT 50";