fix: 创建订单时设置30分钟支付过期时间
This commit is contained in:
@@ -176,6 +176,12 @@ func checkOrdersExpired(orders []models.Order) {
|
||||
}
|
||||
}
|
||||
|
||||
// getPaymentExpiryTime 获取支付过期时间(当前时间 + 30分钟)
|
||||
func getPaymentExpiryTime() *time.Time {
|
||||
t := time.Now().Add(30 * time.Minute)
|
||||
return &t
|
||||
}
|
||||
|
||||
func (h *OrderHandler) List(c *gin.Context) {
|
||||
userID := c.GetUint("user_id")
|
||||
role, _ := c.Get("role")
|
||||
@@ -401,6 +407,7 @@ func (h *OrderHandler) Create(c *gin.Context) {
|
||||
Status: models.OrderStatusPendingPayment,
|
||||
ShippingAddressID: &req.ShippingAddressID,
|
||||
PaymentMethod: req.PaymentMethod,
|
||||
PaymentExpiresAt: getPaymentExpiryTime(),
|
||||
}
|
||||
|
||||
tx := utils.DB.Begin()
|
||||
|
||||
Reference in New Issue
Block a user