namespace HoneyBox.Admin.Business.Models.Advert;

#region Request Models

/// <summary>
/// 广告列表查询请求
/// </summary>
public class AdvertListRequest : PagedRequest
{
    /// <summary>
    /// 广告类型ID
    /// </summary>
    public int? TypeId { get; set; }
}

/// <summary>
/// 创建广告请求
/// </summary>
public class AdvertCreateRequest
{
    /// <summary>
    /// 广告类型ID
    /// </summary>
    public int TypeId { get; set; }

    /// <summary>
    /// 广告图片URL
    /// </summary>
    public string ImageUrl { get; set; } = string.Empty;

    /// <summary>
    /// 排序值，越小越靠前
    /// </summary>
    public int Sort { get; set; }

    /// <summary>
    /// 跳转类型：0-不跳转 1-优惠券 2-一番赏 3-无限赏 4-连击赏 5-自定义URL
    /// </summary>
    public int JumpType { get; set; }

    /// <summary>
    /// 关联优惠券ID（跳转类型为优惠券时使用）
    /// </summary>
    public int? CouponId { get; set; }

    /// <summary>
    /// 关联盒子ID（跳转类型为盒子时使用）
    /// </summary>
    public int? GoodsId { get; set; }

    /// <summary>
    /// 自定义跳转链接（跳转类型为自定义URL时使用）
    /// </summary>
    public string? UrlLink { get; set; }
}

/// <summary>
/// 更新广告请求
/// </summary>
public class AdvertUpdateRequest : AdvertCreateRequest
{
}

/// <summary>
/// 创建广告类型请求
/// </summary>
public class AdvertTypeCreateRequest
{
    /// <summary>
    /// 类型名称
    /// </summary>
    public string Name { get; set; } = string.Empty;

    /// <summary>
    /// 排序值
    /// </summary>
    public int Sort { get; set; }
}

/// <summary>
/// 更新广告类型请求
/// </summary>
public class AdvertTypeUpdateRequest : AdvertTypeCreateRequest
{
}

#endregion

#region Response Models

/// <summary>
/// 广告响应模型
/// </summary>
public class AdvertResponse
{
    /// <summary>
    /// 广告ID
    /// </summary>
    public int Id { get; set; }

    /// <summary>
    /// 广告类型ID
    /// </summary>
    public int TypeId { get; set; }

    /// <summary>
    /// 广告类型名称
    /// </summary>
    public string TypeName { get; set; } = string.Empty;

    /// <summary>
    /// 广告图片URL
    /// </summary>
    public string ImageUrl { get; set; } = string.Empty;

    /// <summary>
    /// 排序值
    /// </summary>
    public int Sort { get; set; }

    /// <summary>
    /// 跳转类型：0-不跳转 1-优惠券 2-一番赏 3-无限赏 4-连击赏 5-自定义URL
    /// </summary>
    public int JumpType { get; set; }

    /// <summary>
    /// 跳转类型名称
    /// </summary>
    public string JumpTypeName { get; set; } = string.Empty;

    /// <summary>
    /// 关联优惠券ID
    /// </summary>
    public int? CouponId { get; set; }

    /// <summary>
    /// 关联盒子ID
    /// </summary>
    public int? GoodsId { get; set; }

    /// <summary>
    /// 自定义跳转链接
    /// </summary>
    public string? UrlLink { get; set; }

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

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime? UpdatedAt { get; set; }
}

/// <summary>
/// 广告类型响应模型
/// </summary>
public class AdvertTypeResponse
{
    /// <summary>
    /// 类型ID
    /// </summary>
    public int Id { get; set; }

    /// <summary>
    /// 类型名称
    /// </summary>
    public string Name { get; set; } = string.Empty;

    /// <summary>
    /// 排序值
    /// </summary>
    public int Sort { get; set; }

    /// <summary>
    /// 该类型下的广告数量
    /// </summary>
    public int AdvertCount { get; set; }
}

#endregion

#region Helper Classes

/// <summary>
/// 广告跳转类型枚举
/// </summary>
public static class AdvertJumpTypes
{
    public const int None = 0;        // 不跳转
    public const int Coupon = 1;      // 优惠券
    public const int YiFanShang = 2;  // 一番赏
    public const int WuXianShang = 3; // 无限赏
    public const int LianJiShang = 4; // 连击赏
    public const int CustomUrl = 5;   // 自定义URL

    public static string GetJumpTypeName(int jumpType) => jumpType switch
    {
        None => "不跳转",
        Coupon => "优惠券",
        YiFanShang => "一番赏",
        WuXianShang => "无限赏",
        LianJiShang => "连击赏",
        CustomUrl => "自定义URL",
        _ => "未知类型"
    };
}

#endregion
