Files
full/module/ec/order/internal/logic/common/no.go

15 lines
400 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 common
import (
"fmt"
"math/rand"
"time"
)
// 订单号2位年份6位随机数共18位
func CreateOrderNo() string {
t := time.Now().Local()
rand := fmt.Sprintf("%06v", rand.New(rand.NewSource(time.Now().UnixNano())).Int31n(1000000))
return fmt.Sprintf("%d%d%d%d%d%d%s", t.Year()-2000, t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), rand)
}