5 Commity d9b2bfcfc5 ... 25853ec804

Autor SHA1 Wiadomość Data
  panzhilin 25853ec804 Merge remote-tracking branch 'origin/release_20260123' into release_20260123 3 miesięcy temu
  panzhilin 43eb0936f1 Fix:酒吧演出同步人员配置的数据 3 miesięcy temu
  panzhilin 7af619b350 BUGFix:2424 价目表(0115):菜品新建页面,预约规则未设置为必填项 3 miesięcy temu
  panzhilin 1591028bf0 Fix:区域设施设备列表图片不显示 3 miesięcy temu
  panzhilin c6a911b928 Fix:酒吧演出将单次演出时间截取给到演出开始和结束的时间字段 3 miesięcy temu

+ 117 - 4
alien-store/src/main/java/shop/alien/store/service/impl/BarPerformanceServiceImpl.java

@@ -18,6 +18,8 @@ import shop.alien.mapper.StoreStaffConfigMapper;
 import shop.alien.store.service.BarPerformanceService;
 import shop.alien.store.util.ai.AiContentModerationUtil;
 
+import java.time.LocalTime;
+import java.time.ZoneId;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -115,13 +117,22 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
                 if (barPerformance.getDailyStartDate().after(barPerformance.getDailyEndDate())) {
                     throw new IllegalArgumentException("开始日期不能晚于结束日期");
                 }
-                // 验证时间字段(复用single_start_datetime和single_end_datetime,只使用时间部分)
+                // 验证时间字段(使用single_start_datetime和single_end_datetime,提取时间部分)
                 if (barPerformance.getSingleStartDatetime() == null) {
                     throw new IllegalArgumentException("每天定时演出必须填写开始时间");
                 }
                 if (barPerformance.getSingleEndDatetime() == null) {
                     throw new IllegalArgumentException("每天定时演出必须填写结束时间");
                 }
+                // 从single_start_datetime和single_end_datetime中提取时间部分,存到daily_start_time和daily_end_time
+                LocalTime startTime = barPerformance.getSingleStartDatetime().toInstant()
+                        .atZone(ZoneId.systemDefault())
+                        .toLocalTime();
+                LocalTime endTime = barPerformance.getSingleEndDatetime().toInstant()
+                        .atZone(ZoneId.systemDefault())
+                        .toLocalTime();
+                barPerformance.setDailyStartTime(startTime);
+                barPerformance.setDailyEndTime(endTime);
                 // 每天定时不需要周天数据,清除周天字段(设置为空字符串,确保数据库插入时包含该字段)
                 barPerformance.setPerformanceWeek("");
                 break;
@@ -144,13 +155,22 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
                 if (StringUtils.isEmpty(barPerformance.getPerformanceWeek())) {
                     throw new IllegalArgumentException("每周定时演出必须选择演出日期");
                 }
-                // 验证时间字段(复用single_start_datetime和single_end_datetime,只使用时间部分)
+                // 验证时间字段(使用single_start_datetime和single_end_datetime,提取时间部分)
                 if (barPerformance.getSingleStartDatetime() == null) {
                     throw new IllegalArgumentException("每周定时演出必须填写开始时间");
                 }
                 if (barPerformance.getSingleEndDatetime() == null) {
                     throw new IllegalArgumentException("每周定时演出必须填写结束时间");
                 }
+                // 从single_start_datetime和single_end_datetime中提取时间部分,存到daily_start_time和daily_end_time
+                LocalTime weeklyStartTime = barPerformance.getSingleStartDatetime().toInstant()
+                        .atZone(ZoneId.systemDefault())
+                        .toLocalTime();
+                LocalTime weeklyEndTime = barPerformance.getSingleEndDatetime().toInstant()
+                        .atZone(ZoneId.systemDefault())
+                        .toLocalTime();
+                barPerformance.setDailyStartTime(weeklyStartTime);
+                barPerformance.setDailyEndTime(weeklyEndTime);
                 break;
             default:
                 throw new IllegalArgumentException("演出频次类型无效");
@@ -341,11 +361,34 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
             return null;
         }
 
+        // 检查并更新已删除的员工配置ID
+        String originalStaffConfigIds = barPerformance.getStaffConfigIds();
+        String updatedStaffConfigIds = checkAndUpdateDeletedStaff(originalStaffConfigIds);
+        
+        // 如果员工配置ID有变化,更新数据库
+        if (updatedStaffConfigIds != null && !updatedStaffConfigIds.equals(originalStaffConfigIds)) {
+            try {
+                LambdaUpdateWrapper<BarPerformance> updateWrapper = new LambdaUpdateWrapper<>();
+                updateWrapper.eq(BarPerformance::getId, id);
+                updateWrapper.set(BarPerformance::getStaffConfigIds, updatedStaffConfigIds);
+                int updateResult = barPerformanceMapper.update(null, updateWrapper);
+                if (updateResult > 0) {
+                    // 更新成功,同步更新本地对象
+                    barPerformance.setStaffConfigIds(updatedStaffConfigIds);
+                    log.info("酒吧演出ID={}的演出嘉宾字段已更新,原值:{},新值:{}", 
+                            id, originalStaffConfigIds, updatedStaffConfigIds);
+                }
+            } catch (Exception e) {
+                log.error("更新酒吧演出ID={}的演出嘉宾字段失败,异常信息:{}", 
+                        id, e.getMessage(), e);
+            }
+        }
+
         // 转换为VO对象
         BarPerformanceDetailVo detailVo = new BarPerformanceDetailVo();
         BeanUtils.copyProperties(barPerformance, detailVo);
 
-        // 查询并设置表演嘉宾列表
+        // 查询并设置表演嘉宾列表(使用更新后的staffConfigIds)
         List<PerformerVo> performers = queryPerformersByStaffConfigIds(barPerformance.getStaffConfigIds());
         detailVo.setPerformers(performers);
 
@@ -353,6 +396,76 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
     }
 
     /**
+     * 检查并更新已删除的员工配置ID
+     * 如果发现员工被删除,从staffConfigIds中移除这些已删除的员工ID
+     * 
+     * @param staffConfigIds 员工配置ID字符串,逗号分隔,如 "41,25"
+     * @return 更新后的员工配置ID字符串,如果无变化则返回原值
+     */
+    private String checkAndUpdateDeletedStaff(String staffConfigIds) {
+        if (StringUtils.isEmpty(staffConfigIds)) {
+            return staffConfigIds;
+        }
+
+        try {
+            // 解析员工ID字符串
+            String[] idArray = staffConfigIds.split(",");
+            List<Integer> originalStaffIdList = new ArrayList<>();
+            
+            for (String idStr : idArray) {
+                if (StringUtils.isNotEmpty(idStr.trim())) {
+                    try {
+                        Integer staffId = Integer.parseInt(idStr.trim());
+                        if (staffId > 0) {
+                            originalStaffIdList.add(staffId);
+                        }
+                    } catch (NumberFormatException e) {
+                        log.warn("解析员工配置ID失败,无效的ID:{}", idStr);
+                    }
+                }
+            }
+
+            if (originalStaffIdList.isEmpty()) {
+                return staffConfigIds;
+            }
+
+            // 批量查询员工配置信息(MyBatis-Plus的selectBatchIds会自动过滤已删除的记录)
+            List<StoreStaffConfig> staffList = storeStaffConfigMapper.selectBatchIds(originalStaffIdList);
+            
+            // 获取实际查询到的员工ID列表(未删除的员工)
+            final List<Integer> existingStaffIdList;
+            if (staffList != null && !staffList.isEmpty()) {
+                existingStaffIdList = staffList.stream()
+                        .filter(staff -> staff != null && staff.getDeleteFlag() != null && staff.getDeleteFlag() == 0)
+                        .map(StoreStaffConfig::getId)
+                        .collect(Collectors.toList());
+            } else {
+                existingStaffIdList = new ArrayList<>();
+            }
+
+            // 比较原始ID列表和查询到的ID列表,找出被删除的员工ID
+            List<Integer> deletedStaffIdList = originalStaffIdList.stream()
+                    .filter(id -> !existingStaffIdList.contains(id))
+                    .collect(Collectors.toList());
+
+            // 如果有员工被删除,更新staffConfigIds字段
+            if (!deletedStaffIdList.isEmpty()) {
+                log.info("发现酒吧演出关联的员工被删除,员工ID列表:{}", deletedStaffIdList);
+                // 构建新的staffConfigIds字符串(只包含未删除的员工ID)
+                String updatedStaffConfigIds = existingStaffIdList.stream()
+                        .map(String::valueOf)
+                        .collect(Collectors.joining(","));
+                return updatedStaffConfigIds;
+            }
+        } catch (Exception e) {
+            log.error("检查并更新已删除的员工配置ID异常,staffConfigIds={},异常信息:{}", 
+                    staffConfigIds, e.getMessage(), e);
+        }
+
+        return staffConfigIds;
+    }
+
+    /**
      * 根据员工配置ID字符串查询表演嘉宾列表
      * 
      * @param staffConfigIds 员工配置ID字符串,逗号分隔,如 "41,25"
@@ -387,7 +500,7 @@ public class BarPerformanceServiceImpl implements BarPerformanceService {
                 return performerList;
             }
 
-            // 批量查询员工配置信息
+            // 批量查询员工配置信息(MyBatis-Plus的selectBatchIds会自动过滤已删除的记录)
             List<StoreStaffConfig> staffList = storeStaffConfigMapper.selectBatchIds(staffIdList);
             
             if (staffList != null && !staffList.isEmpty()) {

+ 20 - 4
alien-store/src/main/java/shop/alien/store/service/impl/SportsEquipmentFacilityServiceImpl.java

@@ -1421,10 +1421,26 @@ public class SportsEquipmentFacilityServiceImpl extends ServiceImpl<SportsEquipm
             }
             
             if (!CollectionUtils.isEmpty(equipmentIdList)) {
-                // 查询设备信息(用于后续扩展,当前vo中没有equipmentList字段)
-                // List<FitnessEquipmentInfo> equipmentList = new ArrayList<>(
-                //         fitnessEquipmentInfoService.listByIds(equipmentIdList));
-                // 注意:如果需要返回设备信息,可以在vo中添加equipmentList字段
+                // 查询设备信息,设置设备相关字段(取第一个设备的信息)
+                List<FitnessEquipmentInfo> equipmentList = new ArrayList<>(
+                        fitnessEquipmentInfoService.listByIds(equipmentIdList));
+                if (!CollectionUtils.isEmpty(equipmentList)) {
+                    // 取第一个设备的信息(如果有多个设备,取第一个)
+                    FitnessEquipmentInfo firstEquipment = equipmentList.get(0);
+                    if (firstEquipment != null) {
+                        // 设置设备ID
+                        vo.setEquipmentId(firstEquipment.getId());
+                        // 设置设备名称
+                        vo.setEquipmentName(firstEquipment.getEquipmentName());
+                        // 设置设备数量
+                        vo.setEquipmentNums(firstEquipment.getEquipmentNums());
+                        // 设置设备图片URL
+                        vo.setEquipmentImage(firstEquipment.getEquipmentImage());
+                        log.info("设置设备信息到VO,equipmentId={},equipmentName={},equipmentImage={}", 
+                                firstEquipment.getId(), firstEquipment.getEquipmentName(), 
+                                firstEquipment.getEquipmentImage());
+                    }
+                }
             }
         }
         

+ 15 - 1
alien-store/src/main/java/shop/alien/store/service/impl/StoreCuisineServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fasterxml.jackson.core.type.TypeReference;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -22,7 +23,6 @@ import shop.alien.store.service.StoreCuisineService;
 
 import java.io.IOException;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -49,6 +49,13 @@ public class StoreCuisineServiceImpl extends ServiceImpl<StoreCuisineMapper, Sto
      */
     @Override
     public boolean addCuisineCombo(CuisineComboDto cuisineComboDto) {
+        // 验证:如果需要预约,预约规则必填
+        if (cuisineComboDto.getNeedReserve() != null && cuisineComboDto.getNeedReserve() == 1) {
+            if (StringUtils.isBlank(cuisineComboDto.getReserveRule())) {
+                throw new IllegalArgumentException("需要预约时,预约规则不能为空");
+            }
+        }
+        
         // 1. 保存主表信息到 store_cuisine
         StoreCuisine cuisine = new StoreCuisine();
         BeanUtils.copyProperties(cuisineComboDto, cuisine);
@@ -70,6 +77,13 @@ public class StoreCuisineServiceImpl extends ServiceImpl<StoreCuisineMapper, Sto
      */
     @Override
     public boolean updateCuisineCombo(CuisineComboDto cuisineComboDto) {
+        // 验证:如果需要预约,预约规则必填
+        if (cuisineComboDto.getNeedReserve() != null && cuisineComboDto.getNeedReserve() == 1) {
+            if (StringUtils.isBlank(cuisineComboDto.getReserveRule())) {
+                throw new IllegalArgumentException("需要预约时,预约规则不能为空");
+            }
+        }
+        
         Integer comboId = cuisineComboDto.getId();
 
         // 1. 更新主表信息