Ver código fonte

修复支付订单bug

kobe6258 4 meses atrás
pai
commit
d10fa04ff5
2 arquivos alterados com 4 adições e 4 exclusões
  1. 1 1
      domian/order/trade_order.go
  2. 3 3
      service/order/order_service.go

+ 1 - 1
domian/order/trade_order.go

@@ -69,7 +69,7 @@ func CreateTradeOrder(userId, templateUserId int, productOrderNo, tradeOrderNo,
 		logger.Error("创建支付订单失败%v", err)
 		return
 	}
-	err = tx.Model(&order.ProductOrder{}).Updates(map[string]interface{}{
+	err = tx.Model(&order.ProductOrder{}).Where("id = ?", productOrder.ID).Updates(map[string]interface{}{
 		"trade_id":     tradeOrder.ID,
 		"trade_no":     tradeOrder.TransactionID,
 		"payment_time": time.Now(),

+ 3 - 3
service/order/order_service.go

@@ -83,9 +83,9 @@ func CreateProductOrder(templateUser user.User, productId int, orderNo string) (
 		return
 	}
 	//校验是否有相同待支付的产品订单
-	var exisitOrder orderService.ProductOrderDTO
-	exisitOrder, err = orderService.GetUserOrderByProduct(productId, templateUser.Id)
-	if (err != nil && !errors.Is(err, gorm.ErrRecordNotFound)) || exisitOrder.Status == productOrderStatusMap[orderDao.OrderStatusPending] {
+	var existOrder orderService.ProductOrderDTO
+	existOrder, err = orderService.GetUserOrderByProduct(productId, templateUser.Id)
+	if (err != nil && !errors.Is(err, gorm.ErrRecordNotFound)) || existOrder.Status == productOrderStatusMap[orderDao.OrderStatusPending] {
 		err = exception.NewWithException(exception.DuplicateSubscribe, "当前产品有正在进行中的订单,请勿重复下单")
 		return
 	}