package com.yiqi.common.utils;

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

/**
 * @author xiaohei
 * @date 2023/10/17
 */
public class CodeUtils {

    /**
     * 生成订单商品核销码
     *
     * @return
     */
    public static String genVerifyCode() {
        String year = new SimpleDateFormat("yy").format(new Date());
        String day = String.format("%tj", new Date());
        double random = Math.random() * 10000000;
        while (random < 1000000) {
            random = Math.random() * 10000000;
        }
        int intRandom = Double.valueOf(random).intValue();
        String verifyCode = year + day + intRandom;
        return verifyCode;
    }

    public static void main(String[] args) {
        System.out.println(genVerifyCode());
    }
}
