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:42
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/10/21 上午10:42
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum JdOrderStateEnum {

	UNKNOW(-1, "UNKNOW"),
	已完成(100, "已完成"),
	部分退货(99, "部分退货"),
	;

	private Integer key;
	private String  desc;

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

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

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

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

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