PayDeviceEnum.java 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. package com.zanxiang.common.enums;
  2. import lombok.Getter;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import java.util.stream.Collectors;
  6. /**
  7. * 支付设备类型
  8. *
  9. * @author xufeng
  10. * @date 2022/6/16 18:07
  11. */
  12. @Getter
  13. public enum PayDeviceEnum {
  14. /**
  15. * Pc端支付
  16. */
  17. PC_PAY(1, "pc", "Pc端支付"),
  18. /**
  19. * h5支付
  20. */
  21. H5_PAY(2, "h5", "Wap端h5支付"),
  22. /**
  23. * App支付
  24. */
  25. APP_PAY(3, "app", "App支付"),
  26. /**
  27. * 小程序支付
  28. */
  29. MINI_APP_PAY(4, "mp", "小程序支付"),
  30. /**
  31. * 小程序支付
  32. */
  33. MI_PAY(5, "miPay", "米大师支付");
  34. private Integer code;
  35. private String name;
  36. private String desc;
  37. PayDeviceEnum(Integer code, String name, String desc) {
  38. this.code = code;
  39. this.name = name;
  40. this.desc = desc;
  41. }
  42. public static String getCodeByNum(Integer code) {
  43. PayDeviceEnum[] values = PayDeviceEnum.values();
  44. for (int i = 0; i < values.length; i++) {
  45. if (values[i].getCode().equals(code)) {
  46. return values[i].getName();
  47. }
  48. }
  49. return "";
  50. }
  51. public static String getDescByNum(Integer code) {
  52. PayDeviceEnum[] values = PayDeviceEnum.values();
  53. for (int i = 0; i < values.length; i++) {
  54. if (values[i].getCode().equals(code)) {
  55. return values[i].getDesc();
  56. }
  57. }
  58. return "";
  59. }
  60. public static String getSqlCode(Integer code) {
  61. return "," + code + ",";
  62. }
  63. public static String getDesc(String obj) {
  64. List<String> Desc = new ArrayList<>(10);
  65. String str = obj.substring(1, obj.length() - 1);
  66. String[] strArr = str.split(",");
  67. for (int i = 0; i < strArr.length; i++) {
  68. String name = PayDeviceEnum.getDescByNum(Integer.valueOf(strArr[i]));
  69. Desc.add(name);
  70. }
  71. return Desc.stream().collect(Collectors.joining(","));
  72. }
  73. }