using System;
using System.Reflection;

namespace Yi.Framework.AiHub.Domain.Shared.Enums;

/// <summary>
/// 激活码商品特性
/// </summary>
[AttributeUsage(AttributeTargets.Field)]
public class ActivationCodeGoodsAttribute : Attribute
{
    public decimal Price { get; }
    public long TokenAmount { get; }
    public int VipMonths { get; }
    public int VipDays { get; }
    public bool IsCombo { get; }
    public bool IsReusable { get; }
    public bool IsSameTypeOnce { get; }
    public string DisplayName { get; }
    public string Content { get; }

    public ActivationCodeGoodsAttribute(
        double price,
        long tokenAmount,
        int vipMonths,
        bool isCombo,
        bool isReusable,
        bool isSameTypeOnce,
        string displayName,
        string content,
        int vipDays = 0)
    {
        Price = (decimal)price;
        TokenAmount = tokenAmount;
        VipMonths = vipMonths;
        VipDays = vipDays;
        IsCombo = isCombo;
        IsReusable = isReusable;
        IsSameTypeOnce = isSameTypeOnce;
        DisplayName = displayName;
        Content = content;
    }
}

/// <summary>
/// 激活码商品类型
/// </summary>
public enum ActivationCodeGoodsTypeEnum
{
    /// <summary>
    /// 48.90【意心Ai会员1月+2000w 尊享Token】新人首单组合包（推荐）
    /// </summary>
    [ActivationCodeGoods(price: 48.90, tokenAmount: 20000000, vipMonths: 1, isCombo: true, isReusable: false,
        isSameTypeOnce: true, displayName: "意心Ai会员1月+2000w 尊享Token", content: "新人首单组合包")]
    Vip1MonthPlus2000W = 1,

    /// <summary>
    /// 1.00【10w 尊享Token】测试体验包
    /// </summary>
    [ActivationCodeGoods(price: 1.00, tokenAmount: 100000, vipMonths: 0, isCombo: false, isReusable: false,
        isSameTypeOnce: false, displayName: "10w 尊享Token", content: "测试体验包")]
    Premium10W = 2,

    /// <summary>
    /// 9.90【1000w 尊享Token】意心会员首单回馈包
    /// </summary>
    [ActivationCodeGoods(price: 9.90, tokenAmount: 10000000, vipMonths: 0, isCombo: false, isReusable: false,
        isSameTypeOnce: true, displayName: "1000w 尊享Token", content: "意心会员首单回馈包")]
    Premium1000W = 3,

    /// <summary>
    /// 22.90【意心Ai会员1月】特价包
    /// </summary>
    [ActivationCodeGoods(price: 22.90, tokenAmount: 0, vipMonths: 1, isCombo: false, isReusable: false,
        isSameTypeOnce: false, displayName: "意心Ai会员1月", content: "特价包")]
    Vip1Month = 4,

    /// <summary>
    /// 138.90【5000w 尊享Token】特价包
    /// </summary>
    [ActivationCodeGoods(price: 138.90, tokenAmount: 50000000, vipMonths: 0, isCombo: false, isReusable: false,
        isSameTypeOnce: false, displayName: "5000w 尊享Token", content: "特价包")]
    Premium5000W = 5,

    /// <summary>
    /// 198.90【1亿 尊享Token】特价包
    /// </summary>
    [ActivationCodeGoods(price: 198.90, tokenAmount: 100000000, vipMonths: 0, isCombo: false, isReusable: false,
        isSameTypeOnce: false, displayName: "1亿 尊享Token", content: "特价包")]
    Premium1Yi = 6,

    /// <summary>
    /// 1【意心Ai会员1天+50w 尊享Token】新人试用首单组合包
    /// </summary>
    [ActivationCodeGoods(price: 1, tokenAmount: 500000, vipMonths: 0, vipDays: 1, isCombo: true, isReusable: false,
        isSameTypeOnce: true, displayName: "意心Ai会员1天+50w 尊享Token", content: "新人首单组合包")]
    Vip1DayTest = 7,

    /// <summary>
    /// 0【10w 尊享Token】免费包
    /// </summary>
    [ActivationCodeGoods(price: 0, tokenAmount: 100000, vipMonths: 0, isCombo: false, isReusable: true,
        isSameTypeOnce: false, displayName: "10w 尊享Token", content: "免费包")]
    Premium10WFree = 100,
    
    
    
    
    /// <summary>
    /// 0【888w 尊享Token】活动包
    /// </summary>
    [ActivationCodeGoods(price: 0, tokenAmount: 8880000, vipMonths: 0, isCombo: false, isReusable: false,
        isSameTypeOnce: false, displayName: "888w 尊享Token", content: "888w活动赠送福利包")]
    Premium888WFree = 200,
    
    /// <summary>
    /// 0【666w 尊享Token】活动包
    /// </summary>
    [ActivationCodeGoods(price: 0, tokenAmount: 6660000, vipMonths: 0, isCombo: false, isReusable: false,
        isSameTypeOnce: false, displayName: "666w 尊享Token", content: "666w活动赠送福利包")]
    Premium666WFree = 201,
    
    /// <summary>
    /// 0【100w 尊享Token】活动包
    /// </summary>
    [ActivationCodeGoods(price: 0, tokenAmount: 1000000, vipMonths: 0, isCombo: false, isReusable: false,
        isSameTypeOnce: false, displayName: "100w 尊享Token", content: "100w活动赠送福利包")]
    Premium100WFree = 202,
}

public static class ActivationCodeGoodsTypeEnumExtensions
{
    public static ActivationCodeGoodsAttribute? GetGoods(this ActivationCodeGoodsTypeEnum goodsType)
    {
        var fieldInfo = goodsType.GetType().GetField(goodsType.ToString());
        return fieldInfo?.GetCustomAttribute<ActivationCodeGoodsAttribute>();
    }
}