@@ -112,3 +112,154 @@ type SellerInfo struct {
RegisterPhone string ` json:"register_phone" `
TaxPayerNum string ` json:"tax_payer_num" `
}
// QueryInvoiceSetting 查询门店发票设置
func ( a * API ) QueryInvoiceSetting ( baiduShopId [ ] string ) ( [ ] * SettingList , error ) {
parameter := make ( [ ] * StoreIdList , 0 , len ( baiduShopId ) )
for _ , v := range baiduShopId {
parameter = append ( parameter , & StoreIdList { BaiDuShopId : v } )
}
data , err := a . AccessAPI ( "invoice.settings.list" , map [ string ] interface { } { "shop_list" : parameter } )
if err != nil {
return nil , err
}
if data . ErrNo != 0 {
return nil , fmt . Errorf ( data . Error )
}
result := make ( [ ] * SettingList , 0 , 0 )
if err = utils . UnmarshalUseNumber ( utils . MustMarshal ( data . Data . ( map [ string ] interface { } ) [ "settings_list" ] ) , & result ) ; err != nil {
return nil , err
}
return result , nil
}
type StoreIdList struct {
BaiDuShopId string ` json:"baidu_shop_id" ` // 平台门店ID
ShopId string ` json:"shop_id" ` // 合作方门店ID
}
type SettingList struct {
BaiDuShopId string ` json:"baidu_shop_id" ` // 平台门店ID
ShopId string ` json:"shop_id" ` // 合作方门店ID
Settings struct {
InvoiceMode string ` json:"invoice_mode" ` // 开具方式 SYS_MANUAL 枚举: SYS_MANUAL("人工开具"), OPEN_API("开放平台"), FLASH_INVOICE("闪电开票"), CODE_INVOICE("扫码开票"), H5_REDIRECT("H5植入"),OTHER("其他形式");
InvoiceMaterial string ` json:"invoice_material" ` // 发票材质 PAPER 枚举: PAPER("纸质"), ELECTRONIC("电子");
InvoiceClass string ` json:"invoice_class" ` // 发票种类 VAT_COMMON 枚举: VAT_COMMON("普通发票"), VAT_SPECIAL("专用发票"), QUOTA("定额发票");
} ` json:"settings" `
InvoiceContact struct {
Person string ` json:"person" ` // 联系人
Phone string ` json:"phone" ` // 电话
} ` json:"invoice_contact" `
}
// BathUpdateInvoiceSetting 批量更新门店发票设置
func ( a * API ) BathUpdateInvoiceSetting ( baiDuStoreId string , setting * StoreInvoiceSetting ) ( [ ] * ResultList , [ ] * ResultList , error ) {
data , err := a . AccessAPI ( "invoice.settings.batchUpdate" , map [ string ] interface { } {
"shop_list" : append ( [ ] * StoreIdList { } , & StoreIdList { BaiDuShopId : baiDuStoreId } ) ,
"settings" : & setting ,
} )
if err != nil {
return nil , nil , err
}
if data . ErrNo != 0 {
return nil , nil , fmt . Errorf ( data . Error )
}
successList := make ( [ ] * ResultList , 0 , 0 )
failList := make ( [ ] * ResultList , 0 , 0 )
respList := data . Data . ( map [ string ] interface { } )
if respList [ "success_shop_list" ] != nil {
if err = utils . UnmarshalUseNumber ( utils . MustMarshal ( respList [ "success_shop_list" ] ) , successList ) ; err != nil {
return nil , nil , err
}
}
if respList [ "failed_shop_list" ] != nil {
if err = utils . UnmarshalUseNumber ( utils . MustMarshal ( respList [ "failed_shop_list" ] ) , failList ) ; err != nil {
return nil , nil , err
}
}
return successList , failList , nil
}
type StoreInvoiceSetting struct {
InvoiceMaterial string ` json:"invoice_material" ` // PAPER 枚举: PAPER("纸质"), ELECTRONIC("电子");
InvoiceClass string ` json:"invoice_class" ` // VAT_COMMON 枚举: VAT_COMMON("普通发票"), VAT_SPECIAL("专用发票"), QUOTA("定额发票")
InvoiceContact struct {
Person string ` json:"person" ` // 联系人
Phone string ` json:"phone" ` // 电话
} ` json:"invoice_contact" `
InvoiceMode string ` json:"invoice_mode" ` // 开具方式 SYS_MANUAL 枚举: SYS_MANUAL("人工开具"), OPEN_API("开放平台"), FLASH_INVOICE("闪电开票"), CODE_INVOICE("扫码开票"), H5_REDIRECT("H5植入"),OTHER("其他形式");
}
type ResultList struct {
BaiDuShopId string ` json:"baidu_shop_id" ` // 平台门店ID
ShopId string ` json:"shop_id" ` // 合作方门店ID
Msg string ` json:"msg" `
}
// QueryUnansweredInvoice 查询门店未回复发票信息
func ( a * API ) QueryUnansweredInvoice ( baiDuStoreId string ) ( * QueryUnansweredInvoiceResult , error ) {
data , err := a . AccessAPI ( "invoice.apply.list" , map [ string ] interface { } {
"baidu_shop_id" : baiDuStoreId ,
"status" : "INIT" ,
"page_no" : 1 ,
"page_size" : 100 ,
} )
if err != nil {
return nil , err
}
if data . ErrNo != 0 {
return nil , fmt . Errorf ( data . Error )
}
result := & QueryUnansweredInvoiceResult { }
if err = utils . UnmarshalUseNumber ( utils . MustMarshal ( data . Data ) , result ) ; err != nil {
return nil , err
}
return result , nil
}
type QueryUnansweredInvoiceResult struct {
PageNo int ` json:"page_no" ` // 页码
PageSize int ` json:"page_size" ` // 每页条数
TotalCount int ` json:"total_count" ` // 总条数
TotalPage int ` json:"total_page" ` // 总页数
RecordList [ ] * InvoiceApplyBody ` json:"record_list" ` // 申请单列表
}
// InvoiceApplyBody 用户申请发票body 消息推送接口
type InvoiceApplyBody struct {
ApplicationNo string ` json:"application_no" ` // 申请单编号
BaiduShopId string ` json:"baidu_shop_id" ` // 平台门店ID, 与合作方门店ID至少有一个
ShopId string ` json:"shop_id" ` // 合作方门店ID, 与平台门店ID 至少有一个
InvoiceMaterial string ` json:"invoice_material" ` // 发票材质
InvoiceClass string ` json:"invoice_class" ` // 发票种类
Status string ` json:"status" ` // 申请状态,目前仅支持
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" ` // 抬头类型
} ` json:"buyer_title" ` // 购方信息
OrderList [ ] struct {
CreateTime int64 ` json:"create_time" `
InvoiceAmount float64 ` json:"invoice_amount" `
OrderId int64 ` json:"order_id" `
} ` json:"order_list" `
BuyerContact struct {
Email string ` json:"email" ` // 邮箱
} ` json:"buyer_contact" ` // 购方用户联系信息
TotalInvoiceAmount float64 ` json:"total_invoice_amount" ` // 开票总金额,单位元
}
// InvoiceEmailPush 邮箱推送 消息推送接口
type InvoiceEmailPush struct {
ApplicationNo string ` json:"application_no" ` // 是 申请单编号
BaiduShopId string ` json:"baidu_shop_id" ` // 否 平台门店ID, 与合作方门店ID至少有一个
ShopId string ` json:"shop_id" ` // 否 合作方门店ID, 与平台门店ID 至少有一个
Email string ` json:"email" ` // 是 邮箱
}