package com.jeesharp.business.modules.coupon.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 优惠券模板类型，对应 {@code app_coupon_template.coupon_type}。
 *
 * @author jeesharp
 * @since 2026-05-07
 */
@Getter
@AllArgsConstructor
public enum CouponTemplateTypeEnum {

    /**
     * 满减券
     */
    FULL_REDUCTION(1, "满减券"),

    /**
     * 折扣券
     */
    DISCOUNT(2, "折扣券"),

    /**
     * 无门槛券
     */
    NO_THRESHOLD(3, "无门槛券"),

    /**
     * 兑换券
     */
    EXCHANGE(4, "兑换券");

    private final Integer value;
    private final String desc;

    public static CouponTemplateTypeEnum fromValue(Integer value) {
        if (value == null) {
            return null;
        }
        for (CouponTemplateTypeEnum e : values()) {
            if (e.value.equals(value)) {
                return e;
            }
        }
        return null;
    }

    public static String getDescByValue(Integer value) {
        CouponTemplateTypeEnum e = fromValue(value);
        return e != null ? e.getDesc() : "";
    }
}
