returns-api.js
5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
/**
* 退换货API
* @author: yyq<yanqing.yang@yoho.cn>
* @date: 2016/7/19
*/
'use strict';
const api = global.yoho.API;
/**
* 获取快递公司列表API
* @function getExpressCompanyAsync
* @return { Object } 快递公司列表
*/
const getExpressCompanyAsync = () => {
return api.get('', {
method: 'app.express.getExpressCompany'
}, {code: 200});
};
/**
* 获取订单信息API
* @function getOrderInfoAsync
* @param { number } orderCode 订单编号
* @param { number } uid 用户uid
* @param { string } sessionKey session
* @return { Object } 订单信息
*/
const getOrderInfoAsync = (orderCode, uid, sessionKey) => {
return api.get('', {
method: 'app.SpaceOrders.info',
order_code: orderCode,
uid: uid,
session_key: sessionKey
}, {code: 200});
};
/**
* 获取订单退货信息API
* @function getRefundGoodsAsync
* @param { number } orderCode 订单编号
* @param { number } uid 用户uid
* @return { Object } 订单退货信息
*/
const getRefundGoodsAsync = (orderCode, uid) => {
return api.get('', {
method: 'app.refund.goodsList',
order_code: orderCode,
uid: uid
}, {code: 200});
};
/**
* 获取退货详情信息API
* @function getRefundDetailAsync
* @param { number } applyId 退货申请id
* @param { number } uid 用户uid
* @return { Object } 退货详情信息
*/
const getRefundDetailAsync = (applyId, uid) => {
return api.get('', {
method: 'app.refund.detail',
id: applyId,
uid: uid
}, {code: 200});
};
/**
* 退货申请提交API
* @function refundSubmitAsync
* @param { number } orderCode 订单编号
* @param { number } uid 用户uid
* @param { Object } goods 退货商品信息
* @param { Object } payment 退款信息
* @return { Object } 退货申请结果
*/
const refundSubmitAsync = (orderCode, uid, goods, payment) => {
return api.get('', {
method: 'app.refund.submit',
order_code: orderCode,
uid: uid,
goods: JSON.stringify(goods),
payment: JSON.stringify(payment)
}, {code: 200});
};
/**
* 获取换货商品信息API
* @function getChangeGoodsListAsync
* @param { number } orderCode 订单编号
* @param { number } uid 用户uid
* @return { Object } 换货商品信息
*/
const getChangeGoodsListAsync = (orderCode, uid) => {
return api.get('', {
method: 'app.change.goodsList',
order_code: orderCode,
uid: uid
});
};
/**
* 获取商品信息API
* @function getProductInfoAsync
* @param { number } productId 商品id
* @param { number } productSkn 商品skn
* @return { Object } 商品信息
*/
const getProductInfoAsync = (productId, productSkn) => {
return api.get('', {
method: 'app.product.data',
product_id: productId,
product_skn: productSkn
});
};
/**
* 获取换货详情API
* @function getExchangeDetail
* @param { number } id 收藏id
* @param { number } uid 用户uid
* @return { Object } 换货详情
*/
const getExchangeDetail = (id, uid) => {
return api.get('', {
method: 'app.change.detail',
id: id,
uid: uid
});
};
/**
* 换货申请提交API
* @function changeSubmitAsync
* @param { number } data 换货信息
* @param { number } uid 用户uid
* @return { Object } 换货申请结果
*/
const changeSubmitAsync = (data, uid) => {
const requestData = Object.assign(data, {
method: 'app.change.submit',
uid: uid,
goods: JSON.stringify(data.goods)
});
return api.get('', requestData);
};
/**
* 设置寄回快递信息API
* @function setExpressNumberAsync
* @param { number } uid 用户uid
* @param { number } param 寄回快递信息
* @param { boolean } isChange 是否换货 true--换货 false--退货
* @return { Object } 设置快递结果
*/
const setExpressNumberAsync = (uid, param, isChange) => {
return api.post('', {
method: isChange ? 'app.change.setexpress' : 'app.refund.setexpress',
uid: uid,
id: param.id,
express_id: param.companyId,
express_number: param.number,
express_company: param.companyName
});
};
/**
* 取消退换货API
* @function cancelReturnAsync
* @param { number } id 收藏id
* @param { number } uid 用户uid
* @param { boolean } isChange 是否换货 true--换货 false--退货
* @return { Object } 取消结果
*/
const cancelReturnAsync = (id, uid, isChange) => {
return api.post('', {
method: isChange ? 'app.change.cancel' : 'app.refund.cancel',
id: id,
uid: uid
});
};
/**
* 获取退货银行列表API
* @function getRefundBank
* @return { Object } 银行列表信息
*/
const getRefundBank = () => {
return api.get('', {
method: 'app.refund.refundBank'
});
};
/**
* 获取换货类型API
* @param { number } uid 用户uid
* @param { number } areaCode 地区码
* @return { Object } 换货类型
*/
const getChangeTypeAsync = (uid, areaCode) => {
return api.get('', {
method: 'app.change.getDelivery',
uid: uid,
area_code: areaCode
}, {
code: 200
});
};
module.exports = {
getExpressCompanyAsync,
getOrderInfoAsync,
getRefundGoodsAsync,
getChangeGoodsListAsync,
getProductInfoAsync,
getRefundDetailAsync,
refundSubmitAsync,
getExchangeDetail,
changeSubmitAsync,
setExpressNumberAsync,
cancelReturnAsync,
getRefundBank,
getChangeTypeAsync
};