Просмотр исходного кода

bugfix:3377门店详情(提测0304): 门店没数据只是固定显示评价,商铺动态,更多推荐,剩下不显示

刘云鑫 1 месяц назад
Родитель
Сommit
fbb059a494

+ 10 - 5
alien-store/src/main/java/shop/alien/store/controller/AiTagsController.java

@@ -86,13 +86,18 @@ public class AiTagsController {
                 // 4. 解析响应体(根据外部接口返回格式调整)
                 String responseBody = exchange.getBody();
                 JSONObject jsonObject = JSONObject.parseObject(responseBody);
-                JSONArray jsonArray = jsonObject.getJSONObject("data").getJSONArray("list");
-                if(jsonArray.isEmpty()){
+                if(null != jsonObject) {
+                    JSONArray jsonArray = jsonObject.getJSONObject("data").getJSONArray("list");
+
+                    if (jsonArray.isEmpty()) {
+                        return R.data(new ArrayList<>());
+                    }
+                    String negativeComment = jsonArray.getJSONObject(0).getString("negative_comment");
+                    // 这里简单返回原始字符串(根据实际情况调整)
+                    return R.data(parseComment(negativeComment));
+                } else {
                     return R.data(new ArrayList<>());
                 }
-                String negativeComment = jsonArray.getJSONObject(0).getString("negative_comment");
-                // 这里简单返回原始字符串(根据实际情况调整)
-                return R.data(parseComment(negativeComment));
             } else {
                 return R.fail("获取店铺标签失败:" + exchange.getStatusCode());
             }

+ 118 - 2
alien-store/src/main/java/shop/alien/store/controller/StoreInfoController.java

@@ -26,8 +26,9 @@ import shop.alien.entity.storePlatform.StoreLicenseHistory;
 import shop.alien.mapper.*;
 import shop.alien.mapper.storePlantform.StoreLicenseHistoryMapper;
 import shop.alien.store.config.BaseRedisService;
-import shop.alien.store.service.StoreInfoService;
-import shop.alien.store.service.StoreQualificationService;
+import shop.alien.store.service.*;
+import shop.alien.entity.store.StoreCuisine;
+import shop.alien.entity.store.StorePrice;
 import shop.alien.entity.store.UserLoginInfo;
 import shop.alien.util.common.TokenInfo;
 import springfox.documentation.annotations.ApiIgnore;
@@ -75,6 +76,12 @@ public class StoreInfoController {
     private final StoreUserMapper storeUserMapper;
     private final LifeFansMapper lifeFansMapper;
 
+    private final StoreCuisineService storeCuisineService;
+    private final StorePriceService storePriceService;
+    private final StoreStaffConfigService storeStaffConfigService;
+    private final PerformanceListService performanceListService;
+    private final SportsEquipmentFacilityService sportsEquipmentFacilityService;
+
     @ApiOperation("获取所有门店")
     @ApiOperationSupport(order = 1)
     @GetMapping("/getAll")
@@ -1806,6 +1813,115 @@ public class StoreInfoController {
     }
     
     /**
+     * 根据经营板块返回店铺详情页可展示的标签(仅当对应接口有数据时才展示)
+     * <p>
+     * 美食:价目表、人员;
+     * 休闲娱乐:价目表、人员、演出;
+     * 生活服务:价目表、设施、教练、人员。
+     * 每个标签会调用对应数据接口判断是否有数据,无数据则不返回该标签。
+     * </p>
+     *
+     * @param storeId         门店 ID
+     * @param businessSection 经营板块:传 dictId 或名称。1/美食、2/休闲娱乐、3/生活服务
+     * @return 有数据的标签列表,每项包含标签名和对应接口路径
+     */
+    @ApiOperation("根据经营板块获取店铺详情页展示标签(仅展示有数据的标签)")
+    @ApiOperationSupport(order = 100)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "storeId", value = "门店ID", dataType = "Integer", paramType = "query", required = true),
+            @ApiImplicitParam(name = "businessSection", value = "经营板块:1或美食、2或休闲娱乐、3或生活服务", dataType = "String", paramType = "query", required = true)
+    })
+    @GetMapping("/getStoreSectionTags")
+    public R<Map<String, Boolean>> getStoreSectionTags(
+            @RequestParam Integer storeId,
+            @RequestParam String businessSection) {
+        log.info("StoreInfoController.getStoreSectionTags?storeId={}, businessSection={}", storeId, businessSection);
+        if (storeId == null) {
+            return R.fail("门店ID不能为空");
+        }
+        if (StringUtils.isBlank(businessSection)) {
+            return R.fail("经营板块不能为空");
+        }
+        String section = businessSection.trim();
+        boolean isFood = "3".equals(section) || "美食".equals(section);
+        boolean isLeisure = "2".equals(section) || "休闲娱乐".equals(section);
+        boolean isLifeService = "1".equals(section) || "生活服务".equals(section);
+        if (!isFood && !isLeisure && !isLifeService) {
+            return R.fail("未知的经营板块: " + businessSection);
+        }
+        Map<String, Boolean> tags = buildSectionTagsByData(storeId, isFood, isLeisure, isLifeService);
+        return R.data(tags);
+    }
+
+    /**
+     * 根据实际数据判断各标签是否有数据,返回 Map(key 为标签名,value 有数据 true / 无数据 false)
+     */
+    private Map<String, Boolean> buildSectionTagsByData(Integer storeId, boolean isFood, boolean isLeisure, boolean isLifeService) {
+        Map<String, Boolean> map = new HashMap<>(8);
+
+        map.put("showPriceCard", hasPriceListData(storeId));
+        map.put("showStaffCard", hasStaffData(storeId));
+
+        if (isLeisure) {
+            map.put("showPerformance", hasPerformanceData(storeId));
+        }
+        if (isLifeService) {
+            map.put("showFacilityServiceCard", hasFacilityData(storeId));
+        }
+
+        return map;
+    }
+
+    /** 价目表是否有数据:美食价目或通用价目存在且已上架 */
+    private boolean hasPriceListData(Integer storeId) {
+        long cuisineCount = storeCuisineService.count(
+                new LambdaQueryWrapper<StoreCuisine>()
+                        .eq(StoreCuisine::getStoreId, storeId)
+                        .eq(StoreCuisine::getShelfStatus, 1));
+        if (cuisineCount > 0) {
+            return true;
+        }
+        return storePriceService.count(
+                new LambdaQueryWrapper<StorePrice>()
+                        .eq(StorePrice::getStoreId, storeId)
+                        .eq(StorePrice::getShelfStatus, 1)) > 0;
+    }
+
+    /** 人员是否有数据:按标题分组的员工列表非空 */
+    private boolean hasStaffData(Integer storeId) {
+        try {
+            List<StaffTitleGroupVo> groups = storeStaffConfigService.queryStaffListByTitle(storeId);
+            return CollectionUtils.isNotEmpty(groups);
+        } catch (Exception e) {
+            log.warn("查询人员数据异常 storeId={}, {}", storeId, e.getMessage());
+            return false;
+        }
+    }
+
+    /** 演出是否有数据:演出列表接口有记录 */
+    private boolean hasPerformanceData(Integer storeId) {
+        try {
+            IPage<PerformanceListVo> page = performanceListService.queryPerformanceList(1, 1, storeId);
+            return page != null && page.getTotal() > 0;
+        } catch (Exception e) {
+            log.warn("查询演出数据异常 storeId={}, {}", storeId, e.getMessage());
+            return false;
+        }
+    }
+
+    /** 设施是否有数据:运动器材设施分类汇总有数据 */
+    private boolean hasFacilityData(Integer storeId) {
+        try {
+            List<SportsEquipmentFacilityCategorySummaryVo> list = sportsEquipmentFacilityService.getCategorySummary(storeId);
+            return CollectionUtils.isNotEmpty(list);
+        } catch (Exception e) {
+            log.warn("查询设施数据异常 storeId={}, {}", storeId, e.getMessage());
+            return false;
+        }
+    }
+
+
+    /**
      * 店铺信息(包含商户头像)
      */
     @Data