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

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package wechatpayapiv3
import (
"context"
"github.com/dtapps/go-library/utils/gojson"
"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
}
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
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
err = gojson.Unmarshal(request.ResponseBody, &response)
return newTransferBatchesResult(response, request.ResponseBody, request, err)
}