发票归集(包年)
<p>[TOC]</p>
<h3>使用流程</h3>
<h4>第一步 -- 登录税局</h4>
<p>归集之前,需要先调用登录接口去登录税局
详见:[登录相关接口](<a href="https://www.showdoc.com.cn/p/0fb3859cda04befe7b8d85a15cfa3335">https://www.showdoc.com.cn/p/0fb3859cda04befe7b8d85a15cfa3335</a> "登录相关接口")</p>
<h4>第二步 -- 发起归集任务</h4>
<p>发票归集采用异步的方式,先发起归集任务
发起归集任务后,会返回taskNo,用于查询归集结果</p>
<h4>第三步 -- 查询归集结果</h4>
<p>发起归集任务,用发起归集任务接口返回的taskNo去调用查询归集结果接口,即可查询归集结果</p>
<hr />
<h3>接口调用说明</h3>
<h4>请求方式</h4>
<p>如接口没有单独说明,所有接口均为:<strong>POST</strong></p>
<h4>请求格式</h4>
<p>如接口没有单独说明,所有接口均为:<strong>application/x-www-form-urlencoded</strong></p>
<h4>请求参数</h4>
<p>请求参数包括公共参数和业务参数(业务参数见具体接口说明)
调用接口时,需要把<strong>公共参数</strong>和<strong>业务参数</strong>一并放在<strong>请求参数</strong>中提交</p>
<h5>公共请求参数</h5>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>appId</td>
<td>String</td>
<td>是</td>
<td>服务商分配的唯一标识</td>
</tr>
<tr>
<td>timestamp</td>
<td>Long</td>
<td>是</td>
<td>当前时间戳(毫秒)</td>
</tr>
<tr>
<td>sign</td>
<td>String</td>
<td>是</td>
<td>签名,详见<a href="#签名算法">签名算法说明</a></td>
</tr>
</tbody>
</table>
<p><a name="签名算法"></a></p>
<h5>签名算法说明</h5>
<pre><code>sign = sha256(appId + appSecret + timestamp)</code></pre>
<p>用服务商分配的 <strong>appId</strong>、服务商分配的 <strong>appSecret</strong>,当前时间戳(毫秒) <strong>timestamp</strong>,按上述顺序拼接成字符串,再进行 <strong>sha256</strong> 哈希得到。如下:</p>
<pre><code class="language-java">String appId = &quot;xyzxy2121zxyz&quot;;
String timestamp = &quot;1555378976238&quot;;
String appSecret = &quot;efcefcef1121cefcefc1212121&quot;;
String str = appId + appSecret + timestamp;
String sign = sha256(str);</code></pre>
<h4>返回说明</h4>
<h5>公共返回字段说明</h5>
<p>所有接口均返回以下公共字段:</p>
<table>
<thead>
<tr>
<th>字段名</th>
<th><div style="width:420px">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>code</td>
<td>返回码,详见:code返回码说明</td>
</tr>
<tr>
<td>msg</td>
<td>code对应的描述</td>
</tr>
<tr>
<td>taskNo</td>
<td>本次请求号</td>
</tr>
<tr>
<td>data</td>
<td>返回具体结果,object类型,详见data返回字段描述</td>
</tr>
</tbody>
</table>
<p><a name="公共code返回码说明"></a></p>
<h5>公共code返回码说明</h5>
<p>所有接口公共返回码如下:</p>
<table>
<thead>
<tr>
<th>code</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>200</td>
<td>成功</td>
</tr>
<tr>
<td>400</td>
<td>参数错误</td>
</tr>
<tr>
<td>404</td>
<td>接口地址不正确</td>
</tr>
<tr>
<td>500</td>
<td>系统维护,请稍候再试</td>
</tr>
<tr>
<td>601</td>
<td>接口未开通</td>
</tr>
<tr>
<td>602</td>
<td>账号停用</td>
</tr>
<tr>
<td>604</td>
<td>接口停用</td>
</tr>
<tr>
<td>606</td>
<td>调用超限,请稍候再试</td>
</tr>
<tr>
<td>607</td>
<td>ip不在白名单</td>
</tr>
<tr>
<td>609</td>
<td>请求过于频繁,请稍候再试</td>
</tr>
<tr>
<td>610</td>
<td>请求超时</td>
</tr>
<tr>
<td>999</td>
<td>其他,以实际返回为准</td>
</tr>
</tbody>
</table>
<hr />
<h3>发起归集任务接口</h3>
<h4>接口描述</h4>
<ul>
<li>用于发起归集任务</li>
</ul>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/invoice/collect/year/request</code></p>
<h4>业务参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>nsrsbh</td>
<td>String</td>
<td>是</td>
<td>纳税人识别号</td>
</tr>
<tr>
<td>dateType</td>
<td>String</td>
<td>否</td>
<td>日期类型,0-按月(时间跨度不超过一年), 1-按天(时间跨度不超过一个月), 默认:0</td>
</tr>
<tr>
<td>kpsjq</td>
<td>String</td>
<td>是</td>
<td>开票时间起,按月格式:yyyyMM,按日期格式:yyyyMMdd</td>
</tr>
<tr>
<td>kpsjz</td>
<td>String</td>
<td>是</td>
<td>开票时间止,按月格式:yyyyMM,按日期格式:yyyyMMdd</td>
</tr>
<tr>
<td>fplx</td>
<td>String</td>
<td>否</td>
<td>发票类型, 多个以英文","分割,详见:<a href="https://www.showdoc.com.cn/p/b8ef364b0b7b0825676bdc31f104134b#发票类型说明">发票类型说明</a></td>
</tr>
<tr>
<td>jxxbz</td>
<td>String</td>
<td>否</td>
<td>进销项标志,jx-进项,xx-销项。为空表示全部</td>
</tr>
</tbody>
</table>
<h4>成功返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 200,
&quot;msg&quot;: &quot;成功&quot;,
&quot;taskNo&quot;: &quot;526782409178028989145499&quot;
}</code></pre>
<h4>未登录或登录失效返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 301,
&quot;msg&quot;: &quot;未登录或登录失效,请先调用登录接口&quot;
}</code></pre>
<h4>失败返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 400,
&quot;msg&quot;: &quot;纳税人识别号不能为空&quot;
}</code></pre>
<h4>code返回码说明</h4>
<p>公共返回码请参阅:<a href="#公共code返回码说明">公共code返回码说明</a></p>
<table>
<thead>
<tr>
<th>code</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>301</td>
<td>未登录或登录失效,请先调用登录接口</td>
</tr>
<tr>
<td>302</td>
<td>相同时间的发票正在归集中,无需再次发起</td>
</tr>
</tbody>
</table>
<hr />
<h3>查询归集结果接口</h3>
<h4>接口描述</h4>
<ul>
<li>用于发起归集任务之后查询归结结果</li>
</ul>
<h4>请求地址</h4>
<p><code>https://api.jumdata.com/invoice/collect/result</code></p>
<h4>业务参数</h4>
<table>
<thead>
<tr>
<th>名称</th>
<th>类型</th>
<th>必须</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>nsrsbh</td>
<td>String</td>
<td>是</td>
<td>纳税人识别号</td>
</tr>
<tr>
<td>requestTaskNo</td>
<td>String</td>
<td>是</td>
<td>发起归集任务接口返回的taskNo</td>
</tr>
</tbody>
</table>
<h4>成功返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 200,
&quot;msg&quot;: &quot;成功&quot;,
&quot;taskNo&quot;: &quot;043439882226367117195632&quot;,
&quot;data&quot;: {
&quot;requestTaskNo&quot;: &quot;952389968135471173207309&quot;,
&quot;nsrsbh&quot;: &quot;91330110MA2CC1X505&quot;,
&quot;kpsjq&quot;: &quot;202211&quot;, // 开票时间起
&quot;kpsjz&quot;: &quot;202211&quot;, // 开票时间止
&quot;resultUrl&quot;: &quot;&quot;, // 开票记录下载地址
&quot;result&quot;: [ // 开票记录
{
&quot;fpdm&quot;: &quot;3300224130&quot;, // 发票代码
&quot;fphm&quot;: &quot;19134628&quot;, // 发票号码
&quot;gfsbh&quot;: &quot;&quot;, // 购买方税号
&quot;xfsbh&quot;: &quot;91330110MA2CC1X505&quot;, // 销售方税号
&quot;gfmc&quot;: &quot;杭州****科技有限公司&quot;, // 购买方
&quot;xfmc&quot;: &quot;杭州安那其科技有限公司&quot;, // 销售方
&quot;fplx&quot;: &quot;01&quot;, // 发票类型
&quot;jxxbz&quot;: &quot;xx&quot;, // 进销项标志
&quot;kpr&quot;: &quot;张三&quot;, // 开票人
&quot;se&quot;: 558.66, // 税额
&quot;kprq&quot;: &quot;2022-11-30 00:00:00&quot;, // 开票日期
&quot;bz&quot;: &quot;&quot;, //
&quot;jshj&quot;: 9868, // 价税合计
&quot;je&quot;: 9309.34, // 不含税金额
&quot;fpztDm&quot;: &quot;0&quot;, //
&quot;hwxx&quot;: [ // 内容
{
&quot;ggxh&quot;: &quot;&quot;,
&quot;se&quot;: 558.66,
&quot;fpdm&quot;: &quot;3300224130&quot;,
&quot;jldw&quot;: &quot;&quot;,
&quot;dj&quot;: &quot;93094.339622641509434&quot;,
&quot;mc&quot;: &quot;*研发和技术服务*服务费&quot;,
&quot;mxxh&quot;: &quot;1&quot;,
&quot;sl&quot;: &quot;1&quot;,
&quot;je&quot;: 9309.34,
&quot;slv&quot;: 0.06,
&quot;spbm&quot;: &quot;3040101000000000000&quot;,
&quot;fphm&quot;: &quot;19134628&quot;
}
]
},
...
]
}
}</code></pre>
<h4>归集中返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 301,
&quot;msg&quot;: &quot;正在归集,请稍后再试&quot;,
&quot;taskNo&quot;: &quot;043439882226367117195632&quot;
}</code></pre>
<h4>归集失败返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 302,
&quot;msg&quot;: &quot;归集失败,请重新发起归集任务&quot;,
&quot;taskNo&quot;: &quot;043439882226367117195632&quot;
}</code></pre>
<h4>接口调用失败返回样例</h4>
<pre><code class="language-json">{
&quot;code&quot;: 400,
&quot;msg&quot;: &quot;纳税人识别号不能为空&quot;
}</code></pre>
<h4>code返回码说明</h4>
<p>公共返回码请参阅:<a href="#公共code返回码说明">公共code返回码说明</a></p>
<table>
<thead>
<tr>
<th>code</th>
<th><div style="width:420px;">说明</div></th>
</tr>
</thead>
<tbody>
<tr>
<td>201</td>
<td>不存在taskNo为[xxx]的归集任务</td>
</tr>
<tr>
<td>301</td>
<td>正在归集,请稍后再试</td>
</tr>
<tr>
<td>302</td>
<td>归集失败,请重新发起归集任务</td>
</tr>
</tbody>
</table>
<hr />