parent
df75d09be5
commit
020b08e9b3
@ -0,0 +1,44 @@
|
|||||||
|
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)
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package wechatpayopen
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"go.dtapp.net/gorequest"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProfitSharingOrdersResponse struct {
|
||||||
|
SubMchid string `json:"sub_mchid"` // 子商户号
|
||||||
|
TransactionId string `json:"transaction_id"` // 微信订单号
|
||||||
|
OutOrderNo string `json:"out_order_no"` // 商户分账单号
|
||||||
|
OrderId string `json:"order_id"` // 微信分账单号
|
||||||
|
State string `json:"state"` // 分账单状态
|
||||||
|
Receivers []struct {
|
||||||
|
Amount int `json:"amount"` // 分账金额
|
||||||
|
Description string `json:"description"` // 分账描述
|
||||||
|
Type string `json:"type"` // 分账接收方类型
|
||||||
|
Account string `json:"account"` // 分账接收方账号
|
||||||
|
Result string `json:"result"` // 分账结果
|
||||||
|
FailReason string `json:"fail_reason"` // 分账失败原因
|
||||||
|
DetailId string `json:"detail_id"` // 分账明细单号
|
||||||
|
CreateTime string `json:"create_time"` // 分账创建时间
|
||||||
|
FinishTime string `json:"finish_time"` // 分账完成时间
|
||||||
|
} `json:"receivers,omitempty"` // 分账接收方列表
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProfitSharingOrdersResult struct {
|
||||||
|
Result ProfitSharingOrdersResponse // 结果
|
||||||
|
Body []byte // 内容
|
||||||
|
Http gorequest.Response // 请求
|
||||||
|
Err error // 错误
|
||||||
|
ApiError ApiError // 接口错误
|
||||||
|
}
|
||||||
|
|
||||||
|
func newProfitSharingOrdersResult(result ProfitSharingOrdersResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingOrdersResult {
|
||||||
|
return &ProfitSharingOrdersResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProfitSharingOrders 请求分账API
|
||||||
|
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_1.shtml
|
||||||
|
func (c *Client) ProfitSharingOrders(ctx context.Context, notMustParams ...gorequest.Params) *ProfitSharingOrdersResult {
|
||||||
|
// 参数
|
||||||
|
params := gorequest.NewParamsWith(notMustParams...)
|
||||||
|
params.Set("sub_mchid", c.GetSubMchId()) // 子商户号
|
||||||
|
params.Set("appid", c.GetSpAppid()) // 应用ID
|
||||||
|
params.Set("sub_appid", c.GetSubAppid()) // 子商户应用ID
|
||||||
|
// 请求
|
||||||
|
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/orders", params, http.MethodPost)
|
||||||
|
if err != nil {
|
||||||
|
return newProfitSharingOrdersResult(ProfitSharingOrdersResponse{}, request.ResponseBody, request, err, ApiError{})
|
||||||
|
}
|
||||||
|
// 定义
|
||||||
|
var response ProfitSharingOrdersResponse
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &response)
|
||||||
|
// 错误
|
||||||
|
var apiError ApiError
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &apiError)
|
||||||
|
return newProfitSharingOrdersResult(response, request.ResponseBody, request, err, apiError)
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
package wechatpayopen
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"go.dtapp.net/gorequest"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProfitSharingOrdersOutOrderNoResponse struct {
|
||||||
|
SubMchid string `json:"sub_mchid"` // 子商户号
|
||||||
|
TransactionId string `json:"transaction_id"` // 微信订单号
|
||||||
|
OutOrderNo string `json:"out_order_no"` // 商户分账单号
|
||||||
|
OrderId string `json:"order_id"` // 微信分账单号
|
||||||
|
State string `json:"state"` // 分账单状态
|
||||||
|
Receivers []struct {
|
||||||
|
Amount int `json:"amount"` // 分账金额
|
||||||
|
Description string `json:"description"` // 分账描述
|
||||||
|
Type string `json:"type"` // 分账接收方类型
|
||||||
|
Account string `json:"account"` // 分账接收方账号
|
||||||
|
Result string `json:"result"` // 分账结果
|
||||||
|
FailReason string `json:"fail_reason"` // 分账失败原因
|
||||||
|
DetailId string `json:"detail_id"` // 分账明细单号
|
||||||
|
CreateTime string `json:"create_time"` // 分账创建时间
|
||||||
|
FinishTime string `json:"finish_time"` // 分账完成时间
|
||||||
|
} `json:"receivers,omitempty"` // 分账接收方列表
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProfitSharingOrdersOutOrderNoResult struct {
|
||||||
|
Result ProfitSharingOrdersOutOrderNoResponse // 结果
|
||||||
|
Body []byte // 内容
|
||||||
|
Http gorequest.Response // 请求
|
||||||
|
Err error // 错误
|
||||||
|
ApiError ApiError // 接口错误
|
||||||
|
}
|
||||||
|
|
||||||
|
func newProfitSharingOrdersOutOrderNoResult(result ProfitSharingOrdersOutOrderNoResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingOrdersOutOrderNoResult {
|
||||||
|
return &ProfitSharingOrdersOutOrderNoResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProfitSharingOrdersOutOrderNo 查询分账结果API
|
||||||
|
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_2.shtml
|
||||||
|
func (c *Client) ProfitSharingOrdersOutOrderNo(ctx context.Context, transactionId, outOrderNo string) *ProfitSharingOrdersOutOrderNoResult {
|
||||||
|
// 参数
|
||||||
|
params := gorequest.NewParams()
|
||||||
|
params.Set("sub_mchid", c.GetSubMchId()) // 子商户号
|
||||||
|
params.Set("transaction_id", transactionId) // 微信订单号
|
||||||
|
params.Set("out_order_no", outOrderNo) // 商户分账单号
|
||||||
|
// 请求
|
||||||
|
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/orders/"+outOrderNo, params, http.MethodGet)
|
||||||
|
if err != nil {
|
||||||
|
return newProfitSharingOrdersOutOrderNoResult(ProfitSharingOrdersOutOrderNoResponse{}, request.ResponseBody, request, err, ApiError{})
|
||||||
|
}
|
||||||
|
// 定义
|
||||||
|
var response ProfitSharingOrdersOutOrderNoResponse
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &response)
|
||||||
|
// 错误
|
||||||
|
var apiError ApiError
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &apiError)
|
||||||
|
return newProfitSharingOrdersOutOrderNoResult(response, request.ResponseBody, request, err, apiError)
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
package wechatpayopen
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"go.dtapp.net/gorequest"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProfitSharingOrdersUnfreezeResponse struct {
|
||||||
|
SubMchid string `json:"sub_mchid"` // 子商户号
|
||||||
|
TransactionId string `json:"transaction_id"` // 微信订单号
|
||||||
|
OutOrderNo string `json:"out_order_no"` // 商户分账单号
|
||||||
|
OrderId string `json:"order_id"` // 微信分账单号
|
||||||
|
State string `json:"state"` // 分账单状态
|
||||||
|
Receivers []struct {
|
||||||
|
Amount int `json:"amount"` // 分账金额
|
||||||
|
Description string `json:"description"` // 分账描述
|
||||||
|
Type string `json:"type"` // 分账接收方类型
|
||||||
|
Account string `json:"account"` // 分账接收方账号
|
||||||
|
Result string `json:"result"` // 分账结果
|
||||||
|
FailReason string `json:"fail_reason"` // 分账失败原因
|
||||||
|
DetailId string `json:"detail_id"` // 分账明细单号
|
||||||
|
CreateTime string `json:"create_time"` // 分账创建时间
|
||||||
|
FinishTime string `json:"finish_time"` // 分账完成时间
|
||||||
|
} `json:"receivers,omitempty"` // 分账接收方列表
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProfitSharingOrdersUnfreezeResult struct {
|
||||||
|
Result ProfitSharingOrdersUnfreezeResponse // 结果
|
||||||
|
Body []byte // 内容
|
||||||
|
Http gorequest.Response // 请求
|
||||||
|
Err error // 错误
|
||||||
|
ApiError ApiError // 接口错误
|
||||||
|
}
|
||||||
|
|
||||||
|
func newProfitSharingOrdersUnfreezeResult(result ProfitSharingOrdersUnfreezeResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingOrdersUnfreezeResult {
|
||||||
|
return &ProfitSharingOrdersUnfreezeResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProfitSharingOrdersUnfreeze 解冻剩余资金API
|
||||||
|
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_5.shtml
|
||||||
|
func (c *Client) ProfitSharingOrdersUnfreeze(ctx context.Context, transactionId, outOrderNo, description string) *ProfitSharingOrdersUnfreezeResult {
|
||||||
|
// 参数
|
||||||
|
params := gorequest.NewParams()
|
||||||
|
params.Set("sub_mchid", c.GetSubMchId()) // 子商户号
|
||||||
|
params.Set("transaction_id", transactionId) // 微信订单号
|
||||||
|
params.Set("out_order_no", outOrderNo) // 商户分账单号
|
||||||
|
params.Set("description", description) // 分账描述
|
||||||
|
// 请求
|
||||||
|
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/orders/unfreeze", params, http.MethodPost)
|
||||||
|
if err != nil {
|
||||||
|
return newProfitSharingOrdersUnfreezeResult(ProfitSharingOrdersUnfreezeResponse{}, request.ResponseBody, request, err, ApiError{})
|
||||||
|
}
|
||||||
|
// 定义
|
||||||
|
var response ProfitSharingOrdersUnfreezeResponse
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &response)
|
||||||
|
// 错误
|
||||||
|
var apiError ApiError
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &apiError)
|
||||||
|
return newProfitSharingOrdersUnfreezeResult(response, request.ResponseBody, request, err, apiError)
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package wechatpayopen
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"go.dtapp.net/gorequest"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProfitSharingReceiversAddResponse struct {
|
||||||
|
SubMchid string `json:"sub_mchid"` // 子商户号
|
||||||
|
Type string `json:"type"` // 分账接收方类型
|
||||||
|
Account string `json:"account"` // 分账接收方账号
|
||||||
|
Name string `json:"name,omitempty"` // 分账接收方全称
|
||||||
|
RelationType string `json:"relation_type"` // 与分账方的关系类型
|
||||||
|
CustomRelation string `json:"custom_relation,omitempty"` // 自定义的分账关系
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProfitSharingReceiversAddResult struct {
|
||||||
|
Result ProfitSharingReceiversAddResponse // 结果
|
||||||
|
Body []byte // 内容
|
||||||
|
Http gorequest.Response // 请求
|
||||||
|
Err error // 错误
|
||||||
|
ApiError ApiError // 接口错误
|
||||||
|
}
|
||||||
|
|
||||||
|
func newProfitSharingReceiversAddResult(result ProfitSharingReceiversAddResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingReceiversAddResult {
|
||||||
|
return &ProfitSharingReceiversAddResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProfitSharingReceiversAdd 添加分账接收方API
|
||||||
|
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_8.shtml
|
||||||
|
func (c *Client) ProfitSharingReceiversAdd(ctx context.Context, Type, account, name, relationType, customRelation string) *ProfitSharingReceiversAddResult {
|
||||||
|
// 参数
|
||||||
|
params := gorequest.NewParams()
|
||||||
|
params.Set("sub_mchid", c.GetSubMchId()) // 子商户号
|
||||||
|
params.Set("appid", c.GetSpAppid()) // 应用ID
|
||||||
|
params.Set("sub_appid", c.GetSubAppid()) // 子商户应用ID
|
||||||
|
params.Set("type", Type) // 分账接收方类型
|
||||||
|
if Type == MERCHANT_ID {
|
||||||
|
params.Set("account", account) // 商户号
|
||||||
|
params.Set("name", name) // 商户全称
|
||||||
|
}
|
||||||
|
if Type == PERSONAL_OPENID && name != "" {
|
||||||
|
params.Set("account", account) // 个人openid
|
||||||
|
params.Set("name", name) // 个人姓名
|
||||||
|
}
|
||||||
|
if Type == PERSONAL_SUB_OPENID && name != "" {
|
||||||
|
params.Set("account", account) // 个人sub_openid
|
||||||
|
params.Set("name", name) // 个人姓名
|
||||||
|
}
|
||||||
|
params.Set("relation_type", relationType) // 与分账方的关系类型
|
||||||
|
if relationType == "CUSTOM" {
|
||||||
|
params.Set("custom_relation", customRelation) // 自定义的分账关系
|
||||||
|
}
|
||||||
|
// 请求
|
||||||
|
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/receivers/delete", params, http.MethodPost)
|
||||||
|
if err != nil {
|
||||||
|
return newProfitSharingReceiversAddResult(ProfitSharingReceiversAddResponse{}, request.ResponseBody, request, err, ApiError{})
|
||||||
|
}
|
||||||
|
// 定义
|
||||||
|
var response ProfitSharingReceiversAddResponse
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &response)
|
||||||
|
// 错误
|
||||||
|
var apiError ApiError
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &apiError)
|
||||||
|
return newProfitSharingReceiversAddResult(response, request.ResponseBody, request, err, apiError)
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
package wechatpayopen
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"go.dtapp.net/gorequest"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProfitSharingReceiversDeleteResponse struct {
|
||||||
|
SubMchid string `json:"sub_mchid"` // 子商户号
|
||||||
|
Type string `json:"type"` // 分账接收方类型
|
||||||
|
Account string `json:"account"` // 分账接收方账号
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProfitSharingReceiversDeleteResult struct {
|
||||||
|
Result ProfitSharingReceiversDeleteResponse // 结果
|
||||||
|
Body []byte // 内容
|
||||||
|
Http gorequest.Response // 请求
|
||||||
|
Err error // 错误
|
||||||
|
ApiError ApiError // 接口错误
|
||||||
|
}
|
||||||
|
|
||||||
|
func newProfitSharingReceiversDeleteResult(result ProfitSharingReceiversDeleteResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingReceiversDeleteResult {
|
||||||
|
return &ProfitSharingReceiversDeleteResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProfitSharingReceiversDelete 删除分账接收方API
|
||||||
|
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_9.shtml
|
||||||
|
func (c *Client) ProfitSharingReceiversDelete(ctx context.Context, Type, account string) *ProfitSharingReceiversDeleteResult {
|
||||||
|
// 参数
|
||||||
|
params := gorequest.NewParams()
|
||||||
|
params.Set("sub_mchid", c.GetSubMchId()) // 子商户号
|
||||||
|
params.Set("appid", c.GetSpAppid()) // 应用ID
|
||||||
|
params.Set("sub_appid", c.GetSubAppid()) // 子商户应用ID
|
||||||
|
params.Set("type", Type) // 分账接收方类型
|
||||||
|
if Type == MERCHANT_ID {
|
||||||
|
params.Set("account", account) // 商户号
|
||||||
|
}
|
||||||
|
if Type == PERSONAL_OPENID {
|
||||||
|
params.Set("account", account) // 个人openid
|
||||||
|
}
|
||||||
|
if Type == PERSONAL_SUB_OPENID {
|
||||||
|
params.Set("account", account) // 个人sub_openid
|
||||||
|
}
|
||||||
|
// 请求
|
||||||
|
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/receivers/delete", params, http.MethodPost)
|
||||||
|
if err != nil {
|
||||||
|
return newProfitSharingReceiversDeleteResult(ProfitSharingReceiversDeleteResponse{}, request.ResponseBody, request, err, ApiError{})
|
||||||
|
}
|
||||||
|
// 定义
|
||||||
|
var response ProfitSharingReceiversDeleteResponse
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &response)
|
||||||
|
// 错误
|
||||||
|
var apiError ApiError
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &apiError)
|
||||||
|
return newProfitSharingReceiversDeleteResult(response, request.ResponseBody, request, err, apiError)
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package wechatpayopen
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"go.dtapp.net/gorequest"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProfitSharingReturnOrdersResponse struct {
|
||||||
|
SubMchid string `json:"sub_mchid"` // 子商户号
|
||||||
|
OrderId string `json:"order_id"` // 微信分账单号
|
||||||
|
OutOrderNo string `json:"out_order_no"` // 商户分账单号
|
||||||
|
OutReturnNo string `json:"out_return_no"` // 商户回退单号
|
||||||
|
ReturnId string `json:"return_id"` // 微信回退单号
|
||||||
|
ReturnMchid string `json:"return_mchid"` // 回退商户号
|
||||||
|
Amount int `json:"amount"` // 回退金额
|
||||||
|
Description string `json:"description"` // 回退描述
|
||||||
|
Result string `json:"result"` // 回退结果
|
||||||
|
FailReason string `json:"fail_reason"` // 失败原因
|
||||||
|
CreateTime string `json:"create_time"` // 创建时间
|
||||||
|
FinishTime string `json:"finish_time"` // 完成时间
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProfitSharingReturnOrdersResult struct {
|
||||||
|
Result ProfitSharingReturnOrdersResponse // 结果
|
||||||
|
Body []byte // 内容
|
||||||
|
Http gorequest.Response // 请求
|
||||||
|
Err error // 错误
|
||||||
|
ApiError ApiError // 接口错误
|
||||||
|
}
|
||||||
|
|
||||||
|
func newProfitSharingReturnOrdersResult(result ProfitSharingReturnOrdersResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingReturnOrdersResult {
|
||||||
|
return &ProfitSharingReturnOrdersResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProfitSharingReturnOrders 请求分账回退API
|
||||||
|
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_3.shtml
|
||||||
|
func (c *Client) ProfitSharingReturnOrders(ctx context.Context, notMustParams ...gorequest.Params) *ProfitSharingReturnOrdersResult {
|
||||||
|
// 参数
|
||||||
|
params := gorequest.NewParamsWith(notMustParams...)
|
||||||
|
params.Set("sub_mchid", c.GetSubMchId()) // 子商户号
|
||||||
|
// 请求
|
||||||
|
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/return-orders", params, http.MethodPost)
|
||||||
|
if err != nil {
|
||||||
|
return newProfitSharingReturnOrdersResult(ProfitSharingReturnOrdersResponse{}, request.ResponseBody, request, err, ApiError{})
|
||||||
|
}
|
||||||
|
// 定义
|
||||||
|
var response ProfitSharingReturnOrdersResponse
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &response)
|
||||||
|
// 错误
|
||||||
|
var apiError ApiError
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &apiError)
|
||||||
|
return newProfitSharingReturnOrdersResult(response, request.ResponseBody, request, err, apiError)
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package wechatpayopen
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"go.dtapp.net/gorequest"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProfitSharingReturnOrdersOutReturnNoResponse struct {
|
||||||
|
SubMchid string `json:"sub_mchid"` // 子商户号
|
||||||
|
OrderId string `json:"order_id"` // 微信分账单号
|
||||||
|
OutOrderNo string `json:"out_order_no"` // 商户分账单号
|
||||||
|
OutReturnNo string `json:"out_return_no"` // 商户回退单号
|
||||||
|
ReturnId string `json:"return_id"` // 微信回退单号
|
||||||
|
ReturnMchid string `json:"return_mchid"` // 回退商户号
|
||||||
|
Amount int `json:"amount"` // 回退金额
|
||||||
|
Description string `json:"description"` // 回退描述
|
||||||
|
Result string `json:"result"` // 回退结果
|
||||||
|
FailReason string `json:"fail_reason"` // 失败原因
|
||||||
|
CreateTime string `json:"create_time"` // 创建时间
|
||||||
|
FinishTime string `json:"finish_time"` // 完成时间
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProfitSharingReturnOrdersOutReturnNoResult struct {
|
||||||
|
Result ProfitSharingReturnOrdersOutReturnNoResponse // 结果
|
||||||
|
Body []byte // 内容
|
||||||
|
Http gorequest.Response // 请求
|
||||||
|
Err error // 错误
|
||||||
|
ApiError ApiError // 接口错误
|
||||||
|
}
|
||||||
|
|
||||||
|
func newProfitSharingReturnOrdersOutReturnNoResult(result ProfitSharingReturnOrdersOutReturnNoResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingReturnOrdersOutReturnNoResult {
|
||||||
|
return &ProfitSharingReturnOrdersOutReturnNoResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProfitSharingReturnOrdersOutReturnNo 查询分账回退结果API
|
||||||
|
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_4.shtml
|
||||||
|
func (c *Client) ProfitSharingReturnOrdersOutReturnNo(ctx context.Context, outReturnNo, outOrderNo string) *ProfitSharingReturnOrdersOutReturnNoResult {
|
||||||
|
// 参数
|
||||||
|
params := gorequest.NewParams()
|
||||||
|
params.Set("sub_mchid", c.GetSubMchId()) // 子商户号
|
||||||
|
params.Set("out_return_no", outReturnNo) // 商户回退单号
|
||||||
|
params.Set("out_order_no", outOrderNo) // 商户分账单号
|
||||||
|
// 请求
|
||||||
|
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/return-orders/"+outReturnNo, params, http.MethodGet)
|
||||||
|
if err != nil {
|
||||||
|
return newProfitSharingReturnOrdersOutReturnNoResult(ProfitSharingReturnOrdersOutReturnNoResponse{}, request.ResponseBody, request, err, ApiError{})
|
||||||
|
}
|
||||||
|
// 定义
|
||||||
|
var response ProfitSharingReturnOrdersOutReturnNoResponse
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &response)
|
||||||
|
// 错误
|
||||||
|
var apiError ApiError
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &apiError)
|
||||||
|
return newProfitSharingReturnOrdersOutReturnNoResult(response, request.ResponseBody, request, err, apiError)
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package wechatpayopen
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"go.dtapp.net/gorequest"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ProfitSharingTransactionsAmountsResponse struct {
|
||||||
|
TransactionId string `json:"transaction_id"` // 微信订单号
|
||||||
|
UnsplitAmount int `json:"unsplit_amount"` // 订单剩余待分金额
|
||||||
|
}
|
||||||
|
|
||||||
|
type ProfitSharingTransactionsAmountsResult struct {
|
||||||
|
Result ProfitSharingTransactionsAmountsResponse // 结果
|
||||||
|
Body []byte // 内容
|
||||||
|
Http gorequest.Response // 请求
|
||||||
|
Err error // 错误
|
||||||
|
ApiError ApiError // 接口错误
|
||||||
|
}
|
||||||
|
|
||||||
|
func newProfitSharingTransactionsAmountsResult(result ProfitSharingTransactionsAmountsResponse, body []byte, http gorequest.Response, err error, apiError ApiError) *ProfitSharingTransactionsAmountsResult {
|
||||||
|
return &ProfitSharingTransactionsAmountsResult{Result: result, Body: body, Http: http, Err: err, ApiError: apiError}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProfitSharingTransactionsAmounts 查询剩余待分金额API
|
||||||
|
// https://pay.weixin.qq.com/wiki/doc/apiv3_partner/apis/chapter8_1_6.shtml
|
||||||
|
func (c *Client) ProfitSharingTransactionsAmounts(ctx context.Context, transactionId string) *ProfitSharingTransactionsAmountsResult {
|
||||||
|
// 参数
|
||||||
|
params := gorequest.NewParams()
|
||||||
|
// 请求
|
||||||
|
request, err := c.request(ctx, apiUrl+"/v3/profitsharing/transactions/"+transactionId, params, http.MethodGet)
|
||||||
|
if err != nil {
|
||||||
|
return newProfitSharingTransactionsAmountsResult(ProfitSharingTransactionsAmountsResponse{}, request.ResponseBody, request, err, ApiError{})
|
||||||
|
}
|
||||||
|
// 定义
|
||||||
|
var response ProfitSharingTransactionsAmountsResponse
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &response)
|
||||||
|
// 错误
|
||||||
|
var apiError ApiError
|
||||||
|
err = json.Unmarshal(request.ResponseBody, &apiError)
|
||||||
|
return newProfitSharingTransactionsAmountsResult(response, request.ResponseBody, request, err, apiError)
|
||||||
|
}
|
Loading…
Reference in new issue