-
Notifications
You must be signed in to change notification settings - Fork 165
/
client.go
75 lines (57 loc) · 2.43 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package invoice
import (
"context"
"github.com/ArtisanCloud/PowerLibs/v3/object"
"github.com/ArtisanCloud/PowerWeChat/v3/src/kernel"
response2 "github.com/ArtisanCloud/PowerWeChat/v3/src/kernel/response"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/invoice/request"
"github.com/ArtisanCloud/PowerWeChat/v3/src/work/invoice/response"
)
type Client struct {
BaseClient *kernel.BaseClient
}
// 查询电子发票
// https://developer.work.weixin.qq.com/document/path/90284
func (comp *Client) GetInvoiceInfo(ctx context.Context, cardID string, encryptCode string) (*response.ResponseInvoiceGetInfo, error) {
result := &response.ResponseInvoiceGetInfo{}
data := &object.HashMap{
"card_id": cardID,
"encrypt_code": encryptCode,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/card/invoice/reimburse/getinvoiceinfo", data, nil, nil, result)
return result, err
}
// 批量查询电子发票
// https://developer.work.weixin.qq.com/document/path/90287
func (comp *Client) GetInvoiceInfoBatch(ctx context.Context, invoiceList []*request.RequestCardInvoice) (*response.ResponseInvoiceGetInfoBatch, error) {
result := &response.ResponseInvoiceGetInfoBatch{}
data := &object.HashMap{
"item_list": invoiceList,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/card/invoice/reimburse/getinvoiceinfobatch", data, nil, nil, result)
return result, err
}
// 更新发票状态
// https://developer.work.weixin.qq.com/document/path/90285
func (comp *Client) UpdateInvoiceStatus(ctx context.Context, cardID string, encryptCode string, status string) (*response2.ResponseWork, error) {
result := &response2.ResponseWork{}
data := &object.HashMap{
"card_id": cardID,
"encrypt_code": encryptCode,
"reimburse_status": status,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/card/invoice/reimburse/updateinvoicestatus", data, nil, nil, result)
return result, err
}
// 批量更新发票状态
// https://developer.work.weixin.qq.com/document/path/90286
func (comp *Client) UpdateStatusBatch(ctx context.Context, openid string, status string, invoiceList []*request.RequestCardInvoice) (*response2.ResponseWork, error) {
result := &response2.ResponseWork{}
data := &object.HashMap{
"openid": openid,
"reimburse_status": status,
"invoice_list": invoiceList,
}
_, err := comp.BaseClient.HttpPostJson(ctx, "cgi-bin/card/invoice/reimburse/updatestatusbatch", data, nil, nil, result)
return result, err
}