|
@@ -209,30 +209,43 @@ public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> impl
|
|
|
// 解析教学日和非教学日数据
|
|
// 解析教学日和非教学日数据
|
|
|
List<OrderVO.TimeSlotData> teachingList = parseTimeSlotData(appSite.getTeachingDay());
|
|
List<OrderVO.TimeSlotData> teachingList = parseTimeSlotData(appSite.getTeachingDay());
|
|
|
List<OrderVO.TimeSlotData> nonTeachingList = parseTimeSlotData(appSite.getNoTeachingDay());
|
|
List<OrderVO.TimeSlotData> nonTeachingList = parseTimeSlotData(appSite.getNoTeachingDay());
|
|
|
|
|
+
|
|
|
|
|
+ log.info("[previewOrderPlaceSchool] placeId={}, startTime={}, teachingList={}, nonTeachingList={}",
|
|
|
|
|
+ placeId, DateUtil.format(startTime, "yyyy-MM-dd"), appSite.getTeachingDay(), appSite.getNoTeachingDay());
|
|
|
|
|
|
|
|
timeSlot.forEach(a -> {
|
|
timeSlot.forEach(a -> {
|
|
|
- LocalTime slotStart = LocalTime.parse(DateUtil.format(a.getStartTime(), "HH:mm"));
|
|
|
|
|
- LocalTime slotEnd = LocalTime.parse(DateUtil.format(a.getEndTime(), "HH:mm"));
|
|
|
|
|
|
|
+ // is_teaching: 0=是(教学日), 1=否(非教学日)
|
|
|
boolean isTeaching = a.getIsTeaching() == 0;
|
|
boolean isTeaching = a.getIsTeaching() == 0;
|
|
|
List<OrderVO.TimeSlotData> targetList = isTeaching ? teachingList : nonTeachingList;
|
|
List<OrderVO.TimeSlotData> targetList = isTeaching ? teachingList : nonTeachingList;
|
|
|
- Optional<OrderVO.TimeSlotData> matchedSlot = targetList.stream()
|
|
|
|
|
- .filter(t -> {
|
|
|
|
|
- LocalTime invStart = LocalTime.parse(t.getStartTime());
|
|
|
|
|
- LocalTime invEnd = LocalTime.parse(t.getEndTime());
|
|
|
|
|
- // 严格匹配有交集的时间段(不包含端点相接)
|
|
|
|
|
- return invStart.isBefore(invEnd) && slotStart.isBefore(invEnd) && slotEnd.isAfter(invStart);
|
|
|
|
|
- })
|
|
|
|
|
- .findFirst();
|
|
|
|
|
- matchedSlot.ifPresent(timeSlotData -> {
|
|
|
|
|
- int totalInventory = Integer.parseInt(timeSlotData.getTicketNum());
|
|
|
|
|
- int bookedCount = appOrderMapper.queryBookedCount(
|
|
|
|
|
- placeId,
|
|
|
|
|
- DateUtil.format(startTime, "yyyy-MM-dd"),
|
|
|
|
|
- timeSlotData.getStartTime(),
|
|
|
|
|
- timeSlotData.getEndTime()
|
|
|
|
|
- );
|
|
|
|
|
- a.setInventory(totalInventory - bookedCount);
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ log.info("[previewOrderPlaceSchool] 原始timeSlot: is_teaching={}, 使用配置={}, startTime={}, endTime={}",
|
|
|
|
|
+ a.getIsTeaching(), isTeaching ? "教学日" : "非教学日", a.getStartTime(), a.getEndTime());
|
|
|
|
|
+
|
|
|
|
|
+ // 根据 is_teaching 动态替换时间段配置
|
|
|
|
|
+ if (!targetList.isEmpty()) {
|
|
|
|
|
+ OrderVO.TimeSlotData timeSlotData = targetList.get(0);
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 更新时间段
|
|
|
|
|
+ LocalTime newStartTime = LocalTime.parse(timeSlotData.getStartTime(), DateTimeFormatter.ofPattern("HH:mm"));
|
|
|
|
|
+ LocalTime newEndTime = LocalTime.parse(timeSlotData.getEndTime(), DateTimeFormatter.ofPattern("HH:mm"));
|
|
|
|
|
+ a.setStartTime(java.sql.Time.valueOf(newStartTime));
|
|
|
|
|
+ a.setEndTime(java.sql.Time.valueOf(newEndTime));
|
|
|
|
|
+ a.setName(timeSlotData.getStartTime() + "-" + timeSlotData.getEndTime());
|
|
|
|
|
+
|
|
|
|
|
+ // 计算库存
|
|
|
|
|
+ int totalInventory = Integer.parseInt(timeSlotData.getTicketNum());
|
|
|
|
|
+ int bookedCount = appOrderMapper.queryBookedCount(
|
|
|
|
|
+ placeId,
|
|
|
|
|
+ DateUtil.format(startTime, "yyyy-MM-dd"),
|
|
|
|
|
+ timeSlotData.getStartTime(),
|
|
|
|
|
+ timeSlotData.getEndTime()
|
|
|
|
|
+ );
|
|
|
|
|
+ a.setInventory(totalInventory - bookedCount);
|
|
|
|
|
+ log.info("[previewOrderPlaceSchool] 更新后timeSlot: startTime={}, endTime={}, inventory={}",
|
|
|
|
|
+ a.getStartTime(), a.getEndTime(), a.getInventory());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("[previewOrderPlaceSchool] 解析时间段失败: {}", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
AppSitePlace appSitePlace = appSitePlaceMapper.selectById(placeId);
|
|
AppSitePlace appSitePlace = appSitePlaceMapper.selectById(placeId);
|
|
|
previewOrderPlaceSchool.setName(appSite.getName())
|
|
previewOrderPlaceSchool.setName(appSite.getName())
|
|
@@ -360,13 +373,50 @@ public class OrderServiceImpl extends ServiceImpl<AppOrderMapper, AppOrder> impl
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public List<OrderVO.PreviewOrderPlaceSchoolTime> previewOrderPlaceSchoolTime(String placeId) {
|
|
public List<OrderVO.PreviewOrderPlaceSchoolTime> previewOrderPlaceSchoolTime(String placeId) {
|
|
|
- List<OrderVO.PreviewOrderPlaceSchoolTime> previewOrderPlaceSchoolTimes = appTeachingTimeMapper.previewOrderPlaceSchoolTime(appSitePlaceMapper.selectById(placeId).getOrgCode());
|
|
|
|
|
- AppSite appSite = appSiteMapper.selectOne(Wrappers.<AppSite>lambdaQuery().eq(AppSite::getId, appSitePlaceMapper.selectById(placeId).getSiteId()));
|
|
|
|
|
|
|
+ AppSitePlace sitePlace = appSitePlaceMapper.selectById(placeId);
|
|
|
|
|
+ String orgCode = sitePlace.getOrgCode();
|
|
|
|
|
+ log.info("[previewOrderPlaceSchoolTime] placeId={}, orgCode={}, siteId={}", placeId, orgCode, sitePlace.getSiteId());
|
|
|
|
|
+
|
|
|
|
|
+ // 直接查询 nm_teaching_time 表的原始数据,确认数据库中的配置
|
|
|
|
|
+ List<AppTeachingTime> rawTeachingTimes = appTeachingTimeMapper.selectList(
|
|
|
|
|
+ Wrappers.<AppTeachingTime>lambdaQuery()
|
|
|
|
|
+ .eq(AppTeachingTime::getOrgCode, orgCode)
|
|
|
|
|
+ .ge(AppTeachingTime::getDay, cn.hutool.core.date.DateUtil.beginOfDay(new java.util.Date()))
|
|
|
|
|
+ .le(AppTeachingTime::getDay, cn.hutool.core.date.DateUtil.offsetDay(new java.util.Date(), 6))
|
|
|
|
|
+ .eq(AppTeachingTime::getDelFlag, 0)
|
|
|
|
|
+ );
|
|
|
|
|
+ log.info("[previewOrderPlaceSchoolTime] 原始数据库查询 nm_teaching_time 表,找到{}条记录:", rawTeachingTimes.size());
|
|
|
|
|
+ rawTeachingTimes.forEach(t -> log.info(" -> day={}, is_teaching={}", t.getDay(), t.getIsTeaching()));
|
|
|
|
|
+
|
|
|
|
|
+ List<OrderVO.PreviewOrderPlaceSchoolTime> previewOrderPlaceSchoolTimes = appTeachingTimeMapper.previewOrderPlaceSchoolTime(orgCode);
|
|
|
|
|
+ AppSite appSite = appSiteMapper.selectOne(Wrappers.<AppSite>lambdaQuery().eq(AppSite::getId, sitePlace.getSiteId()));
|
|
|
|
|
+
|
|
|
|
|
+ log.info("[previewOrderPlaceSchoolTime] Mapper查询到{}条教学时间记录", previewOrderPlaceSchoolTimes.size());
|
|
|
|
|
+ previewOrderPlaceSchoolTimes.forEach(t -> log.info("[previewOrderPlaceSchoolTime] day={}, is_teaching={}, namedDay={}", t.getDay(), t.getIsTeaching(), t.getNamedDay()));
|
|
|
|
|
+
|
|
|
// 解析教学日和非教学日数据
|
|
// 解析教学日和非教学日数据
|
|
|
List<OrderVO.TimeSlotData> teachingList = parseTimeSlotData(appSite.getTeachingDay());
|
|
List<OrderVO.TimeSlotData> teachingList = parseTimeSlotData(appSite.getTeachingDay());
|
|
|
List<OrderVO.TimeSlotData> nonTeachingList = parseTimeSlotData(appSite.getNoTeachingDay());
|
|
List<OrderVO.TimeSlotData> nonTeachingList = parseTimeSlotData(appSite.getNoTeachingDay());
|
|
|
|
|
+
|
|
|
|
|
+ log.info("[previewOrderPlaceSchoolTime] teachingList size={}, nonTeachingList size={}", teachingList.size(), nonTeachingList.size());
|
|
|
|
|
+ log.info("[previewOrderPlaceSchoolTime] 教学日原始配置 teachingDay={}", appSite.getTeachingDay());
|
|
|
|
|
+ log.info("[previewOrderPlaceSchoolTime] 非教学日原始配置 noTeachingDay={}", appSite.getNoTeachingDay());
|
|
|
|
|
+ if (!teachingList.isEmpty()) {
|
|
|
|
|
+ log.info("[previewOrderPlaceSchoolTime] teachingList[0]: startTime={}, endTime={}, ticketNum={}",
|
|
|
|
|
+ teachingList.get(0).getStartTime(), teachingList.get(0).getEndTime(), teachingList.get(0).getTicketNum());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!nonTeachingList.isEmpty()) {
|
|
|
|
|
+ log.info("[previewOrderPlaceSchoolTime] nonTeachingList[0]: startTime={}, endTime={}, ticketNum={}",
|
|
|
|
|
+ nonTeachingList.get(0).getStartTime(), nonTeachingList.get(0).getEndTime(), nonTeachingList.get(0).getTicketNum());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
previewOrderPlaceSchoolTimes.forEach(previewOrderPlaceSchoolTime -> {
|
|
previewOrderPlaceSchoolTimes.forEach(previewOrderPlaceSchoolTime -> {
|
|
|
|
|
+ // is_teaching: 0=是(教学日), 1=否(非教学日)
|
|
|
boolean isTeaching = previewOrderPlaceSchoolTime.getIsTeaching() == 0;
|
|
boolean isTeaching = previewOrderPlaceSchoolTime.getIsTeaching() == 0;
|
|
|
|
|
+ log.info("[previewOrderPlaceSchoolTime] day={}, is_teaching={}, 使用配置={}",
|
|
|
|
|
+ previewOrderPlaceSchoolTime.getDay(),
|
|
|
|
|
+ previewOrderPlaceSchoolTime.getIsTeaching(),
|
|
|
|
|
+ isTeaching ? "教学日(teachingList)" : "非教学日(nonTeachingList)");
|
|
|
List<OrderVO.TimeSlotData> targetList = isTeaching ? teachingList : nonTeachingList;
|
|
List<OrderVO.TimeSlotData> targetList = isTeaching ? teachingList : nonTeachingList;
|
|
|
if (!targetList.isEmpty()) {
|
|
if (!targetList.isEmpty()) {
|
|
|
// 找到最早开始时间
|
|
// 找到最早开始时间
|