package top.continew.admin.business.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.math.BigDecimal;

/**
 * 计费规则枚举
 * 
 * @author jiay
 * @since 2025/09/22
 */
@Getter
@AllArgsConstructor
public enum BillingRuleEnum {

    // 生成平台-艺术类
    AI_PAINTING(10000L, "生成平台-艺术类", "AI绘画", new BigDecimal("0.13")),
    AI_MUSIC(10002L, "生成平台-艺术类", "AI音乐", new BigDecimal("0.4")),
    AI_VIDEO_TEXT(10003L, "生成平台-艺术类", "AI视频-文生视频", new BigDecimal("1.5")),
    AI_VIDEO_IMAGE(10004L, "生成平台-艺术类", "AI视频-图生视频", new BigDecimal("1.5")),
    AI_3D(10005L, "生成平台-艺术类", "AI3D", new BigDecimal("0.5")),

    // 效率工具 - AI绘画
    AI_PAINTING_GENERAL(10006L, "效率工具", "AI绘画-通用", new BigDecimal("0.3")),
    AI_PAINTING_PORTRAIT(10007L, "效率工具", "AI绘画-人物肖像", new BigDecimal("0.3")),
    AI_PAINTING_FLAT_DESIGN(10008L, "效率工具", "AI绘画-平面设计", new BigDecimal("0.3")),
    AI_PAINTING_ART_DESIGN(10009L, "效率工具", "AI绘画-环艺设计", new BigDecimal("0.3")),
    AI_PAINTING_ECOMMERCE(10010L, "效率工具", "AI绘画-电商产品", new BigDecimal("0.3")),

    // 效率工具 - AI视频
    AI_AUDIO(10011L, "效率工具", "AI音频", new BigDecimal("0.3")),
    AI_VIDEO_PREPRODUCTION(10012L, "效率工具", "AI视频-前期制作", new BigDecimal("0.5")),
    AI_VIDEO_SPECIAL_EFFECTS(10013L, "效率工具", "AI视频-视频特效", new BigDecimal("1")),
    AI_VIDEO_PRODUCTION(10014L, "效率工具", "AI视频-视频生成", new BigDecimal("1")),

    // 效率工具 - AI3D
    AI_3D_TOOL(10015L, "效率工具", "AI3D", new BigDecimal("0.5")),

    // 大语言模型
    LANGUAGE_MODEL_MULTIMODAL(10016L, "大语言模型", "多模态", new BigDecimal("0.01")), // 1000 token 扣0.01元

    // AI写作
    AI_WRITING_IMAGE(10001L, "AI写作", "图片", new BigDecimal("1")), // KEXUE_MULTIMODAL
    AI_WRITING_TEXT(10018L, "AI写作", "文本", new BigDecimal("0.01")), // 1000 token 扣0.01元

    // deep research
    DEEP_RESEARCH(10019L, "deep research", "深度研究", new BigDecimal("1")),

    // AI编程级
    AI_PROGRAMMING_MONKEY_OUTLOOK(10020L, "AI编程级", "monkey outlook", new BigDecimal("0.2")),

    // AI编程入门
    AI_PROGRAMMING_CANVAS(10021L, "AI编程入门", "canvas", new BigDecimal("0.03")),

    // 智能体开发
    AGENT_DEVELOPMENT_ADVANCED(10022L, "智能体开发", "包含高级", new BigDecimal("0.1")),

    // 教学智能体
    TEACHING_AGENT(10023L, "教学智能体", "基础", new BigDecimal("0.1")),

    // genie research
    GENIE_RESEARCH(10024L, "GENIE research", "京东智能体", new BigDecimal("1"))

    ;

    /**
     * 平台编码
     */
    private final Long platformId;

    /**
     * 大类
     */
    private final String majorCategory;

    /**
     * 分类
     */
    private final String subCategory;

    /**
     * 计费金额(元)
     */
    private final BigDecimal price;

    /**
     * 根据平台编码获取计费规则
     *
     * @param platformId 平台编码
     * @return 计费规则
     */
    public static BillingRuleEnum getByPlatformId(Long platformId) {
        for (BillingRuleEnum rule : values()) {
            if (rule.getPlatformId().equals(platformId)) {
                return rule;
            }
        }
        return null;
    }

    /**
     * 根据平台编码获取计费金额
     *
     * @param platformId 平台编码
     * @return 计费金额(元)
     */
    public static BigDecimal getPriceByPlatformId(Long platformId) {
        BillingRuleEnum rule = getByPlatformId(platformId);
        return rule != null ? rule.getPrice() : BigDecimal.ZERO;
    }

    /**
     * 检查平台编码是否为token计费类型
     *
     * @param platformId 平台编码
     * @return 是否为token计费
     */
    public static boolean isTokenBilling(Long platformId) {
        return 10016L == platformId || 10018L == platformId;
    }
}