phpcjl
2024-12-05 51d4bcf7580a18e1ec8bae50348713e84c264f45
1.完成开发门店打分接口
4个文件已修改
22 ■■■■ 已修改文件
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/mapper/ShopMapper.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/ShopService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/service/impl/ShopServiceImpl.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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 -> {