package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum DemandOrderStatus {
	CREATE(0, "初始意向"),
	INTENTIONMONEY(1,"交付意向金"),
	SIGN(2,"签订合同"),
	CONTRACTMONEY(3, "交付合同金"),
	COMMISSION(4,"交付佣金"),
	SERVICEMONEY(5, "交付服务金"),
	SHUTDOWN(6,"关闭"),
	OTHER(7, "其他");

	private DemandOrderStatus(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

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

	static {
		for (DemandOrderStatus value : DemandOrderStatus.values()) {
			status.put(value.getCode(), value);
		}
	}

	public static DemandOrderStatus getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return OTHER;
	}

	public static DemandOrderStatus getStatus(String code) {
		if (StringUtils.isNumeric(code)) {
			return getStatus(Integer.parseInt(code));
		}
		return OTHER;
	}

	public static boolean containsType(Integer code) {
		return status.containsKey(code);
	}

	private Integer	code;
	private String	desc;

	public Integer getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}

}
