package com.goafanti.common.enums;

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

import org.apache.commons.lang3.StringUtils;

public enum OrderFlowState {
	DDBG(0, "订单变更"), 
	RWPD(1, "任务分派"),
	TPCL(2, "特批处理"),
	LSQR(3, "流水确认"),
	QT(9, "其他"),
	;

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

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

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

	public static boolean isPayed(OrderFlowState os) {
		return os == RWPD || os == QT;
	}

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

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

	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;
	}

}
