using TakeoutSaaS.Domain.Finance.Enums;
using TakeoutSaaS.Domain.Finance.Models;

namespace TakeoutSaaS.Domain.Finance.Repositories;

/// <summary>
/// 经营报表仓储契约。
/// </summary>
public interface IFinanceBusinessReportRepository
{
    /// <summary>
    /// 确保门店存在默认成本配置。
    /// </summary>
    Task EnsureDefaultCostProfilesAsync(
        long tenantId,
        long storeId,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 为指定分页周期补齐快照并排队。
    /// </summary>
    Task QueueSnapshotsForPageAsync(
        long tenantId,
        long storeId,
        FinanceBusinessReportPeriodType periodType,
        int page,
        int pageSize,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 查询经营报表分页结果。
    /// </summary>
    Task<FinanceBusinessReportPageSnapshot> SearchPageAsync(
        long tenantId,
        long storeId,
        FinanceBusinessReportPeriodType periodType,
        int page,
        int pageSize,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 查询经营报表详情。
    /// </summary>
    Task<FinanceBusinessReportDetailSnapshot?> GetDetailAsync(
        long tenantId,
        long storeId,
        long reportId,
        bool allowRealtimeBuild,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 查询批量导出详情集合。
    /// </summary>
    Task<IReadOnlyList<FinanceBusinessReportDetailSnapshot>> ListBatchDetailsAsync(
        long tenantId,
        long storeId,
        FinanceBusinessReportPeriodType periodType,
        int page,
        int pageSize,
        bool allowRealtimeBuild,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 拉取待处理任务。
    /// </summary>
    Task<IReadOnlyList<FinanceBusinessReportPendingSnapshot>> GetPendingSnapshotsAsync(
        int take,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 执行报表快照生成。
    /// </summary>
    Task GenerateSnapshotAsync(
        long snapshotId,
        CancellationToken cancellationToken = default);
}

