fix(firstleg): execute carrier schedule due queries

This commit is contained in:
2026-08-25 13:46:33 +08:00
parent 0302985f21
commit 72f3f9f971
2 changed files with 27 additions and 4 deletions
@@ -49,8 +49,8 @@ public interface CarrierScheduleQueryMapper extends BaseMapper<CarrierScheduleQu
@Select("""
SELECT * FROM fl_carrier_schedule_query
WHERE status IN ('READY','MANUAL_REQUIRED')
AND next_allowed_at IS NOT NULL AND next_allowed_at&lt;=#{now}
AND (lease_until IS NULL OR lease_until&lt;#{now})
AND next_allowed_at IS NOT NULL AND next_allowed_at <= #{now}
AND (lease_until IS NULL OR lease_until < #{now})
ORDER BY next_allowed_at,id LIMIT #{limit}
""")
List<CarrierScheduleQueryEntity> selectDue(@Param("now") LocalDateTime now, @Param("limit") int limit);
@@ -59,8 +59,8 @@ public interface CarrierScheduleQueryMapper extends BaseMapper<CarrierScheduleQu
UPDATE fl_carrier_schedule_query SET lease_owner=#{owner},lease_until=#{leaseUntil},
updated_at=CURRENT_TIMESTAMP(3)
WHERE id=#{id} AND status IN ('READY','MANUAL_REQUIRED')
AND next_allowed_at IS NOT NULL AND next_allowed_at&lt;=#{now}
AND (lease_until IS NULL OR lease_until&lt;#{now})
AND next_allowed_at IS NOT NULL AND next_allowed_at <= #{now}
AND (lease_until IS NULL OR lease_until < #{now})
""")
int claimLease(@Param("id") long id, @Param("owner") String owner,
@Param("now") LocalDateTime now, @Param("leaseUntil") LocalDateTime leaseUntil);