From e29f80387fe48e7783671996ff394c60991ae8ea Mon Sep 17 00:00:00 2001 From: loshiqi <553578653@qq.com> Date: Tue, 10 Mar 2026 10:13:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=9F=E4=B8=80=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=94=A8=E6=88=B7=E8=AE=A2=E5=8D=95=E7=BB=84=E6=89=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uuid.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/uuid.go b/uuid.go index 0cbd317..38ff2da 100644 --- a/uuid.go +++ b/uuid.go @@ -4,6 +4,7 @@ import ( "crypto/rand" "encoding/hex" "fmt" + "time" ) // Simple call @@ -69,3 +70,13 @@ func ParseUUID(uuid string) ([]byte, error) { return ret, nil } + +// 根据用户id获取订单号 标准时间毫秒级+user_id +func CreateOrderSn(user_id string) string { + if user_id == "" { + user_id = GetRandomNumber(5) + } + t := time.Now() + order_sn := fmt.Sprintf("%s%03d%s", t.Format("20060102150405"), t.Nanosecond()/1e6, user_id) + return order_sn +}