From 7bfc2a1dbd3994e5068d9d179863e6a721912885 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 23 Jul 2026 06:41:08 +0000 Subject: [PATCH] fix: pass context.Context to alipay TradePreCreate call The smartwalle/alipay/v3 Client.TradePreCreate method signature requires a context.Context as its first argument. Add a Ctx field to UserRechargeLinkReq, populate it from the HTTP request context in Bind, and forward it to the TradePreCreate call to fix the build failure. --- internal/model/web/alipay.go | 6 ++++-- internal/servants/web/alipay.go | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/internal/model/web/alipay.go b/internal/model/web/alipay.go index 803a66fd..4d6d6586 100644 --- a/internal/model/web/alipay.go +++ b/internal/model/web/alipay.go @@ -27,8 +27,9 @@ type UserWalletBillsResp base.PageResp type UserRechargeLinkReq struct { BaseInfo `json:"-" form:"-" binding:"-"` - Host string `json:"-" form:"-" binding:"-"` - Amount int64 `json:"amount" form:"amount" binding:"required"` + Ctx context.Context `json:"-" form:"-" binding:"-"` + Host string `json:"-" form:"-" binding:"-"` + Amount int64 `json:"amount" form:"amount" binding:"required"` } type UserRechargeLinkResp struct { @@ -82,6 +83,7 @@ func (r *UserWalletBillsReq) Bind(c *gin.Context) error { func (r *UserRechargeLinkReq) Bind(c *gin.Context) error { r.Host = c.Request.Host + r.Ctx = c.Request.Context() return bindAny(c, r) } diff --git a/internal/servants/web/alipay.go b/internal/servants/web/alipay.go index 3734d2d9..d88eafbc 100644 --- a/internal/servants/web/alipay.go +++ b/internal/servants/web/alipay.go @@ -80,7 +80,7 @@ func (s *alipayPrivSrv) UserRechargeLink(req *web.UserRechargeLinkReq) (*web.Use p.Subject = "PaoPao用户钱包充值" p.TotalAmount = fmt.Sprintf("%.2f", float64(recharge.Amount)/100.0) p.NotifyURL = "https://" + req.Host + "/v1/alipay/notify" - rsp, err := s.alipayClient.TradePreCreate(p) + rsp, err := s.alipayClient.TradePreCreate(req.Ctx, p) if err != nil { logrus.Errorf("client.TradePreCreate err: %v\n", err) return nil, web.ErrRechargeReqFail