AfterSaleStatusEnum.java 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package com.ylx.massage.enums;
  2. import lombok.Getter;
  3. /**
  4. * 售后状态枚举
  5. */
  6. @Getter
  7. public enum AfterSaleStatusEnum {
  8. WAIT_AUDIT(0, "待审核"),
  9. REFUND_COMPLETED(1, "退款完成"),
  10. WAITING_USER_RETURN(2, "等待用户寄回"),
  11. WAITING_MERCHANT_RECEIVE(3, "等待商家收货"),
  12. WAITING_MERCHANT_SHIP(4, "等待商家寄出"),
  13. COMPLETED(5, "订单完成"),
  14. CANCELLED(6, "售后取消");
  15. private final Integer code;
  16. private final String desc;
  17. AfterSaleStatusEnum(Integer code, String desc) {
  18. this.code = code;
  19. this.desc = desc;
  20. }
  21. /**
  22. * 根据code获取枚举值
  23. * @param code 代码
  24. * @return 枚举值
  25. */
  26. public static AfterSaleStatusEnum valueOf(Integer code) {
  27. if (code == null) {
  28. return null;
  29. }
  30. for (AfterSaleStatusEnum value : AfterSaleStatusEnum.values()) {
  31. if (value.getCode().equals(code)) {
  32. return value;
  33. }
  34. }
  35. return null;
  36. }
  37. public static String getDescByCode(Integer code) {
  38. if (code == null) {
  39. return "";
  40. }
  41. for (AfterSaleStatusEnum value : AfterSaleStatusEnum.values()) {
  42. if (value.getCode().equals(code)) {
  43. return value.getDesc();
  44. }
  45. }
  46. return "";
  47. }
  48. }