Jelajahi Sumber

BUGfix:基础设施与服务重构修改

panzhilin 3 bulan lalu
induk
melakukan
09b8e9e6b1

+ 4 - 0
alien-entity/src/main/java/shop/alien/entity/store/FitnessEquipmentInfo.java

@@ -48,6 +48,10 @@ public class FitnessEquipmentInfo implements Serializable {
     @TableField("equipment_image")
     private String equipmentImage;
 
+    @ApiModelProperty(value = "数量")
+    @TableField("equipment_nums")
+    private Integer equipmentNums;
+
     @ApiModelProperty(value = "设备描述")
     @TableField("description")
     private String description;

+ 4 - 0
alien-entity/src/main/java/shop/alien/entity/store/SportsEquipmentFacility.java

@@ -90,5 +90,9 @@ public class SportsEquipmentFacility implements Serializable {
     @ApiModelProperty(value = "区域ID(关联sports_facility_area.id)")
     @TableField("area_id")
     private Integer areaId;
+
+    @ApiModelProperty(value = "收费类型(0:免费, 1:收费) - 已废弃")
+    @TableField("billing_type")
+    private Integer billingType;
 }
 

+ 29 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/DeleteFacilityRequestVo.java

@@ -0,0 +1,29 @@
+package shop.alien.entity.store.vo;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 删除设施请求VO(根据fitness_equipment_info的ID删除)
+ *
+ * @author assistant
+ * @since 2025-12-31
+ */
+@Data
+@JsonInclude(JsonInclude.Include.NON_NULL)
+@ApiModel(value = "DeleteFacilityRequestVo对象", description = "删除设施请求视图对象")
+public class DeleteFacilityRequestVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "设备ID(fitness_equipment_info表的主键ID)", required = true, example = "1")
+    private Integer id;
+
+    @ApiModelProperty(value = "设备ID(fitness_equipment_info表的主键ID),与id字段等价", required = false, example = "1")
+    private Integer equipmentId;
+}
+

+ 18 - 0
alien-entity/src/main/java/shop/alien/entity/store/vo/SportsEquipmentFacilityVo.java

@@ -57,5 +57,23 @@ public class SportsEquipmentFacilityVo implements Serializable {
 
     @ApiModelProperty(value = "图片列表")
     private List<String> imageList;
+
+    @ApiModelProperty(value = "区域ID(关联sports_facility_area.id)")
+    private Integer areaId;
+
+    @ApiModelProperty(value = "设备ID列表(fitness_equipment_info表的id,用逗号分隔)")
+    private String fitnessEquipmentIds;
+
+    @ApiModelProperty(value = "设备名称(用于创建fitness_equipment_info记录)")
+    private String equipmentName;
+
+    @ApiModelProperty(value = "设备数量(用于创建fitness_equipment_info记录)")
+    private Integer equipmentNums;
+
+    @ApiModelProperty(value = "设备图片URL(用于创建fitness_equipment_info记录)")
+    private String equipmentImage;
+
+    @ApiModelProperty(value = "设备ID(fitness_equipment_info表的主键ID,用于修改时根据设备ID查询设施记录)")
+    private Integer equipmentId;
 }
 

+ 10 - 0
alien-entity/src/main/java/shop/alien/mapper/SportsEquipmentFacilityMapper.java

@@ -2,6 +2,8 @@ package shop.alien.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
 import shop.alien.entity.store.SportsEquipmentFacility;
 
 /**
@@ -13,5 +15,13 @@ import shop.alien.entity.store.SportsEquipmentFacility;
 @Mapper
 public interface SportsEquipmentFacilityMapper extends BaseMapper<SportsEquipmentFacility> {
 
+    /**
+     * 根据设备ID查询设施记录(包括已删除的记录,绕过逻辑删除)
+     *
+     * @param equipmentId 设备ID(fitness_equipment_info表的主键ID)
+     * @return 设施记录列表
+     */
+    @Select("SELECT * FROM sports_equipment_facility WHERE fitness_equipment_ids LIKE CONCAT('%', #{equipmentId}, '%') ORDER BY created_time DESC LIMIT 1")
+    SportsEquipmentFacility selectByEquipmentIdIncludeDeleted(@Param("equipmentId") Integer equipmentId);
 }
 

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

@@ -4,9 +4,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.web.bind.annotation.*;
 import shop.alien.entity.result.R;
+import shop.alien.entity.store.FitnessEquipmentInfo;
 import shop.alien.entity.store.SportsEquipmentFacility;
+import shop.alien.entity.store.vo.DeleteFacilityRequestVo;
 import shop.alien.entity.store.vo.FitnessEquipmentCategoryDetailVo;
 import shop.alien.entity.store.vo.SportsEquipmentFacilityCategorySummaryVo;
 import shop.alien.entity.store.vo.SportsEquipmentFacilityCategoryVo;
@@ -72,7 +75,7 @@ public class SportsEquipmentFacilityController {
             @ApiImplicitParam(name = "areaId", value = "区域ID", dataType = "int", paramType = "query", required = true)
     })
     @GetMapping("/listByArea")
-    public R<List<SportsEquipmentFacilityVo>> getListByArea(
+    public R<List<FitnessEquipmentInfo>> getListByArea(
             @RequestParam Integer storeId,
             @RequestParam Integer areaId) {
         log.info("SportsEquipmentFacilityController.getListByArea?storeId={},areaId={}", storeId, areaId);
@@ -85,7 +88,7 @@ public class SportsEquipmentFacilityController {
                 log.warn("根据区域ID查询设备列表失败,区域ID无效:{}", areaId);
                 return R.fail("区域ID不能为空且必须大于0");
             }
-            List<SportsEquipmentFacilityVo> result = facilityService.getListByAreaId(storeId, areaId);
+            List<FitnessEquipmentInfo> result = facilityService.getListByAreaId(storeId, areaId);
             log.info("根据区域ID查询设备列表成功,storeId={},areaId={},设备数量:{}", storeId, areaId, result.size());
             return R.data(result);
         } catch (IllegalArgumentException e) {
@@ -119,19 +122,39 @@ public class SportsEquipmentFacilityController {
     public R<Boolean> saveFacility(@RequestBody SportsEquipmentFacilityVo vo) {
         log.info("SportsEquipmentFacilityController.saveFacility?vo={}", vo);
         try {
+            // 参数验证
+            if (vo == null) {
+                return R.fail("请求参数不能为空");
+            }
+            if (vo.getStoreId() == null || vo.getStoreId() <= 0) {
+                return R.fail("门店ID不能为空且必须大于0");
+            }
+            if (vo.getAreaId() == null || vo.getAreaId() <= 0) {
+                return R.fail("区域ID不能为空且必须大于0");
+            }
+            if (StringUtils.isBlank(vo.getEquipmentName())) {
+                return R.fail("设备名称不能为空");
+            }
+            
             SportsEquipmentFacility facility = new SportsEquipmentFacility();
             facility.setStoreId(vo.getStoreId());
+            facility.setAreaId(vo.getAreaId()); // 设置区域ID
             facility.setFacilityCategory(vo.getFacilityCategory());
             facility.setFacilityName(vo.getFacilityName());
             facility.setQuantity(vo.getQuantity());
             facility.setBrand(vo.getBrand());
             facility.setDescription(vo.getDescription());
             facility.setDisplayInStoreDetail(vo.getDisplayInStoreDetail());
-            boolean result = facilityService.saveFacility(facility, vo.getImageList());
+            
+            // 传递vo参数,包含设备信息(equipmentName、equipmentNums、equipmentImage)
+            boolean result = facilityService.saveFacility(facility, vo.getImageList(), vo);
             if (result) {
                 return R.success("新增成功");
             }
             return R.fail("新增失败");
+        } catch (IllegalArgumentException e) {
+            log.warn("新增运动器材设施失败,参数验证失败:{}", e.getMessage());
+            return R.fail(e.getMessage());
         } catch (Exception e) {
             log.error("SportsEquipmentFacilityController.saveFacility异常", e);
             return R.fail(e.getMessage());
@@ -144,23 +167,34 @@ public class SportsEquipmentFacilityController {
     public R<Boolean> updateFacility(@RequestBody SportsEquipmentFacilityVo vo) {
         log.info("SportsEquipmentFacilityController.updateFacility?vo={}", vo);
         try {
-            if (vo.getId() == null) {
-                return R.fail("主键ID不能为空");
+            // 参数验证:必须提供id(设施ID)或equipmentId(设备ID)之一
+            if (vo.getId() == null && (vo.getEquipmentId() == null || vo.getEquipmentId() <= 0)) {  
+                return R.fail("主键ID或设备ID不能为空");
             }
+            
             SportsEquipmentFacility facility = new SportsEquipmentFacility();
-            facility.setId(vo.getId());
+            // 如果提供了设施ID,使用设施ID;否则会在Service层根据equipmentId查询
+            if (vo.getId() != null) {
+                facility.setId(vo.getId());
+            }
             facility.setStoreId(vo.getStoreId());
             facility.setFacilityCategory(vo.getFacilityCategory());
             facility.setFacilityName(vo.getFacilityName());
             facility.setQuantity(vo.getQuantity());
-            facility.setBrand(vo.getBrand());
+            facility.setBrand(vo.getBrand()); 
             facility.setDescription(vo.getDescription());
             facility.setDisplayInStoreDetail(vo.getDisplayInStoreDetail());
-            boolean result = facilityService.updateFacility(facility, vo.getImageList());
+            facility.setAreaId(vo.getAreaId()); // 设置区域ID
+            
+            // 传递vo参数,包含设备信息(equipmentName、equipmentNums、equipmentImage、equipmentId)
+            boolean result = facilityService.updateFacility(facility, vo.getImageList(), vo);
             if (result) {
                 return R.success("修改成功");
             }
             return R.fail("修改失败");
+        } catch (IllegalArgumentException e) {
+            log.warn("修改运动器材设施失败,参数验证失败:{}", e.getMessage());
+            return R.fail(e.getMessage());
         } catch (Exception e) {
             log.error("SportsEquipmentFacilityController.updateFacility异常", e);
             return R.fail(e.getMessage());
@@ -170,17 +204,36 @@ public class SportsEquipmentFacilityController {
     @ApiOperation("删除运动器材设施")
     @ApiOperationSupport(order = 7)
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "主键ID", dataType = "int", paramType = "query", required = true)
+            @ApiImplicitParam(name = "request", value = "删除设备请求参数", dataType = "DeleteFacilityRequestVo", paramType = "body", required = true)
     })
     @PostMapping("/delete")
-    public R<Boolean> deleteFacility(@RequestParam Integer id) {
-        log.info("SportsEquipmentFacilityController.deleteFacility?id={}", id);
+    public R<Boolean> deleteFacility(@RequestBody DeleteFacilityRequestVo request) {
+        log.info("SportsEquipmentFacilityController.deleteFacility?request={}", request);
         try {
-            boolean result = facilityService.deleteFacility(id);
+            // 参数验证
+            if (request == null) {
+                log.warn("删除运动器材设施失败,请求参数为空");
+                return R.fail("请求参数不能为空");
+            }
+            
+            // 优先使用equipmentId,如果没有则使用id
+            Integer equipmentId = request.getEquipmentId();
+            if (equipmentId == null || equipmentId <= 0) {
+                equipmentId = request.getId();
+            }
+            if (equipmentId == null || equipmentId <= 0) {
+                log.warn("删除运动器材设施失败,设备ID无效:id={},equipmentId={}", request.getId(), request.getEquipmentId());
+                return R.fail("设备ID不能为空且必须大于0");
+            }
+            
+            boolean result = facilityService.deleteFacility(equipmentId);
             if (result) {
                 return R.success("删除成功");
             }
             return R.fail("删除失败");
+        } catch (IllegalArgumentException e) {
+            log.warn("删除运动器材设施失败,参数验证失败:{}", e.getMessage());
+            return R.fail(e.getMessage());
         } catch (Exception e) {
             log.error("SportsEquipmentFacilityController.deleteFacility异常", e);
             return R.fail(e.getMessage());

+ 10 - 6
alien-store/src/main/java/shop/alien/store/service/SportsEquipmentFacilityService.java

@@ -2,6 +2,7 @@ package shop.alien.store.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import shop.alien.entity.store.FitnessEquipmentInfo;
 import shop.alien.entity.store.SportsEquipmentFacility;
 import shop.alien.entity.store.vo.FitnessEquipmentCategoryDetailVo;
 import shop.alien.entity.store.vo.SportsEquipmentFacilityCategorySummaryVo;
@@ -43,9 +44,9 @@ public interface SportsEquipmentFacilityService extends IService<SportsEquipment
      *
      * @param storeId 门店ID
      * @param areaId  区域ID
-     * @return List<SportsEquipmentFacilityVo>
+     * @return List<FitnessEquipmentInfo> 设备信息列表
      */
-    List<SportsEquipmentFacilityVo> getListByAreaId(Integer storeId, Integer areaId);
+    List<FitnessEquipmentInfo> getListByAreaId(Integer storeId, Integer areaId);
 
     /**
      * 根据ID查询详情
@@ -60,26 +61,29 @@ public interface SportsEquipmentFacilityService extends IService<SportsEquipment
      *
      * @param facility 设施信息
      * @param imageList 图片列表
+     * @param vo 视图对象(包含设备信息:equipmentName、equipmentNums、equipmentImage等)
      * @return boolean
      */
-    boolean saveFacility(SportsEquipmentFacility facility, List<String> imageList);
+    boolean saveFacility(SportsEquipmentFacility facility, List<String> imageList, SportsEquipmentFacilityVo vo);
 
     /**
      * 修改运动器材设施
      *
      * @param facility 设施信息
      * @param imageList 图片列表
+     * @param vo 视图对象(包含设备信息:equipmentName、equipmentNums、equipmentImage等)
      * @return boolean
      */
-    boolean updateFacility(SportsEquipmentFacility facility, List<String> imageList);
+    boolean updateFacility(SportsEquipmentFacility facility, List<String> imageList, SportsEquipmentFacilityVo vo);
 
     /**
      * 删除运动器材设施
+     * 根据fitness_equipment_info表的ID删除,会找到所有包含该设备ID的设施记录并处理
      *
-     * @param id 主键ID
+     * @param equipmentId 设备ID(fitness_equipment_info表的主键ID
      * @return boolean
      */
-    boolean deleteFacility(Integer id);
+    boolean deleteFacility(Integer equipmentId);
 
     /**
      * 查询指定店铺按分类汇总的设备信息(用户端)

+ 514 - 44
alien-store/src/main/java/shop/alien/store/service/impl/SportsEquipmentFacilityServiceImpl.java

@@ -26,7 +26,6 @@ import shop.alien.mapper.StoreImgMapper;
 import shop.alien.store.service.FitnessEquipmentInfoService;
 import shop.alien.store.service.SportsEquipmentFacilityService;
 import shop.alien.store.service.SportsFacilityAreaService;
-import shop.alien.entity.store.SportsFacilityArea;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -137,7 +136,7 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
     }
 
     @Override
-    public List<SportsEquipmentFacilityVo> getListByAreaId(Integer storeId, Integer areaId) {
+    public List<FitnessEquipmentInfo> getListByAreaId(Integer storeId, Integer areaId) {
         log.info("根据区域ID查询设备列表,storeId={},areaId={}", storeId, areaId);
         
         // 参数验证
@@ -152,20 +151,64 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
         }
         
         try {
+            // 1. 根据区域ID查询该区域下的所有设施记录
             LambdaQueryWrapper<SportsEquipmentFacility> queryWrapper = new LambdaQueryWrapper<>();
             queryWrapper.eq(SportsEquipmentFacility::getStoreId, storeId)
                     .eq(SportsEquipmentFacility::getAreaId, areaId)
-                    .eq(SportsEquipmentFacility::getDeleteFlag, DELETE_FLAG_NOT_DELETED)
-                    .orderByDesc(SportsEquipmentFacility::getCreatedTime);
+                    .eq(SportsEquipmentFacility::getDeleteFlag, DELETE_FLAG_NOT_DELETED);
             
             List<SportsEquipmentFacility> facilityList = facilityMapper.selectList(queryWrapper);
-            List<SportsEquipmentFacilityVo> voList = facilityList.stream()
-                    .map(this::convertToVo)
+            
+            // 2. 收集所有设备ID(从fitnessEquipmentIds字段中提取)
+            List<Integer> equipmentIdList = new ArrayList<>();
+            for (SportsEquipmentFacility facility : facilityList) {
+                String fitnessEquipmentIds = facility.getFitnessEquipmentIds();
+                if (StringUtils.isNotBlank(fitnessEquipmentIds)) {
+                    String[] idArray = fitnessEquipmentIds.split(ID_SEPARATOR);
+                    for (String idStr : idArray) {
+                        String trimmedId = idStr.trim();
+                        if (StringUtils.isNotBlank(trimmedId)) {
+                            try {
+                                Integer equipmentId = Integer.parseInt(trimmedId);
+                                if (equipmentId > 0 && !equipmentIdList.contains(equipmentId)) {
+                                    equipmentIdList.add(equipmentId);
+                                }
+                            } catch (NumberFormatException e) {
+                                log.warn("解析设备ID失败,跳过无效ID:{},storeId={},areaId={}", 
+                                        trimmedId, storeId, areaId);
+                            }
+                        }
+                    }
+                }
+            }
+            
+            // 3. 如果没有设备ID,返回空列表
+            if (CollectionUtils.isEmpty(equipmentIdList)) {
+                log.info("根据区域ID查询设备列表,未找到设备ID,storeId={},areaId={}", storeId, areaId);
+                return new ArrayList<>();
+            }
+            
+            // 4. 根据设备ID列表查询设备信息
+            List<FitnessEquipmentInfo> equipmentList = new ArrayList<>(
+                    fitnessEquipmentInfoService.listByIds(equipmentIdList));
+            
+            // 5. 过滤掉已删除和禁用的设备,并按sortOrder排序
+            List<FitnessEquipmentInfo> resultList = equipmentList.stream()
+                    .filter(equipment -> equipment != null 
+                            && equipment.getDeleteFlag() != null 
+                            && equipment.getDeleteFlag() == DELETE_FLAG_NOT_DELETED
+                            && equipment.getStatus() != null 
+                            && equipment.getStatus() == STATUS_ENABLED)
+                    .sorted((e1, e2) -> {
+                        Integer sort1 = e1.getSortOrder() != null ? e1.getSortOrder() : 0;
+                        Integer sort2 = e2.getSortOrder() != null ? e2.getSortOrder() : 0;
+                        return sort1.compareTo(sort2);
+                    })
                     .collect(Collectors.toList());
             
             log.info("根据区域ID查询设备列表成功,storeId={},areaId={},设备数量:{}", 
-                    storeId, areaId, voList.size());
-            return voList;
+                    storeId, areaId, resultList.size());
+            return resultList;
         } catch (Exception e) {
             log.error("根据区域ID查询设备列表异常,storeId={},areaId={},异常信息:{}", 
                     storeId, areaId, e.getMessage(), e);
@@ -175,10 +218,54 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
 
     @Override
     public SportsEquipmentFacilityVo getDetail(Integer id) {
+        log.info("查询设备设施详情,id={}", id);
+        
+        if (id == null || id <= 0) {
+            log.warn("查询设备设施详情失败,ID无效:{}", id);
+            return null;
+        }
+        
+        // 1. 先尝试根据设施ID查询(sports_equipment_facility表的主键ID)
         SportsEquipmentFacility facility = facilityMapper.selectById(id);
+        
+        // 2. 如果查询不到,尝试根据设备ID查询(fitness_equipment_info表的主键ID)
         if (facility == null) {
-            return null;
+            log.info("根据设施ID查询不到记录,尝试根据设备ID查询,equipmentId={}", id);
+            // 根据设备ID查询包含该设备的设施记录
+            LambdaQueryWrapper<SportsEquipmentFacility> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.like(SportsEquipmentFacility::getFitnessEquipmentIds, id)
+                    .orderByDesc(SportsEquipmentFacility::getCreatedTime); // 按创建时间降序,取最新的
+            List<SportsEquipmentFacility> facilityList = facilityMapper.selectList(queryWrapper);
+            
+            if (!CollectionUtils.isEmpty(facilityList)) {
+                // 优先取未删除的记录
+                for (SportsEquipmentFacility fac : facilityList) {
+                    if (fac.getDeleteFlag() == null || fac.getDeleteFlag() == DELETE_FLAG_NOT_DELETED) {
+                        facility = fac;
+                        break;
+                    }
+                }
+                // 如果没有未删除的记录,取第一个(可能是已删除的)
+                if (facility == null) {
+                    facility = facilityList.get(0);
+                }
+                log.info("根据设备ID查询到设施记录,equipmentId={},facilityId={},deleteFlag={}", 
+                        id, facility.getId(), facility.getDeleteFlag());
+            } else {
+                // 如果仍然查询不到,尝试查询已删除的记录(绕过逻辑删除)
+                facility = facilityMapper.selectByEquipmentIdIncludeDeleted(id);
+                if (facility != null) {
+                    log.info("根据设备ID查询到已删除的设施记录,equipmentId={},facilityId={},deleteFlag={}", 
+                            id, facility.getId(), facility.getDeleteFlag());
+                } else {
+                    log.warn("根据设施ID和设备ID都查询不到记录,id={}", id);
+                    return null;
+                }
+            }
+        } else {
+            log.info("根据设施ID查询到记录,facilityId={},deleteFlag={}", id, facility.getDeleteFlag());
         }
+        
         return convertToVo(facility);
     }
 
@@ -192,10 +279,25 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
     }
 
     @Override
-    public boolean saveFacility(SportsEquipmentFacility facility, List<String> imageList) {
-        // 校验图片数量(最多20张)
-        if (!CollectionUtils.isEmpty(imageList) && imageList.size() > 20) {
-            throw new RuntimeException("实景图片最多上传20张");
+    public boolean saveFacility(SportsEquipmentFacility facility, List<String> imageList, SportsEquipmentFacilityVo vo) {
+        log.info("保存设备设施,facility={},imageList大小={},vo={}", facility, 
+                imageList != null ? imageList.size() : 0, vo);
+        
+        // 参数验证
+        if (facility == null) {
+            log.warn("保存设备设施失败,设备信息为空");
+            throw new IllegalArgumentException("设备信息不能为空");
+        }
+        
+        if (facility.getStoreId() == null || facility.getStoreId() <= 0) {
+            log.warn("保存设备设施失败,门店ID无效:{}", facility.getStoreId());
+            throw new IllegalArgumentException("门店ID不能为空且必须大于0");
+        }
+        
+        // 校验图片数量(最多9张,根据UI需求)
+        if (!CollectionUtils.isEmpty(imageList) && imageList.size() > 9) {
+            log.warn("保存设备设施失败,图片数量超过限制:{}", imageList.size());
+            throw new RuntimeException("图片最多上传9张");
         }
         
         // 如果提供了areaId,验证区域是否存在且未删除
@@ -207,26 +309,103 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
             }
         }
         
-        // 保存设施信息
+        // 如果facilityCategory为null,设置默认值0(数据库要求不能为空)
+        if (facility.getFacilityCategory() == null) {
+            facility.setFacilityCategory(0);
+            log.info("新增设备时facilityCategory为null,已设置默认值0");
+        }
+        
+        // 如果facilityName为null,设置默认值为空字符串(数据库要求不能为空)
+        if (facility.getFacilityName() == null) {
+            facility.setFacilityName("");
+            log.info("新增设备时facilityName为null,已设置默认值为空字符串");
+        }
+        
+        // 1. 如果提供了设备信息(equipmentName),先创建FitnessEquipmentInfo记录
+        Integer equipmentId = null;
+        if (vo != null && StringUtils.isNotBlank(vo.getEquipmentName())) {
+            FitnessEquipmentInfo equipmentInfo = new FitnessEquipmentInfo();
+            equipmentInfo.setEquipmentName(vo.getEquipmentName().trim());
+            // 设备类型默认为6(其他),因为UI中没有选择设备类型
+            equipmentInfo.setEquipmentType(6); // 6:其他
+            if (vo.getEquipmentNums() != null && vo.getEquipmentNums() > 0) {
+                equipmentInfo.setEquipmentNums(vo.getEquipmentNums());
+            } else {
+                equipmentInfo.setEquipmentNums(1); // 默认数量为1
+            }
+            if (StringUtils.isNotBlank(vo.getEquipmentImage())) {
+                equipmentInfo.setEquipmentImage(vo.getEquipmentImage());
+            }
+            // 设置默认值
+            equipmentInfo.setSortOrder(0);
+            equipmentInfo.setStatus(STATUS_ENABLED);
+            equipmentInfo.setDeleteFlag(DELETE_FLAG_NOT_DELETED);
+            
+            boolean saveEquipmentResult = fitnessEquipmentInfoService.saveEquipment(equipmentInfo);
+            if (saveEquipmentResult && equipmentInfo.getId() != null) {
+                equipmentId = equipmentInfo.getId();
+                log.info("创建设备信息成功,equipmentId={},equipmentName={}", equipmentId, vo.getEquipmentName());
+            } else {
+                log.warn("创建设备信息失败,equipmentName={}", vo.getEquipmentName());
+                throw new RuntimeException("创建设备信息失败");
+            }
+        }
+        
+        // 2. 保存设施信息
+        // 如果创建了设备信息,将设备ID保存到fitnessEquipmentIds字段
+        if (equipmentId != null) {
+            facility.setFitnessEquipmentIds(String.valueOf(equipmentId));
+        }
+        
         boolean result = this.save(facility);
-        if (result && !CollectionUtils.isEmpty(imageList) && facility.getFacilityCategory() != null) {
-            // 删除该分类下的旧图片(如果存在)
+        if (!result) {
+            log.error("保存设备设施失败,保存数据库失败:facility={}", facility);
+            throw new RuntimeException("保存设备设施失败");
+        }
+        
+        // 3. 保存图片,使用facility.id作为business_id
+        if (!CollectionUtils.isEmpty(imageList) && facility.getId() != null) {
+            // 删除该设备下的旧图片(如果存在)
             LambdaQueryWrapper<StoreImg> deleteWrapper = new LambdaQueryWrapper<>();
             deleteWrapper.eq(StoreImg::getStoreId, facility.getStoreId())
-                    .eq(StoreImg::getBusinessId, facility.getFacilityCategory())
+                    .eq(StoreImg::getBusinessId, facility.getId())
                     .eq(StoreImg::getImgType, IMG_TYPE_SPORTS_EQUIPMENT);
             storeImgMapper.delete(deleteWrapper);
-            // 保存新图片,business_id存储facility_category
-            saveImages(facility.getFacilityCategory(), facility.getStoreId(), imageList);
+            // 保存新图片,business_id存储facility.id
+            saveImagesByFacilityId(facility.getId(), facility.getStoreId(), imageList);
         }
+        
+        log.info("保存设备设施成功,facilityId={},storeId={},areaId={},equipmentId={}", 
+                facility.getId(), facility.getStoreId(), facility.getAreaId(), equipmentId);
         return result;
     }
 
     @Override
-    public boolean updateFacility(SportsEquipmentFacility facility, List<String> imageList) {
-        // 校验图片数量(最多20张)
-        if (!CollectionUtils.isEmpty(imageList) && imageList.size() > 20) {
-            throw new RuntimeException("实景图片最多上传20张");
+    public boolean updateFacility(SportsEquipmentFacility facility, List<String> imageList, SportsEquipmentFacilityVo vo) {
+        log.info("修改设备设施,facility={},imageList大小={},vo={}", facility, 
+                imageList != null ? imageList.size() : 0, vo);
+        
+        // 参数验证
+        if (facility == null) {
+            log.warn("修改设备设施失败,设备信息为空");
+            throw new IllegalArgumentException("设备信息不能为空");
+        }
+        
+        // 验证:必须提供设施ID或设备ID之一
+        if (facility.getId() == null && (vo == null || vo.getEquipmentId() == null || vo.getEquipmentId() <= 0)) {
+            log.warn("修改设备设施失败,设施ID和设备ID都为空");
+            throw new IllegalArgumentException("设施ID或设备ID不能为空");
+        }
+        
+        if (facility.getStoreId() == null || facility.getStoreId() <= 0) {
+            log.warn("修改设备设施失败,门店ID无效:{}", facility.getStoreId());
+            throw new IllegalArgumentException("门店ID不能为空且必须大于0");
+        }
+        
+        // 校验图片数量(最多9张,根据UI需求)
+        if (!CollectionUtils.isEmpty(imageList) && imageList.size() > 9) {
+            log.warn("修改设备设施失败,图片数量超过限制:{}", imageList.size());
+            throw new RuntimeException("图片最多上传9张");
         }
         
         // 如果提供了areaId,验证区域是否存在且未删除
@@ -238,26 +417,256 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
             }
         }
         
-        // 更新设施信息
+        // 查询现有设施记录
+        // 如果vo中提供了equipmentId(fitness_equipment_info的ID),则根据设备ID查询设施记录
+        SportsEquipmentFacility existingFacility = null;
+        if (vo != null && vo.getEquipmentId() != null && vo.getEquipmentId() > 0) {
+            // 根据设备ID查询包含该设备的设施记录(包括已删除的记录,因为可能需要恢复)
+            // 由于@TableLogic的存在,先查询未删除的记录
+            LambdaQueryWrapper<SportsEquipmentFacility> queryWrapper = new LambdaQueryWrapper<>();
+            queryWrapper.like(SportsEquipmentFacility::getFitnessEquipmentIds, vo.getEquipmentId())
+                    .orderByDesc(SportsEquipmentFacility::getCreatedTime); // 按创建时间降序,取最新的
+            List<SportsEquipmentFacility> facilityList = facilityMapper.selectList(queryWrapper);
+            
+            if (!CollectionUtils.isEmpty(facilityList)) {
+                // 找到未删除的记录,取第一个
+                existingFacility = facilityList.get(0);
+            } else {
+                // 如果没有找到未删除的记录,查询已删除的记录(需要绕过@TableLogic)
+                // 使用自定义SQL查询包括已删除的记录
+                existingFacility = facilityMapper.selectByEquipmentIdIncludeDeleted(vo.getEquipmentId());
+                if (existingFacility != null) {
+                    log.info("根据设备ID查询到已删除的设施记录,equipmentId={},facilityId={},deleteFlag={}", 
+                            vo.getEquipmentId(), existingFacility.getId(), existingFacility.getDeleteFlag());
+                } else {
+                    log.warn("根据设备ID查询设施记录失败(包括已删除的记录),equipmentId={}", vo.getEquipmentId());
+                }
+            }
+            
+            if (existingFacility != null) {
+                // 更新facility的ID为查询到的设施ID
+                facility.setId(existingFacility.getId());
+                log.info("根据设备ID查询到设施记录,equipmentId={},facilityId={},deleteFlag={}", 
+                        vo.getEquipmentId(), existingFacility.getId(), existingFacility.getDeleteFlag());
+            }
+        } else if (facility.getId() != null) {
+            // 如果没有提供equipmentId,则根据设施ID查询
+            existingFacility = this.getById(facility.getId());
+        }
+        
+        if (existingFacility == null) {
+            log.warn("修改设备设施失败,设施不存在:facilityId={},equipmentId={}", 
+                    facility.getId(), vo != null ? vo.getEquipmentId() : null);
+            throw new IllegalArgumentException("设施不存在");
+        }
+        
+        // 如果设施已被删除,恢复它(设置deleteFlag为0)
+        if (existingFacility.getDeleteFlag() != null && existingFacility.getDeleteFlag() != DELETE_FLAG_NOT_DELETED) {
+            log.info("设施已被删除,恢复设施记录:facilityId={}", existingFacility.getId());
+            existingFacility.setDeleteFlag(DELETE_FLAG_NOT_DELETED);
+            facility.setDeleteFlag(DELETE_FLAG_NOT_DELETED);
+        }
+        
+        // 如果facilityCategory为null,设置默认值0(数据库要求不能为空)
+        if (facility.getFacilityCategory() == null) {
+            facility.setFacilityCategory(0);
+            log.info("修改设备时facilityCategory为null,已设置默认值0");
+        }
+        
+        // 如果facilityName为null,设置默认值为空字符串(数据库要求不能为空)
+        if (facility.getFacilityName() == null) {
+            facility.setFacilityName("");
+            log.info("修改设备时facilityName为null,已设置默认值为空字符串");
+        }
+        
+        // 1. 如果提供了设备信息(equipmentName),更新或创建FitnessEquipmentInfo记录
+        Integer equipmentId = null;
+        if (vo != null && StringUtils.isNotBlank(vo.getEquipmentName())) {
+            // 如果fitnessEquipmentIds不为空,说明已有设备,更新现有设备
+            String existingEquipmentIds = existingFacility.getFitnessEquipmentIds();
+            if (StringUtils.isNotBlank(existingEquipmentIds)) {
+                // 解析现有设备ID列表,取第一个设备ID进行更新
+                String[] equipmentIdArray = existingEquipmentIds.split(ID_SEPARATOR);
+                if (equipmentIdArray.length > 0) {
+                    try {
+                        equipmentId = Integer.parseInt(equipmentIdArray[0].trim());
+                        // 更新现有设备信息
+                        FitnessEquipmentInfo equipmentInfo = fitnessEquipmentInfoService.getById(equipmentId);
+                        if (equipmentInfo != null && equipmentInfo.getDeleteFlag() != null 
+                                && equipmentInfo.getDeleteFlag() == DELETE_FLAG_NOT_DELETED) {
+                            equipmentInfo.setEquipmentName(vo.getEquipmentName().trim());
+                            if (vo.getEquipmentNums() != null && vo.getEquipmentNums() > 0) {
+                                equipmentInfo.setEquipmentNums(vo.getEquipmentNums());
+                            }
+                            if (StringUtils.isNotBlank(vo.getEquipmentImage())) {
+                                equipmentInfo.setEquipmentImage(vo.getEquipmentImage());
+                            }
+                            boolean updateEquipmentResult = fitnessEquipmentInfoService.updateEquipment(equipmentInfo);
+                            if (updateEquipmentResult) {
+                                log.info("更新设备信息成功,equipmentId={},equipmentName={}", equipmentId, vo.getEquipmentName());
+                            } else {
+                                log.warn("更新设备信息失败,equipmentId={}", equipmentId);
+                                throw new RuntimeException("更新设备信息失败");
+                            }
+                        } else {
+                            // 设备不存在或已删除,创建新设备
+                            equipmentId = null;
+                        }
+                    } catch (NumberFormatException e) {
+                        log.warn("解析设备ID失败,existingEquipmentIds={},异常信息:{}", existingEquipmentIds, e.getMessage());
+                        equipmentId = null;
+                    }
+                }
+            }
+            
+            // 如果没有现有设备或设备已删除,创建新设备
+            if (equipmentId == null) {
+                FitnessEquipmentInfo equipmentInfo = new FitnessEquipmentInfo();
+                equipmentInfo.setEquipmentName(vo.getEquipmentName().trim());
+                // 设备类型默认为6(其他),因为UI中没有选择设备类型
+                equipmentInfo.setEquipmentType(6); // 6:其他
+                if (vo.getEquipmentNums() != null && vo.getEquipmentNums() > 0) {
+                    equipmentInfo.setEquipmentNums(vo.getEquipmentNums());
+                } else {
+                    equipmentInfo.setEquipmentNums(1); // 默认数量为1
+                }
+                if (StringUtils.isNotBlank(vo.getEquipmentImage())) {
+                    equipmentInfo.setEquipmentImage(vo.getEquipmentImage());
+                }
+                // 设置默认值
+                equipmentInfo.setSortOrder(0);
+                equipmentInfo.setStatus(STATUS_ENABLED);
+                equipmentInfo.setDeleteFlag(DELETE_FLAG_NOT_DELETED);
+                
+                boolean saveEquipmentResult = fitnessEquipmentInfoService.saveEquipment(equipmentInfo);
+                if (saveEquipmentResult && equipmentInfo.getId() != null) {
+                    equipmentId = equipmentInfo.getId();
+                    log.info("创建设备信息成功,equipmentId={},equipmentName={}", equipmentId, vo.getEquipmentName());
+                } else {
+                    log.warn("创建设备信息失败,equipmentName={}", vo.getEquipmentName());
+                    throw new RuntimeException("创建设备信息失败");
+                }
+            }
+        }
+        
+        // 2. 更新设施信息
+        // 如果更新了设备信息,更新fitnessEquipmentIds字段
+        if (equipmentId != null) {
+            facility.setFitnessEquipmentIds(String.valueOf(equipmentId));
+        }
+        
         boolean result = this.updateById(facility);
-        if (result && !CollectionUtils.isEmpty(imageList) && facility.getFacilityCategory() != null) {
-            // 删除该分类下的旧图片
+        if (!result) {
+            log.error("修改设备设施失败,更新数据库失败:facility={}", facility);
+            throw new RuntimeException("修改设备设施失败");
+        }
+        
+        // 3. 保存图片,使用facility.id作为business_id
+        if (!CollectionUtils.isEmpty(imageList) && facility.getId() != null) {
+            // 删除该设施下的旧图片(如果存在)
             LambdaQueryWrapper<StoreImg> deleteWrapper = new LambdaQueryWrapper<>();
             deleteWrapper.eq(StoreImg::getStoreId, facility.getStoreId())
-                    .eq(StoreImg::getBusinessId, facility.getFacilityCategory())
+                    .eq(StoreImg::getBusinessId, facility.getId())
                     .eq(StoreImg::getImgType, IMG_TYPE_SPORTS_EQUIPMENT);
             storeImgMapper.delete(deleteWrapper);
-            // 保存新图片,business_id存储facility_category
-            saveImages(facility.getFacilityCategory(), facility.getStoreId(), imageList);
+            // 保存新图片,business_id存储facility.id
+            saveImagesByFacilityId(facility.getId(), facility.getStoreId(), imageList);
         }
+        
+        log.info("修改设备设施成功,facilityId={},storeId={},areaId={},equipmentId={}", 
+                facility.getId(), facility.getStoreId(), facility.getAreaId(), equipmentId);
         return result;
     }
 
     @Override
-    public boolean deleteFacility(Integer id) {
-        // 注意:图片和设施没有关系,只和facility_category有关系,所以删除设施时不删除图片
-        // 删除设施
-        return this.removeById(id);
+    public boolean deleteFacility(Integer equipmentId) {
+        log.info("删除设备设施,equipmentId={}", equipmentId);
+        
+        // 参数验证
+        if (equipmentId == null || equipmentId <= 0) {
+            log.warn("删除设备设施失败,设备ID无效:{}", equipmentId);
+            throw new IllegalArgumentException("设备ID不能为空且必须大于0");
+        }
+        
+        // 验证设备是否存在
+        FitnessEquipmentInfo equipmentInfo = fitnessEquipmentInfoService.getById(equipmentId);
+        if (equipmentInfo == null || equipmentInfo.getDeleteFlag() == null 
+                || equipmentInfo.getDeleteFlag() != DELETE_FLAG_NOT_DELETED) {
+            log.warn("删除设备设施失败,设备不存在或已删除:equipmentId={}", equipmentId);
+            throw new IllegalArgumentException("设备不存在或已删除");
+        }
+        
+        // 1. 查询所有包含该设备ID的设施记录
+        LambdaQueryWrapper<SportsEquipmentFacility> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(SportsEquipmentFacility::getDeleteFlag, DELETE_FLAG_NOT_DELETED)
+                .like(SportsEquipmentFacility::getFitnessEquipmentIds, equipmentId);
+        List<SportsEquipmentFacility> facilityList = this.list(queryWrapper);
+        
+        if (CollectionUtils.isEmpty(facilityList)) {
+            log.warn("删除设备设施失败,未找到包含该设备ID的设施记录:equipmentId={}", equipmentId);
+            // 即使没有找到设施记录,也删除设备信息
+            boolean deleteEquipmentResult = fitnessEquipmentInfoService.deleteEquipment(equipmentId);
+            return deleteEquipmentResult;
+        }
+        
+        // 2. 对每个设施记录,从fitnessEquipmentIds中移除该设备ID
+        for (SportsEquipmentFacility facility : facilityList) {
+            String fitnessEquipmentIds = facility.getFitnessEquipmentIds();
+            if (StringUtils.isNotBlank(fitnessEquipmentIds)) {
+                // 解析设备ID列表
+                List<String> equipmentIdList = new ArrayList<>();
+                String[] equipmentIdArray = fitnessEquipmentIds.split(ID_SEPARATOR);
+                for (String idStr : equipmentIdArray) {
+                    String trimmedId = idStr.trim();
+                    if (StringUtils.isNotBlank(trimmedId)) {
+                        try {
+                            Integer id = Integer.parseInt(trimmedId);
+                            // 如果不是要删除的设备ID,保留
+                            if (!id.equals(equipmentId)) {
+                                equipmentIdList.add(trimmedId);
+                            }
+                        } catch (NumberFormatException e) {
+                            log.warn("解析设备ID失败,idStr={},异常信息:{}", idStr, e.getMessage());
+                        }
+                    }
+                }
+                
+                // 更新设施的fitnessEquipmentIds
+                if (equipmentIdList.isEmpty()) {
+                    // 如果移除后设备列表为空,删除该设施
+                    boolean deleteFacilityResult = this.removeById(facility.getId());
+                    if (deleteFacilityResult) {
+                        log.info("删除设施成功(设备列表为空),facilityId={},equipmentId={}", 
+                                facility.getId(), equipmentId);
+                    } else {
+                        log.warn("删除设施失败(设备列表为空),facilityId={},equipmentId={}", 
+                                facility.getId(), equipmentId);
+                    }
+                } else {
+                    // 如果移除后设备列表不为空,更新设施的设备ID列表
+                    String newFitnessEquipmentIds = String.join(ID_SEPARATOR, equipmentIdList);
+                    facility.setFitnessEquipmentIds(newFitnessEquipmentIds);
+                    boolean updateFacilityResult = this.updateById(facility);
+                    if (updateFacilityResult) {
+                        log.info("更新设施设备ID列表成功,facilityId={},equipmentId={},新设备ID列表:{}", 
+                                facility.getId(), equipmentId, newFitnessEquipmentIds);
+                    } else {
+                        log.warn("更新设施设备ID列表失败,facilityId={},equipmentId={}", 
+                                facility.getId(), equipmentId);
+                    }
+                }
+            }
+        }
+        
+        // 3. 逻辑删除设备信息
+        boolean deleteEquipmentResult = fitnessEquipmentInfoService.deleteEquipment(equipmentId);
+        if (deleteEquipmentResult) {
+            log.info("删除设备信息成功,equipmentId={}", equipmentId);
+        } else {
+            log.warn("删除设备信息失败,equipmentId={}", equipmentId);
+        }
+        
+        return deleteEquipmentResult;
     }
 
     /**
@@ -861,7 +1270,27 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
     }
 
     /**
-     * 保存图片
+     * 保存图片(使用facility.id作为business_id)
+     * 
+     * @param facilityId 设施ID
+     * @param storeId 门店ID
+     * @param imageList 图片列表
+     */
+    private void saveImagesByFacilityId(Integer facilityId, Integer storeId, List<String> imageList) {
+        for (int i = 0; i < imageList.size(); i++) {
+            StoreImg storeImg = new StoreImg();
+            storeImg.setStoreId(storeId);
+            storeImg.setImgType(IMG_TYPE_SPORTS_EQUIPMENT);
+            storeImg.setBusinessId(facilityId); // business_id存储facility.id
+            storeImg.setImgUrl(imageList.get(i));
+            storeImg.setImgSort(i + 1);
+            storeImg.setImgDescription("运动器材设施实景图片");
+            storeImgMapper.insert(storeImg);
+        }
+    }
+    
+    /**
+     * 保存图片(旧方法,保留用于兼容,使用facility_category作为business_id)
      * 
      * @param facilityCategory 设施分类
      * @param storeId 门店ID
@@ -895,17 +1324,58 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
         if (facility.getDisplayInStoreDetail() != null) {
             vo.setDisplayInStoreDetailText(facility.getDisplayInStoreDetail() == 1 ? "显示" : "隐藏");
         }
-        // 查询图片列表,根据store_id和facility_category查询
-        LambdaQueryWrapper<StoreImg> imageWrapper = new LambdaQueryWrapper<>();
-        imageWrapper.eq(StoreImg::getStoreId, facility.getStoreId())
-                .eq(StoreImg::getBusinessId, facility.getFacilityCategory())
-                .eq(StoreImg::getImgType, IMG_TYPE_SPORTS_EQUIPMENT);
-        imageWrapper.orderByAsc(StoreImg::getImgSort);
-        List<StoreImg> imageList = storeImgMapper.selectList(imageWrapper);
-        if (!CollectionUtils.isEmpty(imageList)) {
-            vo.setImageList(imageList.stream().map(StoreImg::getImgUrl)
-                    .collect(Collectors.toList()));
+        
+        // 查询图片列表,优先使用facility.id作为business_id,兼容历史数据使用facility_category
+        List<String> imageList = new ArrayList<>();
+        if (facility.getId() != null) {
+            // 优先查询使用facility.id作为business_id的图片(新数据)
+            LambdaQueryWrapper<StoreImg> imageWrapper = new LambdaQueryWrapper<>();
+            imageWrapper.eq(StoreImg::getStoreId, facility.getStoreId())
+                    .eq(StoreImg::getBusinessId, facility.getId())
+                    .eq(StoreImg::getImgType, IMG_TYPE_SPORTS_EQUIPMENT)
+                    .orderByAsc(StoreImg::getImgSort);
+            List<StoreImg> imageListByFacilityId = storeImgMapper.selectList(imageWrapper);
+            if (!CollectionUtils.isEmpty(imageListByFacilityId)) {
+                imageList = imageListByFacilityId.stream().map(StoreImg::getImgUrl)
+                        .collect(Collectors.toList());
+            } else if (facility.getFacilityCategory() != null) {
+                // 如果没有找到,尝试使用facility_category查询(兼容历史数据)
+                LambdaQueryWrapper<StoreImg> imageWrapperByCategory = new LambdaQueryWrapper<>();
+                imageWrapperByCategory.eq(StoreImg::getStoreId, facility.getStoreId())
+                        .eq(StoreImg::getBusinessId, facility.getFacilityCategory())
+                        .eq(StoreImg::getImgType, IMG_TYPE_SPORTS_EQUIPMENT)
+                        .orderByAsc(StoreImg::getImgSort);
+                List<StoreImg> imageListByCategory = storeImgMapper.selectList(imageWrapperByCategory);
+                if (!CollectionUtils.isEmpty(imageListByCategory)) {
+                    imageList = imageListByCategory.stream().map(StoreImg::getImgUrl)
+                            .collect(Collectors.toList());
+                }
+            }
+        }
+        vo.setImageList(imageList);
+        
+        // 如果fitnessEquipmentIds不为空,查询关联的设备信息
+        if (StringUtils.isNotBlank(facility.getFitnessEquipmentIds())) {
+            // 解析设备ID列表
+            List<Integer> equipmentIdList = new ArrayList<>();
+            String[] equipmentIdArray = facility.getFitnessEquipmentIds().split(ID_SEPARATOR);
+            for (String equipmentIdStr : equipmentIdArray) {
+                try {
+                    Integer equipmentId = Integer.parseInt(equipmentIdStr.trim());
+                    equipmentIdList.add(equipmentId);
+                } catch (NumberFormatException e) {
+                    log.warn("解析设备ID失败,equipmentIdStr={},异常信息:{}", equipmentIdStr, e.getMessage());
+                }
+            }
+            
+            if (!CollectionUtils.isEmpty(equipmentIdList)) {
+                // 查询设备信息(用于后续扩展,当前vo中没有equipmentList字段)
+                // List<FitnessEquipmentInfo> equipmentList = new ArrayList<>(
+                //         fitnessEquipmentInfoService.listByIds(equipmentIdList));
+                // 注意:如果需要返回设备信息,可以在vo中添加equipmentList字段
+            }
         }
+        
         return vo;
     }
 

+ 2 - 51
alien-store/src/main/java/shop/alien/store/service/impl/SportsFacilityAreaServiceImpl.java

@@ -18,8 +18,6 @@ import shop.alien.mapper.StoreImgMapper;
 import shop.alien.store.service.SportsFacilityAreaService;
 
 import java.util.List;
-import java.util.Set;
-import java.util.stream.Collectors;
 
 /**
  * 运动设施区域服务实现类
@@ -181,25 +179,7 @@ public class SportsFacilityAreaServiceImpl extends ServiceImpl<SportsFacilityAre
             throw new IllegalArgumentException("区域不存在或已删除");
         }
 
-        // 处理唯一索引冲突:如果存在同名且已删除的记录,先物理删除它们
-        LambdaQueryWrapper<SportsFacilityArea> conflictWrapper = new LambdaQueryWrapper<>();
-        conflictWrapper.eq(SportsFacilityArea::getStoreId, area.getStoreId())
-                .eq(SportsFacilityArea::getAreaName, area.getAreaName())
-                .eq(SportsFacilityArea::getDeleteFlag, DELETE_FLAG_DELETED)
-                .ne(SportsFacilityArea::getId, areaId); // 排除当前要删除的记录
-        List<SportsFacilityArea> conflictAreas = this.list(conflictWrapper);
-        
-        if (!CollectionUtils.isEmpty(conflictAreas)) {
-            // 物理删除冲突的记录(已删除的重复记录)
-            List<Integer> conflictIds = conflictAreas.stream()
-                    .map(SportsFacilityArea::getId)
-                    .collect(Collectors.toList());
-            this.removeByIds(conflictIds);
-            log.info("物理删除冲突的已删除区域记录,storeId={},areaName={},冲突记录ID={}", 
-                    area.getStoreId(), area.getAreaName(), conflictIds);
-        }
-
-        // 1. 逻辑删除区域
+        // 1. 逻辑删除区域(区域名称允许重复,无需处理唯一索引冲突)
         LambdaUpdateWrapper<SportsFacilityArea> areaUpdateWrapper = new LambdaUpdateWrapper<>();
         areaUpdateWrapper.eq(SportsFacilityArea::getId, areaId)
                 .set(SportsFacilityArea::getDeleteFlag, DELETE_FLAG_DELETED);
@@ -249,36 +229,7 @@ public class SportsFacilityAreaServiceImpl extends ServiceImpl<SportsFacilityAre
             throw new IllegalArgumentException("部分区域不存在或不属于该门店");
         }
 
-        // 查询要删除的区域信息,用于检查唯一索引冲突
-        List<SportsFacilityArea> areasToDelete = this.list(checkWrapper);
-        
-        // 处理唯一索引冲突:在逻辑删除之前,先物理删除所有已删除的同名记录
-        // 这样可以避免将当前记录设置为已删除时,与已存在的已删除同名记录冲突
-        Set<String> areaNames = areasToDelete.stream()
-                .map(SportsFacilityArea::getAreaName)
-                .collect(Collectors.toSet());
-        
-        for (String areaName : areaNames) {
-            // 查询所有已删除的同名记录(包括当前要删除的记录之外的同名已删除记录)
-            LambdaQueryWrapper<SportsFacilityArea> conflictWrapper = new LambdaQueryWrapper<>();
-            conflictWrapper.eq(SportsFacilityArea::getStoreId, storeId)
-                    .eq(SportsFacilityArea::getAreaName, areaName)
-                    .eq(SportsFacilityArea::getDeleteFlag, DELETE_FLAG_DELETED)
-                    .notIn(SportsFacilityArea::getId, areaIds); // 排除当前要删除的记录(它们还未删除)
-            List<SportsFacilityArea> conflictAreas = this.list(conflictWrapper);
-            
-            if (!CollectionUtils.isEmpty(conflictAreas)) {
-                // 物理删除冲突的记录(已删除的重复记录)
-                List<Integer> conflictIds = conflictAreas.stream()
-                        .map(SportsFacilityArea::getId)
-                        .collect(Collectors.toList());
-                this.removeByIds(conflictIds);
-                log.info("物理删除冲突的已删除区域记录,storeId={},areaName={},冲突记录ID={}", 
-                        storeId, areaName, conflictIds);
-            }
-        }
-
-        // 1. 批量逻辑删除区域
+        // 1. 批量逻辑删除区域(区域名称允许重复,无需处理唯一索引冲突)
         LambdaUpdateWrapper<SportsFacilityArea> areaUpdateWrapper = new LambdaUpdateWrapper<>();
         areaUpdateWrapper.eq(SportsFacilityArea::getStoreId, storeId)
                 .in(SportsFacilityArea::getId, areaIds)