diff --git a/src/V2/entity.go b/src/V2/entity.go index 81be88e..6c31d7c 100644 --- a/src/V2/entity.go +++ b/src/V2/entity.go @@ -188,6 +188,11 @@ type ProfitSharing struct { Receivers []Receiver `json:"receivers,omitempty"` // 接收方列表 } +// ProfitSharing 单次分账参数 +type ProfitSharingAmountQuery struct { + TransactionID string `json:"transaction_id,omitempty"` // 微信支付ID +} + // ProfitSharingQuery 分账结果查询参数 type ProfitSharingQuery struct { TransactionID string `json:"transaction_id,omitempty"` // 微信支付ID diff --git a/src/V2/pay.go b/src/V2/pay.go index 1ded759..564e293 100644 --- a/src/V2/pay.go +++ b/src/V2/pay.go @@ -8,6 +8,7 @@ import ( "errors" "io" "io/ioutil" + "log" "net/http" "strconv" "strings" @@ -219,11 +220,13 @@ func (c WxPay) RefundQuery(params RefundQuery) (map[string]string, error) { } // ProfitSharingOrderAmountQuery 查询最大分账比例 -func (c WxPay) ProfitSharingOrderAmountQuery(params Receiver) (map[string]string, error) { - m := c.publicParams() - b, _ := json.Marshal(params) - m["receiver"] = string(b) +func (c WxPay) ProfitSharingOrderAmountQuery(params ProfitSharingAmountQuery) (map[string]string, error) { + m := utils.MAPMerge(utils.Struct2Map(params), c.publicParams()) + delete(m, "appid") + delete(m, "sub_appid") + delete(m, "sub_mch_id") m["sign"] = utils.SignHMACSHA256(m, c.config.Secret) + log.Println("m,", m) return c.request("https://api.mch.weixin.qq.com/pay/profitsharingorderamountquery", strings.NewReader(utils.MAP2XML(m)), false) }