Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ 添加 支付宝商家账户账务明细查询 #350

Merged
merged 5 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions alipay/data_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ import (
"github.com/go-pay/gopay"
)

// Deprecated
// 支付宝已不再支持
// alipay.data.bill.balance.query(支付宝商家账户当前余额查询)
// 文档地址:https://opendocs.alipay.com/apis/api_15/alipay.data.bill.balance.query
// 文档地址:https://opendocs.alipay.com/open/2acb3c34_alipay.data.bill.balance.query
func (a *Client) DataBillBalanceQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *DataBillBalanceQueryResponse, err error) {
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "alipay.data.bill.balance.query"); err != nil {
Expand All @@ -29,6 +27,25 @@ func (a *Client) DataBillBalanceQuery(ctx context.Context, bm gopay.BodyMap) (al
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// alipay.data.bill.accountlog.query(支付宝商家账户账务明细查询)
// 文档地址:https://opendocs.alipay.com/open/dae3ac99_alipay.data.bill.accountlog.query
func (a *Client) DataBillAccountLogQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *DataBillAccountLogQueryResponse, err error) {
var bs []byte
if bs, err = a.doAliPay(ctx, bm, "alipay.data.bill.accountlog.query"); err != nil {
return nil, err
}
aliRsp = new(DataBillAccountLogQueryResponse)
if err = json.Unmarshal(bs, aliRsp); err != nil || aliRsp.Response == nil {
return nil, fmt.Errorf("[%w], bytes: %s", gopay.UnmarshalErr, string(bs))
}
if err = bizErrCheck(aliRsp.Response.ErrorResponse); err != nil {
return aliRsp, err
}
signData, signDataErr := a.getSignData(bs, aliRsp.AlipayCertSn)
aliRsp.SignData = signData
return aliRsp, a.autoVerifySignByCert(aliRsp.Sign, signData, signDataErr)
}

// alipay.data.dataservice.bill.downloadurl.query(查询对账单下载地址)
// 文档地址:https://opendocs.alipay.com/open/02e7gr
func (a *Client) DataBillDownloadUrlQuery(ctx context.Context, bm gopay.BodyMap) (aliRsp *DataBillDownloadUrlQueryResponse, err error) {
Expand Down
37 changes: 37 additions & 0 deletions alipay/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,43 @@ type DataBillBalanceQuery struct {
TotalAmount string `json:"total_amount,omitempty"`
AvailableAmount string `json:"available_amount,omitempty"`
FreezeAmount string `json:"freeze_amount,omitempty"`
SettleAmount string `json:"settle_amount,omitempty"`
}

// ===================================================
type DataBillAccountLogQueryResponse struct {
Response *DataBillAccountLogQuery `json:"alipay_data_bill_accountlog_query_response"`
AlipayCertSn string `json:"alipay_cert_sn,omitempty"`
SignData string `json:"-"`
Sign string `json:"sign"`
}

type DataBillAccountLogQuery struct {
ErrorResponse
PageNo string `json:"page_no,omitempty"`
PageSize string `json:"page_size,omitempty"`
TotalSize string `json:"total_size,omitempty"`
DetailList []AccountLogItemResult `json:"detail_list,omitempty"`
}

type AccountLogItemResult struct {
TransDt string `json:"trans_dt,omitempty"`
AccountLogId string `json:"account_log_id,omitempty"`
AlipayOrderNo string `json:"alipay_order_no,omitempty"`
MerchantOrderNo string `json:"merchant_order_no,omitempty"`
TransAmount string `json:"trans_amount,omitempty"`
Balance string `json:"balance,omitempty"`
Type string `json:"type,omitempty"`
OtherAccount string `json:"other_account,omitempty"`
TransMemo string `json:"trans_memo,omitempty"`
Direction string `json:"direction,omitempty"`
BillSource string `json:"bill_source,omitempty"`
BizNos string `json:"biz_nos,omitempty"`
BizOrigNo string `json:"biz_orig_no,omitempty"`
BizDesc string `json:"biz_desc,omitempty"`
MerchantOutRefundNo string `json:"merchant_out_refund_no,omitempty"`
ComplementInfo string `json:"complement_info,omitempty"`
StoreName string `json:"store_name,omitempty"`
}

// ===================================================
Expand Down