25 lines
353 B
Go
25 lines
353 B
Go
package utils
|
|
|
|
import (
|
|
"fmt"
|
|
"math/rand"
|
|
"time"
|
|
)
|
|
|
|
type idUtil struct {
|
|
}
|
|
|
|
// Id 暴露接口
|
|
func Id() *idUtil {
|
|
return &idUtil{}
|
|
}
|
|
|
|
// GenOrderNo 生成订单Id
|
|
func (idUtil) GenOrderNo() string {
|
|
ss := time.Now().Format("20060102")
|
|
sss := time.Now().UnixNano() / 1e8
|
|
r := rand.Intn(1000)
|
|
n := fmt.Sprintf("%s%d%03d", ss, sss, r)
|
|
return n
|
|
}
|