mirror of
https://github.com/silenceper/wechat.git
synced 2026-03-01 00:35:26 +08:00
Compare commits
5 Commits
revert-685
...
b12825f83b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b12825f83b | ||
|
|
86cbd8c0b2 | ||
|
|
46c3722308 | ||
|
|
7d11af713b | ||
|
|
fafb1784da |
24
.github/workflows/go.yml
vendored
24
.github/workflows/go.yml
vendored
@@ -10,17 +10,21 @@ jobs:
|
|||||||
golangci:
|
golangci:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go-version: [1.16.x,1.17.x,1.18.x]
|
go-version: [ '1.16','1.17','1.18','1.19','1.20' ]
|
||||||
name: golangci-lint
|
name: golangci-lint
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/setup-go@v3
|
- name: Setup Golang ${{ matrix.go-version }}
|
||||||
- uses: actions/checkout@v3
|
uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: ${{ matrix.go-version }}
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v3.2.0
|
uses: golangci/golangci-lint-action@v3
|
||||||
with:
|
with:
|
||||||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
||||||
version: latest
|
version: v1.52.2
|
||||||
build:
|
build:
|
||||||
name: Test
|
name: Test
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -28,7 +32,7 @@ jobs:
|
|||||||
redis:
|
redis:
|
||||||
image: redis
|
image: redis
|
||||||
ports:
|
ports:
|
||||||
- 6379:6379
|
- 6379:6379
|
||||||
options: --entrypoint redis-server
|
options: --entrypoint redis-server
|
||||||
memcached:
|
memcached:
|
||||||
image: memcached
|
image: memcached
|
||||||
@@ -38,14 +42,14 @@ jobs:
|
|||||||
# strategy set
|
# strategy set
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
go: ["1.16", "1.17", "1.18"]
|
go: [ '1.16','1.17','1.18','1.19','1.20' ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- name: Set up Go 1.x
|
- name: Set up Go 1.x
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: ${{ matrix.go }}
|
go-version: ${{ matrix.go }}
|
||||||
id: go
|
id: go
|
||||||
- name: Test
|
- name: Test
|
||||||
run: go test -v -race ./...
|
run: go test -v -race ./...
|
||||||
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
@@ -11,17 +11,17 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
-
|
-
|
||||||
name: Set up Go
|
name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v4
|
||||||
with:
|
with:
|
||||||
go-version: 1.15
|
go-version: 1.16
|
||||||
-
|
-
|
||||||
name: Run GoReleaser
|
name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v2
|
uses: goreleaser/goreleaser-action@v4
|
||||||
with:
|
with:
|
||||||
version: latest
|
version: latest
|
||||||
args: release --rm-dist
|
args: release --rm-dist
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ type MixMessage struct {
|
|||||||
Title string `xml:"Title"`
|
Title string `xml:"Title"`
|
||||||
Description string `xml:"Description"`
|
Description string `xml:"Description"`
|
||||||
URL string `xml:"Url"`
|
URL string `xml:"Url"`
|
||||||
|
BizMsgMenuID int64 `xml:"bizmsgmenuid"`
|
||||||
|
|
||||||
// 事件相关
|
// 事件相关
|
||||||
Event EventType `xml:"Event" json:"Event"`
|
Event EventType `xml:"Event" json:"Event"`
|
||||||
|
|||||||
230
work/addresslist/linkedcorp.go
Normal file
230
work/addresslist/linkedcorp.go
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
package addresslist
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/silenceper/wechat/v2/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// getPermListURL 获取应用的可见范围
|
||||||
|
getPermListURL = "https://qyapi.weixin.qq.com/cgi-bin/linkedcorp/agent/get_perm_list?access_token=%s"
|
||||||
|
// getLinkedCorpUserURL 获取互联企业成员详细信息
|
||||||
|
getLinkedCorpUserURL = "https://qyapi.weixin.qq.com/cgi-bin/linkedcorp/user/get?access_token=%s"
|
||||||
|
// linkedCorpSimpleListURL 获取互联企业部门成员
|
||||||
|
linkedCorpSimpleListURL = "https://qyapi.weixin.qq.com/cgi-bin/linkedcorp/user/simplelist?access_token=%s"
|
||||||
|
// linkedCorpUserListURL 获取互联企业部门成员详情
|
||||||
|
linkedCorpUserListURL = "https://qyapi.weixin.qq.com/cgi-bin/linkedcorp/user/list?access_token=%s"
|
||||||
|
// linkedCorpDepartmentListURL 获取互联企业部门列表
|
||||||
|
linkedCorpDepartmentListURL = "https://qyapi.weixin.qq.com/cgi-bin/linkedcorp/department/list?access_token=%s"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetPermListResponse 获取应用的可见范围响应
|
||||||
|
type GetPermListResponse struct {
|
||||||
|
util.CommonError
|
||||||
|
UserIDs []string `json:"userids"`
|
||||||
|
DepartmentIDs []string `json:"department_ids"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPermList 获取应用的可见范围
|
||||||
|
// see https://developer.work.weixin.qq.com/document/path/93172
|
||||||
|
func (r *Client) GetPermList() (*GetPermListResponse, error) {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.HTTPPost(fmt.Sprintf(getPermListURL, accessToken), ""); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &GetPermListResponse{}
|
||||||
|
if err = util.DecodeWithError(response, result, "GetPermList"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLinkedCorpUserRequest 获取互联企业成员详细信息请求
|
||||||
|
type GetLinkedCorpUserRequest struct {
|
||||||
|
UserID string `json:"userid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLinkedCorpUserResponse 获取互联企业成员详细信息响应
|
||||||
|
type GetLinkedCorpUserResponse struct {
|
||||||
|
util.CommonError
|
||||||
|
UserInfo LinkedCorpUserInfo `json:"user_info"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkedCorpUserInfo 互联企业成员详细信息
|
||||||
|
type LinkedCorpUserInfo struct {
|
||||||
|
UserID string `json:"userid"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Department []string `json:"department"`
|
||||||
|
Mobile string `json:"mobile"`
|
||||||
|
Telephone string `json:"telephone"`
|
||||||
|
Email string `json:"email"`
|
||||||
|
Position string `json:"position"`
|
||||||
|
CorpID string `json:"corpid"`
|
||||||
|
Extattr Extattr `json:"extattr"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extattr 互联企业成员详细信息扩展属性
|
||||||
|
type Extattr struct {
|
||||||
|
Attrs []ExtattrItem `json:"attrs"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtattrItem 互联企业成员详细信息扩展属性条目
|
||||||
|
type ExtattrItem struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Value string `json:"value,omitempty"`
|
||||||
|
Type int `json:"type"`
|
||||||
|
Text ExtattrItemText `json:"text,omitempty"`
|
||||||
|
Web ExtattrItemWeb `json:"web,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtattrItemText 互联企业成员详细信息自定义属性(文本)
|
||||||
|
type ExtattrItemText struct {
|
||||||
|
Value string `json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExtattrItemWeb 互联企业成员详细信息自定义属性(网页)
|
||||||
|
type ExtattrItemWeb struct {
|
||||||
|
URL string `json:"url"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLinkedCorpUser 获取互联企业成员详细信息
|
||||||
|
// see https://developer.work.weixin.qq.com/document/path/93171
|
||||||
|
func (r *Client) GetLinkedCorpUser(req *GetLinkedCorpUserRequest) (*GetLinkedCorpUserResponse, error) {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.PostJSON(fmt.Sprintf(getLinkedCorpUserURL, accessToken), req); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &GetLinkedCorpUserResponse{}
|
||||||
|
if err = util.DecodeWithError(response, result, "GetLinkedCorpUser"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkedCorpSimpleListRequest 获取互联企业部门成员请求
|
||||||
|
type LinkedCorpSimpleListRequest struct {
|
||||||
|
DepartmentID string `json:"department_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkedCorpSimpleListResponse 获取互联企业部门成员响应
|
||||||
|
type LinkedCorpSimpleListResponse struct {
|
||||||
|
util.CommonError
|
||||||
|
Userlist []LinkedCorpUser `json:"userlist"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkedCorpUser 企业部门成员
|
||||||
|
type LinkedCorpUser struct {
|
||||||
|
UserID string `json:"userid"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Department []string `json:"department"`
|
||||||
|
CorpID string `json:"corpid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkedCorpSimpleList 获取互联企业部门成员
|
||||||
|
// see https://developer.work.weixin.qq.com/document/path/93168
|
||||||
|
func (r *Client) LinkedCorpSimpleList(req *LinkedCorpSimpleListRequest) (*LinkedCorpSimpleListResponse, error) {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.PostJSON(fmt.Sprintf(linkedCorpSimpleListURL, accessToken), req); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &LinkedCorpSimpleListResponse{}
|
||||||
|
if err = util.DecodeWithError(response, result, "LinkedCorpSimpleList"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkedCorpUserListRequest 获取互联企业部门成员详情请求
|
||||||
|
type LinkedCorpUserListRequest struct {
|
||||||
|
DepartmentID string `json:"department_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkedCorpUserListResponse 获取互联企业部门成员详情响应
|
||||||
|
type LinkedCorpUserListResponse struct {
|
||||||
|
util.CommonError
|
||||||
|
UserList []LinkedCorpUserInfo `json:"userlist"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkedCorpUserList 获取互联企业部门成员详情
|
||||||
|
// see https://developer.work.weixin.qq.com/document/path/93169
|
||||||
|
func (r *Client) LinkedCorpUserList(req *LinkedCorpUserListRequest) (*LinkedCorpUserListResponse, error) {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.PostJSON(fmt.Sprintf(linkedCorpUserListURL, accessToken), req); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &LinkedCorpUserListResponse{}
|
||||||
|
if err = util.DecodeWithError(response, result, "LinkedCorpUserList"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkedCorpDepartmentListRequest 获取互联企业部门列表请求
|
||||||
|
type LinkedCorpDepartmentListRequest struct {
|
||||||
|
DepartmentID string `json:"department_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkedCorpDepartmentListResponse 获取互联企业部门列表响应
|
||||||
|
type LinkedCorpDepartmentListResponse struct {
|
||||||
|
util.CommonError
|
||||||
|
DepartmentList []LinkedCorpDepartment `json:"department_list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkedCorpDepartment 互联企业部门
|
||||||
|
type LinkedCorpDepartment struct {
|
||||||
|
DepartmentID string `json:"department_id"`
|
||||||
|
DepartmentName string `json:"department_name"`
|
||||||
|
ParentID string `json:"parentid"`
|
||||||
|
Order int `json:"order"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LinkedCorpDepartmentList 获取互联企业部门列表
|
||||||
|
// see https://developer.work.weixin.qq.com/document/path/93170
|
||||||
|
func (r *Client) LinkedCorpDepartmentList(req *LinkedCorpDepartmentListRequest) (*LinkedCorpDepartmentListResponse, error) {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.PostJSON(fmt.Sprintf(linkedCorpDepartmentListURL, accessToken), req); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &LinkedCorpDepartmentListResponse{}
|
||||||
|
if err = util.DecodeWithError(response, result, "LinkedCorpDepartmentList"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
17
work/invoice/client.go
Normal file
17
work/invoice/client.go
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
package invoice
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/silenceper/wechat/v2/work/context"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Client 电子发票接口实例
|
||||||
|
type Client struct {
|
||||||
|
*context.Context
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewClient 初始化实例
|
||||||
|
func NewClient(ctx *context.Context) *Client {
|
||||||
|
return &Client{
|
||||||
|
ctx,
|
||||||
|
}
|
||||||
|
}
|
||||||
191
work/invoice/invoice.go
Normal file
191
work/invoice/invoice.go
Normal file
@@ -0,0 +1,191 @@
|
|||||||
|
package invoice
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/silenceper/wechat/v2/util"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// getInvoiceInfoURL 查询电子发票
|
||||||
|
getInvoiceInfoURL = "https://qyapi.weixin.qq.com/cgi-bin/card/invoice/reimburse/getinvoiceinfo?access_token=%s"
|
||||||
|
// updateInvoiceStatusURL 更新发票状态
|
||||||
|
updateInvoiceStatusURL = "https://qyapi.weixin.qq.com/cgi-bin/card/invoice/reimburse/updateinvoicestatus?access_token=%s"
|
||||||
|
// updateStatusBatchURL 批量更新发票状态
|
||||||
|
updateStatusBatchURL = "https://qyapi.weixin.qq.com/cgi-bin/card/invoice/reimburse/updatestatusbatch?access_token=%s"
|
||||||
|
// getInvoiceInfoBatchURL 批量查询电子发票
|
||||||
|
getInvoiceInfoBatchURL = "https://qyapi.weixin.qq.com/cgi-bin/card/invoice/reimburse/getinvoiceinfobatch?access_token=%s"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetInvoiceInfoRequest 查询电子发票请求
|
||||||
|
type GetInvoiceInfoRequest struct {
|
||||||
|
CardID string `json:"card_id"`
|
||||||
|
EncryptCode string `json:"encrypt_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetInvoiceInfoResponse 查询电子发票响应
|
||||||
|
type GetInvoiceInfoResponse struct {
|
||||||
|
util.CommonError
|
||||||
|
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 UserInfo `json:"user_info"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UserInfo 发票的用户信息
|
||||||
|
type UserInfo struct {
|
||||||
|
Fee int64 `json:"fee"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
BillingTime int64 `json:"billing_time"`
|
||||||
|
BillingNo string `json:"billing_no"`
|
||||||
|
BillingCode string `json:"billing_code"`
|
||||||
|
Info []Info `json:"info"`
|
||||||
|
FeeWithoutTax int64 `json:"fee_without_tax"`
|
||||||
|
Tax int64 `json:"tax"`
|
||||||
|
Detail string `json:"detail"`
|
||||||
|
PdfURL string `json:"pdf_url"`
|
||||||
|
TripPdfURL string `json:"trip_pdf_url"`
|
||||||
|
ReimburseStatus string `json:"reimburse_status"`
|
||||||
|
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"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Info 商品信息结构
|
||||||
|
type Info struct {
|
||||||
|
Name string `json:"name"`
|
||||||
|
Num int64 `json:"num"`
|
||||||
|
Unit string `json:"unit"`
|
||||||
|
Fee int64 `json:"fee"`
|
||||||
|
Price int64 `json:"price"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetInvoiceInfo 查询电子发票
|
||||||
|
// see https://developer.work.weixin.qq.com/document/path/90284
|
||||||
|
func (r *Client) GetInvoiceInfo(req *GetInvoiceInfoRequest) (*GetInvoiceInfoResponse, error) {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.PostJSON(fmt.Sprintf(getInvoiceInfoURL, accessToken), req); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &GetInvoiceInfoResponse{}
|
||||||
|
if err = util.DecodeWithError(response, result, "GetInvoiceInfo"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateInvoiceStatusRequest 更新发票状态请求
|
||||||
|
type UpdateInvoiceStatusRequest struct {
|
||||||
|
CardID string `json:"card_id"`
|
||||||
|
EncryptCode string `json:"encrypt_code"`
|
||||||
|
ReimburseStatus string `json:"reimburse_status"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateInvoiceStatus 更新发票状态
|
||||||
|
// see https://developer.work.weixin.qq.com/document/path/90285
|
||||||
|
func (r *Client) UpdateInvoiceStatus(req *UpdateInvoiceStatusRequest) error {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.PostJSON(fmt.Sprintf(updateInvoiceStatusURL, accessToken), req); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return util.DecodeWithCommonError(response, "UpdateInvoiceStatus")
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStatusBatchRequest 批量更新发票状态
|
||||||
|
type UpdateStatusBatchRequest struct {
|
||||||
|
OpenID string `json:"openid"`
|
||||||
|
ReimburseStatus string `json:"reimburse_status"`
|
||||||
|
InvoiceList []Invoice `json:"invoice_list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invoice 发票卡券
|
||||||
|
type Invoice struct {
|
||||||
|
CardID string `json:"card_id"`
|
||||||
|
EncryptCode string `json:"encrypt_code"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateStatusBatch 批量更新发票状态
|
||||||
|
// see https://developer.work.weixin.qq.com/document/path/90286
|
||||||
|
func (r *Client) UpdateStatusBatch(req *UpdateStatusBatchRequest) error {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.PostJSON(fmt.Sprintf(updateStatusBatchURL, accessToken), req); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return util.DecodeWithCommonError(response, "UpdateStatusBatch")
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetInvoiceInfoBatchRequest 批量查询电子发票请求
|
||||||
|
type GetInvoiceInfoBatchRequest struct {
|
||||||
|
ItemList []Invoice `json:"item_list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetInvoiceInfoBatchResponse 批量查询电子发票响应
|
||||||
|
type GetInvoiceInfoBatchResponse struct {
|
||||||
|
util.CommonError
|
||||||
|
ItemList []Item `json:"item_list"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Item 电子发票的结构化信息
|
||||||
|
type Item 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 UserInfo `json:"user_info"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetInvoiceInfoBatch 批量查询电子发票
|
||||||
|
// see https://developer.work.weixin.qq.com/document/path/90287
|
||||||
|
func (r *Client) GetInvoiceInfoBatch(req *GetInvoiceInfoBatchRequest) (*GetInvoiceInfoBatchResponse, error) {
|
||||||
|
var (
|
||||||
|
accessToken string
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if accessToken, err = r.GetAccessToken(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
var response []byte
|
||||||
|
if response, err = util.PostJSON(fmt.Sprintf(getInvoiceInfoBatchURL, accessToken), req); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result := &GetInvoiceInfoBatchResponse{}
|
||||||
|
if err = util.DecodeWithError(response, result, "GetInvoiceInfoBatch"); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return result, nil
|
||||||
|
}
|
||||||
@@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/silenceper/wechat/v2/work/config"
|
"github.com/silenceper/wechat/v2/work/config"
|
||||||
"github.com/silenceper/wechat/v2/work/context"
|
"github.com/silenceper/wechat/v2/work/context"
|
||||||
"github.com/silenceper/wechat/v2/work/externalcontact"
|
"github.com/silenceper/wechat/v2/work/externalcontact"
|
||||||
|
"github.com/silenceper/wechat/v2/work/invoice"
|
||||||
"github.com/silenceper/wechat/v2/work/kf"
|
"github.com/silenceper/wechat/v2/work/kf"
|
||||||
"github.com/silenceper/wechat/v2/work/material"
|
"github.com/silenceper/wechat/v2/work/material"
|
||||||
"github.com/silenceper/wechat/v2/work/message"
|
"github.com/silenceper/wechat/v2/work/message"
|
||||||
@@ -79,3 +80,8 @@ func (wk *Work) GetMessage() *message.Client {
|
|||||||
func (wk *Work) GetAppChat() *appchat.Client {
|
func (wk *Work) GetAppChat() *appchat.Client {
|
||||||
return appchat.NewClient(wk.ctx)
|
return appchat.NewClient(wk.ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetInvoice get invoice
|
||||||
|
func (wk *Work) GetInvoice() *invoice.Client {
|
||||||
|
return invoice.NewClient(wk.ctx)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user