using TakeoutSaaS.Application.App.Members.MessageReach.Dto;

namespace TakeoutSaaS.Application.App.Members.MessageReach.Services;

/// <summary>
/// 会员消息触达应用服务。
/// </summary>
public interface IMemberMessageReachAppService
{
    /// <summary>
    /// 获取月度统计。
    /// </summary>
    Task<MemberMessageReachStatsDto> GetStatsAsync(long tenantId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 分页查询消息。
    /// </summary>
    Task<MemberMessageReachListResultDto> SearchMessagesAsync(
        long tenantId,
        SearchMemberMessageInput input,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取消息详情。
    /// </summary>
    Task<MemberMessageReachDetailDto?> GetMessageDetailAsync(
        long tenantId,
        long messageId,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取消息调度元信息。
    /// </summary>
    Task<MemberMessageDispatchMetaDto?> GetDispatchMetaAsync(
        long tenantId,
        long messageId,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 保存消息草稿或发送任务。
    /// </summary>
    Task<MemberMessageDispatchMetaDto> SaveMessageAsync(
        long tenantId,
        SaveMemberMessageInput input,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 绑定消息对应的 Hangfire 任务 ID。
    /// </summary>
    Task BindDispatchJobAsync(
        long tenantId,
        long messageId,
        string? hangfireJobId,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 删除消息并返回原任务 ID。
    /// </summary>
    Task<string?> DeleteMessageAsync(
        long tenantId,
        long messageId,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 估算目标人群数量。
    /// </summary>
    Task<MemberMessageAudienceEstimateDto> EstimateAudienceAsync(
        long tenantId,
        MemberMessageAudienceEstimateInput input,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 分页查询模板。
    /// </summary>
    Task<MemberMessageTemplateListResultDto> SearchTemplatesAsync(
        long tenantId,
        SearchMemberMessageTemplateInput input,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取模板详情。
    /// </summary>
    Task<MemberMessageTemplateDto?> GetTemplateAsync(
        long tenantId,
        long templateId,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 保存模板。
    /// </summary>
    Task<MemberMessageTemplateDto> SaveTemplateAsync(
        long tenantId,
        SaveMemberMessageTemplateInput input,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 删除模板。
    /// </summary>
    Task DeleteTemplateAsync(
        long tenantId,
        long templateId,
        CancellationToken cancellationToken = default);

    /// <summary>
    /// 执行消息发送。
    /// </summary>
    Task ExecuteDispatchAsync(
        long tenantId,
        long messageId,
        CancellationToken cancellationToken = default);
}
