package utils

import (
	"math/rand"
	"time"
)

const source = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

// 生成订单号  模版 BD20250220104501+6位随机数 避免 订单号重复
func GetOrderNo() string {
	return "BD" + time.Now().Format("20060102150405") + GetRandomString(6)
}

// 生成随机字符串
func GetRandomString(length int) string {
	rand.Seed(time.Now().UnixNano())
	bytes := make([]byte, length)
	for i := 0; i < length; i++ {
		bytes[i] = source[rand.Intn(62)]
	}
	return string(bytes)
}