diff --git a/app/main/api/internal/logic/pay/paymentlogic.go b/app/main/api/internal/logic/pay/paymentlogic.go index 74c96b6..1377d07 100644 --- a/app/main/api/internal/logic/pay/paymentlogic.go +++ b/app/main/api/internal/logic/pay/paymentlogic.go @@ -62,6 +62,7 @@ func (l *PaymentLogic) Payment(req *types.PaymentReq) (resp *types.PaymentResp, orderReq := &service.CreateOrderRequest{ PayMethod: payMethod, ProductEn: data.Product, + OrderNo: outTradeNo, } orderResp, err := l.svcCtx.PayService.CreateOrder(l.ctx, orderReq) diff --git a/app/main/api/internal/service/payService.go b/app/main/api/internal/service/payService.go index 59f5611..e0f2572 100644 --- a/app/main/api/internal/service/payService.go +++ b/app/main/api/internal/service/payService.go @@ -116,7 +116,7 @@ func (p *PayService) CreateOrder(ctx context.Context, req *CreateOrderRequest) ( if err != nil { return nil, fmt.Errorf("获取用户失败: %v", err) } - var outTradeNo string + outTradeNo := req.OrderNo var orderID int64 amount := product.SellPrice if user.Inside == 1 { @@ -129,15 +129,15 @@ func (p *PayService) CreateOrder(ctx context.Context, req *CreateOrderRequest) ( switch req.PayMethod { case "alipay": orderReq := &payment.AlipayCreateOrderRequest{ - Amount: amount, - Subject: product.ProductName, - Platform: payment.PlatformH5, + Amount: amount, + Subject: product.ProductName, + Platform: payment.PlatformH5, + OutTradeNo: outTradeNo, } resp, err := p.alipayService.CreateOrder(ctx, orderReq) if err != nil { return fmt.Errorf("创建支付宝订单失败: %v", err) } - outTradeNo = resp.OrderNo payData = resp.PayParams case "wechat": orderReq := &payment.Order{ @@ -465,6 +465,7 @@ const ( type CreateOrderRequest struct { PayMethod PayMethod `json:"pay_method"` // 支付方式:alipay, wechat, apple ProductEn string `json:"product_en"` // 商品英文名 + OrderNo string `json:"order_no"` // 订单号 } type CreateOrderResponse struct {