sf-express-sdk
(顺丰快递接口)丰桥服务平台部分接口实现、npm package
使用方法
- npm包安装
npm install sf-express-sdk
-
在丰桥官网申请API接入,获取:客户编码、校验码、调用地址
-
覆盖代码中的 <客户编码>
, <校验码>
, <调用地址>
API列表
-
下单
OrderService(<opt>)
-
订单过滤
OrderFilterService(<opt>)
-
订单查询
OrderSearchService(<orderid>)
-
路由信息查询(根据顺丰运单号)
RouteService({tracking_number: <mailno>, tracking_type:1, method_type:1})
-
路由信息查询(根据客户订单号)
RouteServiceByOrderId(<orderid>)
-
取消订单
OrderConfirmServiceCancel(<orderid>)
OrderConfirmService({orderid: <orderid>, dealtype: 2})
配置
const SF = require('sf-express-sdk');
const sf = new SF({
clientCode: '<客户编码>',
checkWord: '<校验码>',
url: '<调用地址>'
});
下单
const createOrderOpts = {
"orderid": "0002",
"is_docall": 1,
"sendstarttime": "2019-06-14 11:30:00",
"express_type": "1",
"j_company": "西瓜の公司",
"j_contact": "大西瓜",
"j_tel": "15842345665",
"j_province": "山东省",
"j_city": "青岛市",
"j_qu": "崂山区",
"j_address": "丽达广场对面",
"d_company": "菠萝の公司",
"d_contact": "大菠萝",
"d_tel": "15544456578",
"d_province": "山东省",
"d_city": "临沂市",
"d_qu": "兰山区",
"d_address": "金雀山路齐鲁大厦",
"pay_method": "1",
"custid": "7551234567",
"daishou": "0",
"things": "小笼包",
"things_num": "1",
"remark": "精密仪器,小心轻拿轻放~",
}
sf.OrderService(createOrderOpts).then(function(result) {
console.log(JSON.stringify(result))
}).catch(function(err) {
console.log(err)
})
订单过滤
const filterOpts = {
"search_orderid":"0002",
"search_d_address":"金雀山路齐鲁大厦",
"search_d_tel":"15544456578",
"search_j_custid":"7551234567",
"search_j_address":"丽达广场对面",
"search_j_tel":"15842345665"
}
sf.OrderFilterService(filterOpts).then(function(result){
console.log(JSON.stringify(result))
}).catch(function(err) {
console.log(err)
})
订单查询
sf.OrderSearchService('0002').then(function(result) {
console.log(JSON.stringify(result))
}).catch(function(err) {
console.log(err)
})
路由信息查询(根据顺丰运单号)
sf.RouteService({tracking_number: '444010688260'}).then(function(result) {
console.log(JSON.stringify(result))
}).catch(function(err) {
console.log(err)
})
路由信息查询(根据客户订单号)
sf.RouteServiceByOrderId('0002').then(function(result) {
console.log(JSON.stringify(result))
}).catch(function(err) {
console.log(err)
})
取消订单
sf.OrderConfirmService({
orderid: '0002',
dealtype: 2
}).then(function(result) {
console.log(JSON.stringify(result))
}).catch(function(err) {
console.log(err)
})
sf.OrderConfirmServiceCancel('0002').then(function(result) {
console.log(JSON.stringify(result))
}).catch(function(err) {
console.log(err)
})