PayWayEnum.java 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package com.zanxiang.common.enums;
  2. /**
  3. * 支付方式枚举
  4. *
  5. * @author xufeng
  6. * @date 2022/6/9 10:41
  7. */
  8. public enum PayWayEnum {
  9. ALIPAY("Alipay", "支付宝", 1),
  10. WXPAY("Wxpay", "微信支付", 2),
  11. UNIONPAY("Unionpay", "银联支付", 3);
  12. private final String code;
  13. private final String name;
  14. private final Integer num;
  15. PayWayEnum(String code, String name, Integer num) {
  16. this.code = code;
  17. this.name = name;
  18. this.num = num;
  19. }
  20. public String getName() {
  21. return name;
  22. }
  23. public String getCode() {
  24. return code;
  25. }
  26. public Integer getNum() {
  27. return num;
  28. }
  29. /**
  30. * 通过num获取pay code
  31. *
  32. * @param num
  33. * @return code
  34. */
  35. public static String getCodeByNum(Integer num) {
  36. PayWayEnum[] values = PayWayEnum.values();
  37. for (int i = 0; i < values.length; i++) {
  38. if (values[i].getNum().equals(num))
  39. return values[i].getCode();
  40. }
  41. return "";
  42. }
  43. }