Переглянути джерело

Fix:酒吧演出将单次演出时间截取给到演出开始和结束的时间字段

panzhilin 3 місяців тому
батько
коміт
c6a911b928

+ 22 - 2
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("演出频次类型无效");