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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 商城订单配送方式，与 {@code mall_order.delivery_type} 存储值一致。
 *
 * @author jeesharp
 * @since 2026-05-15
 */
@Getter
@AllArgsConstructor
public enum MallDeliveryTypeEnum {

    /** 快递配送 */
    DELIVERY("DELIVERY", "配送"),

    /** 到店自提 */
    PICKUP("PICKUP", "到店自提");

    private final String code;
    private final String desc;

    public static MallDeliveryTypeEnum fromCode(String code) {
        if (code == null || code.isBlank()) {
            return null;
        }
        for (MallDeliveryTypeEnum e : values()) {
            if (e.code.equalsIgnoreCase(code.trim())) {
                return e;
            }
        }
        return null;
    }
}
