package cn.reghao.tnb.file.app.zorder.model.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * @author reghao
 * @date 2024-04-26 15:50:53
 */
public enum OrderStatus {
    toPay(1, "待付款"),
    toDelivery(2, "待收货"),
    toConfirm(3, "待确认"),
    cancelled(4, "已取消"),
    completed(5, "已完成");
    
    private final int code;
    private final String desc;

    private static Map<Integer, OrderStatus> map = new HashMap<>();
    static {
        for (OrderStatus status : OrderStatus.values()) {
            map.put(status.code, status);
        }
    }
    OrderStatus(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static OrderStatus getByCode(int code) {
        return map.get(code);
    }
}
