package com.caimei.util; import java.util.Random; /** * 订单编号 * * @author : Charles * @date : 2020/3/19 */ public class OrderNoUtils { /** * 订单模块生成新订单号 * * @param platform * @return */ public static String getOrderNo(String platform) { Random rand = new Random(); String code = ""; for (int j = 0; j < 5; j++) { code += rand.nextInt(10) + ""; } return platform + System.currentTimeMillis() / 1000 + code; } /*** * 子订单编号生成 * @param orderNo * @param num * @return */ public static String getShopOrderNo(String orderNo, Integer num) { if (num < 10) { return orderNo + "0" + num; } else { return orderNo + num; } } /** * 根据订单列表类型获取订单状态 * * @param listType * @return status */ public static int[] getStatusByListType(Integer listType) { // listType:列表类型(1:待确认,2:待支付,3:待发货,4:已发货,5:退货退款) switch (listType) { case 1: // status待确认(0) return new int[]{0}; case 2: // status待支付(21,22,23,11,12,13) return new int[]{21, 22, 23, 11, 12, 13}; case 3: // status待发货(11,12,21,22,31,32), return new int[]{11, 12, 21, 22, 31, 32}; case 4: // status已发货(12,13,22,23,32,33), return new int[]{12, 13, 22, 23, 32, 33}; case 5: // status退货退款(1,2) return new int[]{1, 2, 7}; default: return null; } } }