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.
go-library/service/wechatpayapiv3/transfer.batches.go

43 lines
1.7 KiB

2 years ago
package wechatpayapiv3
import (
"context"
1 year ago
"github.com/dtapps/go-library/utils/gojson"
2 years ago
"github.com/dtapps/go-library/utils/gorequest"
"net/http"
)
type TransferBatchesResponse struct {
OutBatchNo string `json:"out_batch_no"` // 商户系统内部的商家批次单号,在商户系统内部唯一
BatchId string `json:"batch_id"` // 微信批次单号,微信商家转账系统返回的唯一标识
CreateTime string `json:"create_time"` // 批次受理成功时返回按照使用rfc3339所定义的格式格式为YYYY-MM-DDThh:mm:ss+TIMEZONE
2 years ago
}
type TransferBatchesResult struct {
Result TransferBatchesResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
}
func newTransferBatchesResult(result TransferBatchesResponse, body []byte, http gorequest.Response, err error) *TransferBatchesResult {
return &TransferBatchesResult{Result: result, Body: body, Http: http, Err: err}
}
// TransferBatches 发起商家转账
// https://pay.weixin.qq.com/docs/merchant/apis/batch-transfer-to-balance/transfer-batch/initiate-batch-transfer.html
2 years ago
func (c *Client) TransferBatches(ctx context.Context, notMustParams ...gorequest.Params) *TransferBatchesResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
params.Set("appid", c.GetAppId())
// 请求
request, err := c.request(ctx, apiUrl+"/v3/transfer/batches", params, http.MethodPost, false)
if err != nil {
return newTransferBatchesResult(TransferBatchesResponse{}, request.ResponseBody, request, err)
}
// 定义
var response TransferBatchesResponse
1 year ago
err = gojson.Unmarshal(request.ResponseBody, &response)
2 years ago
return newTransferBatchesResult(response, request.ResponseBody, request, err)
}