OrderState.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package com.goafanti.order.enums;
  2. import java.util.HashMap;
  3. import java.util.Map;
  4. public enum OrderState {
  5. /** 意向订单 **/
  6. INTENTION(0,"意向订单 "),
  7. /** 等待支付首付款 **/
  8. WAIT_FOR_FIRST_PAY(1,"等待支付首付"),
  9. /** 等待支付尾款 **/
  10. WAIT_FOR_LAST_PAY(2,"等待支付尾款"),
  11. /** 已完成 **/
  12. COMPLETED(3,"已完成"),
  13. /** 已取消 **/
  14. CANCELLED(4,"已取消"),
  15. /** 无效 **/
  16. INVALID(10, "无效");
  17. private OrderState(Integer code, String desc) {
  18. this.code = code;
  19. this.desc = desc;
  20. }
  21. private static Map<Integer, OrderState> status = new HashMap<Integer, OrderState>();
  22. static {
  23. for (OrderState value : OrderState.values()) {
  24. status.put(value.getCode(), value);
  25. }
  26. }
  27. public static OrderState getStatus(Integer code) {
  28. if (containsType(code)) {
  29. return status.get(code);
  30. }
  31. return INVALID;
  32. }
  33. public static boolean containsType(Integer code) {
  34. return status.containsKey(code);
  35. }
  36. private Integer code;
  37. private String desc;
  38. public Integer getCode() {
  39. return code;
  40. }
  41. public void setCode(Integer code) {
  42. this.code = code;
  43. }
  44. public String getDesc() {
  45. return desc;
  46. }
  47. public void setDesc(String desc) {
  48. this.desc = desc;
  49. }
  50. }