order.go 675 B

1234567891011121314151617181920212223242526
  1. /**
  2. #*****************************************************************************
  3. # @file order.go
  4. # @author MakerYang(https://www.makeryang.com)
  5. # @statement 免费课程配套开源项目,任何形式收费均为盗版
  6. #*****************************************************************************
  7. */
  8. package Utils
  9. import (
  10. "math/rand"
  11. "time"
  12. )
  13. func CreateOrderNum() string {
  14. str := "0123456789"
  15. bytes := []byte(str)
  16. result := make([]byte, 0)
  17. r := rand.New(rand.NewSource(time.Now().UnixNano()))
  18. for i := 0; i < 8; i++ {
  19. result = append(result, bytes[r.Intn(len(bytes))])
  20. }
  21. order := time.Now().Format("20060102150405") + string(result)
  22. return order
  23. }