-
Notifications
You must be signed in to change notification settings - Fork 3
/
tax.go
74 lines (69 loc) · 1.47 KB
/
tax.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
package tax
import (
"context"
"fmt"
"github.com/YunzhanghuOpen/sdk-go/api"
"github.com/YunzhanghuOpen/sdk-go/errorx"
"github.com/YunzhanghuOpen/sdk-go/example/base"
)
// GetTaxFileExample 下载个税扣缴明细表
func GetTaxFileExample(client api.Tax) {
req := &api.GetTaxFileRequest{
DealerID: base.DealerID,
EntID: "accumulus_tj",
YearMonth: "2022-02",
}
resp, err := client.GetTaxFile(context.TODO(), req)
if err != nil {
e, ok := errorx.FromError(err)
if !ok {
// 发生异常
fmt.Println(err)
return
}
// 失败返回
fmt.Println(e.Code, e.Message)
return
}
// 操作成功
fmt.Println(resp)
for _, file := range resp.FileInfo {
pwd, err := base.DecodeZipPwd(file.Pwd) // 解密zip压缩文件密码
if err != nil {
return
}
fmt.Println(pwd)
}
}
// GetUserCrossExample 查询纳税人是否为跨集团用户
func GetUserCrossExample(client api.Tax) {
req := &api.GetUserCrossRequest{
DealerID: base.DealerID,
EntID: "accumulus_tj",
Year: "2022",
IDCard: "11010519491231002X",
}
resp, err := client.GetUserCross(context.TODO(), req)
if err != nil {
e, ok := errorx.FromError(err)
if !ok {
// 发生异常
fmt.Println(err)
return
}
// 失败返回
fmt.Println(e.Code, e.Message)
}
// 操作成功
fmt.Println(resp)
}
// Example 样例
func Example() {
client := base.NewClient()
for _, example := range []func(api.Tax){
GetTaxFileExample,
GetUserCrossExample,
} {
example(client)
}
}