-
Notifications
You must be signed in to change notification settings - Fork 164
/
client.go
57 lines (45 loc) · 1.69 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package promotion
import (
"github.com/ArtisanCloud/PowerLibs/v2/object"
payment "github.com/ArtisanCloud/PowerWeChat/v2/src/payment/kernel"
"github.com/ArtisanCloud/PowerWeChat/v2/src/payment/promotion/request"
"github.com/ArtisanCloud/PowerWeChat/v2/src/payment/promotion/response"
)
type Client struct {
*payment.BaseClient
}
func NewClient(app *payment.ApplicationPaymentInterface) (*Client, error) {
baseClient, err := payment.NewBaseClient(app)
if err != nil {
return nil, err
}
return &Client{
baseClient,
}, nil
}
// 向员工付款
// https://work.weixin.qq.com/api/doc/90000/90135/90278
func (comp *Client) PayTransferToPocket(data *request.RequestPayTransferToPocket) (*response.ResponsePayTransferToPocket, error) {
result := &response.ResponsePayTransferToPocket{}
//params, err := object.StructToHashMapWithTag(data, "json")
params, err := object.StructToHashMap(data)
if err != nil {
return nil, err
}
endpoint := comp.Wrap("/mmpaymkttransfers/promotion/paywwsptrans2pocket")
_, err = comp.SafeRequest(endpoint, params, "POST", &object.HashMap{}, false, result)
return result, err
}
// 查询付款记录
// https://work.weixin.qq.com/api/doc/90000/90135/90279
func (comp *Client) QueryTransferToPocket(data *request.RequestQueryTransferToPocket) (*response.ResponseQueryTransferToPocket, error) {
result := &response.ResponseQueryTransferToPocket{}
//params, err := object.StructToHashMapWithTag(data,"json")
params, err := object.StructToHashMap(data)
if err != nil {
return nil, err
}
endpoint := comp.Wrap("/mmpaymkttransfers/promotion/querywwsptrans2pocket")
_, err = comp.SafeRequest(endpoint, params, "POST", &object.HashMap{}, false, result)
return result, err
}