修复手工预约作品日历空指针

This commit is contained in:
2026-07-23 10:12:30 +08:00
parent 3c6261f180
commit 0a4db094b0
2 changed files with 52 additions and 7 deletions
@@ -831,13 +831,13 @@ public class PlanningServiceImpl implements PlanningService {
List<PlanningAppointmentVO> result = new ArrayList<>();
Set<Long> reservationItemIds = new HashSet<>();
for (AppointmentReservationDO reservation : safeList(reservations)) {
OrderItemDO item = itemMap.get(reservation.getOrderItemId());
OrderDO order = orderMap.get(reservation.getOrderId());
OrderItemDO item = getByNullableId(itemMap, reservation.getOrderItemId());
OrderDO order = getByNullableId(orderMap, reservation.getOrderId());
if (!isVisibleOrder(order, shopId)) {
continue;
}
ProductDO product = item == null ? null : productMap.get(item.getProductId());
UserDO customer = customerMap.get(order.getUserId());
ProductDO product = item == null ? null : getByNullableId(productMap, item.getProductId());
UserDO customer = getByNullableId(customerMap, order.getUserId());
result.add(toAppointmentVO(reservation, item, order, product, customer, artistMap));
if (reservation.getOrderItemId() != null) {
reservationItemIds.add(reservation.getOrderItemId());
@@ -847,12 +847,12 @@ public class PlanningServiceImpl implements PlanningService {
if (item.getId() != null && reservationItemIds.contains(item.getId())) {
continue;
}
OrderDO order = orderMap.get(item.getOrderId());
OrderDO order = getByNullableId(orderMap, item.getOrderId());
if (!isVisibleOrder(order, shopId)) {
continue;
}
ProductDO product = productMap.get(item.getProductId());
UserDO customer = customerMap.get(order.getUserId());
ProductDO product = getByNullableId(productMap, item.getProductId());
UserDO customer = getByNullableId(customerMap, order.getUserId());
result.add(toAppointmentVO(null, item, order, product, customer, artistMap));
}
result.sort(Comparator.comparing(PlanningAppointmentVO::getStartTime, Comparator.nullsLast(String::compareTo))
@@ -1415,6 +1415,10 @@ public class PlanningServiceImpl implements PlanningService {
.collect(Collectors.toMap(UserDO::getId, Function.identity(), (a, b) -> a));
}
private <T> T getByNullableId(Map<Long, T> source, Long id) {
return id == null ? null : source.get(id);
}
private record AppointmentTimeSegment(LocalDate workDate, LocalTime startTime, LocalTime endTime) {
}