跳转到内容
返回官网

子订单申请

子单号申请接口

客户在下单成功后 ,因业务场景需要可以调用此接口获取更多的子单号数。但不能超过配置的最大数/1200个。

一、请求参数

POST https://kf.fw199.com/gateway/sfexpress/order/getsubmailno

参数名类型说明示例
appidString合作伙伴AppIduwkahf@jfs92
timestampString当前时间戳
request_dataStringjson格式的业务参数见下表1.1
client_codeString顺丰的客户编码
check_wordString顺丰的校验码
signString接口签名如何计算生成见示例代码

一(一)、参数request_data 的说明

#属性名类型(约束)必填默认值描述
1orderIdString(64)客户订单号
2parcelQtyInteger子单号数

二、请求示例代码

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

#属性名类型(约束)必填默认值描述
1successboolean返回状态 true/false
2errorCodeInteger条件错误代码
3errorMsgString条件错误详细信息
4msgDataObject条件如果success为true,这个字段代表筛单结果;Success为false时,此字段为空

四(一)、返回参数msgData说明

#属性名类型(约束)必填默认值描述
1orderIdString(64)客户订单号
2parcelQtyInteger子单号数
3waybillNoInfoListList运单号

四(二)、返回参数waybillNoInfoList的说明

waybillType :运单号类型 , 1:母单 2 :子单 3 : 签回单