package com.zt.plat.module.contractorder.enums;

import lombok.Getter;

@Getter
public enum OrderTypeEnum {
    // 基础业务订单
    SALE("SALE", "销售", 0),
    PUR("PUR", "采购", 1),
    ENT("ENT", "委托加工", 2),
    ENTED_PUR("ENTED_PUR", "来料加工-采购", 3),
    ENTED_SALE("ENTED_SALE", "来料加工-销售", 10),

    // 物流服务订单
    HD_13("13HD", "货运代理", 4),
    YS_10("10YS", "货物运输", 5),
    CC_11("11CC", "货物保管仓储", 6),
    BX_03("03BX", "货物保险", 7);

    /** 订单类型编码（字典键值） */
    private final String code;
    /** 订单类型描述（字典标签） */
    private final String description;
    /** 排序号（字典排序） */
    private final Integer sort;

    OrderTypeEnum(String code, String description, Integer sort) {
        this.code = code;
        this.description = description;
        this.sort = sort;
    }

    /**
     * 根据编码获取枚举
     */
    public static OrderTypeEnum getByCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            return null;
        }
        for (OrderTypeEnum type : values()) {
            if (type.getCode().equals(code.trim())) {
                return type;
            }
        }
        return null;
    }

}