using System.ComponentModel.DataAnnotations;
using QYZH.InteractiveMagazine.Models.Enum;

namespace QYZH.InteractiveMagazine.Models.Dto.Compensation;

/// <summary>
/// 补偿任务分页查询输入
/// </summary>
public class CompensationTaskQueryInput : PageQueryModel
{
    /// <summary>
    /// 按用户Id筛选
    /// </summary>
    public long? UserId { get; set; }

    /// <summary>
    /// 按任务类型筛选（PetFeeding/UserPoints/UserGrowth/SendNotification）
    /// </summary>
    public CompensationTaskTypeEnum? TaskType { get; set; }

    /// <summary>
    /// 按状态筛选（Pending/Processing/Success/Failed/Cancelled）
    /// </summary>
    public CompensationTaskStatusEnum? Status { get; set; }

    /// <summary>
    /// 按业务来源筛选（CheckIn/Purchase/Activity等）
    /// </summary>
    public string? BusinessSource { get; set; }
}

/// <summary>
/// 手动重试补偿任务输入
/// </summary>
public class CompensationRetryInput
{
    /// <summary>
    /// 重试原因
    /// </summary>
    [Required(ErrorMessage = "重试原因不能为空")]
    public string Reason { get; set; } = string.Empty;
}

/// <summary>
/// 标记补偿任务已解决输入
/// </summary>
public class CompensationResolveInput
{
    /// <summary>
    /// 处理说明
    /// </summary>
    [Required(ErrorMessage = "处理说明不能为空")]
    public string ResolveNote { get; set; } = string.Empty;
}

/// <summary>
/// 补偿任务管理输出（含用户昵称）
/// </summary>
public class CompensationManageOutput
{
    /// <summary>
    /// 任务Id
    /// </summary>
    public long Id { get; set; }

    /// <summary>
    /// 任务类型
    /// </summary>
    public CompensationTaskTypeEnum TaskType { get; set; }

    /// <summary>
    /// 业务来源
    /// </summary>
    public string BusinessSource { get; set; } = string.Empty;

    /// <summary>
    /// 关联业务Id
    /// </summary>
    public string? BusinessId { get; set; }

    /// <summary>
    /// 用户Id
    /// </summary>
    public long UserId { get; set; }

    /// <summary>
    /// 用户昵称
    /// </summary>
    public string? UserName { get; set; }

    /// <summary>
    /// 处理参数（JSON）
    /// </summary>
    public string Payload { get; set; } = string.Empty;

    /// <summary>
    /// 异常消息
    /// </summary>
    public string ErrorMessage { get; set; } = string.Empty;

    /// <summary>
    /// 异常来源
    /// </summary>
    public string ErrorSource { get; set; } = string.Empty;

    /// <summary>
    /// 已重试次数
    /// </summary>
    public int RetryCount { get; set; }

    /// <summary>
    /// 最大重试次数
    /// </summary>
    public int MaxRetries { get; set; }

    /// <summary>
    /// 状态
    /// </summary>
    public CompensationTaskStatusEnum Status { get; set; }

    /// <summary>
    /// 最后处理时间
    /// </summary>
    public DateTime? ProcessedAt { get; set; }

    /// <summary>
    /// 计划执行时间
    /// </summary>
    public DateTime? ScheduledAt { get; set; }

    /// <summary>
    /// 处理结果
    /// </summary>
    public string? ResultMessage { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreatedAt { get; set; }
}

/// <summary>
/// 补偿任务详情输出（含审计字段）
/// </summary>
public class CompensationManageDetailOutput
{
    /// <summary>
    /// 任务Id
    /// </summary>
    public long Id { get; set; }

    /// <summary>
    /// 任务类型
    /// </summary>
    public CompensationTaskTypeEnum TaskType { get; set; }

    /// <summary>
    /// 业务来源
    /// </summary>
    public string BusinessSource { get; set; } = string.Empty;

    /// <summary>
    /// 关联业务Id
    /// </summary>
    public string? BusinessId { get; set; }

    /// <summary>
    /// 用户Id
    /// </summary>
    public long UserId { get; set; }

    /// <summary>
    /// 用户昵称
    /// </summary>
    public string? UserName { get; set; }

    /// <summary>
    /// 处理参数（JSON）
    /// </summary>
    public string Payload { get; set; } = string.Empty;

    /// <summary>
    /// 异常消息
    /// </summary>
    public string ErrorMessage { get; set; } = string.Empty;

    /// <summary>
    /// 异常来源
    /// </summary>
    public string ErrorSource { get; set; } = string.Empty;

    /// <summary>
    /// 已重试次数
    /// </summary>
    public int RetryCount { get; set; }

    /// <summary>
    /// 最大重试次数
    /// </summary>
    public int MaxRetries { get; set; }

    /// <summary>
    /// 状态
    /// </summary>
    public CompensationTaskStatusEnum Status { get; set; }

    /// <summary>
    /// 最后处理时间
    /// </summary>
    public DateTime? ProcessedAt { get; set; }

    /// <summary>
    /// 计划执行时间
    /// </summary>
    public DateTime? ScheduledAt { get; set; }

    /// <summary>
    /// 处理结果
    /// </summary>
    public string? ResultMessage { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    public DateTime CreatedAt { get; set; }

    /// <summary>
    /// 创建人
    /// </summary>
    public string? CreatedBy { get; set; }

    /// <summary>
    /// 修改人
    /// </summary>
    public string? UpdatedBy { get; set; }

    /// <summary>
    /// 修改时间
    /// </summary>
    public DateTime? UpdatedAt { get; set; }
}
