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

@@ -100,12 +100,12 @@ var (
CodeLogoCombineErr = &StatusResponse{5115, "logo combine fail"} // 合图失败
CodeLogoCombineNoFoundErr = &StatusResponse{5116, "template record not found"} // 模版不存在
CodeErrOrder = &StatusResponse{5300, "ocreate order failed"} // 订单错误
CodeErrOrderCreatShoppingCartEmpty = &StatusResponse{5301, "ocreate order failed, shopping cart is empty"} // 订单创建失败,购物车为空
CodeErrOrderCreatShoppingCartNotMatched = &StatusResponse{5302, "ocreate order failed, shopping cart not matched"} // 订单创建失败,购物车不相符
CodeErrOrderCreatProductAbsent = &StatusResponse{5303, "ocreate order failed, product is absent"} // 订单创建失败,商品不存在
CodeErrOrderCreatProductPriceAbsent = &StatusResponse{5304, "ocreate order failed, price of product is absent"} // 订单创建失败,商品价格不存在
CodeErrOrderCreatProductAccessoryAbsent = &StatusResponse{5305, "ocreate order failed, accessory of product is absent"} // 订单创建失败,商品配件不存在
CodeErrOrder = &StatusResponse{5300, "create order failed"} // 订单错误
CodeErrOrderCreatShoppingCartEmpty = &StatusResponse{5301, "create order failed, shopping cart is empty"} // 订单创建失败,购物车为空
CodeErrOrderCreatShoppingCartNotMatched = &StatusResponse{5302, "create order failed, shopping cart not matched"} // 订单创建失败,购物车不相符
CodeErrOrderCreatProductAbsent = &StatusResponse{5303, "create order failed, product is absent"} // 订单创建失败,商品不存在
CodeErrOrderCreatProductPriceAbsent = &StatusResponse{5304, "create order failed, price of product is absent"} // 订单创建失败,商品价格不存在
CodeErrOrderCreatProductAccessoryAbsent = &StatusResponse{5305, "create order failed, accessory of product is absent"} // 订单创建失败,商品配件不存在
)
type Response struct {

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
}