using Fake.Domain.Repositories; using Oms.Domain.OrdersAggregate.Entities; namespace Oms.Domain.OrdersAggregate.Repositories; public interface IOrderSideEffectRepository : IRepository { /// /// 是否已有未结束(以及可选的已完成)步骤。用于避免重复入队。 /// Task ExistsAsync( int orderId, string step, bool includeDone, CancellationToken cancellationToken = default); Task> ListDueIdsAsync(int take, DateTime now, CancellationToken cancellationToken = default); /// /// 取同一步骤最近一条入参,用于把创单时捕获的轨迹授权头带到排货后的刷新。 /// Task FindLatestPayloadJsonAsync( int orderId, string step, CancellationToken cancellationToken = default); /// /// 仅当当前仍是 pending 时改为 running,并增加尝试次数。 /// Task TryClaimAsync(int id, DateTime now, CancellationToken cancellationToken = default); Task MarkDoneAsync(int id, DateTime now, CancellationToken cancellationToken = default); Task MarkRetryAsync( int id, string status, string? lastError, DateTime? nextRunTime, DateTime now, CancellationToken cancellationToken = default); /// /// 执行过程中进程退出时,把长时间停在 running 的步骤放回 pending。 /// Task ResetStaleRunningAsync(DateTime staleBefore, DateTime now, CancellationToken cancellationToken = default); /// /// 仍显示「预报计费/排货处理中」、且没有待执行、执行中或已完成预报步骤的订单。 /// Task> ListStuckForecastOrderIdsAsync( string processingReason, DateTime olderThan, int take, CancellationToken cancellationToken = default); }