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

15 lines
400 B
Go
Raw Normal View History

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