package com.goafanti.order.enums;

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

public enum OrderChangeType {
	//变更类型 0退单退款 1项目及金额变更 2仅项目变更 3仅金额变更 4重报 5赠送
	TDTK(0,"退单退款"),
	XMJJEBG(1,"项目及金额变更"),
	JXMBG(2,"仅项目变更"),
	JJEBG(3,"仅金额变更"),
	CB(4,"重报"),
	ZS(5,"赠送"),
	/** 无效 **/
	INVALID(10, "INVALID");
	
	private OrderChangeType(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	private static Map<Integer, OrderChangeType> status = new HashMap<Integer, OrderChangeType>();

	static {
		for (OrderChangeType value : OrderChangeType.values()) {
			status.put(value.getCode(), value);
		}
	}
	public static OrderChangeType getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return INVALID;
	}
	
	public static String getValueByCode(Integer code){
        for(OrderChangeType orderChangeType:OrderChangeType.values()){
            if(code.equals(orderChangeType.getCode())){
                return orderChangeType.getDesc();
            }
        }
        return  null;
    }
	
	public static boolean containsType(Integer code) {
		return status.containsKey(code);
	}
	private Integer	code;
	private String	desc;
	public Integer getCode() {
		return code;
	}
	public void setCode(Integer code) {
		this.code = code;
	}
	public String getDesc() {
		return desc;
	}
	public void setDesc(String desc) {
		this.desc = desc;
	}
}
