票据同步识别与查验

  • url:/common/InvoiceOCR/ocrSyncWithConfig/v2
  • method:post
  • 数据格式:json

说明

  • 该接口使用前请联系产品开通发票识别与查验子账号,然后点击配置
  • 建议先在测试环境配置开通,防止开通子账号导致主系统发票识别查验出现异常
  • 同步进行识别和查验时,单个文件最多支持 5 张票据数据
  • 同步进行识别和查验时,建议超时时间设置在 60s 以上

请求参数

字段名称 字段类型 字段描述 是否必填 长度限制 说明
bizId String 业务唯一识别码 true 36
timestamp Long 当前次接口同步时间对应的时间戳 true 13
data Object 请求业务参数 true NA
data.attachment_url String 文件地址 true NA
data.purchase_invoice String 票据池 true NA
data.create_expense String 是否创建消费记录 false NA 不传默认为 N
data.user_code String 工号 (employee_number) false NA data.create_expense=Y 时必传

返回参数

字段名称 字段类型 字段描述
resCode Integer (200000:成功) 识别查验失败:错误编码
resMsg String 返回信息描述
data Array 识别查验结果列表,一张文件可能识别出多张票据,每张票据对应一条数据
data.bizId String 业务唯一识别码,与请求入参一致
data.timestamp Long 当前次接口同步时间对应的时间戳,与请求入参一致
data.user_code String 工号
data.ocr_result Object 识别返回。结构见下方 data.ocr_result。当前接口会按单张票据拆分,每条 data 中对应一张票据
data.check_result Object 查验返回。结构见下方 data.check_result
data.expense_result Object 创建消费记录返回。仅当 create_expense=Y 时返回

data.ocr_result

字段名称 字段类型 字段描述
ocr_result.invoice_ocr_log_id Long 识别日志表 ID
ocr_result.image_size Array\ 图片分辨率,格式为 [width, height]
ocr_result.page Integer 页码,从 0 开始
ocr_result.page_number String 多页发票页码
ocr_result.receipt_currency String 票据币种
ocr_result.attachment_url String 文件地址
ocr_result.invoice_type String 发票类型
ocr_result.direction Integer 发票顺时针旋转方向
ocr_result.region Array\ 单张发票区域,格式为 [x1, y1, x2, y2]
ocr_result.invoice_code String 发票代码;火车票场景可能为车次
ocr_result.invoice_number String 发票号码
ocr_result.receipt_date String 开票日期,格式 yyyyMMdd
ocr_result.amount BigDecimal 不含税金额
ocr_result.tax_amount BigDecimal 税额
ocr_result.total_amount BigDecimal 价税合计
ocr_result.subtotal_amount BigDecimal 小计
ocr_result.tax_rate BigDecimal 税率
ocr_result.highway_flag String 高速标识
ocr_result.remark String 备注
ocr_result.title String 发票标题
ocr_result.check_code String 校验码
ocr_result.agent_mark String 是否代开
ocr_result.buyer_name String 购买方名称
ocr_result.buyer_tax_code String 购买方纳税人识别号
ocr_result.buyer_bank_account String 购买方银行账号
ocr_result.buyer_addr_tel String 购买方地址、电话
ocr_result.buyer_address String 购买方地址
ocr_result.seller_name String 销售方名称
ocr_result.seller_tax_code String 销售方纳税人识别号
ocr_result.seller_bank_account String 销售方银行账号
ocr_result.seller_addr_tel String 销售方地址、电话
ocr_result.seller_address String 销售方地址
ocr_result.purchase_order String 采购订单
ocr_result.province String
ocr_result.city String
ocr_result.company_seal String 是否有公司印章
ocr_result.date String 票据日期。交通票场景可能为乘车日期
ocr_result.start_time String 开始时间,格式 HH:mm
ocr_result.end_time String 结束时间,格式 HH:mm
ocr_result.start_datetime String 开始日期时间或乘车时间
ocr_result.end_datetime String 结束日期时间
ocr_result.mileage BigDecimal 里程
ocr_result.license_plate String 车牌号
ocr_result.destination_city String 起点
ocr_result.destination_city_to String 终点
ocr_result.location_from String 出发地/取车地点
ocr_result.location_to String 到达地/还车地点
ocr_result.station_from String 出发站点
ocr_result.station_to String 到达站点
ocr_result.train_class String 火车座位类型
ocr_result.train_number String 车次
ocr_result.name String 乘车人姓名
ocr_result.id_card String 乘车人身份证号
ocr_result.passenger_name String 乘客/入住人/用车人
ocr_result.currency String 币种
ocr_result.fare BigDecimal 票价
ocr_result.civil_avn_dev_fund BigDecimal 民航发展基金
ocr_result.fuel_surcharge BigDecimal 燃油附加费
ocr_result.other_taxes BigDecimal 航空客票单其它税费
ocr_result.insurance BigDecimal 航空客票单保险费
ocr_result.red_letter_flag String 红字发票标识
ocr_result.error_num_flag Boolean 发票号码是否存在错误
ocr_result.international_flag String 国内国际航班标志
ocr_result.subject String 科目
ocr_result.buyer_account String 缴款单位/人账号
ocr_result.buyer_bank String 开户银行
ocr_result.flight_detail Array 航班信息
ocr_result.flight_class String 航班座位类型
ocr_result.flight_number String 航班号
ocr_result.purchase_invoice String 票据池
ocr_result.other_info String 其他信息
ocr_result.items Array 票据明细行,结构见下方 data.ocr_result.items
ocr_result.custom_data String 定制数据
ocr_result.country String 国家
ocr_result.consume_scene String 消费场景
ocr_result.shop_location String 商户地址
ocr_result.duration Integer 晚数/天数
ocr_result.mobile_number String 号码/账户
ocr_result.cross_border_flag String 是否跨境

data.ocr_result.items

字段名称 字段类型 字段描述
items.name String 货物或应税劳务、服务名称
items.specification String 规格型号
items.unit String 单位
items.quantity BigDecimal 数量
items.price BigDecimal 单价
items.amount BigDecimal 金额
items.tax_rate Integer 税率
items.tax_amount BigDecimal 税额
items.total_amount BigDecimal 价税合计
items.material_name String 明细名称

data.check_result

字段名称 字段类型 字段描述
check_result.result Integer 查验结果,1 为成功,其他为失败
check_result.invoice_type String 发票类型
check_result.invoice_code String 发票代码
check_result.invoice_num String 发票号码
check_result.receipt_date Long 发票日期,时间戳
check_result.check_code String 校验码
check_result.total_amount BigDecimal 价税合计
check_result.amount BigDecimal 金额
check_result.tax_amount BigDecimal 税额
check_result.remark String 备注
check_result.buyer_name String 购方名称
check_result.buyer_tax_code String 购方税号
check_result.buyer_address_phone String 购方地址、电话
check_result.buyer_account String 购方开户行及账号
check_result.seller_name String 销方名称
check_result.seller_tax_code String 销方税号
check_result.seller_address_phone String 销方地址、电话
check_result.seller_account String 销方开户行及账号
check_result.cancellation_mark String 作废标识
check_result.detail_list Array 查验明细行,结构见下方 data.check_result.detail_list
check_result.receipt_id Integer 票据主键 ID
check_result.log_id Long 识别批次日志 ID
check_result.dkbs String 抵扣标识

data.check_result.detail_list

字段名称 字段类型 字段描述
detail_list.name String 货物名称
detail_list.specification String 规格型号
detail_list.unit String 单位
detail_list.total_amount BigDecimal 价税合计
detail_list.amount BigDecimal 金额
detail_list.tax_amount BigDecimal 税额
detail_list.price BigDecimal 不含税单价
detail_list.quantity BigDecimal 数量
detail_list.tax_rate BigDecimal 税率
detail_list.classification_code String 税收分类编码
detail_list.start_date Long 开始日期,时间戳
detail_list.end_date Long 结束日期,时间戳
detail_list.license_plate String 车牌号
detail_list.car_type String 车辆类型

data.expense_result

字段名称 字段类型 字段描述
expense_result.expense_id Long 此次请求产生的expense id
expense_result.invoice_message String 业务校验产生的错误信息
expense_result.invoice_message_code String 业务校验产生的错误编码
expense_result.invoice_status String 发票识别查验状态
expense_result.val_rule_result String 校验规则结果

请求示例 (当无需创建消费记录时)

{
  "data": {
    "attachment_url": "示例文件地址",
    "purchase_invoice": "N"
  },
  "bizId": "示例业务唯一识别码",
  "timestamp": 1727247523662
}

请求示例 (当需创建消费记录时)

{
  "data": {
    "attachment_url": "示例文件地址",
    "purchase_invoice": "N",
    "create_expense": "Y",
    "user_code": "示例工号"
  },
  "bizId": "示例业务唯一识别码",
  "timestamp": 1727247523662
}

返回示例 (当未配置密钥时)

{
    "resCode": 400000,
    "resMsg": "配置校验失败,请预先配置识别密钥"
}

返回示例 (当需创建消费记录时)

{
  "resCode": 200000,
  "resMsg": "success",
  "data": [
    {
      "bizId": "示例业务唯一识别码",
      "timestamp": 1727247523662,
      "user_code": "示例工号",
      "ocr_result": {
        "invoice_ocr_log_id": 1000000000000000001,
        "image_size": [
          1415,
          2000
        ],
        "page": 0,
        "attachment_url": "示例文件地址",
        "invoice_type": "21",
        "direction": 0,
        "region": [
          0,
          875,
          1415,
          2000
        ],
        "invoice_code": "",
        "amount": 11.68,
        "tax_amount": 1.52,
        "total_amount": 13.20,
        "highway_flag": "N",
        "invoice_number": "示例发票号码",
        "receipt_date": "20251224",
        "remark": "",
        "title": "电子发票(普通发票)",
        "check_code": "",
        "buyer_name": "示例购买方名称",
        "buyer_tax_code": "示例购买方税号",
        "buyer_bank_account": "",
        "buyer_addr_tel": "",
        "seller_name": "示例销售方名称",
        "seller_tax_code": "示例销售方税号",
        "seller_bank_account": "",
        "seller_addr_tel": "",
        "province": "示例省份",
        "city": "",
        "date": "2025年12月24日",
        "company_seal": "N",
        "items": [
          {
            "name": "示例商品名称",
            "specification": "示例规格型号",
            "unit": "件",
            "quantity": 1,
            "price": 12.30,
            "amount": 12.30,
            "tax_rate": 13,
            "tax_amount": 1.60,
            "material_name": "示例商品名称"
          },
          {
            "name": "示例折扣行名称",
            "specification": "",
            "unit": "",
            "quantity": 0,
            "price": 0,
            "amount": -0.62,
            "tax_rate": 13,
            "tax_amount": -0.08,
            "material_name": "示例折扣行名称"
          }
        ]
      },
      "check_result": {
        "result": 1,
        "invoice_type": "21",
        "invoice_code": "",
        "invoice_num": "示例发票号码",
        "receipt_date": 1766534400000,
        "total_amount": 13.2,
        "amount": 11.68,
        "tax_amount": 1.52,
        "remark": "",
        "buyer_name": "示例购买方名称",
        "buyer_tax_code": "示例购买方税号",
        "buyer_address_phone": "",
        "buyer_account": "",
        "seller_name": "示例销售方名称",
        "seller_tax_code": "示例销售方税号",
        "seller_address_phone": "示例销售方地址电话",
        "seller_account": "示例销售方开户行及账号",
        "cancellation_mark": "N",
        "detail_list": [
          {
            "name": "示例商品名称",
            "specification": "示例规格型号",
            "unit": "件",
            "total_amount": 13.9,
            "amount": 12.3,
            "tax_amount": 1.6,
            "price": 12.30,
            "quantity": 1.00,
            "tax_rate": 13,
            "classification_code": "示例税收分类编码"
          },
          {
            "name": "示例折扣行名称",
            "specification": "",
            "unit": "",
            "total_amount": -0.70,
            "amount": -0.62,
            "tax_amount": -0.08,
            "tax_rate": 13,
            "classification_code": "示例税收分类编码"
          }
        ],
        "log_id": 1000000000000000001,
        "dkbs": "N"
      },
      "expense_result": {
        "expense_id": 100000001,
        "invoice_status": "Y"
      }
    },
    {
      "bizId": "示例业务唯一识别码",
      "timestamp": 1727247523662,
      "user_code": "示例工号",
      "ocr_result": {
        "invoice_ocr_log_id": 1000000000000000002,
        "image_size": [
          1415,
          2000
        ],
        "page": 1,
        "attachment_url": "示例文件地址",
        "invoice_type": "21",
        "invoice_number": "示例发票号码",
        "receipt_date": "20251227",
        "amount": 14.98,
        "tax_amount": 1.94,
        "total_amount": 16.92,
        "buyer_name": "示例购买方名称",
        "buyer_tax_code": "示例购买方税号",
        "seller_name": "示例销售方名称",
        "seller_tax_code": "示例销售方税号",
        "items": [
          {
            "name": "示例商品名称",
            "specification": "示例规格型号",
            "unit": "件",
            "quantity": 1,
            "price": 8.76,
            "amount": 8.76,
            "tax_rate": 13,
            "tax_amount": 1.14
          }
        ]
      },
      "check_result": {
        "result": 1,
        "invoice_type": "21",
        "invoice_num": "示例发票号码",
        "receipt_date": 1766793600000,
        "total_amount": 16.92,
        "amount": 14.98,
        "tax_amount": 1.94,
        "cancellation_mark": "N",
        "detail_list": [
          {
            "name": "示例商品名称",
            "specification": "示例规格型号",
            "unit": "件",
            "total_amount": 9.90,
            "amount": 8.76,
            "tax_amount": 1.14,
            "price": 8.76,
            "quantity": 1.00,
            "tax_rate": 13,
            "classification_code": "示例税收分类编码"
          }
        ],
        "log_id": 1000000000000000002,
        "dkbs": "N"
      },
      "expense_result": {
        "expense_id": 100000002,
        "invoice_status": "Y"
      }
    }
  ]
}

results matching ""

    No results matching ""