package cn.superdesk.uniorder.common.enums.thirdpart.jd;

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

/**
 * @Description: 售后状态 未进售后 售后完成 已进售后
 * @Author: linjinyu
 * @CreateDate: 2021/10/21 上午10:41
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/10/21 上午10:41
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum JdAfterSaleStateEnum {

	UNKNOW(-1, "UNKNOW"),
	未进售后(10, "未进售后"),
	已进售后(20, "已进售后"),
	售后完成(21, "售后完成"),
	;

	private Integer key;
	private String  desc;

	JdAfterSaleStateEnum(Integer key, String desc) {
		this.key = key;
		this.desc = desc;
	}

	public Integer getKey() {
		return key;
	}

	public String getDesc() {
		return desc;
	}

	public static String getDesc(Integer key) {
		for (JdAfterSaleStateEnum c : JdAfterSaleStateEnum.values()) {
			if (c.key.equals(key)) {
				return c.getDesc();
			}
		}
		return null;
	}

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

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

	public static JdAfterSaleStateEnum get(Integer key) {
		return LOOKUP.get(key);
	}

	public static JdAfterSaleStateEnum getByDesc(String desc) {
		for (JdAfterSaleStateEnum stateEnum : JdAfterSaleStateEnum.values()) {
			if (stateEnum.desc.equals(desc)) {
				return stateEnum;
			}
		}
		return JdAfterSaleStateEnum.UNKNOW;
	}
}
