Przeglądaj źródła

feat:新增商铺入驻获取三级分类数据接口

penghao 2 tygodni temu
rodzic
commit
35463f21d9

+ 22 - 1
alien-store/src/main/java/shop/alien/store/controller/StoreInfoController.java

@@ -1050,7 +1050,28 @@ public class StoreInfoController {
             return R.fail("获取推荐店铺失败,请稍后重试");
         }
     }
-
+    /**
+     * 根据business_classify字段获取字典表数据实现UI图中的功能
+     * RESTful风格:GET /store/info/business-classifies
+     * 返回扁平化的分类列表,用于多选分类功能
+     *
+     * @param parentId 父分类ID(可选),如果提供则只返回该父分类下的子分类
+     * @return R<List<StoreDictionaryVo>> 分类列表(扁平化,仅子分类)
+     */
+    @ApiOperation("获取店铺分类信息)")
+    @ApiOperationSupport(order = 19)
+    @GetMapping("/business-classifies")
+    public R<List<StoreDictionaryVo>> getBusinessClassifyData(
+            @RequestParam(value = "parentId", required = false) Integer parentId) {
+        log.info("StoreInfoController.getBusinessClassifyData?parentId={}", parentId);
+        try {
+            List<StoreDictionaryVo> result = storeInfoService.getBusinessClassifyData(parentId);
+            return R.data(result);
+        } catch (Exception e) {
+            log.error("获取business_classify分类数据异常", e);
+            return R.fail("获取分类数据失败,请稍后重试");
+        }
+    }
 
 
     @ApiOperation(value = "获取banner图详情")

+ 10 - 1
alien-store/src/main/java/shop/alien/store/service/StoreInfoService.java

@@ -309,7 +309,7 @@ public interface StoreInfoService extends IService<StoreInfo> {
      * @param distance    距离范围(单位:公里)
      * @param sortType    排序模式(1:智能排序,2:好评优先,3:距离优先)
      * @param businessType 店铺类型(KTV=3、洗浴汗蒸=4、按摩足浴=5,酒吧需要查询字典表),可选
-     * @param categoryId 字典表id,根据此id查询经营板块、经营种类、分类并匹配店铺,可选
+     * @param categoryId  分类ID(二级或三级分类的dictId,从getAllBusinessSection接口获取),可选
      * @param pageNum     页码
      * @param pageSize    页容
      * @return IPage<StoreInfoVo> 分页的门店信息列表
@@ -352,6 +352,15 @@ public interface StoreInfoService extends IService<StoreInfo> {
      */
     List<StoreInfoVo> getRecommendedStores(String businessSection, String businessTypes, String businessClassify, Double lon, Double lat);
 
+    /**
+     * 获取三级分类数据
+     * 根据二级分类ID获取该分类下的三级分类
+     *
+     * @param parentId 二级分类ID
+     * @return List<StoreDictionaryVo> 三级分类列表
+     */
+    List<StoreDictionaryVo> getBusinessClassifyData(Integer parentId);
+
 
 
 

+ 15 - 12
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.geo.Point;
 import org.springframework.http.*;
@@ -42,6 +43,7 @@ import shop.alien.store.util.CommonConstant;
 import shop.alien.store.util.FileUploadUtil;
 import shop.alien.store.util.GroupConstant;
 import shop.alien.store.util.ai.AiAuthTokenUtil;
+import shop.alien.store.util.ali.AliApi;
 import shop.alien.util.ali.AliOSSUtil;
 import shop.alien.util.common.DistanceUtil;
 import shop.alien.util.common.constant.CouponStatusEnum;
@@ -59,6 +61,7 @@ import java.text.SimpleDateFormat;
 import java.time.*;
 import java.time.format.DateTimeFormatter;
 import java.time.format.DateTimeFormatterBuilder;
+import java.time.format.SignStyle;
 import java.time.temporal.ChronoField;
 import java.time.temporal.ChronoUnit;
 import java.util.*;
@@ -71,13 +74,13 @@ import java.util.stream.Collectors;
  * @author ssk
  * @since 2024-12-05
  */
-@Service
 @Slf4j
+@Service
 @RequiredArgsConstructor
 @Transactional
 public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo> implements StoreInfoService {
-    private static final int DEFAULT_DISTANCE_METER = 1000;
 
+    private static final int DEFAULT_DISTANCE_METER = 1000;
 
     private final String DEFAULT_PASSWORD = "123456";
 
@@ -880,7 +883,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         tagStoreRelationLambdaQueryWrapper.eq(TagStoreRelation::getStoreId, storeInfo.getId());
         tagStoreRelationLambdaQueryWrapper.eq(TagStoreRelation::getDeleteFlag, 0);
         int tagStoreCount = tagStoreRelationMapper.selectCount(tagStoreRelationLambdaQueryWrapper);
-        if(tagStoreCount == 0){
+        if (tagStoreCount == 0) {
             TagStoreRelation tagStoreRelation = new TagStoreRelation();
             tagStoreRelation.setStoreId(storeInfo.getId());
             tagStoreRelation.setDeleteFlag(0);
@@ -1540,9 +1543,9 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
 
         com.alibaba.fastjson2.JSONObject jsonObject = new com.alibaba.fastjson2.JSONObject();
         if (2 == approvalStatus) {
-            jsonObject.put("message", "您在"+createDate+"提交的入驻店铺申请,审核失败。失败原因:"+reason+"。");
+            jsonObject.put("message", "您在" + createDate + "提交的入驻店铺申请,审核失败。失败原因:" + reason + "。");
         } else {
-            jsonObject.put("message", "您在"+createDate+"提交的入驻店铺申请,已通过审核,欢迎您的加入。");
+            jsonObject.put("message", "您在" + createDate + "提交的入驻店铺申请,已通过审核,欢迎您的加入。");
         }
         lifeNotice.setContext(jsonObject.toJSONString());
         lifeNotice.setNoticeType(1); // 系统通知
@@ -2723,14 +2726,14 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         if (lon == null || lat == null) {
             throw new IllegalArgumentException("经纬度参数不能为空");
         }
-
+        
         // 智能检测:如果参数可能传反了(lat超出范围但lon在范围内),给出提示
         if (Math.abs(lat) > 90 && Math.abs(lon) <= 90) {
             throw new IllegalArgumentException(
                     String.format("参数可能传反了!当前值: lon=%s, lat=%s。经度范围: [-180, 180],纬度范围: [-90, 90]。请检查参数顺序。", lon, lat)
             );
         }
-
+        
         // 校验经纬度范围:经度 [-180, 180],纬度 [-90, 90]
         if (lon < -180 || lon > 180) {
             throw new IllegalArgumentException("经度参数超出有效范围 [-180, 180],当前值: " + lon);
@@ -2908,7 +2911,7 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
 
         // 提取所有门店ID
         List<Integer> storeIds = storeInfoVoList.stream().map(StoreInfoVo::getId).collect(Collectors.toList());
-
+        
         if (CollectionUtils.isEmpty(storeIds)) {
             // 如果没有符合条件的店铺,返回空结果
             IPage<StoreInfoVo> emptyPage = new Page<>(pageNum, pageSize);
@@ -3169,18 +3172,18 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         if (StringUtils.isNotEmpty(likeKeyword)) {
             wrapper.like(OcrImageUpload::getOcrResult, likeKeyword);
         }
-        
+
         OcrImageUpload ocrImageUpload = ocrImageUploadMapper.selectOne(wrapper);
-        
+
         if (ocrImageUpload == null || StringUtils.isEmpty(ocrImageUpload.getOcrResult())) {
             return new com.alibaba.fastjson2.JSONObject();
         }
-        
+
         com.alibaba.fastjson2.JSONObject jsonObject = com.alibaba.fastjson2.JSONObject.parseObject(ocrImageUpload.getOcrResult());
         if (includeImageUrl && StringUtils.isNotEmpty(ocrImageUpload.getImageUrl())) {
             jsonObject.put("imageUrl", ocrImageUpload.getImageUrl());
         }
-        
+
         return jsonObject;
     }