Bläddra i källkod

Merge remote-tracking branch 'origin/sit-eight-categories' into sit-eight-categories

liyafei 3 dagar sedan
förälder
incheckning
91d409ca59

+ 9 - 2
alien-entity/src/main/java/shop/alien/entity/store/vo/StoreStaffFitnessDetailVo.java

@@ -7,19 +7,20 @@ import lombok.Data;
 import shop.alien.entity.store.StoreStaffConfig;
 import shop.alien.entity.store.StoreStaffFitnessBase;
 import shop.alien.entity.store.StoreStaffFitnessCertification;
+import shop.alien.entity.store.StoreStaffFitnessExperience;
 
 import java.io.Serializable;
 import java.util.List;
 
 /**
- * 健身教练详情视图对象(包含员工信息、基本信息和认证/荣誉列表
+ * 健身教练详情视图对象(包含员工信息、基本信息、认证/荣誉列表和从业经历
  *
  * @author system
  * @since 2025-01-XX
  */
 @Data
 @JsonInclude(JsonInclude.Include.NON_NULL)
-@ApiModel(value = "StoreStaffFitnessDetailVo对象", description = "健身教练详情视图对象(包含员工信息、基本信息和认证/荣誉列表)")
+@ApiModel(value = "StoreStaffFitnessDetailVo对象", description = "健身教练详情视图对象(包含员工信息、基本信息、认证/荣誉列表和从业经历)")
 public class StoreStaffFitnessDetailVo implements Serializable {
 
     private static final long serialVersionUID = 1L;
@@ -35,5 +36,11 @@ public class StoreStaffFitnessDetailVo implements Serializable {
 
     @ApiModelProperty(value = "荣誉列表(type=2)")
     private List<StoreStaffFitnessCertification> honorList;
+
+    @ApiModelProperty(value = "从业经历列表")
+    private List<StoreStaffFitnessExperience> experienceList;
+
+    @ApiModelProperty(value = "店铺名称")
+    private String storeName;
 }
 

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

@@ -199,8 +199,8 @@ public class SportsEquipmentFacilityController {
             @ApiImplicitParam(name = "storeId", value = "门店ID", dataType = "int", paramType = "query", required = true)
     })
     @GetMapping("/storeCategorySummary")
-    public R<List<SportsEquipmentFacilityCategoryVo>> getstoreCategorySummary(@RequestParam Integer storeId) {
-        log.info("SportsEquipmentFacilityController.getstoreCategorySummary?storeId={}", storeId);
+    public R<List<SportsEquipmentFacilityCategoryVo>> getStoreCategorySummary(@RequestParam Integer storeId) {
+        log.info("SportsEquipmentFacilityController.getStoreCategorySummary?storeId={}", storeId);
         return R.data(facilityService.getstoreCategorySummary(storeId));
     }
 

+ 3 - 7
alien-store/src/main/java/shop/alien/store/controller/StoreStaffConfigController.java

@@ -337,12 +337,12 @@ public class StoreStaffConfigController {
     }
 
     /**
-     * 查询健身教练详情(包含员工信息、基本信息和认证/荣誉列表
+     * 查询健身教练详情(包含员工信息、基本信息、认证/荣誉列表和从业经历
      *
      * @param id 员工主键ID
-     * @return 健身教练详情(包含员工信息、基本信息和认证/荣誉列表
+     * @return 健身教练详情(包含员工信息、基本信息、认证/荣誉列表和从业经历
      */
-    @ApiOperation("查询健身教练详情(包含员工信息、基本信息和认证/荣誉列表)用户端")
+    @ApiOperation("查询健身教练详情(包含员工信息、基本信息、认证/荣誉列表和从业经历)用户端")
     @ApiOperationSupport(order = 9)
     @ApiImplicitParams({
             @ApiImplicitParam(name = "id", value = "员工主键ID", dataType = "Integer", paramType = "query", required = true)
@@ -366,10 +366,6 @@ public class StoreStaffConfigController {
                 return R.fail("员工不存在");
             }
 
-            log.info("查询健身教练详情成功,id={},认证数量:{},荣誉数量:{}",
-                    id,
-                    result.getCertificationList() != null ? result.getCertificationList().size() : 0,
-                    result.getHonorList() != null ? result.getHonorList().size() : 0);
             return R.data(result);
         } catch (Exception e) {
             log.error("查询健身教练详情异常,id={},异常信息:{}", id, e.getMessage(), e);

+ 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值来查询图片

+ 36 - 3
alien-store/src/main/java/shop/alien/store/service/impl/StoreStaffConfigServiceImpl.java

@@ -25,6 +25,7 @@ import shop.alien.store.service.StoreStaffConfigService;
 import shop.alien.store.service.StoreStaffFitnessBaseService;
 import shop.alien.store.service.StoreStaffFitnessCertificationService;
 import shop.alien.store.service.StoreStaffFitnessCourseService;
+import shop.alien.store.service.StoreStaffFitnessExperienceService;
 import shop.alien.store.util.CommonConstant;
 import shop.alien.store.util.ai.AiContentModerationUtil;
 import shop.alien.util.ali.AliOSSUtil;
@@ -72,6 +73,8 @@ public class StoreStaffConfigServiceImpl implements StoreStaffConfigService {
 
     private final AiContentModerationUtil aiContentModerationUtil;
 
+    private final StoreStaffFitnessExperienceService storeStaffFitnessExperienceService;
+
     /**
      * 认证类型:认证
      */
@@ -894,17 +897,47 @@ public class StoreStaffConfigServiceImpl implements StoreStaffConfigService {
             List<shop.alien.entity.store.StoreStaffFitnessCertification> honorList =
                     storeStaffFitnessCertificationService.getListByStaffIdAndType(id, HONOR_TYPE);
 
+
+            // 查询从业经历列表
+            List<shop.alien.entity.store.StoreStaffFitnessExperience> experienceList = null;
+            try {
+                experienceList = storeStaffFitnessExperienceService.getListByStaffId(id);
+            } catch (Exception e) {
+                log.warn("查询从业经历列表失败,id={},异常信息:{}", id, e.getMessage());
+                // 从业经历查询失败不影响整体返回,设置为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);
             detailVo.setBaseInfo(baseInfo);
             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={},认证数量:{},荣誉数量:{}",
-                    id,
+            log.info("查询健身教练详情成功,id={},认证数量:{},荣誉数量:{},从业经历数量:{},店铺名称:{}",
+                    id, 
                     certificationList != null ? certificationList.size() : 0,
-                    honorList != null ? honorList.size() : 0);
+                    honorList != null ? honorList.size() : 0,
+                    experienceList != null ? experienceList.size() : 0,
+                    storeName);
             return detailVo;
         } catch (Exception e) {
             log.error("查询健身教练详情异常,id={},异常信息:{}", id, e.getMessage(), e);