根据业务条件查询当前企业采集的发票
POST
/m6/bill/invoice/query/v2返回格式
返回数据中的data数组中每个对象格式,需结合文档做处理:发票数据规范
请求示例
package com.kingdee.apitest;
import com.alibaba.fastjson.JSONObject;
import com.kingdee.apitest.AES.AES128;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.util.StringUtils;
import static com.kingdee.apitest.ThirdPartyDemo.getAccessToken;
public class InvoiceQueryV2Demo {
//测试环境: https://api-dev.piaozone.com/test
//正式环境: https://api.piaozone.com
private static final String HOST = "https://api-dev.piaozone.com/test";
private static final String API_PATH = "/m6/bill/invoice/query/v2?access_token={access_token}";
private static final String CONTENT_TYPE = "application/json";
private static final CloseableHttpClient httpClient = HttpClients.createDefault();
private static final String client_id = "client_id";
private static final String client_secret = "client_secret";
private static final String encrypt_key = "encrypt_key";
public static void main(String[] args) throws Exception {
long currentTimeMillis = System.currentTimeMillis();
String sign = client_id + client_secret + currentTimeMillis;
String md5Hex = DigestUtils.md5Hex(sign);
//获取access_token
String accessToken = AccessTokenDemo.getAccessToken(client_id, md5Hex, currentTimeMillis);
if(StringUtils.hasLength(accessToken)){
//调用企业采集发票查询接口,自行组装查询条件,开始日期,结束日期为必需
JSONObject queryCondition = new JSONObject();
queryCondition.put("startTime","2020-01-01");
queryCondition.put("endTime","2021-05-01");
JSONObject checkResult = queryInvoiceV2Page(accessToken, queryCondition);
System.out.println(checkResult);
}
}
/**
* 查询发票接口
* @param accessToken
* @param queryCondition 查询条件
* @return
*/
private static JSONObject queryInvoiceV2Page(String accessToken, JSONObject queryCondition) throws Exception {
String query_path = API_PATH.replace("{access_token}", accessToken);
HttpPost httpPost = new HttpPost(HOST + query_path);
httpPost.setHeader("Content-Type", CONTENT_TYPE);
//将请求的JSON数据用AES128加密,加密方法请下载对应接口文档中的JAVA方式
String paramsStr = AES128.encrypt(queryCondition.toJSONString(), encrypt_key);
StringEntity stringEntity = new StringEntity(paramsStr);
httpPost.setEntity(stringEntity);
CloseableHttpResponse httpResponse = httpClient.execute(httpPost);
HttpEntity httpEntity = httpResponse.getEntity();
String result = EntityUtils.toString(httpEntity);
return JSONObject.parseObject(result);
}
}
请求参数
Query 参数
access_token
string
必需
访问token,获取方式请查阅《对接约定》
reqid
string
可选
当前13位毫秒级时间戳加3位随机数字(总共16位)
示例值:
1624601109096123
Body 参数application/json
pageNo
integer
页码
pageSize
integer
可选
一页展示的条数-最大50
startTime
string
开票开始日期
endTime
string
开票结束日期
invoiceTypes
#/definitions/107770817可选
authenticateFlags
string
可选
认证标志:0未任何认证及勾选,1勾选,2勾选认证,3扫描认证
salerTaxNo
string
销方税号
buyerTaxNo
string
购方税号
invoiceStatus
string
可选
发票状态:0:正常、1:失控、2:作废、3:红冲、4:异常
示例
未设置
示例代码
返回响应
标准响应格式(200)
HTTP 状态码: 200
内容格式: JSONapplication/json
数据结构
object {0}
示例
{
"errcode":"0000",
"description":"success",
"totalElement": 1,
"totalPage": 1,
"currentPage": 1,
"pageSize": 10,
"data": [{ //发票明细信息
}]
}
最后修改时间: 4 个月前