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 +}