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/merchant.fund.dayendbalance.go

48 lines
1.9 KiB

2 years ago
package wechatpayopen
import (
2 years ago
"context"
2 years ago
"encoding/json"
"fmt"
"go.dtapp.net/gorequest"
"net/http"
)
type MerchantFundDayEndBalanceResponse struct {
AvailableAmount int64 `json:"available_amount"` // 可用余额
PendingAmount int64 `json:"pending_amount"` // 不可用余额
}
type MerchantFundDayEndBalanceResult struct {
2 years ago
Result MerchantFundDayEndBalanceResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
ApiError ApiError // 接口错误
2 years ago
}
2 years ago
func newMerchantFundDayEndBalanceResult(result MerchantFundDayEndBalanceResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *MerchantFundDayEndBalanceResult {
return &MerchantFundDayEndBalanceResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
2 years ago
}
// MerchantFundDayEndBalance 查询电商平台账户日终余额API
// accountType 账户类型 BASIC基本账户 OPERATION运营账户 FEES手续费账户
// date 日期 示例值2019-08-17
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter7_7_4.shtml
2 years ago
func (c *Client) MerchantFundDayEndBalance(ctx context.Context, accountType, date string) *MerchantFundDayEndBalanceResult {
2 years ago
// 参数
params := gorequest.NewParams()
// 请求
2 years ago
request, err := c.request(ctx, fmt.Sprintf(apiUrl+"/v3/merchant/fund/dayendbalance/%s?date=%s", accountType, date), params, http.MethodGet)
2 years ago
if err != nil {
2 years ago
return newMerchantFundDayEndBalanceResult(MerchantFundDayEndBalanceResponse{}, request.ResponseBody, request, err, ApiError{})
2 years ago
}
// 定义
var response MerchantFundDayEndBalanceResponse
err = json.Unmarshal(request.ResponseBody, &response)
2 years ago
// 错误
var apiError ApiError
err = json.Unmarshal(request.ResponseBody, &apiError)
return newMerchantFundDayEndBalanceResult(response, request.ResponseBody, request, err, apiError)
2 years ago
}