order.go 364 B

123456789101112131415161718
  1. package Utils
  2. import (
  3. "math/rand"
  4. "time"
  5. )
  6. func CreateOrderNum() string {
  7. str := "0123456789"
  8. bytes := []byte(str)
  9. result := make([]byte, 0)
  10. r := rand.New(rand.NewSource(time.Now().UnixNano()))
  11. for i := 0; i < 8; i++ {
  12. result = append(result, bytes[r.Intn(len(bytes))])
  13. }
  14. order := time.Now().Format("20060102150405") + string(result)
  15. return order
  16. }