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

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

/**
 * 折扣方案 1:折扣率 2:折扣价
 * @author Homan Liang
 * @version 1.0
 * @date 2020/2/18
 */
public enum DiscountSchemeEnum {

    DISCOUNT_RATE(1,"折扣率"),

    DISCOUNT_PRICE(2,"折扣价"),

    ;

    private Integer key;
    private String desc;

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

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

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

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