随机生成流水号

public static List createRedPacketNo(int TotNum, String BrcNo) {
        List list = new ArrayList();
        int num = 1;
        while (num <= TotNum) {
            
            Date currentTime = new Date();
            SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
            String dateString = formatter.format(currentTime);
            int x = (int) (Math.random() * 900) + 100;
            int y = (int) (Math.random() * 700) + 100;
            int z = (int) (Math.random() * 500) + 100;
            String packetNo = BrcNo + dateString + x + y + z;
            // 返回红包编号
            list.add(packetNo);
            num++;
        }
        return list;

    }

猜你喜欢

转载自blog.csdn.net/weixin_42210904/article/details/86700647