ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -66,8 +66,8 @@ */ @GetMapping("/nearbyShopList") @ApiOperation(value = "附近门店列表", tags = {"小程序-首页-附近门店列表"}) public R<List<NearbyShopVO>> nearbyShopList(@ApiParam("经度") @RequestParam String longitude, @ApiParam("纬度") @RequestParam String latitude) { public R<List<NearbyShopVO>> nearbyShopList(@ApiParam("经度") @RequestParam BigDecimal longitude, @ApiParam("纬度") @RequestParam BigDecimal latitude) { return R.ok(shopService.nearbyShopList(longitude, latitude)); } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java
@@ -6,6 +6,7 @@ import com.ruoyi.other.vo.ShopDetailVO; import org.apache.ibatis.annotations.Param; import java.math.BigDecimal; import java.util.List; /** @@ -18,7 +19,7 @@ */ public interface ShopMapper extends BaseMapper<Shop> { List<NearbyShopVO> selectNearbyShopList(@Param("longitude") String longitude,@Param("latitude") String latitude); List<NearbyShopVO> selectNearbyShopList(@Param("longitude") BigDecimal longitude,@Param("latitude") BigDecimal latitude); ShopDetailVO selectShopDetail(Integer shopId); ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/ShopService.java
@@ -18,7 +18,7 @@ */ public interface ShopService extends IService<Shop> { List<NearbyShopVO> nearbyShopList(String longitude, String latitude); List<NearbyShopVO> nearbyShopList(BigDecimal longitude, BigDecimal latitude); ShopDetailVO getShopDetail(Integer shopId, BigDecimal longitude, BigDecimal latitude); } ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java
@@ -16,6 +16,7 @@ import javax.annotation.Resource; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -36,10 +37,18 @@ private ShopScoreService shopScoreService; @Override public List<NearbyShopVO> nearbyShopList(String longitude, String latitude) { List<NearbyShopVO> nearbyShopVOS = shopMapper.selectNearbyShopList(longitude, latitude); public List<NearbyShopVO> nearbyShopList(BigDecimal longitude, BigDecimal latitude) { List<NearbyShopVO> nearbyShopVOS = shopMapper.selectNearbyShopList(longitude, longitude); if (nearbyShopVOS == null || nearbyShopVOS.isEmpty()) { return Collections.emptyList(); } List<Long> shopIds = nearbyShopVOS.stream().map(NearbyShopVO::getId).collect(Collectors.toList()); List<ShopScore> shopScores = shopScoreService.list(new LambdaQueryWrapper<ShopScore>().in(ShopScore::getShopId, shopIds)); if (shopScores == null || shopScores.isEmpty()) { return nearbyShopVOS; } Map<Long, List<ShopScore>> shopScoreMap = shopScores.stream().collect(Collectors.groupingBy(ShopScore::getShopId)); nearbyShopVOS.forEach(nearbyShopVO -> {