package com.ycwl.basic.order.enums;

/**
 * 优惠类型枚举
 */
public enum DiscountType {
    
    /**
     * 优惠券
     */
    COUPON("COUPON", "优惠券"),
    
    /**
     * 券码
     */
    VOUCHER("VOUCHER", "券码"),
    
    /**
     * 限时立减
     */
    LIMITED_TIME("LIMITED_TIME", "限时立减"),
    
    /**
     * 套餐优惠
     */
    BUNDLE("BUNDLE", "套餐优惠"),
    
    /**
     * 一口价优惠
     */
    FIXED_PRICE("FIXED_PRICE", "一口价优惠");
    
    private final String code;
    private final String description;
    
    DiscountType(String code, String description) {
        this.code = code;
        this.description = description;
    }
    
    public String getCode() {
        return code;
    }
    
    public String getDescription() {
        return description;
    }
    
    /**
     * 根据code获取枚举
     */
    public static DiscountType fromCode(String code) {
        for (DiscountType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown DiscountType code: " + code);
    }
}