Explorar o código

更多推荐添加入参 storeId 去重

lutong hai 1 día
pai
achega
8fd4e76f5a

+ 6 - 4
alien-store/src/main/java/shop/alien/store/controller/StoreInfoController.java

@@ -1069,11 +1069,13 @@ public class StoreInfoController {
             @ApiImplicitParam(name = "lat", value = "纬度", dataType = "double", paramType = "query", required = true),
             @ApiImplicitParam(name = "businessSection", value = "经营板块", dataType = "String", paramType = "query", required = true),
             @ApiImplicitParam(name = "businessTypes", value = "经营分类", dataType = "String", paramType = "query"),
-            @ApiImplicitParam(name = "businessClassify", value = "分类", dataType = "String", paramType = "query")
+            @ApiImplicitParam(name = "businessClassify", value = "分类", dataType = "String", paramType = "query"),
+            @ApiImplicitParam(name = "storeId", value = "当前商铺ID(传入则从推荐列表中排除该店铺)", dataType = "Integer", paramType = "query")
     })
-    public R<List<StoreInfoVo>> getMoreRecommendedStores(Double lon , Double lat, String businessSection, String businessTypes, String businessClassify) {
-        log.info("StoreInfoController.getMoreRecommendedStores?lon={},lat={},businessSection={},businessTypes={},businessClassify={}", lon,lat, businessSection, businessTypes, businessClassify);
-        return R.data(storeInfoService.getMoreRecommendedStores(lon,lat, businessSection, businessTypes, businessClassify));
+    public R<List<StoreInfoVo>> getMoreRecommendedStores(Double lon , Double lat, String businessSection, String businessTypes, String businessClassify,
+                                                        @RequestParam(required = false) Integer storeId) {
+        log.info("StoreInfoController.getMoreRecommendedStores?lon={},lat={},businessSection={},businessTypes={},businessClassify={},storeId={}", lon,lat, businessSection, businessTypes, businessClassify, storeId);
+        return R.data(storeInfoService.getMoreRecommendedStores(lon,lat, businessSection, businessTypes, businessClassify, storeId));
 
     }
 

+ 3 - 4
alien-store/src/main/java/shop/alien/store/service/StoreInfoService.java

@@ -400,12 +400,11 @@ public interface StoreInfoService extends IService<StoreInfo> {
 
 
     /**
-     * web-分页查询店铺信息
+     * 更多推荐(用户端)。
      *
-
-     * @return IPage<StoreInfoVo>
+     * @param storeId 可选;传入且大于 0 时从推荐列表中排除该商铺(例如当前详情页)
      */
-    List<StoreInfoVo> getMoreRecommendedStores(Double lon , Double lat, String businessSection, String businessTypes, String businessClassify);
+    List<StoreInfoVo> getMoreRecommendedStores(Double lon , Double lat, String businessSection, String businessTypes, String businessClassify, Integer storeId);
 
     /**
      * 根据店铺ID获取推荐店铺列表(用户端)

+ 7 - 1
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -5075,7 +5075,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
      * @return IPage<StoreInfoVo>
      */
     @Override
-    public List<StoreInfoVo> getMoreRecommendedStores(Double lon, Double lat, String businessSection, String businessTypes, String businessClassify) {
+    public List<StoreInfoVo> getMoreRecommendedStores(Double lon, Double lat, String businessSection, String businessTypes, String businessClassify, Integer storeId) {
         // 参数校验
         if (lon == null || lat == null) {
             log.warn("获取更多推荐店铺失败,经纬度为空");
@@ -5182,6 +5182,9 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
             friendQueryWrapper.and(w -> w.isNull("a.food_licence_expiration_time")
                     .or()
                     .gt("a.food_licence_expiration_time", currentDate));
+            if (storeId != null && storeId > 0) {
+                friendQueryWrapper.ne("a.id", storeId);
+            }
             friendQueryWrapper.in("a.id", friendStoreIds);
             friendStoreList = storeInfoMapper.getMoreRecommendedStores(friendQueryWrapper, position);
         }
@@ -5198,6 +5201,9 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         if (StringUtils.isNotEmpty(businessSection)) {
             currentTypeQueryWrapper.eq("a.business_section", businessSection);
         }
+        if (storeId != null && storeId > 0) {
+            currentTypeQueryWrapper.ne("a.id", storeId);
+        }
         List<StoreInfoVo> currentTypeStoreList = storeInfoMapper.getMoreRecommendedStores(currentTypeQueryWrapper, position);
 
         // 合并:好友店铺在前,当前类型店铺在后;按店铺ID去重