You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
wechatpayopen/profitsharing.merchant-conf...

45 lines
1.8 KiB

package wechatpayopen
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
)
type ProfitSharingMerchantConfigsResponse struct {
SubMchid string `json:"sub_mchid"` // 子商户号
MaxRatio int `json:"max_ratio"` // 最大分账比例
}
type ProfitSharingMerchantConfigsResult struct {
Result ProfitSharingMerchantConfigsResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
}
func newProfitSharingMerchantConfigsResult(result ProfitSharingMerchantConfigsResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingMerchantConfigsResult {
return &ProfitSharingMerchantConfigsResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
}
// ProfitSharingMerchantConfigs 查询最大分账比例API
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_7.shtml
func (c *Client) ProfitSharingMerchantConfigs(ctx context.Context) *ProfitSharingMerchantConfigsResult {
// 参数
params := gorequest.NewParams()
// 请求
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/merchant-configs/"+c.GetSubMchId(), params, http.MethodGet)
if err != nil {
return newProfitSharingMerchantConfigsResult(ProfitSharingMerchantConfigsResponse{}, request.ResponseBody, request, err, ApiError{})
}
// 定义
var response ProfitSharingMerchantConfigsResponse
err = json.Unmarshal(request.ResponseBody, &response)
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newProfitSharingMerchantConfigsResult(response, request.ResponseBody, request, err, apiError)
}