package com.goafanti.order.enums; import java.util.HashMap; import java.util.Map; public enum OrderState { /** 意向订单 **/ INTENTION(0,"意向订单 "), /** 等待支付首付款 **/ WAIT_FOR_FIRST_PAY(1,"等待支付首付"), /** 等待支付尾款 **/ WAIT_FOR_LAST_PAY(2,"等待支付尾款"), /** 已完成 **/ COMPLETED(3,"已完成"), /** 已取消 **/ CANCELLED(4,"已取消"), /** 无效 **/ INVALID(10, "无效"); private OrderState(Integer code, String desc) { this.code = code; this.desc = desc; } private static Map status = new HashMap(); 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; } }