04. 圆通快递
1. 物流轨迹查询接口
【接口描述】
根据圆通物流运单号查询已有的快件物流信息,在物流信息里面会包含物流状态,如 【客户 **** 已签收】,物流信息保持与官网一致。
【传输方式】
本文档内描述的接口均采用 HTTPS 传输协议。客户方采用 POST 方式发送至本接口。
【报文结构】
| 参数名称 | 说明 |
|---|---|
| sign | 签名 |
| timestamp | 时间戳 |
| param | 传递的参数 |
| format | param 格式 (JSON/XML) |
【请求参数列表】
| 字段名 | 含义 | 类型 | 是否必填(Y:是,N:否) |
|---|---|---|---|
| Number | 圆通物流运单号,一次只能查询一个单号。 | String | Y |
【返回参数列表 (JSON 格式返回字段首字母小写)】
| 字段名 | 含义 | 类型 | 是否必填(Y:是,N:否) |
|---|---|---|---|
| waybill_No | 运单号 | String | Y |
| upload_Time | 走件产生时间 yyyy-MM-dd HH:mm:ss | String | Y |
| infoContent | 物流状态,固定为:GOT 已揽收;ARRIVAL 已收入;DEPARTURE 已发出;SENT_SCAN 派件;INBOUND 自提柜入柜;SIGNED 签收成功;FAILED 签收失败;FORWARDING 转寄;TMS_RETURN 退回; AIRSEND 航空发货;AIRPICK 航空提货 | String | Y |
| processInfo | 物流信息 | String | Y |
| city | 当前操作城市 | String | N |
| district | 当前操作区或者县 | String | N |
| weight | 重量,单位:kg | Number | N |
【签名规则】
- 加密步骤 生成签名规则的具体步骤如下:
| 序号 | 步骤 |
|---|---|
| 1 | 在 POST 时用 "sign" 字段进行签名验证。 |
| 2 | 将 param+method(方法)+v(版本) 拼接得到 data,将 data 和 客户密钥 拼接。(通过 控制台——接口管理,添加自己所需接口,即可得到相应的测试地址、客户编码、客户密钥、方法和版本) |
| 3 | 假设 data 内容为: opentest, partnerId(客户密钥)为 123456。 则要签名的内容为 opentest123456,然后对 opentest123456 先进行 MD5 加密,然后转换为 base64 字符串。 即经过 md5(16 位 byte) 和 base64 后的内容就为 YLstCNa3x8ijQx16e/jqOA== |
【签名示例】
/**
* 开放平台公共加密方法-使用commons-codec-1.11.jar进行md5加密,然后对数组进行base64编码
* @param data = param+method+v
* @param secret
* @return
*/
public static String encryptSignForOpen(String data, String secret) {
String sign;
try {
byte[] signByte = DigestUtils.md5(data + secret);
sign = Base64.encodeBase64String(signByte);
} catch (Throwable e) {
log.error("加密失败.e:{}.", e.toString());
sign = "ERROR";
}
return sign;
}【请求格式 -json】
{
"timestamp": "1619515421751",
"param": "{\"NUMBER\":\"YT2600216627986\"}",
"sign": "rkXHJf8AZbhbZq4yEkQcsQ==",
"format": "JSON"
}【成功返回格式 -json】
[
{
"waybill_No": "YT2000000000000",
"upload_Time": "2023-04-24 20:37:33",
"infoContent": "GOT",
"processInfo": "您的快件被【浙江省金华市义乌市上溪镇】揽收,揽收人: xxx (xxxxxxxxx)",
"city": "金华市",
"district": "义乌市",
"weight": 0.68
},
{
"waybill_No": "YT2000000000000",
"upload_Time": "2023-04-24 23:12:15",
"infoContent": "DEPARTURE",
"processInfo": "您的快件离开【浙江省金华市义乌市上溪镇】,准备发往【义乌转运中心直营公司】",
"city": "金华市",
"district": "义乌市"
},
{
"waybill_No": "YT2000000000000",
"upload_Time": "2023-04-25 01:45:03",
"infoContent": "ARRIVAL",
"processInfo": "您的快件已经到达【义乌转运中心直营公司】",
"city": "金华市",
"district": "义乌市"
},
{
"waybill_No": "YT2000000000000",
"upload_Time": "2023-04-25 02:35:03",
"infoContent": "DEPARTURE",
"processInfo": "您的快件离开【义乌转运中心直营】",
"city": "金华市",
"district": "义乌市"
},
{
"waybill_No": "YT2000000000000",
"upload_Time": "2023-04-25 09:14:38",
"infoContent": "ARRIVAL",
"processInfo": "您的快件已经到达【上虞转运中心公司】",
"city": "绍兴市",
"district": "上虞区"
},
{
"waybill_No": "YT2000000000000",
"upload_Time": "2023-04-25 09:49:16",
"infoContent": "DEPARTURE",
"processInfo": "您的快件离开【上虞转运中心】,准备发往【浙江省绍兴市上虞市公司】",
"city": "绍兴市",
"district": "上虞区"
},
{
"waybill_No": "YT2000000000000",
"upload_Time": "2023-04-25 09:50:56",
"infoContent": "ARRIVAL",
"processInfo": "您的快件已经到达【浙江省绍兴市上虞市公司】",
"city": "绍兴市",
"district": "上虞区"
},
{
"waybill_No": "YT2000000000000",
"upload_Time": "2023-04-25 13:50:14",
"infoContent": "SENT_SCAN",
"processInfo": "【浙江省绍兴市上虞市】的顾金毅(xxxxxxxx)正在派件,圆通已开启“安全呼叫”保护您的电话隐私,请放心接听![95161和185211号段的上海号码为圆通业务员专属号码]",
"city": "绍兴市",
"district": "上虞区"
},
{
"waybill_No": "YT2000000000000",
"upload_Time": "2023-04-25 15:09:52",
"infoContent": "SIGNED",
"processInfo": "您的快件已签收,签收人: xxx。如有疑问请联系: xxxxxxxx,投诉电话: 0575-89288222。感谢使用圆通速递,期待再次为您服务!举手之劳勿忘送件人,请在[评价快递员]处赐予我们五星好评~",
"city": "绍兴市",
"district": "上虞区"
}
]【查询为空返回格式 -json】
{
"map": {
"YT2600205450611": []
},
"code": "1001",
"success": "true",
"message": "查询结果为空。"
}Bitmap Created with Sketch. 数据中心 Created with Sketch. 错误 Created with Sketch. Group Created with Sketch. Group 2 Created with Sketch. Group 4 Created with Sketch. Rectangle 2 Created with Sketch. top Created with Sketch. logo Created with Sketch. 圆通客户管家 菜单缩小首页 Created with Sketch. 圆通 客户管家 top Created with Sketch. img_no.api Created with Sketch. Rectangle 2 Created with Sketch. 账单结算 Created with Sketch. password copy Created with Sketch. Group 22 Created with Sketch. Rectangle 2 Created with Sketch. 正确 Created with Sketch. Shape Created with Sketch. Group 4 Created with Sketch. Group Created with Sketch.
2. 物流轨迹推送服务
【接口描述】
本接口是客户开发,用来接收圆通推送的订单状态。
【传输方式】
圆通通过客户提供的url地址实时推送物流状态, 仅支持form表单的提交方式 。具体可在开放平台联调界面测试。
【报文结构】
| 参数名称 | 说明 |
|---|---|
| logistics_interface | 消息内容 |
| data_digest | 消息签名 |
| clientId | 客户编码(电商标识) |
| type | 订单类型(online:在线下单,offline:线下下单) |
【请求参数列表】
| 字段名 | 含义 | 类型 | 长度 | 是否必填(Y:是,N:否) |
|---|---|---|---|---|
| logisticProviderID | 物流公司ID(YTO) | String | 64 | Y |
| clientID | vip客户标识(客户编号) | String | 64 | Y |
| mailNo | 运单号 | String | 64 | N |
| txLogisticID | 物流号 | String | 64 | Y |
| infoType | 通知类型STATUS:物流状态 | String | 64 | Y |
| infoContent | 操作,固定为:ACCEPT 接单;ORDER_BOOKING 修改预约取件时间;GOT 已揽收;NOT_SEND 揽收失败;ARRIVAL 已收入;DEPARTURE 已发出;SENT_SCAN 派件;INBOUND 自提柜入柜;SIGNED 签收成功;FAILED 签收失败;TMS_RETURN 退回;FORWARDING 转寄;AIRSEND 航空发货;AIRPICK 航空提货 | String | 64 | Y |
| acceptTime | 事件发生时间 | timestamp | Y | |
| remark | 备注或失败原因(值为中文原因或备注) | String | 256 | N |
| weight | 揽收重量 | Double | N | |
| orgName | 网点名称 | String | 64 | N |
| orgCode | 网点编号 | String | 64 | N |
| orgPhone | 网点客服电话 | String | 128 | N |
| empName | 业务员名称 | String | 64 | N |
| empCode | 业务员编号 | String | 64 | N |
| city | 当前操作城市 | String | 64 | N |
| district | 当前操作区或者县 | String | 64 | N |
| signedName | 签收人 | String | 64 | N |
| deliveryName | 该状态操作人员,签收、派送、揽件 | String | 64 | N |
| contactInfo | 联系方式(包括手机,电话等) | String | 256 | N |
| questionCause | 异常原因 | String | 128 | N |
| bookingStartTime | 新的预约取件开始时间 | timestamp | N | |
| bookingEndTime | 新的预约取件结束时间 | timestamp | N | |
| extendFields | 扩展字段 | String | 256 | N |
【返回参数列表】
| 字段名 | 含义 | 类型 | 是否必填(Y:是,N:否) |
|---|---|---|---|
| logisticProviderID | 物流公司ID | String | Y |
| txLogisticID | 物流号 | String | Y |
| success | 成功失败标识 true-成功;false-失败 | boolean | Y |
| reason | 失败原因 | String | N |
【签名规则】
- 加密步骤
生成签名规则的具体步骤如下:
| 序号 | 步骤 |
|---|---|
| 1 | 在POST时用“data_digest”字段进行签名验证。 |
| 2 | 在POST时用“logistics_interface”字段表示要发送的XML报文。 |
| 3 | 假设xml内容为: , partnerId(客户密钥)为123456,则要签名的内容为123456,然后对123456先进行MD5加密,再转换为base64字符串。即经过md5(16位byte)和base64后的内容就为LghTkEmsD2tbQ3fsIBRcBg== 。 |
| 4 | 最终要发送的数据为:logistics_interface=&data_digest=LghTkEmsD2tbQ3fsIBRcBg==&type=online&clientId=ECNAME |
【签名示例】
/**
* 开放平台公共加密方法-使用commons-codec-1.11.jar进行md5加密,然后对数组进行base64编码
* @param data 要发送的XML报文
* @param secret 客户密钥
* @return data_digest
*/
public static String encryptSignForOpen(String data, String secret) {
String sign;
try {
byte[] signByte = DigestUtils.md5(data + secret);
sign = Base64.encodeBase64String(signByte);
} catch (Throwable e) {
log.error("加密失败.e:{}.", e.toString());
sign = "ERROR";
}
return sign;
}【请求格式举例-logistics_interface字段内容】
- 接单(针对需要上门揽收服务的订单)
<UpdateInfo>
<logisticProviderID>YTO</logisticProviderID>
<clientID>TEST</clientID>
<txLogisticID>LP07082300225709</txLogisticID>
<infoType>STATUS</infoType>
<infoContent>ACCEPT</infoContent>
<acceptTime>2007-08-24 08:00:00.0 CST</acceptTime>
<orgName>浙江省宁波市慈溪市龙山镇</orgName>
<orgCode>574075</orgCode>
<orgPhone>021-69773588,021-69774566</orgPhone>
<empName>张三</empName>
<empCode>001011</empCode>
<contactInfo>13888889999</contactInfo>
<remark>浙江省宁波市慈溪市龙山镇 公司 接单成功 网点联系电话: 021-xxxxxxxx 业务员电话:xxxxxxxx</remark>
</UpdateInfo>- 修改预约取件时间
<UpdateInfo>
<txLogisticID>YT20220915083754228220</txLogisticID>
<mailNo>YT2242781591669</mailNo>
<logisticProviderID>YTO</logisticProviderID>
<clientID>TEST</clientID>
<infoType>STATUS</infoType>
<infoContent>ORDER_BOOKING</infoContent>
<remark>订单信息修改</remark>
<acceptTime>2022-09-15 13:15:36.736 CST</acceptTime>
<bookingStartTime>2022-09-15 17:00:00.0 CST</bookingStartTime>
<bookingEndTime>2022-09-15 19:00:00.0 CST</bookingEndTime>
<orgName>广东省广州市天河区新珠江新城</orgName>
<orgCode>200153</orgCode>
<empName>张建雄</empName>
<empCode>02083355</empCode>
</UpdateInfo>- 已揽收
<UpdateInfo>
<txLogisticID>YT20220915083754228220</txLogisticID>
<mailNo>YT2242781591669</mailNo>
<logisticProviderID>YTO</logisticProviderID>
<clientID>TEST</clientID>
<infoType>STATUS</infoType>
<infoContent>GOT</infoContent>
<remark>您的快件被【浙江省金华市义乌市下骆宅建包仓】揽收,揽收人: 李飞 (xxxxxxxx)</remark>
<acceptTime>2023-04-20 22:17:59.0 CST</acceptTime>
<weight>0.05</weight>
<city>金华市</city>
<district>义乌市</district>
</UpdateInfo>- 揽收失败
<UpdateInfo>
<logisticProviderID>YTO</logisticProviderID>
<clientID>TEST</clientID>
<txLogisticID>YT20220915083754228220</txLogisticID>
<infoType>STATUS</infoType>
<infoContent>NOT_SEND</infoContent>
<acceptTime>2007-08-24 08:00:00.0 CST</acceptTime>
<remark>浙江省金华市义乌市下骆宅建包仓 公司 揽收失败,原因:托寄物品为禁限寄品</remark>
<questionCause>托寄物品为禁限寄品</questionCause>
</UpdateInfo>- 已收入
<UpdateInfo>
<txLogisticID>YT20220915083754228220</txLogisticID>
<mailNo>YT2242781591669</mailNo>
<logisticProviderID>YTO</logisticProviderID>
<clientID>TEST</clientID>
<infoType>STATUS</infoType>
<infoContent>ARRIVAL</infoContent>
<remark>您的快件已经到达【义乌转运中心直营公司】</remark>
<acceptTime>2023-04-21 01:03:03.0 CST</acceptTime>
<city>金华市</city>
<district>义乌市</district>
</UpdateInfo>- 已发出
<UpdateInfo>
<txLogisticID>YT20220915083754228220</txLogisticID>
<mailNo>YT2242781591669</mailNo>
<logisticProviderID>YTO</logisticProviderID>
<clientID>TEST</clientID>
<infoType>STATUS</infoType>
<infoContent>DEPARTURE</infoContent>
<remark>您的快件离开【浙江省金华市义乌市下骆宅建包仓】,准备发往【义乌转运中心直营公司】</remark>
<acceptTime>2023-04-20 23:04:16.0 CST</acceptTime>
<city>金华市</city>
<district>义乌市</district>
</UpdateInfo>- 派件中
<UpdateInfo>
<txLogisticID>YT20220915083754228220</txLogisticID>
<mailNo>YT2242781591669</mailNo>
<logisticProviderID>TEST</logisticProviderID>
<deliveryName>李磊磊</deliveryName>
<clientID>JSTAN</clientID>
<infoType>STATUS</infoType>
<infoContent>SENT_SCAN</infoContent>
<remark>【山西省晋城东泽州县巴公镇】的李某某(xxxxxxxx)正在派件,圆通已开启“安全呼叫”保护您的电话隐私,请放心接听![95161和185211号段的上海号码为圆通业务员专属号码]</remark>
<acceptTime>2023-04-22 16:25:38.0 CST</acceptTime>
<contactInfo>18235612343</contactInfo>
<city>晋城市</city>
<district>泽州县</district>
</UpdateInfo>- 自提柜入库
<UpdateInfo>
<txLogisticID>YT20220915083754228220</txLogisticID>
<mailNo>YT2242781591669</mailNo>
<logisticProviderID>YTO</logisticProviderID>
<clientID>TEST</clientID>
<infoType>STATUS</infoType>
<infoContent>INBOUND</infoContent>
<remark>您的快件已到达(西板桥供销社幸福北路2妈妈驿站)西板桥供销社,请您及时取件,联系电话:xxxxxxxx。感谢使用圆通速递,期待再次为您服务!</remark>
<acceptTime>2023-04-22 16:26:38.0 CST</acceptTime>
<city>晋城市</city>
<district>泽州县</district>
</UpdateInfo>- 签收成功
<UpdateInfo>
<txLogisticID>YT20220915083754228220</txLogisticID>
<mailNo>YT2242781591669</mailNo>
<logisticProviderID>YTO</logisticProviderID>
<clientID>TEST</clientID>
<infoType>STATUS</infoType>
<infoContent>SIGNED</infoContent>
<remark>您的快件已在西板桥供销社幸福北路2妈妈驿站被签收,签收方式:本人签收,联系电话:xxxxxxxx。感谢使用圆通速递,期待再次为您服务!举手之劳勿忘送件人,请在[评价快递员]处赐予我们五星好评~</remark>
<signedName>快件已在西板桥供销社幸福北路2妈妈驿站被签收,签收方式:本人签收,联系电话:xxxxxxxx</signedName>
<acceptTime>2023-04-25 14:43:30.0 CST</acceptTime>
<city>晋城市</city>
<district>泽州县</district>
</UpdateInfo>- 签收失败
<UpdateInfo>
<txLogisticID>YT20220915083754228220</txLogisticID>
<mailNo>YT2242781591669</mailNo>
<logisticProviderID>YTO</logisticProviderID>
<clientID>TEST</clientID>
<infoType>STATUS</infoType>
<infoContent>FAILED</infoContent>
<remark>您的快件暂时未投递成功,请耐心等待,如有疑问请联系【广西河池市东兰县公司】(xxxxxxxx)</remark>
<acceptTime>2023-04-25 14:54:53.0 CST</acceptTime>
<city>河池市</city>
<district>东兰县</district>
<questionCause>无法联系收件人</questionCause>
</UpdateInfo>- 退回
<UpdateInfo>
<txLogisticID>YT20220915083754228220</txLogisticID>
<mailNo>YT2242781591669</mailNo>
<logisticProviderID>YTO</logisticProviderID>
<clientID>SFMD</clientID>
<infoType>STATUS</infoType>
<infoContent>TMS_RETURN</infoContent>
<remark>您的快件已被【湖北省荆州市松滋市】安排退回</remark>
<acceptTime>2023-08-04 16:23:07.0 CST</acceptTime>
<city>荆州市</city>
<district>松滋市</district>
</UpdateInfo>- 转寄
<UpdateInfo>
<txLogisticID>YT20220915083754228220</txLogisticID>
<mailNo>YT2242781591669</mailNo>
<logisticProviderID>YTO</logisticProviderID>
<clientID>SFMD</clientID>
<infoType>STATUS</infoType>
<infoContent>FORWARDING</infoContent>
<remark>您的快件已被【南京转运中心】发往到新地址</remark>
<acceptTime>2023-08-04 16:27:57.0 CST</acceptTime>
<city>南京市</city>
<district>玄武区</district>
</UpdateInfo>- 航空发货
<UpdateInfo>
<txLogisticID>YT20220915083754228220</txLogisticID>
<mailNo>YT2242781591669</mailNo>
<logisticProviderID>YTO</logisticProviderID>
<clientID>SXH050708</clientID>
<infoType>STATUS</infoType>
<infoContent>AIRSEND</infoContent>
<remark>快件已到达【北京大兴国际机场】,准备飞往【昆明转运中心】</remark>
<acceptTime>2024-05-07 20:11:36.0 CST</acceptTime>
<city>北京市</city>
<district>朝阳区</district>
</UpdateInfo>- 航空提货
<UpdateInfo>
<txLogisticID>YT20220915083754228220</txLogisticID>
<mailNo>YT2242781591669</mailNo>
<logisticProviderID>YTO</logisticProviderID>
<clientID>SXH050708</clientID>
<infoType>STATUS</infoType>
<infoContent>AIRPICK</infoContent>
<remark>航班已落地,快件发往【昆明转运中心】</remark>
<acceptTime>2024-05-07 20:12:06.0 CST</acceptTime>
<city>昆明市</city>
<district>五华区</district>
</UpdateInfo>【成功返回报文】
<Response>
<logisticProviderID>YTO</logisticProviderID>
<txLogisticID>LP05082300225709000</txLogisticID>
<success>true</success>
</Response>【失败返回报文】
<Response>
<logisticProviderID>YTO</logisticProviderID>
<txLogisticID>LP05082300225709000</txLogisticID>
<success>false</success>
<reason>S01</reason>
</Response>3. 错误编码对照表
订单&物流消息通知类
| 错误编码 | 异常说明 |
|---|---|
| S01 | 非法的XML格式 |
| S02 | 非法的数字签名 |
| S03 | 非法的物流公司 |
| S04 | 非法的通知类型 |
| S05 | 非法的通知内空 |
| S07 | 系统异常,请重试 |
| S08 | 非法的电商平台 |
电子面单类
| 错误编码 | 异常说明 |
|---|---|
| S01 | 订单报文不合法 |
| S02 | 数字签名不匹配 |
| S03 | 没有剩余单号 |
| S04 | 接口请求参数为空:logistics_interface, data_digest或clientId |
| S05 | 唯品会专用 |
| S06 | 请求太快 |
| S07 | url解码失败 |
| S08 | 订单号重复:订单号+客户编码+orderType全部重复则为重复 |
| S09 | 数据入库异常 |