Browse Source

增加统一生成用户订单组手

master
loshiqi 4 days ago
parent
commit
e29f80387f
1 changed files with 11 additions and 0 deletions
  1. +11
    -0
      uuid.go

+ 11
- 0
uuid.go View File

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

Loading…
Cancel
Save