feat(virtualpayment): ✨ 添加 postJSONBytesContext 函数并更新相关调用 解决body签名不一致问题 (#886)

* fix typo

* feat(virtualpayment): ✨ 添加广告金相关接口及错误码

- 新增批量任务、退款、广告金充值等相关错误码
- 添加下载订单、查询商家账户余额、查询广告金发放记录等接口
- 实现投诉处理相关接口,包括获取投诉列表、投诉详情、协商历史等
- 完善上传媒体文件及获取签名头部的功能

* feat(virtualpayment): ✨ 优化请求地址组合逻辑,合并多个 case 语句

* 补充虚拟支付道具发货拼团字段

* fix(virtualpayment): 🐛 修正退款错误码注释拼写和商户订单号字段名称

* feat(virtualpayment): ✨ 添加 iOS Apple 支付退款问询事件及相关数据结构

* feat(virtualpayment): ✨ 优化 iOS Apple 支付退款问询事件的注释格式

* feat(virtualpayment): ✨ 添加 postJSONBytesContext 函数并更新相关调用

* fix(miniprogram): ShowSplashAd 传 false 时未序列化发送到微信 API

将 ShowSplashAd 从 bool 改为 *bool,解决 omitempty 导致 false 值
被当作零值省略的问题。微信 API 默认值为 true(展示广告),传 false
无法关闭封面广告。

Closes #882
This commit is contained in:
wwek authored and GitHub committed 2026-06-03 23:31:15 +08:00
1 parent bfbfc844ce
commit d34af7aeeb
2 files changed
+39 -32

No files matched your search

+1 -1
View File
@@ -55,7 +55,7 @@ type QRCoder struct {
// envVersion 要打开的小程序版本。正式版为 "release",体验版为 "trial",开发版为 "develop"
EnvVersion string `json:"env_version,omitempty"`
// ShowSplashAd 控制通过该小程序码进入小程序是否展示封面广告1、默认为true,展示封面广告2、传入为false时,不展示封面广告
ShowSplashAd bool `json:"show_splash_ad,omitempty"`
ShowSplashAd *bool `json:"show_splash_ad,omitempty"`
}
// fetchCode 请求并返回二维码二进制数据
+38 -31
View File
@@ -55,7 +55,7 @@ func (s *VirtualPayment) QueryUserBalance(ctx context.Context, in *QueryUserBala
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -83,7 +83,7 @@ func (s *VirtualPayment) CurrencyPay(ctx context.Context, in *CurrencyPayRequest
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -111,7 +111,7 @@ func (s *VirtualPayment) QueryOrder(ctx context.Context, in *QueryOrderRequest)
return
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -139,7 +139,7 @@ func (s *VirtualPayment) CancelCurrencyPay(ctx context.Context, in *CancelCurren
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -169,7 +169,7 @@ func (s *VirtualPayment) NotifyProvideGoods(ctx context.Context, in *NotifyProvi
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -198,7 +198,7 @@ func (s *VirtualPayment) PresentCurrency(ctx context.Context, in *PresentCurrenc
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -227,7 +227,7 @@ func (s *VirtualPayment) DownloadBill(ctx context.Context, in *DownloadBillReque
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -256,7 +256,7 @@ func (s *VirtualPayment) RefundOrder(ctx context.Context, in *RefundOrderRequest
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -285,7 +285,7 @@ func (s *VirtualPayment) CreateWithdrawOrder(ctx context.Context, in *CreateWith
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -314,7 +314,7 @@ func (s *VirtualPayment) QueryWithdrawOrder(ctx context.Context, in *QueryWithdr
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -343,7 +343,7 @@ func (s *VirtualPayment) StartUploadGoods(ctx context.Context, in *StartUploadGo
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -372,7 +372,7 @@ func (s *VirtualPayment) QueryUploadGoods(ctx context.Context, in *QueryUploadGo
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -401,7 +401,7 @@ func (s *VirtualPayment) StartPublishGoods(ctx context.Context, in *StartPublish
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -430,7 +430,7 @@ func (s *VirtualPayment) QueryPublishGoods(ctx context.Context, in *QueryPublish
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -459,7 +459,7 @@ func (s *VirtualPayment) StartDownloadOrder(ctx context.Context, in *StartDownlo
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -488,7 +488,7 @@ func (s *VirtualPayment) QueryDownloadOrder(ctx context.Context, in *QueryDownlo
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -517,7 +517,7 @@ func (s *VirtualPayment) QueryBizBalance(ctx context.Context, in *QueryBizBalanc
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -546,7 +546,7 @@ func (s *VirtualPayment) QueryTransferAccount(ctx context.Context, in *QueryTran
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -575,7 +575,7 @@ func (s *VirtualPayment) QueryAdverFunds(ctx context.Context, in *QueryAdverFund
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -604,7 +604,7 @@ func (s *VirtualPayment) CreateFundsBill(ctx context.Context, in *CreateFundsBil
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -633,7 +633,7 @@ func (s *VirtualPayment) BindTransferAccount(ctx context.Context, in *BindTransf
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -662,7 +662,7 @@ func (s *VirtualPayment) QueryFundsBill(ctx context.Context, in *QueryFundsBillR
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -691,7 +691,7 @@ func (s *VirtualPayment) QueryRecoverBill(ctx context.Context, in *QueryRecoverB
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -720,7 +720,7 @@ func (s *VirtualPayment) DownloadAdverFundsOrder(ctx context.Context, in *Downlo
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -749,7 +749,7 @@ func (s *VirtualPayment) GetComplaintList(ctx context.Context, in *GetComplaintL
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -778,7 +778,7 @@ func (s *VirtualPayment) GetComplaintDetail(ctx context.Context, in *GetComplain
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -807,7 +807,7 @@ func (s *VirtualPayment) GetNegotiationHistory(ctx context.Context, in *GetNegot
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -836,7 +836,7 @@ func (s *VirtualPayment) ResponseComplaint(ctx context.Context, in *ResponseComp
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -865,7 +865,7 @@ func (s *VirtualPayment) CompleteComplaint(ctx context.Context, in *CompleteComp
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -894,7 +894,7 @@ func (s *VirtualPayment) UploadVPFile(ctx context.Context, in *UploadVPFileReque
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -923,7 +923,7 @@ func (s *VirtualPayment) GetUploadFileSign(ctx context.Context, in *GetUploadFil
}
var response []byte
if response, err = util.PostJSONContext(ctx, address, in); err != nil {
if response, err = postJSONBytesContext(ctx, address, jsonByte); err != nil {
return
}
@@ -939,6 +939,13 @@ func (s *VirtualPayment) hmacSha256(key, data string) string {
return hex.EncodeToString(h.Sum(nil))
}
// postJSONBytesContext POST JSON bytes with context
func postJSONBytesContext(ctx context.Context, address string, jsonByte []byte) ([]byte, error) {
return util.HTTPPostContext(ctx, address, jsonByte, map[string]string{
"Content-Type": "application/json;charset=utf-8",
})
}
// PaySign pay sign
func (s *VirtualPayment) PaySign(url, data string) (string, error) {
if strings.TrimSpace(s.ctx.Config.AppKey) == "" {