package com.ycwl.basic.pricing.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 优惠券类型枚举
 */
@Getter
@AllArgsConstructor
public enum CouponType {
    
    PERCENTAGE("percentage", "百分比折扣"),
    FIXED_AMOUNT("fixed_amount", "固定金额减免");
    
    private final String code;
    private final String description;
    
    /**
     * 根据代码获取枚举
     */
    public static CouponType fromCode(String code) {
        for (CouponType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown coupon type code: " + code);
    }
}