namespace HoneyBox.Admin.Business.Models.Coupon;

#region Request Models

/// <summary>
/// 优惠券列表查询请求
/// </summary>
public class CouponListRequest : PagedRequest
{
    /// <summary>
    /// 标题关键词（模糊搜索）
    /// </summary>
    public string? Keyword { get; set; }

    /// <summary>
    /// 优惠券类型：1-新人优惠券 2-权益优惠券 3-满减优惠券
    /// </summary>
    public int? Type { get; set; }
}

/// <summary>
/// 创建优惠券请求
/// </summary>
public class CouponCreateRequest
{
    /// <summary>
    /// 优惠券标题
    /// </summary>
    public string Title { get; set; } = string.Empty;

    /// <summary>
    /// 满减门槛金额
    /// </summary>
    public decimal MinPrice { get; set; }

    /// <summary>
    /// 优惠金额
    /// </summary>
    public decimal DiscountPrice { get; set; }

    /// <summary>
    /// 有效期（天）
    /// </summary>
    public int ValidDays { get; set; }

    /// <summary>
    /// 优惠券类型：1-新人优惠券 2-权益优惠券 3-满减优惠券
    /// </summary>
    public int Type { get; set; }

    /// <summary>
    /// 使用限制：0-不限制 1-一番赏 2-无限赏 3-擂台赏 4-全局赏 5-领主赏 6-连击赏
    /// </summary>
    public int UseLimit { get; set; }
}

/// <summary>
/// 更新优惠券请求
/// </summary>
public class CouponUpdateRequest : CouponCreateRequest
{
}

/// <summary>
/// 优惠券领取记录列表查询请求
/// </summary>
public class CouponReceiveListRequest : PagedRequest
{
    /// <summary>
    /// 用户ID
    /// </summary>
    public int? UserId { get; set; }

    /// <summary>
    /// 优惠券标题（模糊搜索）
    /// </summary>
    public string? Title { get; set; }

    /// <summary>
    /// 状态：0-未使用 1-已使用 2-已过期
    /// </summary>
    public int? Status { get; set; }
}

#endregion

#region Response Models

/// <summary>
/// 优惠券响应模型
/// </summary>
public class CouponResponse
{
    /// <summary>
    /// 优惠券ID
    /// </summary>
    public int Id { get; set; }

    /// <summary>
    /// 优惠券标题
    /// </summary>
    public string Title { get; set; } = string.Empty;

    /// <summary>
    /// 满减门槛金额
    /// </summary>
    public decimal MinPrice { get; set; }

    /// <summary>
    /// 优惠金额
    /// </summary>
    public decimal DiscountPrice { get; set; }

    /// <summary>
    /// 有效期（天）
    /// </summary>
    public int ValidDays { get; set; }

    /// <summary>
    /// 优惠券类型：1-新人优惠券 2-权益优惠券 3-满减优惠券
    /// </summary>
    public int Type { get; set; }

    /// <summary>
    /// 优惠券类型名称
    /// </summary>
    public string TypeName { get; set; } = string.Empty;

    /// <summary>
    /// 使用限制：0-不限制 1-一番赏 2-无限赏 3-擂台赏 4-全局赏 5-领主赏 6-连击赏
    /// </summary>
    public int UseLimit { get; set; }

    /// <summary>
    /// 使用限制名称
    /// </summary>
    public string UseLimitName { get; set; } = string.Empty;

    /// <summary>
    /// 状态：0-禁用 1-启用
    /// </summary>
    public int Status { get; set; }

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

/// <summary>
/// 优惠券领取记录响应模型
/// </summary>
public class CouponReceiveResponse
{
    /// <summary>
    /// 记录ID
    /// </summary>
    public int Id { get; set; }

    /// <summary>
    /// 用户ID
    /// </summary>
    public int UserId { get; set; }

    /// <summary>
    /// 用户UID
    /// </summary>
    public string Uid { get; set; } = string.Empty;

    /// <summary>
    /// 用户昵称
    /// </summary>
    public string Nickname { get; set; } = string.Empty;

    /// <summary>
    /// 优惠券标题
    /// </summary>
    public string CouponTitle { get; set; } = string.Empty;

    /// <summary>
    /// 满减门槛金额
    /// </summary>
    public decimal MinPrice { get; set; }

    /// <summary>
    /// 优惠金额
    /// </summary>
    public decimal DiscountPrice { get; set; }

    /// <summary>
    /// 状态：0-未使用 1-已使用 2-已过期
    /// </summary>
    public int Status { get; set; }

    /// <summary>
    /// 状态名称
    /// </summary>
    public string StatusName { get; set; } = string.Empty;

    /// <summary>
    /// 过期时间
    /// </summary>
    public DateTime? ExpireTime { get; set; }

    /// <summary>
    /// 领取时间
    /// </summary>
    public DateTime CreatedAt { get; set; }
}

#endregion

#region Helper Classes

/// <summary>
/// 优惠券类型枚举
/// </summary>
public static class CouponTypes
{
    public const int NewUser = 1;      // 新人优惠券
    public const int Equity = 2;       // 权益优惠券
    public const int FullReduction = 3; // 满减优惠券

    public static string GetTypeName(int type) => type switch
    {
        NewUser => "新人优惠券",
        Equity => "权益优惠券",
        FullReduction => "满减优惠券",
        _ => "未知类型"
    };
}

/// <summary>
/// 优惠券使用限制枚举
/// </summary>
public static class CouponUseLimits
{
    public const int NoLimit = 0;      // 不限制
    public const int YiFanShang = 1;   // 一番赏
    public const int WuXianShang = 2;  // 无限赏
    public const int LeiTaiShang = 3;  // 擂台赏
    public const int QuanJuShang = 4;  // 全局赏
    public const int LingZhuShang = 5; // 领主赏
    public const int LianJiShang = 6;  // 连击赏

    public static string GetLimitName(int limit) => limit switch
    {
        NoLimit => "不限制",
        YiFanShang => "一番赏",
        WuXianShang => "无限赏",
        LeiTaiShang => "擂台赏",
        QuanJuShang => "全局赏",
        LingZhuShang => "领主赏",
        LianJiShang => "连击赏",
        _ => "未知限制"
    };
}

/// <summary>
/// 优惠券领取状态枚举
/// </summary>
public static class CouponReceiveStatus
{
    public const int Unused = 0;   // 未使用
    public const int Used = 1;     // 已使用
    public const int Expired = 2;  // 已过期

    public static string GetStatusName(int status) => status switch
    {
        Unused => "未使用",
        Used => "已使用",
        Expired => "已过期",
        _ => "未知状态"
    };
}

#endregion
