using Fake.DependencyInjection; using Oms.Domain.SystemAggregate.Entities; using Oms.Domain.SystemAggregate.Repositories; using Oms.SqlSugarCore.Repositories; namespace Oms.SqlSugarCore.System; public class OrderNotifyLogRepository : OmsSqlSugarRepository, IOrderNotifyLogRepository, IScopedDependency { public async Task ExistsRecentSentAsync( int orderId, string eventCode, string channel, DateTime since, CancellationToken cancellationToken = default) { var code = eventCode.Trim(); var ch = channel.Trim(); return await AnyAsync( x => x.OrderId == orderId && x.EventCode == code && x.Channel == ch && x.CreateTime >= since && x.Status == "sent", cancellationToken); } public async Task> ListByOrderIdAsync( int orderId, CancellationToken cancellationToken = default) { var list = await GetListAsync(x => x.OrderId == orderId, cancellationToken: cancellationToken); return list .OrderByDescending(x => x.CreateTime) .ThenByDescending(x => x.Id) .ToList(); } }