115 lines
3.6 KiB
Go
115 lines
3.6 KiB
Go
package ebaiapi
|
|
|
|
import (
|
|
"fmt"
|
|
"git.rosy.net.cn/baseapi/utils"
|
|
)
|
|
|
|
// UploadInvoice 上传发票回复
|
|
func (a *API) UploadInvoice(baiduShopId, applicationNo, fileUrl string) (*UploadInvoiceResult, error) {
|
|
param := &UpdateInvoice{
|
|
BaiduShopId: baiduShopId,
|
|
ShopId: "",
|
|
RequestList: nil,
|
|
}
|
|
requestList := make([]ApplicationList, 0, 0)
|
|
requestList = append(requestList, ApplicationList{
|
|
ApplicationNo: applicationNo,
|
|
Status: "",
|
|
InvoiceList: nil,
|
|
FileUrl: fileUrl,
|
|
InvoiceClass: "",
|
|
InvoiceCode: "",
|
|
InvoiceDate: "",
|
|
InvoiceMaterial: "",
|
|
InvoiceNo: "",
|
|
Memo: "",
|
|
LineList: nil,
|
|
MachineCode: "",
|
|
SellerInfo: SellerInfo{},
|
|
TaxAmount: "",
|
|
ValidationCode: "",
|
|
})
|
|
param.RequestList = requestList
|
|
|
|
data, err := a.AccessAPI("invoice.apply.batchUpdate", utils.Struct2Map(param, "", false))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
if data.ErrNo != 0 {
|
|
return nil, fmt.Errorf(data.Error)
|
|
}
|
|
result := &UploadInvoiceResult{}
|
|
if err = utils.UnmarshalUseNumber(utils.MustMarshal(data.Data), result); err != nil {
|
|
return nil, err
|
|
}
|
|
return result, nil
|
|
}
|
|
|
|
type UploadInvoiceResult struct {
|
|
SuccessfulApplicationNoList []string `json:"successful_application_no_list"`
|
|
FailedApplicationNoList []string `json:"failed_application_no_list"`
|
|
}
|
|
|
|
// UpdateInvoice 申请
|
|
type UpdateInvoice struct {
|
|
BaiduShopId string `json:"baidu_shop_id"`
|
|
ShopId string `json:"shop_id"`
|
|
RequestList []ApplicationList `json:"request_list"`
|
|
}
|
|
|
|
type ApplicationList struct {
|
|
ApplicationNo string `json:"application_no"`
|
|
Status string `json:"status"`
|
|
InvoiceList []InvoiceList `json:"buyer_title"`
|
|
FileUrl string `json:"file_url"`
|
|
InvoiceClass string `json:"invoice_class"`
|
|
InvoiceCode string `json:"invoice_code"`
|
|
InvoiceDate string `json:"invoice_date"`
|
|
InvoiceMaterial string `json:"invoice_material"`
|
|
InvoiceNo string `json:"invoice_no"`
|
|
Memo string `json:"memo"`
|
|
LineList []LineList `json:"line_list"`
|
|
MachineCode string `json:"machine_code"`
|
|
SellerInfo SellerInfo `json:"seller_info"`
|
|
TaxAmount string `json:"tax_amount"`
|
|
ValidationCode string `json:"validation_code"`
|
|
}
|
|
|
|
type InvoiceList struct {
|
|
AmountWithTax float64 `json:"amount_with_tax"`
|
|
AmountWithoutTax float64 `json:"amount_without_tax"`
|
|
BuyerTitle struct {
|
|
BankAccount string `json:"bank_account"`
|
|
BankName string `json:"bank_name"`
|
|
RegisterAddress string `json:"register_address"`
|
|
RegisterPhone string `json:"register_phone"`
|
|
TaxPayerNum string `json:"tax_payer_num"`
|
|
TitleName string `json:"title_name"`
|
|
TitleType string `json:"title_type"`
|
|
}
|
|
}
|
|
|
|
type LineList struct {
|
|
AmountWithoutTax float64 `json:"amount_without_tax"`
|
|
CargoName string `json:"cargo_name"`
|
|
CargoNo string `json:"cargo_no"`
|
|
Quantity int `json:"quantity"`
|
|
Specification string `json:"specification"`
|
|
TaxAmount int `json:"tax_amount"`
|
|
TaxRate float64 `json:"tax_rate"`
|
|
Unit string `json:"unit"`
|
|
UnitPrice float64 `json:"unit_price"`
|
|
}
|
|
type SellerInfo struct {
|
|
BankAccount string `json:"bank_account"`
|
|
BankName string `json:"bank_name"`
|
|
Checker string `json:"checker"`
|
|
Clerk string `json:"clerk"`
|
|
Name string `json:"name"`
|
|
Payee string `json:"payee"`
|
|
RegisterAddress string `json:"register_address"`
|
|
RegisterPhone string `json:"register_phone"`
|
|
TaxPayerNum string `json:"tax_payer_num"`
|
|
}
|