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 ProgressStatusEnum {

    CANCEL(0,"已取消"),

    ORDER(1,"已下单"),

    GET_ORDER(2,"已接单"),

    DELIVERY(3,"已配送"),

    FINISH(4,"已完成"),

    CONFIRM(5, "已确认"),

    PICK_UP(6, "已提货"),
    ;

    private Integer key;
    private String desc;

    ProgressStatusEnum(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 (ProgressStatusEnum c : ProgressStatusEnum.values()) {
            if (c.key == key) {
                return c.getDesc();
            }
        }
        return null;
    }

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

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

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