取消订单
订单确认/取消接口
客户在确定将货物交付给顺丰托运后,将面单上的一些重要信息,如快件重量通过此接口发送给顺丰 (丰桥下订单接口默认自动确认,不需客户重复确认,该操作用在其它非自动确认的场景)。客户在发货前取消订单。 注意:订单取消之后,订单号也是不能重复利用的。
一、请求参数
| 参数名 | 类型 | 说明 | 示例 |
|---|---|---|---|
| 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 | dealType | Number(1) | 否 | 1 | 客户订单操作标识:1:确认 (下订单接口默认自动确认,不需客户重复确认,该操作用在其它非自动确认的场景)2:取消 |
| 3 | waybillNoInfoList | List | 否 | 顺丰运单号(如dealtype=1,必填) | |
| 4 | customsBatchs | String(20) | 否 | 报关批次 | |
| 5 | collectEmpCode | String(30) | 否 | 揽收员工号 | |
| 6 | inProcessWaybillNo | String(100) | 否 | 头程运单号 | |
| 7 | sourceZoneCode | String(10) | 否 | 原寄地网点代码 | |
| 8 | destZoneCode | String(10) | 否 | 目的地网点代码 | |
| 9 | totalWeight | Number(17,5) | 否 | 订单货物总重量,包含子母件,单位千克,精确到小数点后3位,如果提供此值,必须>0 | |
| 10 | totalVolume | Number(16,5) | 否 | 订单货物总体积,单位立方厘米,精确到小数点后3位,会用于计抛(是否计抛具体商务沟通中双方约定) | |
| 11 | expressTypeId | Number(5) | 否 | 快件产品类别,支持附录《快件产品类别表》的产品编码值,仅可使用与顺丰销售约定的快件产品 | |
| 12 | extraInfoList | List | 否 | 扩展属性 | |
| 13 | totalLength | Number(16, 5) | 否 | 客户订单货物总长,单位厘米,精确到小数点后3位,包含子母件 | |
| 14 | totalWidth | Number(16, 5) | 否 | 客户订单货物总宽,单位厘米,精确到小数点后3位,包含子母件 | |
| 15 | totalHeight | Number(16, 5) | 否 | 客户订单货物总高,单位厘米,精确到小数点后3位,包含子母件 | |
| 16 | serviceList | List | 否 | 增值服务信息 |
一(二)、元素 OrderUpdate/waybillNoInfoList
| # | 属性名 | 类型(约束) | 必填 | 默认值 | 描述 |
|---|---|---|---|---|---|
| 1 | waybillType | Number(1) | 否 | 运单号类型1:母单 2 :子单 3 : 签回单 | |
| 2 | waybillNo | String(15) | 否 | 运单号 |
一(三)、元素 OrderUpdate/waybillNoInfoList
| # | 属性名 | 类型(约束) | 必填 | 默认值 | 描述 |
|---|---|---|---|---|---|
| 1 | attrName | String(256) | 否 | 扩展字段 说明:attrName为字段定义,具体如下表,value存在attrVal | |
| 2 | attrVal | String(1024) | 否 | 扩展字段值 |
扩展字段备注
| attrName | attrVal |
|---|---|
| attr001 | |
| attr002 |
一(四)、元素 OrderUpdate/serviceList
| # | 属性名 | 类型(约束) | 必填 | 默认值 | 描述 |
|---|---|---|---|---|---|
| 1 | name | String(20) | 是 | 增值服务名,如COD等 | |
| 2 | value | String(30) | 条件 | 增值服务扩展属性,参考增值服务传值说明 | |
| 3 | value1 | String(30) | 条件 | 增值服务扩展属性1 | |
| 4 | value2 | String(30) | 条件 | 增值服务扩展属性2 | |
| 5 | value3 | String(30) | 条件 | 增值服务扩展属性3 | |
| 6 | value4 | String(30) | 条件 | 增值服务扩展属性4 |
二、请求示例代码
Java
/** * 订单确认/取消接口 * @throws Exception */ @Test public void updateOrder() throws Exception {
String result ="";
// dealType:2表示取消 String jsonData = "{" + " \"dealType\": 2," + " \"orderId\": \"QIAO-20200618-200\"" + "}";
CloseableHttpClient httpclient = HttpClients.createDefault(); HttpPost httpPost = new HttpPost( Config.SFExpressUpdateOrderUrl );
//业务参数 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": "00017A89782FF53FE03591EC62C18A3F", "apiResultCode": "A1000", "apiResultData": "{\"success\":true,\"errorCode\":\"S0000\",\"errorMsg\":null,\"msgData\":{\"orderId\":\"QIAO-20200618-200\",\"waybillNoInfoList\":[{\"waybillType\":1,\"waybillNo\":\"SF1303262056675\"}],\"resStatus\":2,\"extraInfoList\":null,\"originCode\":null,\"destCode\":null,\"filterResult\":null,\"remark\":null,\"routeLabelInfo\":null,\"sendStartTm\":null}}" }, "trace_id": "6WNQp8Mq9L6hGuJeQgIy" }说明: code为0表示成功,非0为失败,message会包含失败原因。
四、返回参数msgData说明
| # | 属性名 | 类型(约束) | 必填 | 默认值 | 描述 |
|---|---|---|---|---|---|
| 1 | orderId | String(64) | 是 | 客户订单号 | |
| 2 | waybillNoInfoList | List | 否 | 顺丰运单号 | |
| 3 | resStatus | Number(1) | 是 | 备注1:客户订单号与顺丰运单不匹配2 :操作成功 | |
| 4 | extraInfoList | List | 否 | 扩展属性 |
四(一)、返回参数waybillNoInfoList的说明
waybillType :运单号类型 , 1:母单 2 :子单 3 : 签回单