package com.goafanti.order.enums; import java.util.HashMap; import java.util.Map; public enum PayChannel { /** 微信 **/ WECHAT(0,"WECHAT"), /** 支付宝 **/ ALIPAY(1,"ALIPAY"), /** 银联支付 **/ UNIONPAY(2,"UNIONPAY"), /** 无效 **/ INVALID(10, "INVALID"); private PayChannel(Integer code, String desc) { this.code = code; this.desc = desc; } private static Map channels = new HashMap(); static { for (PayChannel value : PayChannel.values()) { channels.put(value.getCode(), value); } } public static PayChannel getStatus(Integer code) { if (containsType(code)) { return channels.get(code); } return INVALID; } public static boolean containsType(Integer code) { return channels.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; } }