子订单申请
子单号申请接口
客户在下单成功后 ,因业务场景需要可以调用此接口获取更多的子单号数。但不能超过配置的最大数/1200个。
一、请求参数
POST https://kf.fw199.com/gateway/sfexpress/order/getsubmailno
| 参数名 | 类型 | 说明 | 示例 |
|---|---|---|---|
| appid | String | 合作伙伴AppId | uwkahf@jfs92 |
| timestamp | String | 当前时间戳 | |
| request_data | String | json格式的业务参数 | 见下表1.1 |
| client_code | String | 顺丰的客户编码 | |
| check_word | String | 顺丰的校验码 | |
| sign | String | 接口签名 | 如何计算生成见示例代码 |
一(一)、参数request_data 的说明
| # | 属性名 | 类型(约束) | 必填 | 默认值 | 描述 |
|---|---|---|---|---|---|
| 1 | orderId | String(64) | 是 | 客户订单号 | |
| 2 | parcelQty | Integer | 是 | 子单号数 |
二、请求示例代码
Java
/** * 子单号申请接口 * @throws Exception */ @Test public void getSubMailNo() throws Exception {
String result =""; // dealType:2表示取消 String jsonData = "{" + " \"orderId\": \"QIAO-20200618-108\"," + " \"parcelQty\": 3" + "}"; CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost( Config.SFExpressGetSubMailNosUrl ); //业务参数 Map<String, String> data = new HashMap<String, String>(); data.put("appid", Config.AppId); data.put("request_data", jsonData); data.put("client_code", Config.SFClientCode); data.put("check_word", Config.SFCheckWord); Long timestamp = System.currentTimeMillis() / 1000; data.put("timestamp", timestamp.toString());
// 参数签名 data.put("sign", Utils.Sign(data,Config.AppSecret)); List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(); for (Map.Entry<String, String> entry : data.entrySet()) { params.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } //发起POST请求 try { httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); HttpResponse httpResponse = httpclient.execute(httpPost); if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { result = EntityUtils.toString(httpResponse.getEntity()); } else { result = ("doPost Error Response: " + httpResponse.getStatusLine().toString()); } } catch (Exception e) { e.printStackTrace();
}
System.out.println(result);
}三、返回结果
{ "code": 0, "message": "ok", "data": { "apiErrorMsg": "", "apiResponseID": "00017A8A28A8E03FD93F21C183CB463F", "apiResultCode": "A1000", "apiResultData": "{\"success\":true,\"errorCode\":\"S0000\",\"errorMsg\":null,\"msgData\":{\"orderId\":\"QIAO-20200618-201\",\"waybillNoInfoList\":[{\"waybillType\":2,\"waybillNo\":\"SF2040562934581\"},{\"waybillType\":2,\"waybillNo\":\"SF2040562934590\"},{\"waybillType\":2,\"waybillNo\":\"SF2040562934606\"},{\"waybillType\":1,\"waybillNo\":\"SF1328425290964\"}]}}" }, "trace_id": "bovpGGuNRZ4EhffgBFTc"}说明: code为0表示成功,非0为失败,message会包含失败原因。
四、元素 apiResultData
| # | 属性名 | 类型(约束) | 必填 | 默认值 | 描述 |
|---|---|---|---|---|---|
| 1 | success | boolean | 是 | 返回状态 true/false | |
| 2 | errorCode | Integer | 条件 | 错误代码 | |
| 3 | errorMsg | String | 条件 | 错误详细信息 | |
| 4 | msgData | Object | 条件 | 如果success为true,这个字段代表筛单结果;Success为false时,此字段为空 |
四(一)、返回参数msgData说明
| # | 属性名 | 类型(约束) | 必填 | 默认值 | 描述 |
|---|---|---|---|---|---|
| 1 | orderId | String(64) | 是 | 客户订单号 | |
| 2 | parcelQty | Integer | 否 | 子单号数 | |
| 3 | waybillNoInfoList | List | 是 | 运单号 |
四(二)、返回参数waybillNoInfoList的说明
waybillType :运单号类型 , 1:母单 2 :子单 3 : 签回单