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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * SPU 发货时效类型，与 {@code mall_spu.ship_time_type} 一致。
 *
 * @author jeesharp
 * @since 2026-05-16
 */
@Getter
@AllArgsConstructor
public enum MallSpuShipTimeTypeEnum {

    /** 今日发 */
    TODAY(1, "今日发"),

    /** 24 小时内发货 */
    WITHIN_24H(2, "24小时发货"),

    /** 48 小时内发货 */
    WITHIN_48H(3, "48小时发货"),

    /** 大于 48 小时发货 */
    OVER_48H(4, "大于48小时发货");

    private final Integer value;
    private final String desc;

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

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