package com.ruoyi.hywz.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * @author lijie
 * @create 2020-12-10 9:36
 * @desc
 **/
public class TradeCodeUtil {

    private static final String pattern = "yyyyMMdd";

    //订单号生成策略1 当前时间+3位随机数
    public static String getCode() {
        return getCode("");
    }

    //订单号生成策略1 当前时间+3位随机数
    public static String getCode(String name) {



        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        String code = sdf.format(new Date());
        int i = (int) (Math.random() * 900) + 100;
        String str = code + System.currentTimeMillis();
        String code1 = str.substring(0, 18).toUpperCase(Locale.ROOT);
        return name+code1;

    }

    public static String getPatternCode() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String code = sdf.format(new Date());
        return code;

    }




}
