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

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

/**
 * @Description: 订单商品类型
 * @Author: linjinyu
 * @CreateDate: 2021/4/23 下午12:32
 * @UpdateUser: linjinyu
 * @UpdateDate: 2021/4/23 下午12:32
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum CommonOrderGoodsTypeEnum {


//	商品类型:1-商品;2-运费;3-杂费;4-赠品;


	商品(1, "商品"),
	运费(2, "运费"),
	杂费(3, "杂费"),
	赠品(4, "赠品"),
	;

	private Integer key;
	private String  desc;

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

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

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

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