优化地图搜索

This commit is contained in:
2025-10-14 19:16:51 +08:00
parent cb01227fa2
commit fddb7bc4af
4 changed files with 18 additions and 3 deletions

View File

@@ -12,4 +12,6 @@ import java.util.List;
@Mapper @Mapper
public interface ArMerchantInfoMapper extends BaseMapper<ArMerchantInfo> { public interface ArMerchantInfoMapper extends BaseMapper<ArMerchantInfo> {
List<ArMerchantInfoVO> merchantMapPage(@Param("request") ARMapMerchantRequest request); List<ArMerchantInfoVO> merchantMapPage(@Param("request") ARMapMerchantRequest request);
List<ArMerchantInfoVO> merchantMapCountry(ARMapMerchantRequest request);
} }

View File

@@ -17,6 +17,18 @@
ORDER BY ORDER BY
distance; distance;
</select> </select>
<select id="merchantMapCountry" resultType="com.fly.boot.biz.ar.vo.ArMerchantInfoVO">
SELECT
s.*,
ROUND( ST_Distance_Sphere ( POINT ( #{request.cLng} , #{request.cLat} ), POINT ( lng, lat ) ), 2 ) AS distance
FROM
ar_merchant_info s
WHERE
ST_Distance_Sphere ( POINT ( #{request.cLng} , #{request.cLat} ), POINT ( lng, lat ) ) &lt;= #{request.distance}
ORDER BY
distance;
</select>
</mapper> </mapper>

View File

@@ -42,7 +42,7 @@ public class ARMapMerchantRequest implements Serializable {
* 距离 * 距离
*/ */
@NotNull(message = "距离不能为空") @NotNull(message = "距离不能为空")
private Integer distance; private BigDecimal distance;
} }

View File

@@ -10,6 +10,7 @@ import com.fly.boot.biz.ar.vo.ArMerchantInfoVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
@Service @Service
@@ -20,8 +21,8 @@ public class ArMerchantInfoServiceImpl extends ServiceImpl<ArMerchantInfoMapper,
List<ArMerchantInfoVO> list = this.baseMapper.merchantMapPage(request); List<ArMerchantInfoVO> list = this.baseMapper.merchantMapPage(request);
if (list.isEmpty()) { if (list.isEmpty()) {
request.setDistance(1000 * 2000); request.setDistance(BigDecimal.valueOf(1000 * 2000L));
return this.baseMapper.merchantMapPage(request); return this.baseMapper.merchantMapCountry(request);
} }
return list; return list;