fix(firstleg): allow public sailing schedule dispatch fallback

This commit is contained in:
2026-09-30 17:53:12 +08:00
parent 36a74eb58e
commit 8d9d38ed4c
3 changed files with 6 additions and 5 deletions
@@ -34,9 +34,10 @@ public interface PortScheduleMapper extends BaseMapper<PortScheduleEntity> {
@Select("""
SELECT * FROM fl_port_schedule
WHERE customer_id=#{customerId} AND ocean_booking_id=#{oceanBookingId}
WHERE (customer_id=#{customerId} OR customer_id=0) AND ocean_booking_id=#{oceanBookingId}
AND container_booking_id=#{containerBookingId}
ORDER BY observed_at DESC,updated_at DESC,id DESC LIMIT 1
ORDER BY CASE WHEN customer_id=#{customerId} THEN 0 ELSE 1 END,
observed_at DESC,updated_at DESC,id DESC LIMIT 1
""")
PortScheduleEntity latestForDispatch(@Param("customerId") long customerId,
@Param("oceanBookingId") long oceanBookingId,
@@ -31,7 +31,7 @@ public class PortScheduleDispatchGateContributor implements OutboundDispatchGate
PortScheduleEntity schedule = repository.latestForDispatch(context.tenantId(), context.oceanBookingId(),
context.containerBookingId());
if (schedule == null) return gate(false, "MISSING");
if (!java.util.Objects.equals(schedule.getCustomerId(), context.tenantId())
if (!(java.util.Objects.equals(schedule.getCustomerId(), context.tenantId()) || schedule.getCustomerId() == 0L)
|| !java.util.Objects.equals(schedule.getOceanBookingId(), context.oceanBookingId())
|| !java.util.Objects.equals(schedule.getContainerBookingId(), context.containerBookingId())) {
return gate(false, "ASSOCIATION_MISMATCH");