forked from shenghui0779/sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reimburse.go
150 lines (130 loc) · 4.96 KB
/
reimburse.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package invoice
import (
"encoding/json"
"github.com/chenghonour/wechat-sdk/urls"
"github.com/chenghonour/wechat-sdk/wx"
)
// ReimburseStatus 发票报销状态
type ReimburseStatus string
const (
InvioceReimburseInit ReimburseStatus = "INVOICE_REIMBURSE_INIT" // 发票初始状态,未锁定
InvioceReimburseLock ReimburseStatus = "INVOICE_REIMBURSE_LOCK" // 发票已锁定,无法重复提交报销
InvioceReimburseClosure ReimburseStatus = "INVOICE_REIMBURSE_CLOSURE" // 发票已核销,从用户卡包中移除
)
type InvoiceUserInfo struct {
Fee int `json:"fee"`
Title string `json:"title"`
BillingTime int64 `json:"billing_time"`
BillingNO string `json:"billing_no"`
BillingCode string `json:"billing_code"`
Tax int `json:"tax"`
FeeWithoutTax int `json:"fee_without_tax"`
Detail string `json:"detail"`
PdfURL string `json:"pdf_url"`
TriPdfUrl string `json:"tri_pdf_url"`
CheckCode string `json:"check_code"`
BuyerNumber string `json:"buyer_number"`
BuyerAddressAndPhone string `json:"buyer_address_and_phone"`
BuyerBankAccount string `json:"buyer_bank_account"`
SellerNumber string `json:"seller_number"`
SellerAddressAndPhone string `json:"seller_address_and_phone"`
SellerBankAccount string `json:"seller_bank_account"`
Remarks string `json:"remarks"`
Cashier string `json:"cashier"`
Maker string `json:"maker"`
ReimburseStatus ReimburseStatus `json:"reimburse_status"`
OrderID string `json:"order_id"`
Info []*InvoiceProductInfo `json:"info"`
}
type InvoiceProductInfo struct {
Name string `json:"name"`
Num int `json:"num"`
Unit string `json:"unit"`
Fee int `json:"fee"`
Price int `json:"price"`
}
type ParamsInvoice struct {
CardID string `json:"card_id"`
EncryptCode string `json:"encrypt_code"`
}
type ResultInvoiceInfo struct {
CardID string `json:"card_id"`
BeginTime int64 `json:"begin_time"`
EndTime int64 `json:"end_time"`
OpenID string `json:"openid"`
Type string `json:"type"`
Payee string `json:"payee"`
Detail string `json:"detail"`
UserInfo *InvoiceUserInfo `json:"user_info"`
}
// GetInvoiceInfo 查询电子发票
func GetInvoiceInfo(cardID, encryptCode string, result *ResultInvoiceInfo) wx.Action {
params := &ParamsInvoice{
CardID: cardID,
EncryptCode: encryptCode,
}
return wx.NewPostAction(urls.CorpInvoiceGetInfo,
wx.WithBody(func() ([]byte, error) {
return wx.MarshalNoEscapeHTML(params)
}),
wx.WithDecode(func(b []byte) error {
return json.Unmarshal(b, result)
}),
)
}
type ParamsInvoiceStatusUpdate struct {
CardID string `json:"card_id"`
EncryptCode string `json:"encrypt_code"`
ReimburseStatus ReimburseStatus `json:"reimburse_status"`
}
// UpdateInvoiceStatus 更新发票状态
func UpdateInvoiceStatus(cardID, encryptCode string, status ReimburseStatus) wx.Action {
params := &ParamsInvoiceStatusUpdate{
CardID: cardID,
EncryptCode: encryptCode,
ReimburseStatus: status,
}
return wx.NewPostAction(urls.CorpInvoiceUpdateStatus,
wx.WithBody(func() ([]byte, error) {
return wx.MarshalNoEscapeHTML(params)
}),
)
}
type ParamsInvoiceBatchInfo struct {
ItemList []*ParamsInvoice `json:"item_list"`
}
type ResultInvoiceBatchInfo struct {
ItemList []*ResultInvoiceInfo `json:"item_list"`
}
// BatchGetInvoiceInfo 批量查询电子发票
func BatchGetInvoiceInfo(invoices []*ParamsInvoice, result *ResultInvoiceBatchInfo) wx.Action {
params := &ParamsInvoiceBatchInfo{
ItemList: invoices,
}
return wx.NewPostAction(urls.CorpInvoiceBatchGetInfo,
wx.WithBody(func() ([]byte, error) {
return wx.MarshalNoEscapeHTML(params)
}),
wx.WithDecode(func(b []byte) error {
return json.Unmarshal(b, result)
}),
)
}
type ParamsInvoiceStatusBatchUpdate struct {
OpenID string `json:"openid"`
ReimburseStatus ReimburseStatus `json:"reimburse_status"`
InvoiceList []*ParamsInvoice `json:"invoice_list"`
}
// BatchUpdateInvoiceStatus 批量更新发票状态
func BatchUpdateInvoiceStatus(openID string, status ReimburseStatus, invoices ...*ParamsInvoice) wx.Action {
params := &ParamsInvoiceStatusBatchUpdate{
OpenID: openID,
ReimburseStatus: status,
InvoiceList: invoices,
}
return wx.NewPostAction(urls.CorpInvoiceBatchUpdateStatus,
wx.WithBody(func() ([]byte, error) {
return wx.MarshalNoEscapeHTML(params)
}),
)
}