fix:购物车下单
This commit is contained in:
@@ -1,7 +1,12 @@
|
||||
package order
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"math/rand"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
type AmountCurrencyReq struct {
|
||||
@@ -75,3 +80,48 @@ func GetAmountInfo(req GetAmountInfoReq) gmodel.AmountInfo {
|
||||
Metadata: req.Metadata,
|
||||
}
|
||||
}
|
||||
|
||||
func GenerateOrderNumber(userID int) string {
|
||||
// 获取当前时间
|
||||
now := time.Now()
|
||||
|
||||
// 生成年月日时分秒的字符串
|
||||
year := strconv.Itoa(now.Year())
|
||||
month := strconv.Itoa(int(now.Month()))
|
||||
day := strconv.Itoa(now.Day())
|
||||
hour := strconv.Itoa(now.Hour())
|
||||
minute := strconv.Itoa(now.Minute())
|
||||
second := strconv.Itoa(now.Second())
|
||||
|
||||
// 生成2位随机数
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
randomNum := fmt.Sprintf("%02d", rand.Intn(100))
|
||||
|
||||
// 拼接订单号
|
||||
orderNumber := year + month + day + hour + minute + second + randomNum + strconv.Itoa(userID)
|
||||
return orderNumber
|
||||
}
|
||||
|
||||
// 初始化订单状态
|
||||
func GenerateOrderStatusLink(req []gmodel.OrderStatus) []gmodel.OrderStatus {
|
||||
var list []gmodel.OrderStatus
|
||||
|
||||
for _, v := range constants.OrderStatusUser {
|
||||
for _, v1 := range req {
|
||||
if v1.StatusCode == v {
|
||||
list = append(list, v1)
|
||||
} else {
|
||||
list = append(list, gmodel.OrderStatus{
|
||||
StatusCode: v,
|
||||
StatusTitle: constants.OrderStatusMessage[v],
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
// 获取订单当前状态
|
||||
func GenerateOrderStatusCurrent() gmodel.OrderStatus {
|
||||
return gmodel.OrderStatus{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user