package com.goafanti.order.enums;

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

/**
 * 订单状态
 * @author Administrator
 *
 */
public enum OrderState {
	/** 订单待确认 **/
	WAIT_FOR_CONFIRM(1,"待确认"),
	/** 买家已取消 **/
	BUYER_CANCEL_BEFORE_SIGN(10,"买家已取消"),
	/** 卖家已拒绝 **/
	SELLER_REFUSE_BEFORE_SIGNL(11,"卖家已拒绝"),
	/** 待签单 **/
	WAIT_FOR_SIGN(2,"待签单"),
	/** 买家已取消 **/
	BUYER_CANCEL_AFTER_SIGN(20,"买家已取消"),
	/** 卖家已取消 **/
	SELLER_CANCEL_AFTER_SIGN(21,"卖家已取消"),
	/** 已签单 **/
	ALREADY_SIGN(3,"已签单"),
	/** 无效 **/
	INVALID(10, "无效");
	
	private OrderState(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

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

	static {
		for (OrderState value : OrderState.values()) {
			status.put(value.getCode(), value);
		}
	}
	public static OrderState getStatus(Integer code) {
		if (containsType(code)) {
			return status.get(code);
		}
		return INVALID;
	}
	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;
	}
	
}
