package cn.superdesk.uniorder.common.enums.lnss;

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

/**
 * @author kite
 * @version 1.0
 * @date 2019/8/10
 */
public enum OrderStatusEnum {

    CANCEL(0,"已取消"),

    NO_SALE(1,"待支付"),

    SALE(2,"待接单"),

    DELIVERY(3,"配送中"),

    SEND(4,"已配送"),

    FINISH(5,"已完成"),

    NO_CONFIRM(6, "待确认"),

    CONFIRM(7, "待提货"),

    PICK_UP(8, "已提货"),

    ;

    private Integer key;
    private String desc;

    OrderStatusEnum(int key, String desc) {
        this.key = key;
        this.desc = desc;
    }

    public int getKey() {
        return key;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDesc(int key) {
        for (OrderStatusEnum c : OrderStatusEnum.values()) {
            if (c.key == key) {
                return c.getDesc();
            }
        }
        return null;
    }

    private static final Map<Integer, OrderStatusEnum> LOOKUP = new HashMap<>();

    static {
        for(OrderStatusEnum s : EnumSet.allOf(OrderStatusEnum.class)) {
            LOOKUP.put(s.getKey(), s);
        }
    }

    /**
     * 方向查找枚举类
     * @param key
     * @return
     */
    public static OrderStatusEnum get(Integer key) {
        return LOOKUP.get(key);
    }
}
