操作手册

接口

开票接口
开票API是自动开具数电发票的接口,支持开具蓝字发票,该接口主要涉及到登录税务局、开票两个接口

登录税务局
开票前置流程,登录税务局

接口协议
该接口采用 WebSocket 协议

接口:/invoice?userId=xxx

请求示例:

{
“type”: “login”,
“data”: {
“companyCode”: “xxx”,
“phone”: “xxx”,
“password”: “xxx”,
“area”: “zhejiang”,
“role”: “法定代表人”
}
}
请求参数:

参数名称 参数说明 是否必须 数据类型
type 请求类型(固定 login) true string
data 请求数据 true object
data:

参数名称 参数说明 是否必须 数据类型
companyCode 统一社会信用代码/纳税人识别号 true string
phone 居民身份证号码/手机号码/用户名 true string
password 个人用户密码 true string
area 区域 true string
role 登录角色 true string
响应状态

响应状态

状态码 说明
200 OK
401 Unauthorized
403 Forbidden
响应参数

参数名称 参数说明 数据类型
type 请求类型(固定 login) string
sendToId 接收方用户ID string
data 响应数据(登录接口无数据,响应登录状态:0 失败,1 成功) string
响应示例

{
“type”: “login”,
“sendToId”: “1111”,
“data”: “1”
}
开票
具体开票接口

接口协议
该接口采用 WebSocket 协议

接口:/invoice?userId=xxx

请求示例:

{
“type” : “invoice_info”,
“data”:
}
请求参数:

参数名称 参数说明 是否必须 数据类型
type 请求类型(固定 login) true string
data 请求数据 true object
data:

参数名称 参数说明 是否必须 数据类型
buyerAddress 购买方公司地址 true string
buyerBank 购买方开户银行 true string
buyerBankAccount 购买方银行帐号 true string
buyerEmail 购买方收票邮箱 true string
buyerIndentification 购买方统一信用代码 true string
buyerName 购买方名称 true string
buyerPhone 购买方电话 true string
buyerInvoiceType 购买方发票信息(0-普通票,1-专票) true integer
buyerBankShow 是否展示购买方银行帐号,0不显示,1显示 true integer
buyerType 购买方组织类型(0-企业,1-个人) true integer
invoiceItems 发票商品列表 必填一条 array
remark 备注信息 true string
sellerBank 销售方银行 true string
sellerBankAccount 销售方银行帐户 true string
sellerIndentification 销售方统一信用代码 true string
sellerLoginAccount 销售方税务局登录帐号 true string
sellerLoginPassword 销售方税务局登录密码 true string
sellerName 销售方公司名称 true string
sellerBankShow 是否展示销售方银行帐号,0不显示,1显示 true integer
invoiceItem:

参数名称 参数说明 是否必须 数据类型
name 名称 是 string
quantity 数量 是 integer
spec 规格 是 string
unit 单位 是 string
unitPrice 单价 是 double
响应状态

状态码 说明
200 OK
401 Unauthorized
403 Forbidden
人脸二维码响应
无需人脸验证时不会响应此数据

响应参数

参数名称 参数说明 数据类型
type 请求类型(固定 invoice_qrcode) string
sendToId 接收方用户ID string
data 响应数据(0 失败;具体的二维码 base64 编码) string
响应示例

{
“type”: “invoice_qrcode”,
“sendToId”: “1111”,
“data”: “data:image/png;base64,xxxxxxxx”
}
扫码失败响应:

{
“type”: “invoice_qrcode”,
“sendToId”: “1111”,
“data”: “0”
}
开票结果响应
响应参数

参数名称 参数说明 数据类型
type 请求类型(固定 invoice_pdf) string
sendToId 接收方用户ID string
data 响应数据(0 失败;开票数据,包含开票成功后的pdf文件地址) string / object
data 成功:

参数名称 参数说明 数据类型
buyerName 购买方名称 string
buyerIndentification 购买方统一信用代码 string
buyerAddress 购买方公司地址 string
buyerPhone 购买方电话 string
buyerInvoiceType 购买方发票信息(0-普通票,1-专票) string
buyerType 购买方组织类型(0-企业,1-个人) string
buyerEmail 购买方收票邮箱 string
buyerBank 购买方开户银行 string
buyerBankAccount 购买方银行帐号 string
buyerBankShow 是否展示购买方银行帐号(0不显示,1显示) string
sellerBankShow 是否展示销售方银行帐号(0不显示,1显示) string
vipId 用户ID string
isDrafts 是否为草稿(0-不是,1-是) string
invoiceItems 商品列表 string
sellerName 销售方公司名称 string
sellerIndentification 销售方统一信用代码 string
sellerBank 销售方银行 string
sellerBankAccount 销售方银行帐户 string
sellerLoginAccount 销售方税务局登录帐号 string
sellerLoginPassword 销售方税务局登录密码 string
invoiceUrl 开票PDF URL string
sellerAddress 销售方地址 string
sellerPhone 销售方电话 string
remark 备注 string
响应示例

{
“type”: “invoice_pdf”,
“sendToId”: “1111”,
“data”: {
“buyerName”: “ABC公司”,
“buyerIndentification”: “91330701MA2DFB848M”,
“buyerAddress”: “浙江省杭州市西湖区文一西路 123 号”,
“buyerPhone”: “13812345678”,
“buyerInvoiceType”: “0”,
“buyerType”: “0”,
“buyerEmail”: “buyer@example.com”,
“buyerBank”: “工商银行杭州分行”,
“buyerBankAccount”: “1234567890123456789”,
“buyerBankShow”: “1”,
“sellerBankShow”: “1”,
“vipId”: “987654”,
“isDrafts”: “0”,
“invoiceItems”: “[{\”name\”:\”商品A\”,\”quantity\”:2,\”spec\”:\”规格A\”,\”unit\”:\”件\”,\”unitPrice\”:100},{\”name\”:\”商品B\”,\”quantity\”:1,\”spec\”:\”规格B\”,\”unit\”:\”套\”,\”unitPrice\”:200}]”,
“sellerName”: “XYZ科技有限公司”,
“sellerIndentification”: “91330701MA2M37T86L”,
“sellerBank”: “招商银行杭州分行”,
“sellerBankAccount”: “9876543210987654321”,
“sellerLoginAccount”: “seller_login”,
“sellerLoginPassword”: “password123”,
“invoiceUrl”: “http://example.com/invoice.pdf“,
“sellerAddress”: “浙江省杭州市滨江区江南大道 456 号”,
“sellerPhone”: “13987654321”,
“remark”: “这是一条测试备注信息。”
}
}
查询发票接口
查询发票API是自动查询历史开具发票的接口,该接口主要涉及到查询发票基本信息、查询发票商品项信息、查询发票文件三个接口

查询发票基本信息
接口协议
该接口采用 WebSocket 协议

接口:/web/invoice?userId=xxx

请求示例:

{
“type”: “query_invoice”,
“data”: {
“login”: {
“companyCode”: “xxx”,
“area”: “zhejiang”,
“phone”: “123456”,
“password”: “lm080918”,
“role”: “法定代表人”,
“companyName”: “xxxx”
},
“condition”: {
“queryType”: 0,
“invoiceSource”: null,
“invoiceType”: null,
“isInvoicePositive”: null,
“countETicketNumbers”: “”,
“invoiceCode”: null,
“invoiceNumber”: null,
“sellerIdentificationNumber”: null,
“sellerName”: null,
“startInvoiceValue”: null,
“endInvoiceValue”: null,
“startInvoiceDate”: “2024-04-01”,
“endInvoiceDate”: “2024-04-12”
},
“page”: {
“pageSize”: 10,
“pageNumber”: 1
}
}
}
请求参数:

参数名称 参数说明 是否必须 数据类型
type 请求类型(固定 query_invoice) true string
data 请求数据 true object
login:

参数名称 参数说明 是否必须 数据类型
companyCode 统一社会信用代码/纳税人识别号 true string
phone 居民身份证号码/手机号码/用户名 true string
password 个人用户密码 true string
area 区域 true string
role 登录角色 true string
condition:

参数名称 参数说明 是否必须 数据类型
queryType 0开具发票,1取得发票 true integer
invoiceSource 发票来源 false string
invoiceType 票种 false string
isInvoicePositive 是否正数发票 false string
countETicketNumbers 数电票号码 false string
invoiceCode 发票代码 false string
invoiceNumber 发票号码 false string
buyerIdentificationNumber 对方纳税人识别号 false string
buyerName 对方纳税人名称 false string
startInvoiceValue 发票金额(起) false double
endInvoiceValue 发票金额(止) false double
startInvoiceDate 开票日期(起) true string
endInvoiceDate 开票日期(止) true string
page:

参数名称 参数说明 是否必须 数据类型
pageSize 每页大小 true integer
pageNumber 页码 true integer
发票基本信息响应
响应状态

响应状态

状态码 说明
200 OK
401 Unauthorized
403 Forbidden
响应参数

参数名称 参数说明 数据类型
type 请求类型(固定 query_invoice) string
sendToId 接收方用户ID string
data 0 失败;发票基本信息数据 string / object
data:

参数名称 参数说明 数据类型
data 具体数据 array
total 总数量 integer
currentPage 当前页 integer
totalPage 总页数 integer
hasNext 是否有下一页 boolean
data项:

参数名称 参数说明 数据类型
id 发票ID long
countETicketNumbers 电子发票数量 string
sellerIdentificationNumber 销售方统一信用代码 string
sellerName 销售方公司名称 string
buyerIdentificationNumber 购买方统一信用代码 string
buyerName 购买方公司名称 string
invoiceDate 发票日期 整数或字符串
totalAmount 发票总金额 double
totalTax 发票总税额 double
totalPriceAndTax 发票价税合计 double
invoiceSource 发票来源 string
invoiceType 发票类型 string
invoiceStatus 发票状态 string
isInvoicePositive 是否为正数金额发票 string
invoiceRiskLevel 发票风险等级 string
drawer 开票人 string
note 备注 string
vipId 用户ID integer
queryType 查询类型 integer
specificBusinessType 具体业务类型 string
响应示例

{
“type”: “login”,
“sendToId”: “1111”,
“data”: {
“data”: { “data”: [{
“specificBusinessType”: “”,
“id”: 123456789,
“countETicketNumbers”: “98765432109876543210”,
“sellerIdentificationNumber”: “91330106552613092B”,
“sellerName”: “ABC科技有限公司”,
“buyerIdentificationNumber”: “91330211725964321M”,
“buyerName”: “XYZ财务咨询公司”,
“invoiceDate”: 1712643071000,
“totalAmount”: -495.05,
“totalTax”: -4.95,
“totalPriceAndTax”: -500,
“invoiceSource”: “电子发票服务平台”,
“invoiceType”: “数电票(普通发票)”,
“invoiceStatus”: “正常”,
“isInvoicePositive”: “否”,
“invoiceRiskLevel”: “正常”,
“drawer”: “张三”,
“note”: “本发票为咨询费用发票”,
“vipId”: 987654321,
“queryType”: 1
}],
“total”: 1,
“currentPage”: 1,
“totalPage”: 1,
“hasNext”: false
}
文件下载响应
响应状态

响应状态

状态码 说明
200 OK
401 Unauthorized
403 Forbidden
响应参数

参数名称 参数说明 数据类型
type 请求类型(固定 query_invoice) string
sendToId 接收方用户ID string
data 1 成功;失败 文件开具日期 string
响应示例

// 成功
{
“type”: “query_invoice_download_zip”,
“sendToId”: “1111”,
“data”: “1”
}
// 失败
{
“type”: “query_invoice_download_zip”,
“sendToId”: “1111”,
“data”: “2024-04-12 10:10:10”
}
文件下载因为网络等种种原因可能失败,提供了一个接口允许重试

该接口采用 WebSocket 协议

接口:/web/invoice?userId=xxx

请求示例:

{
“type”: “query_invoice_download_zip”,
“data”: “2024-04-12 10:10:10”
}
请求参数:

参数名称 参数说明 是否必须 数据类型
type 请求类型(固定 query_invoice_download_zip) true string
data 上次请求查询发票基本信息下载文件失败返回的事件 true string
响应参数同上:文件下载响应

查询发票商品项信息
该接口采用 http 协议

GET /web/invoice/item/{invoiceBasicInfoId}

请求数据类型 application/x-www-form-urlencoded 响应数据类型 [ “/“ ]

请求参数

参数名称 参数说明 请求类型 是否必须 数据类型 schema
invoiceBasicInfoId path true integer(int64)
响应状态

状态码 说明 schema
200 OK RListInvoiceItemEntity
401 Unauthorized
403 Forbidden
响应参数

参数名称 参数说明 类型 schema
code integer(int32) integer(int32)
msg string
data array InvoiceItemEntity
InvoiceItemEntity:

参数名称 参数说明 类型 schema
id item id integer(int64)
invoiceBasicInfoId 发票基础信息id integer(int64)
taxClassificationCode 税收分类编码 string
specificBusinessType 特定业务类型 string
itemName 货物或应税劳务名称 string
spec 规格型号 string
unit 单位 string
quantity 数量 integer(int64)
unitPrice 单价 number
amount 金额 number
taxRate 税率 string
tax 税额 number
totalPriceAndTax 价税合计 number
响应示例

{
“code”: 0,
“msg”: “”,
“data”: [
{
“id”: 0,
“invoiceBasicInfoId”: 0,
“countETicketNumbers”: “”,
“taxClassificationCode”: “”,
“specificBusinessType”: “”,
“itemName”: “”,
“spec”: “”,
“unit”: “”,
“quantity”: 0,
“unitPrice”: 0,
“amount”: 0,
“taxRate”: “”,
“tax”: 0,
“totalPriceAndTax”: 0
}
]
}
查询发票文件
该接口采用 http 协议

GET /web/invoice/file

请求数据类型 application/x-www-form-urlencoded 响应数据类型 [ “/“ ]

请求参数

参数名称 参数说明 请求类型 是否必须 数据类型
invoiceIdList 发票ID array true string
typeList 文件类型 array false string
请求示例

{
“invoiceIdList”: [
“1778381047770263553”,
“1778381047954812931”
],
“typeList”: [
“ofd”
]
}
响应状态

状态码 说明 schema
200 OK RListInvoiceItemEntity
401 Unauthorized
403 Forbidden
响应参数

参数名称 参数说明 类型 schema
code integer(int32) integer(int32)
msg string
data array InvoiceFileEntity
InvoiceItemEntity:

参数名称 参数说明 类型 schema
id id integer(int64)
invoiceBasicInfoId 发票基础信息id integer(int64)
countETicketNumbers 数电票号码 string
url 发票文件地址 string
type 文件类型(pdf、ofd、xml) string
响应示例

{
“code”: 0,
“msg”: “”,
“data”: [
{
“id”: 0,
“invoiceBasicInfoId”: 0,
“countETicketNumbers”: “”,
“url”: “”,
“type”: “”
}
]
}