fix:购物车下单

This commit is contained in:
momo
2023-09-20 18:04:33 +08:00
parent 4d3f1512ac
commit 137919a4d7
7 changed files with 61 additions and 52 deletions

View File

@@ -4,8 +4,6 @@ import (
"fmt"
"fusenapi/constants"
"fusenapi/model/gmodel"
"math/rand"
"strconv"
"time"
)
@@ -82,23 +80,9 @@ func GetAmountInfo(req GetAmountInfoReq) gmodel.AmountInfo {
}
func GenerateOrderNumber(deliveryMethod int, 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) + strconv.Itoa(deliveryMethod)
t := time.Now()
orderNumber := fmt.Sprintf("%d%02d%02d%d", t.Year(), t.Month(), t.Day(), t.Nanosecond())
fmt.Println(orderNumber)
return orderNumber
}
@@ -118,9 +102,9 @@ func GenerateOrderStatusLink(deliveryMethod int64, noTime time.Time, expectedTim
StatusTitle: constants.OrderStatusMessage[v],
})
}
list[0].Ctime = noTime
list[0].Utime = noTime
list[len(list)-1].ExpectedTime = expectedTime
list[0].Ctime = &noTime
list[0].Utime = &noTime
list[len(list)-1].ExpectedTime = &expectedTime
return list
}