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

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

/**
 * @Description: Java类作用描述
 * @Author: linjinyu
 * @CreateDate: 7/16/20 10:59 AM
 * @UpdateUser: linjinyu
 * @UpdateDate: 7/16/20 10:59 AM
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public enum AccountingOrderTypeDimEnum {

	未知订单(-1, "未知订单"),
	一般订单(1, "一般订单"), // 订单 - 商品
	积分订单(2, "积分订单"), // 订单 - 商品 - 流水
	;

	private Integer key;
	private String  desc;

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

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

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

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