Ver Fonte

健身房设备补充信息

zhangchen há 3 dias atrás
pai
commit
e8a4d7b52e

+ 3 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreStaffFitnessDetailVo.java

@@ -39,5 +39,8 @@ public class StoreStaffFitnessDetailVo implements Serializable {
 
     @ApiModelProperty(value = "从业经历列表")
     private List<StoreStaffFitnessExperience> experienceList;
+
+    @ApiModelProperty(value = "店铺名称")
+    private String storeName;
 }
 

+ 240 - 9
alien-store/src/main/java/shop/alien/store/service/impl/SportsEquipmentFacilityServiceImpl.java

@@ -219,8 +219,8 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
         try {
             List<SportsEquipmentFacilityCategorySummaryVo> result = new ArrayList<>();
             
-            // 查询该店铺下所有不同的设施分类名称
-            List<String> categoryNameList = queryDistinctCategoryNames(storeId);
+            // 查询该店铺下所有不同的设施分类名称(专门用于categorySummary)
+            List<String> categoryNameList = queryDistinctCategoryNamesForCategorySummary(storeId);
             
             if (CollectionUtils.isEmpty(categoryNameList)) {
                 log.info("查询指定店铺按分类汇总的设备信息完成,storeId={},未找到分类数据", storeId);
@@ -229,12 +229,11 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
             
             // 按分类名称分组查询
             for (String categoryName : categoryNameList) {
-                SportsEquipmentFacilityCategorySummaryVo categoryVo = buildCategorySummaryVoByCategoryName(
+                SportsEquipmentFacilityCategorySummaryVo categoryVo = buildCategorySummaryVoByCategoryNameForCategorySummary(
                         storeId, categoryName);
                 // 只添加有设备数据的分类
-                if (categoryVo.getFacilityCount() > 0 || !CollectionUtils.isEmpty(categoryVo.getFacilityList())) {
-                    result.add(categoryVo);
-                }
+                result.add(categoryVo);
+
             }
             
             log.info("查询指定店铺按分类汇总的设备信息完成,storeId={},分类数量:{}", storeId, result.size());
@@ -246,6 +245,235 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
     }
     
     /**
+     * 查询指定店铺下所有不同的设施分类名称(专门用于categorySummary接口,不与其他接口共用)
+     *
+     * @param storeId 门店ID
+     * @return 分类名称列表,不会返回null
+     */
+    private List<String> queryDistinctCategoryNamesForCategorySummary(Integer storeId) {
+        try {
+            LambdaQueryWrapper<SportsEquipmentFacility> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.eq(SportsEquipmentFacility::getStoreId, storeId)
+                    .eq(SportsEquipmentFacility::getDeleteFlag, DELETE_FLAG_NOT_DELETED)
+                    .isNotNull(SportsEquipmentFacility::getFacilityCategoryName)
+                    .ne(SportsEquipmentFacility::getFacilityCategoryName, "");
+            
+            List<SportsEquipmentFacility> facilityList = facilityMapper.selectList(queryWrapper);
+            
+            if (CollectionUtils.isEmpty(facilityList)) {
+                return new ArrayList<>();
+            }
+            
+            // 提取所有不同的分类名称并排序
+            return facilityList.stream()
+                    .map(SportsEquipmentFacility::getFacilityCategoryName)
+                    .filter(StringUtils::isNotBlank)
+                    .distinct()
+                    .sorted()
+                    .collect(Collectors.toList());
+        } catch (Exception e) {
+            log.error("查询设施分类名称列表异常(categorySummary专用),storeId={},异常信息:{}", storeId, e.getMessage(), e);
+            return new ArrayList<>();
+        }
+    }
+    
+    /**
+     * 根据分类名称构建分类汇总VO对象(专门用于categorySummary接口,不与其他接口共用)
+     *
+     * @param storeId      门店ID
+     * @param categoryName 分类名称
+     * @return 分类汇总VO对象
+     */
+    private SportsEquipmentFacilityCategorySummaryVo buildCategorySummaryVoByCategoryNameForCategorySummary(Integer storeId, String categoryName) {
+        SportsEquipmentFacilityCategorySummaryVo categoryVo = new SportsEquipmentFacilityCategorySummaryVo();
+        categoryVo.setStoreId(storeId);
+        categoryVo.setFacilityCategoryName(categoryName);
+        
+        // 查询该分类名称下的设备列表(专门用于categorySummary)
+        List<SportsEquipmentFacility> facilityList = queryFacilityListByCategoryNameForCategorySummary(storeId, categoryName);
+        
+        // 收集并解析fitnessEquipmentIds(专门用于categorySummary)
+        List<Integer> fitnessEquipmentIdList = collectFitnessEquipmentIdsForCategorySummary(facilityList, storeId);
+        
+        // 查询FitnessEquipmentInfo列表(专门用于categorySummary)
+        List<FitnessEquipmentInfo> fitnessEquipmentInfoList = queryFitnessEquipmentInfoListForCategorySummary(fitnessEquipmentIdList, storeId);
+
+        // 设置设备列表
+        categoryVo.setFacilityList(fitnessEquipmentInfoList);
+        categoryVo.setFacilityCount(fitnessEquipmentInfoList.size());
+
+        // 查询并设置图片列表(专门用于categorySummary)
+        // 兼容处理:图片存储时business_id存储的是facility_category编号
+        // 需要从该分类名称下的设备中获取facility_category值来查询图片
+        List<String> imageList = queryCategoryImageListByCategoryNameForCategorySummary(storeId, categoryName, facilityList);
+        categoryVo.setImageList(imageList);
+        
+        return categoryVo;
+    }
+    
+    /**
+     * 根据分类名称查询设备列表(专门用于categorySummary接口,不与其他接口共用)
+     *
+     * @param storeId      门店ID
+     * @param categoryName 分类名称
+     * @return 设备列表
+     */
+    private List<SportsEquipmentFacility> queryFacilityListByCategoryNameForCategorySummary(Integer storeId, String categoryName) {
+        LambdaQueryWrapper<SportsEquipmentFacility> facilityWrapper = new LambdaQueryWrapper<>();
+        facilityWrapper.eq(SportsEquipmentFacility::getStoreId, storeId)
+                .eq(SportsEquipmentFacility::getFacilityCategoryName, categoryName)
+                .eq(SportsEquipmentFacility::getDeleteFlag, DELETE_FLAG_NOT_DELETED)
+                .orderByDesc(SportsEquipmentFacility::getCreatedTime);
+        return facilityMapper.selectList(facilityWrapper);
+    }
+    
+    /**
+     * 从设备列表中收集fitnessEquipmentIds并解析为整数列表(专门用于categorySummary接口,不与其他接口共用)
+     *
+     * @param facilityList 设备列表
+     * @param storeId      门店ID(用于日志)
+     * @return 去重后的设备ID列表
+     */
+    private List<Integer> collectFitnessEquipmentIdsForCategorySummary(List<SportsEquipmentFacility> facilityList, Integer storeId) {
+        List<Integer> fitnessEquipmentIdList = new ArrayList<>();
+        
+        if (CollectionUtils.isEmpty(facilityList)) {
+            return fitnessEquipmentIdList;
+        }
+        
+        for (SportsEquipmentFacility facility : facilityList) {
+            String fitnessEquipmentIds = facility.getFitnessEquipmentIds();
+            if (StringUtils.isNotBlank(fitnessEquipmentIds)) {
+                List<Integer> parsedIds = parseFitnessEquipmentIdsForCategorySummary(fitnessEquipmentIds, storeId);
+                for (Integer id : parsedIds) {
+                    if (!fitnessEquipmentIdList.contains(id)) {
+                        fitnessEquipmentIdList.add(id);
+                    }
+                }
+            }
+        }
+        
+        return fitnessEquipmentIdList;
+    }
+    
+    /**
+     * 解析逗号分隔的ID字符串为整数列表(专门用于categorySummary接口,不与其他接口共用)
+     *
+     * @param fitnessEquipmentIds ID字符串(逗号分隔)
+     * @param storeId             门店ID(用于日志)
+     * @return 解析后的ID列表
+     */
+    private List<Integer> parseFitnessEquipmentIdsForCategorySummary(String fitnessEquipmentIds, Integer storeId) {
+        List<Integer> idList = new ArrayList<>();
+        
+        if (StringUtils.isBlank(fitnessEquipmentIds)) {
+            return idList;
+        }
+        
+        String[] idArray = fitnessEquipmentIds.split(ID_SEPARATOR);
+        for (String idStr : idArray) {
+            String trimmedId = idStr.trim();
+            if (StringUtils.isNotBlank(trimmedId)) {
+                try {
+                    Integer id = Integer.parseInt(trimmedId);
+                    if (id >= MIN_VALID_ID) {
+                        idList.add(id);
+                    } else {
+                        log.warn("解析fitnessEquipmentIds失败(categorySummary专用),ID小于最小值:{},storeId={}", 
+                                trimmedId, storeId);
+                    }
+                } catch (NumberFormatException e) {
+                    log.warn("解析fitnessEquipmentIds失败(categorySummary专用),无效的ID格式:{},storeId={},异常信息:{}", 
+                            trimmedId, storeId, e.getMessage());
+                }
+            }
+        }
+        
+        return idList;
+    }
+    
+    /**
+     * 查询健身设备信息列表(专门用于categorySummary接口,不与其他接口共用)
+     *
+     * @param fitnessEquipmentIdList 设备ID列表
+     * @param storeId                门店ID(用于日志)
+     * @return 过滤并排序后的设备信息列表
+     */
+    private List<FitnessEquipmentInfo> queryFitnessEquipmentInfoListForCategorySummary(List<Integer> fitnessEquipmentIdList, Integer storeId) {
+        if (CollectionUtils.isEmpty(fitnessEquipmentIdList)) {
+            return new ArrayList<>();
+        }
+        
+        try {
+            List<FitnessEquipmentInfo> allEquipmentList = new ArrayList<>(
+                    fitnessEquipmentInfoService.listByIds(fitnessEquipmentIdList));
+            
+            // 过滤掉已删除和禁用的设备,并按sort_order排序
+            List<FitnessEquipmentInfo> filteredList = allEquipmentList.stream()
+                    .filter(this::isValidFitnessEquipment)
+                    .sorted(this::compareBySortOrder)
+                    .collect(Collectors.toList());
+            
+            log.info("查询到FitnessEquipmentInfo设备数量(categorySummary专用):{},storeId:{}", 
+                    filteredList.size(), storeId);
+            
+            return filteredList;
+        } catch (Exception e) {
+            log.error("查询FitnessEquipmentInfo列表异常(categorySummary专用),storeId={},异常信息:{}", 
+                    storeId, e.getMessage(), e);
+            return new ArrayList<>();
+        }
+    }
+    
+    /**
+     * 根据分类名称查询图片列表(专门用于categorySummary接口,不与其他接口共用)
+     * 兼容处理:图片存储时business_id存储的是facility_category编号
+     * 需要从该分类名称下的设备中获取facility_category值来查询图片
+     *
+     * @param storeId      门店ID
+     * @param categoryName 分类名称
+     * @param facilityList 该分类下的设备列表
+     * @return 图片URL列表
+     */
+    private List<String> queryCategoryImageListByCategoryNameForCategorySummary(Integer storeId, String categoryName, 
+                                                                               List<SportsEquipmentFacility> facilityList) {
+        try {
+            // 从设备列表中获取所有不同的facility_category值
+            List<Integer> categoryIdList = facilityList.stream()
+                    .map(SportsEquipmentFacility::getFacilityCategory)
+                    .filter(category -> category != null && category > 0)
+                    .distinct()
+                    .collect(Collectors.toList());
+            
+            if (CollectionUtils.isEmpty(categoryIdList)) {
+                return new ArrayList<>();
+            }
+            
+            // 查询所有相关分类的图片
+            LambdaQueryWrapper<StoreImg> imageWrapper = new LambdaQueryWrapper<>();
+            imageWrapper.eq(StoreImg::getStoreId, storeId)
+                    .in(StoreImg::getBusinessId, categoryIdList)
+                    .eq(StoreImg::getImgType, IMG_TYPE_SPORTS_EQUIPMENT)
+                    .orderByAsc(StoreImg::getImgSort);
+            
+            List<StoreImg> imageList = storeImgMapper.selectList(imageWrapper);
+            
+            if (CollectionUtils.isEmpty(imageList)) {
+                return new ArrayList<>();
+            }
+            
+            return imageList.stream()
+                    .map(StoreImg::getImgUrl)
+                    .distinct()
+                    .collect(Collectors.toList());
+        } catch (Exception e) {
+            log.error("查询分类图片列表异常(categorySummary专用),storeId={},categoryName={},异常信息:{}", 
+                    storeId, categoryName, e.getMessage(), e);
+            return new ArrayList<>();
+        }
+    }
+    
+    /**
      * 查询指定店铺下所有不同的设施分类名称
      *
      * @param storeId 门店ID
@@ -288,23 +516,26 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
     private SportsEquipmentFacilityCategorySummaryVo buildCategorySummaryVoByCategoryName(Integer storeId, String categoryName) {
         SportsEquipmentFacilityCategorySummaryVo categoryVo = new SportsEquipmentFacilityCategorySummaryVo();
         categoryVo.setStoreId(storeId);
+
         categoryVo.setFacilityCategoryName(categoryName);
         
         // 查询该分类名称下的设备列表
         List<SportsEquipmentFacility> facilityList = queryFacilityListByCategoryName(storeId, categoryName);
         
         // 设置设备数量:统计该分类名称下的SportsEquipmentFacility记录数量
-        categoryVo.setFacilityCount(facilityList != null ? facilityList.size() : 0);
+//        categoryVo.setFacilityCount(facilityList != null ? facilityList.size() : 0);
         
         // 收集并解析fitnessEquipmentIds
         List<Integer> fitnessEquipmentIdList = collectFitnessEquipmentIds(facilityList, storeId, null);
         
         // 查询FitnessEquipmentInfo列表
         List<FitnessEquipmentInfo> fitnessEquipmentInfoList = queryFitnessEquipmentInfoList(fitnessEquipmentIdList, null, storeId);
-        
+
         // 设置设备列表
         categoryVo.setFacilityList(fitnessEquipmentInfoList);
-        
+
+        categoryVo.setFacilityCount(fitnessEquipmentInfoList.size());
+
         // 查询并设置图片列表
         // 兼容处理:图片存储时business_id存储的是facility_category编号
         // 需要从该分类名称下的设备中获取facility_category值来查询图片

+ 20 - 2
alien-store/src/main/java/shop/alien/store/service/impl/StoreStaffConfigServiceImpl.java

@@ -907,6 +907,22 @@ public class StoreStaffConfigServiceImpl implements StoreStaffConfigService {
                 // 从业经历查询失败不影响整体返回,设置为null即可
             }
 
+            // 根据店铺ID查询店铺名称
+            String storeName = null;
+            if (staffConfig.getStoreId() != null && staffConfig.getStoreId() > 0) {
+                try {
+                    StoreInfo storeInfo = storeInfoMapper.selectById(staffConfig.getStoreId());
+                    if (storeInfo != null) {
+                        storeName = storeInfo.getStoreName();
+                    } else {
+                        log.warn("查询店铺信息失败,店铺不存在:storeId={}", staffConfig.getStoreId());
+                    }
+                } catch (Exception e) {
+                    log.warn("查询店铺信息异常,storeId={},异常信息:{}", staffConfig.getStoreId(), e.getMessage());
+                    // 店铺信息查询失败不影响整体返回,设置为null即可
+                }
+            }
+
             // 构建返回对象
             StoreStaffFitnessDetailVo detailVo = new StoreStaffFitnessDetailVo();
             detailVo.setStaffInfo(staffConfig);
@@ -914,12 +930,14 @@ public class StoreStaffConfigServiceImpl implements StoreStaffConfigService {
             detailVo.setCertificationList(certificationList != null ? certificationList : new ArrayList<>());
             detailVo.setHonorList(honorList != null ? honorList : new ArrayList<>());
             detailVo.setExperienceList(experienceList != null ? experienceList : new ArrayList<>());
+            detailVo.setStoreName(storeName);
 
-            log.info("查询健身教练详情成功,id={},认证数量:{},荣誉数量:{},从业经历数量:{}",
+            log.info("查询健身教练详情成功,id={},认证数量:{},荣誉数量:{},从业经历数量:{},店铺名称:{}",
                     id, 
                     certificationList != null ? certificationList.size() : 0,
                     honorList != null ? honorList.size() : 0,
-                    experienceList != null ? experienceList.size() : 0);
+                    experienceList != null ? experienceList.size() : 0,
+                    storeName);
             return detailVo;
         } catch (Exception e) {
             log.error("查询健身教练详情异常,id={},异常信息:{}", id, e.getMessage(), e);