namespace QYZH.InteractiveMagazine.Models.Dto.Points;
using QYZH.InteractiveMagazine.Models.Enum;

/// <summary>
/// 积分流水查询输入
/// </summary>
public class PointsRecordQueryInput : PageQueryModel
{
    /// <summary>
    /// 用户Id
    /// </summary>
    public long UserId { get; set; }

    /// <summary>
    /// 变动类型筛选
    /// </summary>
    public PointsChangeTypeEnum? ChangeType { get; set; }

    /// <summary>
    /// 流水分类筛选（Income/Expense）
    /// </summary>
    public PointsFlowTypeEnum? Type { get; set; }

    /// <summary>
    /// 状态筛选（Success/Failed 等）
    /// </summary>
    public string? Status { get; set; }
}

/// <summary>
/// 积分流水输出
/// </summary>
public class PointsRecordOutput
{
    /// <summary>
    /// 记录Id
    /// </summary>
    public long Id { get; set; }

    /// <summary>
    /// 变动数值（正数为收入，负数为支出）
    /// </summary>
    public int ChangeAmount { get; set; }

    /// <summary>
    /// 变动后余额
    /// </summary>
    public int BalanceAfter { get; set; }

    /// <summary>
    /// 变动类型（如 SignIn、Exchange、TaskReward 等）
    /// </summary>
    public string ChangeType { get; set; } = string.Empty;

    /// <summary>
    /// 备注描述
    /// </summary>
    public string? Description { get; set; }

    /// <summary>
    /// 流水分类（Income/Expense）
    /// </summary>
    public string Type { get; set; } = string.Empty;

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

/// <summary>
/// 增加积分输入
/// </summary>
public class AddPointsInput
{
    /// <summary>
    /// 用户Id
    /// </summary>
    public long UserId { get; set; }

    /// <summary>
    /// 增加数量
    /// </summary>
    public int Amount { get; set; }

    /// <summary>
    /// 变动类型
    /// </summary>
    public PointsChangeTypeEnum ChangeType { get; set; }

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

    /// <summary>
    /// 备注描述
    /// </summary>
    public string? Description { get; set; }

    /// <summary>
    /// 操作人名称（为空时默认使用用户昵称）
    /// </summary>
    public string? OperatorName { get; set; }
}

/// <summary>
/// 扣除积分输入
/// </summary>
public class DeductPointsInput
{
    /// <summary>
    /// 用户Id
    /// </summary>
    public long UserId { get; set; }

    /// <summary>
    /// 扣除数量
    /// </summary>
    public int Amount { get; set; }

    /// <summary>
    /// 变动类型
    /// </summary>
    public PointsChangeTypeEnum ChangeType { get; set; }

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

    /// <summary>
    /// 备注描述
    /// </summary>
    public string? Description { get; set; }

    /// <summary>
    /// 操作人名称（为空时默认使用用户昵称）
    /// </summary>
    public string? OperatorName { get; set; }
}

/// <summary>
/// 增加积分输出
/// </summary>
public class AddPointsOutput
{
    /// <summary>
    /// 积分流水记录Id
    /// </summary>
    public long RecordId { get; set; }

    /// <summary>
    /// 操作前积分余额
    /// </summary>
    public int PreviousBalance { get; set; }

    /// <summary>
    /// 操作后积分余额
    /// </summary>
    public int NewBalance { get; set; }

    /// <summary>
    /// 实际增加数量
    /// </summary>
    public int AddedAmount { get; set; }
}

/// <summary>
/// 扣除积分输出
/// </summary>
public class DeductPointsOutput
{
    /// <summary>
    /// 积分流水记录Id
    /// </summary>
    public long RecordId { get; set; }

    /// <summary>
    /// 操作前积分余额
    /// </summary>
    public int PreviousBalance { get; set; }

    /// <summary>
    /// 操作后积分余额
    /// </summary>
    public int NewBalance { get; set; }

    /// <summary>
    /// 实际扣除数量
    /// </summary>
    public int DeductedAmount { get; set; }
}

/// <summary>
/// 用户积分概览
/// </summary>
public class PointsSummaryOutput
{
    /// <summary>
    /// 用户Id
    /// </summary>
    public long UserId { get; set; }

    /// <summary>
    /// 当前积分余额
    /// </summary>
    public int CurrentBalance { get; set; }

    /// <summary>
    /// 累计获得积分
    /// </summary>
    public int TotalIncome { get; set; }

    /// <summary>
    /// 累计消耗积分
    /// </summary>
    public int TotalExpense { get; set; }
}
