bindbox-game/scripts/test_order_no.go
2026-01-27 01:33:32 +08:00

25 lines
456 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"fmt"
"math/rand"
"time"
)
func generateOrderNo() string {
// 使用当前时间戳 + 随机数生成订单号
// 格式RG + 年月日时分秒 + 6位随机数
r := rand.New(rand.NewSource(time.Now().UnixNano()))
return fmt.Sprintf("RG%s%06d",
time.Now().Format("20060102150405"),
r.Intn(1000000),
)
}
func main() {
for i := 0; i < 10; i++ {
fmt.Println(generateOrderNo())
time.Sleep(1 * time.Millisecond)
}
}