电子面单云打印接口
电子面单云打印接口,本接口为批量处理, 取面单号时,可以不用传入收件人的相关密文,只需要传入订单号。
1.请求参数:
参数名 | 类型 | 说明 | 示例 |
---|---|---|---|
appid | String | 合作伙伴AppId | uwkahf@jfs92 |
timestamp | String | 当前时间戳 | |
seller_nick | String | 拼多多商家账号,非店铺名称 | kingdo |
sign | String | 接口签名 | 如何计算生成见示例代码 |
request_data | String | 必填 请求的获取电子面单的json数据 |
如果一次取多个单号,将不同的订单加入到trade_order_info_dtos集合中,最多一次可以取100个单号。
request_data的json示例格式,注意类型格式,比如数字型和字符串型的区别
{
"sender": {
"address": {
"city": "上海市",
"detail": "东方路238",
"district": "浦东新区",
"province": "上海市",
"town": "陆家嘴街道"
},
"mobile": "13812197833",
"name": "陈先生",
"phone": ""
},
"trade_order_info_dtos": [{
"logistics_services": "",
"object_id": "a1000",
"order_info": {
"order_channels_type": "pdd",
"trade_order_list": ["210324-595938509442221"]
},
"package_info": {
"goods_description": "好东西",
"id": "10",
"items": [{
"count": 1,
"name": "A4打印纸"
}],
"packaging_description": "A4打印纸的包装说明",
"total_packages_count": 1,
"volume": 22,
"weight": 22
},
"template_url": "https://file-link.pinduoduo.com/xlobo_std",
"user_id": 133214
},
{
"logistics_services": "",
"object_id": "1002",
"order_info": {
"order_channels_type": "pdd",
"trade_order_list": ["210304-155155172182221"]
},
"package_info": {
"goods_description": "11",
"id": "11",
"items": [{
"count": 1,
"name": "A4打印纸"
}],
"packaging_description": "A4打印纸的包装说明",
"total_packages_count": 1,
"volume": 22,
"weight": 22
},
"template_url": "https://file-link.pinduoduo.com/xlobo_std",
"user_id": 133214
}
],
"wp_code": "YZXB"
}
2. 请求示例代码(Java)
/**
* 拼多多电子面单取号 V2版,优化了参数,不需要输入收件相关的密文
* @throws Exception
*/
@Test
public void PddWayBillV2Get() throws Exception {
String seller_nick = Config.PddSellerNick ; // 拼多多卖家账号
//业务参数
Map<String, String> data = new HashMap<String, String>();
data.put("appid", Config.AppId);
data.put("seller_nick", seller_nick);
Long timestamp = System.currentTimeMillis() / 1000;
data.put("timestamp", timestamp.toString());
// 批量取号
String requestData = "{" +
" \"sender\": {" +
" \"address\": {" +
" \"city\": \"上海市\"," +
" \"detail\": \"商城路738\"," +
" \"district\": \"浦东新区\"," +
" \"province\": \"上海市\"," +
" \"town\": \"陆家嘴街道\"" +
" }," +
" \"mobile\": \"13816122233\"," +
" \"name\": \"李先生\"," +
" \"phone\": \"\"" +
" }," +
" \"trade_order_info_dtos\": [{" +
" \"logistics_services\": \"\"," +
" \"object_id\": \"1000\"," +
" \"order_info\": {" +
" \"order_channels_type\": \"pdd\"," +
" \"trade_order_list\": [\"210324-595938509442221\"]" +
" }," +
" \"package_info\": {" +
" \"goods_description\": \"11\"," +
" \"id\": \"10\"," +
" \"items\": [{" +
" \"count\": 1," +
" \"name\": \"A4打印纸\"" +
" }]," +
" \"packaging_description\": \"A4打印纸的包装说明\"," +
" \"total_packages_count\": 1," +
" \"volume\": 22," +
" \"weight\": 22" +
" }, " +
" \"template_url\": \"https://file-link.pinduoduo.com/xlobo_std\"," +
" \"user_id\": 133214" +
" }," +
"" +
" {" +
" \"logistics_services\": \"\"," +
" \"object_id\": \"1002\"," +
" \"order_info\": {" +
" \"order_channels_type\": \"pdd\"," +
" \"trade_order_list\": [\"210304-155155172182221\"]" +
" }," +
" \"package_info\": {" +
" \"goods_description\": \"11\"," +
" \"id\": \"11\"," +
" \"items\": [{" +
" \"count\": 1," +
" \"name\": \"A4打印纸\"" +
" }]," +
" \"packaging_description\": \"A4打印纸的包装说明\"," +
" \"total_packages_count\": 1," +
" \"volume\": 22," +
" \"weight\": 22" +
" }," +
" " +
" \"template_url\": \"https://file-link.pinduoduo.com/xlobo_std\"," +
" \"user_id\": 0" +
" }" +
"" +
" ]," +
" \"wp_code\": \"YZXB\"" +
"}";
data.put("request_data", requestData);
// 参数签名
data.put("sign", Utils.Sign(data,Config.AppSecret));
doHttpRequest(Config.PddWayBillV2GetUrl,data);
}
- 需要注意的是package_info中的id为包裹id ,请不要相同,否则会取到相同的面单号。
- trade_order_info_dtos是集合,用于存放多个要取号的订单。 user_id可以为0,蜂巢会自动替换为当前商家的user_id。此接口相对拼多多的标准接口少了收件人recipient字段。
- trade_order_list虽然是集合, 只需要存入一个订单号,切莫存入多个订单号放到trade_order_list集合。
- 接口取号时发货地址设置为账户网点对应发货地址。
- 其他更多信息可参考拼多多官方说明, 拼多多电子面单接入指南。
- 取得电子面单后,可用拼多多打印组件,将面单信息通过打印机打印到纸质上,如何使用拼多多打印组件
3. 返回结果如下:
限于篇幅,以下json为部分数据
{
"code": 0,
"message": "ok",
"data": [{
"object_id": "1000",
"print_data": {
"encryptedData": "",
"signature": "",
"templateUrl": "",
"ver": ""
},
"waybill_code": "",
"parent_waybill_code": "",
"code": 2,
"message": "业务服务错误,收件人/发件人姓名不能为空"
}, {
"object_id": "1002",
"print_data": {
"encryptedData": "xxxxxxxa78b003c2",
"signature": "mbvOwtIbbt1MvDgtamkacXcRrBkwXRlAM9i5Bsf4vUrqRdZYjlXCpkPfsBD3C3L2WYDzNrtic=",
"templateUrl": "https://file-link.pinduoduo.com/xlobo_std",
"ver": "3"
},
"waybill_code": "9865222208794",
"parent_waybill_code": "",
"code": 0,
"message": "success"
}]
}
返回字段说明
object_id : 请求id,此id为开发者请求时的id,用于返回时标识哪个对象。
parent_waybill_code : 快运母单号
print_data : 面单信息
waybill_code STRING : 面单号
说明: code为0表示成功,非0为失败,message会包含失败原因。失败时一定要注意,可能商户授权过期,或是参数有误。内层的code和message用于表示具体某个订单取号是否成功。code为0表示取号成功。
常见问题
1.电子面单支持给别的店铺获取面单吗?
回答 :支持,举例:A店铺开通电子面单账号,想要用A店铺的面单打印B店铺的订单,在取号调用pdd.waybill.get接口时入参A店铺的账号然后user_id入参B店铺的pdduserid即可
2. 接口返回”发货地址非法”的错误
发货地址必须和店铺后台申请电子面单时的地址完全一致,省市区分别入参相应字段,其余入参detail字段;具体地址可在店铺后台查看或通过查询面单服务订购及面单使用情况接口获取
3. 批量取号时如果失败了,会返回成功的部分吗?
比如一次取100个面单号,会返回100个结果,包括成功和失败的。 可以根据data集合中的code来判断,code为0时,表示对应的快递单取号成功了,如果失败了code为1,message会有失败的原因。 对于失败的订单号,可以根据自定义传入的object_id(可以用订单号等做相应的标识)定位是哪个订单取号失败。
4. 使用pdd.waybill.get获得面单信息后怎么对接到云打印组件?
请参阅开放平台文档“电子面单”部分“云打印交互协议”https://open.pinduoduo.com/application/document/browse?idStr=3BBB4C229B6A8FCC
5. 顺丰取号时,提示“有必选的增值服务没有选择”
顺丰取号时,需要在logistics_services里增加如下相关参数。
"logistics_services":{
"TIMED-DELIVERY": {
"value": "2"},//时效产品
”INSURE": {
"value": "510.1"}//保价
}
注意代码中传值格式为:"logistics_services": "{\"TIMED-DELIVERY\": {\"value\": \"247\"}}"
注意事项:
时效产品不传值则默认为“顺丰特快”;
【保价】服务需要传具体的报价金额,单位为“元”,精确到小数点后1位;
支持的时效产品可在pdd.waybill.search接口获取到;
6. 支持丰网吗
支持的,wp_code传入FENGWANG