using System.Collections.Generic;
using System.Threading.Tasks;
using MDL.Models;
using SqlSugar;

namespace DAL.Interfaces
{
    public interface IBagTagRepository
    {
        Task<int> InsertAsync(BagTagEntity tag);
        Task<BagTagEntity> GetByIdAsync(int id);
        Task<BagTagEntity> GetByTagNumberAsync(string tagNumber);
        Task<List<BagTagEntity>> GetAllAsync();
        Task<int> UpdateAsync(BagTagEntity tag);
        Task<int> InsertWaybillAsync(BagTagWaybillEntity waybill);
        Task<List<MDL.DTOs.BagTagWaybillWithDetailsDto>> GetWaybillsByTagNumberAsync(string tagNumber);

        Task<bool> ExistsByTagNumberAsync(string tagNumber);

        Task<bool> IsWaybillAssociatedAsync(string tagNumber, string finalMileTrackingNumber);

        Task<(List<BagTagEntity> BagTags, int TotalCount)> GetBagTagsBatchAsync(
            int page, 
            int pageSize, 
            string sortBy, 
            string sortOrder, 
            string tagNumber, 
            string channel, 
            string status, 
            string creator);

        Task<int> RemoveWaybillAssociationAsync(string tagNumber, string finalMileTrackingNumber);
        Task<BagTagWaybillEntity> GetWaybillAssociationAsync(string finalMileTrackingNumber);
        Task<bool> IsWaybillAssociatedAnywhereAsync(string finalMileTrackingNumber);
        Task<List<BagTagEntity>> GetAvailableBagTagsByChannelAsync(string channel);

        /// <summary>
        /// 查询符合条件的 USPS 包裹
        /// </summary>
        Task<List<string>> GetEligibleUspsWaybillsAsync(DateTime cutoffTime);

        /// <summary>
        /// 获取符合条件的包裹数量
        /// </summary>
        Task<int> GetEligibleUspsWaybillCountAsync(DateTime cutoffTime);
    }
}