package com.goafanti.order.enums;

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

/**
 * 资金流水科目
 * @author Administrator
 *
 */
public enum TransactionSubject {
	/** 代收 **/
	SUPPLY_COLLECT(0,"代收"),
	/** 代付 **/
	SUPPLY_PAY(1,"代付"),
	/** 退款 **/
	REFUND(2,"退款"),
	/** 无效 **/
	INVALID(10, "INVALID");
	
	private TransactionSubject(Integer code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	private static Map<Integer, TransactionSubject> subjects = new HashMap<Integer, TransactionSubject>();

	static {
		for (TransactionSubject value : TransactionSubject.values()) {
			subjects.put(value.getCode(), value);
		}
	}
	public static TransactionSubject getStatus(Integer code) {
		if (containsType(code)) {
			return subjects.get(code);
		}
		return INVALID;
	}
	public static String getValueByCode(Integer code){
        for(TransactionSubject transactionSubject:TransactionSubject.values()){
            if(code.equals(transactionSubject.getCode())){
                return transactionSubject.getDesc();
            }
        }
        return  null;
    }	
	public static boolean containsType(Integer code) {
		return subjects.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;
	}
}
