OrderNoUtils.java 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package com.caimei.util;
  2. import java.util.Random;
  3. /**
  4. * 订单编号
  5. *
  6. * @author : Charles
  7. * @date : 2020/3/19
  8. */
  9. public class OrderNoUtils {
  10. /**
  11. * 订单模块生成新订单号
  12. *
  13. * @param platform
  14. * @return
  15. */
  16. public static String getOrderNo(String platform) {
  17. Random rand = new Random();
  18. String code = "";
  19. for (int j = 0; j < 5; j++) {
  20. code += rand.nextInt(10) + "";
  21. }
  22. return platform + System.currentTimeMillis() / 1000 + code;
  23. }
  24. /***
  25. * 子订单编号生成
  26. * @param orderNo
  27. * @param num
  28. * @return
  29. */
  30. public static String getShopOrderNo(String orderNo, Integer num) {
  31. if (num < 10) {
  32. return orderNo + "0" + num;
  33. } else {
  34. return orderNo + num;
  35. }
  36. }
  37. /**
  38. * 根据订单列表类型获取订单状态
  39. *
  40. * @param listType
  41. * @return status
  42. */
  43. public static int[] getStatusByListType(Integer listType) {
  44. // listType:列表类型(1:待确认,2:待支付,3:待发货,4:已发货,5:退货退款)
  45. switch (listType) {
  46. case 1:
  47. // status待确认(0)
  48. return new int[]{0};
  49. case 2:
  50. // status待支付(21,22,23,11,12,13)
  51. return new int[]{21, 22, 23, 11, 12, 13};
  52. case 3:
  53. // status待发货(11,12,21,22,31,32),
  54. return new int[]{11, 12, 21, 22, 31, 32};
  55. case 4:
  56. // status已发货(12,13,22,23,32,33),
  57. return new int[]{12, 13, 22, 23, 32, 33};
  58. case 5:
  59. // status退货退款(1,2)
  60. return new int[]{1, 2, 7};
  61. default:
  62. return null;
  63. }
  64. }
  65. }