Skip to content

Commit

Permalink
订单结果查询接口
Browse files Browse the repository at this point in the history
  • Loading branch information
brucexiong committed Nov 13, 2018
1 parent f618e77 commit e88a978
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ package-lock.json
.LSOverride

# Icon must end with two \r
Icon
Icon

# Thumbnails
._*
Expand Down Expand Up @@ -190,3 +190,5 @@ tags
.vscode/
tsconfig.json
jsconfig.json

test.js
21 changes: 13 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ module.exports = class SFWL {
const obj = {
Request: {
_attributes: {
service,
service: `${service}Service`,
lang: 'zh-CN',
},
Head: {
_text: this.clientCode,
},
Body: {
Order: {
[service]: {
_attributes: data,
},
},
Expand All @@ -45,11 +45,6 @@ module.exports = class SFWL {
verifyCode,
}));
const result = xmlJs.xml2js(response.data, { compact: true });
if (result.Response.Head._text !== 'OK') {
const error = new Error('顺丰下单失败');
error.result = result;
throw error;
}
return result;
}

Expand All @@ -60,12 +55,22 @@ module.exports = class SFWL {
* @param {*} addedData AddedService 参数
*/
async order(data, addedData) {
const serviceName = 'OrderService';
const serviceName = 'Order';
if (addedData) {
Object.assign(data, {
AddedService: addedData,
});
}
return this.request(serviceName, data);
}

/**
* 订单结果查询
* https://qiao.sf-express.com/pages/developDoc/index.html?level2=296618&level3=902583&level4=965417
* @param {*} data OrderSearch 参数 { orderid, search_type }
*/
async orderSearch(data) {
const serviceName = 'OrderSearch';
return this.request(serviceName, data);
}
};

0 comments on commit e88a978

Please sign in to comment.