From 0ab9dfd8f122195e4e9f09bd50c59e0a47450bec Mon Sep 17 00:00:00 2001
From: mitao <2763622819@qq.com>
Date: 星期三, 19 三月 2025 15:50:03 +0800
Subject: [PATCH] fix: resolve merge conflicts in .gitignore

---
 ruoyi-common/src/main/java/com/ruoyi/common/utils/CodeGenerateUtils.java |   76 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/CodeGenerateUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/CodeGenerateUtils.java
new file mode 100644
index 0000000..76492bc
--- /dev/null
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/CodeGenerateUtils.java
@@ -0,0 +1,76 @@
+package com.ruoyi.common.utils;
+
+import java.math.BigDecimal;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * @Description
+ * @Author xiaochen
+ * @Date 2021/7/28 10:26
+ */
+public class CodeGenerateUtils {
+
+    /**
+     * @return
+     * @Description 获取商品编码
+     * 商品编码规则:nanoTime(后5位)*5位随机数(10000~99999)
+     * @Author xiaochen
+     */
+    public static String generateProductCode() {
+        long nanoPart = System.nanoTime() % 100000L;
+        if (nanoPart < 10000L) {
+            nanoPart += 10000L;
+        }
+        long randomPart = (long) (Math.random() * (90000) + 10000);
+        String code = "0" + new BigDecimal(nanoPart).multiply(new BigDecimal(randomPart));
+        return code.substring(code.length() - 10);
+    }
+
+    /**
+     * @return
+     * @Description 生成订单编号  10位
+     * 订单编号规则:(10位):(年末尾*月,取后2位)+(用户ID%3.33*日取整后2位)+(timestamp*10000以内随机数,取后6位)
+     * @Author xiaochen
+     */
+    public static String generateOrderSn() {
+        Calendar calendar = Calendar.getInstance();
+        int year = calendar.get(Calendar.YEAR);
+        year = year % 10;
+        if (year == 0) year = 10;
+        int month = calendar.get(Calendar.MONTH) + 1;
+        int yearMonth = year * month;
+        String yearMonthPart = "0" + yearMonth;
+        yearMonthPart = yearMonthPart.substring(yearMonthPart.length() - 2);
+
+        int day = calendar.get(Calendar.DAY_OF_MONTH);
+        double v = Math.random() * 10000;
+        int dayNum = (int) ((v % 3.33) * day);
+        String dayPart = "0" + dayNum;
+        dayPart = dayPart.substring(dayPart.length() - 2);
+
+        String timestampPart = "" + (Math.random() * 10000) * (System.currentTimeMillis() / 10000);
+        timestampPart = timestampPart.replace(".", "").replace("E", "");
+        timestampPart = timestampPart.substring(0, 6);
+        return yearMonthPart + dayPart + timestampPart;
+    }
+
+    /**
+     * @return
+     * @Description 生成统一支付单号  规则:年(2)月(2)日(2)时(2)分(2)+timestamp*5位随机整数取后5位
+     * @Author xiaochen
+     */
+    public static String generateVolumeSn() {
+        Calendar calendar = Calendar.getInstance();
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
+        String dateTime = dateFormat.format(calendar.getTime());
+        dateTime = dateTime.substring(2);
+        String timestampPart = "" + (Math.random() * 10000) * (System.currentTimeMillis() / 10000);
+        timestampPart = timestampPart.replace(".", "").replace("E", "");
+        timestampPart = timestampPart.substring(0, 0);
+        return dateTime + timestampPart;
+    }
+
+}

--
Gitblit v1.7.1