根据业务条件查询当前企业的销项发票
POST
/m7/bill/invoice/items/query返回格式
返回数据中的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;
public class InvoiceItemsQueryDemo {
//测试环境: 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 = "/m7/bill/invoice/items/query?access_token={access_token}";
private static final String CONTENT_TYPE = "application/json";
private static final CloseableHttpClient httpClient = HttpClients.createDefault();
public static void main(String[] args) throws Exception {
String client_id = "client_id";
String secret = "secret";
long currentTimeMillis = System.currentTimeMillis();
String sign = client_id + 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");
queryCondition.put("taxNo","1");
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.encrypt1(queryCondition.toJSONString());
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
结束日期(必填)
invoiceType
string
可选
发票类型:1.普通电子发票2.电子发票专票3.普通纸质发票4.专用纸质发票5.普通纸质卷票7.通用机打8.的士票9.火车票10.飞机票11.其他12.机动车.13.二手车14.定额发票15.通行费16.客运发票17.过路过桥费18.车船税发票(专票)19.完税证明 20.轮船票
taxNo
string
销方税号(必须)
orderNo
string
订单号
示例
{
"pageNo": 0,
"pageSize": 0,
"startTime": "string",
"endTime": "string",
"invoiceType": "string",
"taxNo": "string",
"orderNo": "string"
}
示例代码
返回响应
标准响应格式(200)
HTTP 状态码: 200
内容格式: JSONapplication/json
数据结构
object {0}
示例
{
"errcode":"0000",
"description":"success",
"totalElement": 1,
"totalPage": 1,
"currentPage": 1,
"pageSize": 10,
"data": [{ //发票明细信息
}]
}
最后修改时间: 4 个月前