|
@@ -209,17 +209,15 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
LocalTime slotStart = LocalTime.parse(DateUtil.format(a.getStartTime(), "HH:mm"));
|
|
|
LocalTime slotEnd = LocalTime.parse(DateUtil.format(a.getEndTime(), "HH:mm"));
|
|
|
boolean isTeaching = a.getIsTeaching() == 0;
|
|
|
-
|
|
|
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 !slotStart.isAfter(invEnd) && !slotEnd.isBefore(invStart);
|
|
|
+ // 严格匹配有交集的时间段(不包含端点相接)
|
|
|
+ return invStart.isBefore(invEnd) && slotStart.isBefore(invEnd) && slotEnd.isAfter(invStart);
|
|
|
})
|
|
|
.findFirst();
|
|
|
-
|
|
|
matchedSlot.ifPresent(timeSlotData -> {
|
|
|
int totalInventory = Integer.parseInt(timeSlotData.getTicketNum());
|
|
|
int bookedCount = appOrderMapper.queryBookedCount(
|
|
@@ -228,8 +226,7 @@ public class OrderServiceImpl implements IOrderService {
|
|
|
timeSlotData.getStartTime(),
|
|
|
timeSlotData.getEndTime()
|
|
|
);
|
|
|
- int availableInventory = totalInventory - bookedCount;
|
|
|
- a.setInventory(availableInventory);
|
|
|
+ a.setInventory(totalInventory - bookedCount);
|
|
|
});
|
|
|
});
|
|
|
AppSitePlace appSitePlace = appSitePlaceMapper.selectById(placeId);
|