orders-api.js
5.04 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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/**
* @author: weiqingting<qingting.wei@yoho.cn>
*/
'use strict';
const api = global.yoho.API;
/**
* 我的订单-分页
* @param type uid
* @param type page
* @param type limit
* @param type type 获取订单类型 type=1全部,type=2待付款,type=3待发货,type=4待收货,type=5待评论(已成功) 7取消
* @return type
*/
exports.getUserOrders = (uid, page, limit, type)=>{
return api.get('', {
method: 'app.SpaceOrders.get',
uid: uid,
type: type,
page: page,
limit: limit
});
};
/**
* 订单详情
* @param type uid
* @param type orderCode
* @return type
*/
exports.getOrderDetail = (uid, orderCode)=>{
return api.get('', {
method: 'app.SpaceOrders.detail',
uid: uid,
order_code: orderCode
});
};
/**
* 取消订单
* @param type uid
* @param type orderCode
* @return type
*/
exports.cancelUserOrder = (uid, orderCode, reason, reasonId)=>{
let options = {
method: 'app.SpaceOrders.close',
uid: uid,
order_code: orderCode
};
if (reasonId) {
Object.assign(options, {
reasonId: reasonId,
reasons: reason
});
}
return api.get('', options);
};
/**
* 确认订单
* @param type uid
* @param type orderCode
* @return type
*/
exports.confirmUserOrder = (uid, orderCode)=>{
return api.get('', {
method: 'app.SpaceOrders.confirm',
uid: uid,
order_code: orderCode
});
};
/**
* 获取虚拟订单ticketCode
* @param type orderCode
* @return type
*/
exports.getTicketCode = (orderCode)=>{
let options = {
method: 'app.SpaceOrders.getQrByOrderCode',
order_code: orderCode
};
return api.get('', options);
};
/**
* 我的订单-查看物流
*
* @param int orderCode 订单号
* @param int uid 用户ID
* @return array
*/
exports.getLogisticsData = (orderCode, uid)=>{
return api.get('', {
method: 'app.express.li',
order_code: orderCode,
uid: uid
});
};
/**
* 获取历史订单
* @param type uid
* @param type page
* @param type limit
*/
exports.getHistoryOrders = (uid, page, limit)=>{
return api.get('', {
method: 'app.SpaceOrders.history',
uid: uid,
page: page,
limit: limit
});
};
/**
* 更新订单的支付方式
*
* @param int orderCode 订单号
* @param int payment 支付方式
* @param int uid 用户ID
* @return array
*/
exports.updateOrderPayment = (orderCode, payment, uid)=>{
let options = {
method: 'app.SpaceOrders.updateOrdersPaymentByCode',
order_code: Number(orderCode),
payment: payment,
uid: uid
};
return api.get('', options);
};
/**
* 取消订单原因列表
* @return type
*/
exports.closeReasons = ()=>{
return api.get('', {
method: 'app.SpaceOrders.closeReasons'
});
};
/**
* 订单详情页——地址修改
* @param type order_code
* @param type address_id
* @return type
*/
exports.updateDeliveryAddress = (orderId, userName, areaCode, address, mobile, phone, uid)=>{
let options = {
method: 'app.SpaceOrders.updateDeliveryAddress',
order_code: orderId,
user_name: userName,
area_code: areaCode,
address: address,
uid: uid
};
if (mobile) {
Object.assign(options, {mobile: mobile});
}
if (phone) {
Object.assign(options, {phone: phone});
}
return api.get('', options);
};
/**
* 查看订单详情
*
* @param string orderCode 订单号
* @param int uid 用户ID
* @param string sessionKey 用户会话
* @return array
*/
exports.viewOrderData = (orderCode, uid, sessionKey)=>{
return api.get('', {
method: 'app.SpaceOrders.info',
order_code: orderCode,
uid: uid,
session_key: sessionKey
});
};
/**
* 重新加入购物车
*/
exports.reBuy = (uid, orderId) => {
return api.get('', {
method: 'app.Shopping.readd',
uid: uid,
order_code: orderId
});
};
/**
* 删除订单数据
*/
exports.del = (uid, gender, channel, orderId) => {
return api.get('', {
method: 'app.SpaceOrders.delOrderByCode',
uid: uid,
gender: gender,
yh_channel: channel,
order_code: orderId
});
};
/**
* 申请退款
*/
exports.refund = (uid, orderId, reasonId, reason) => {
let params = {
uid: uid,
order_code: orderId
};
if (reasonId) {
params.reason_id = reasonId;
}
if (reason) {
params.reason = reason;
}
return api.get('', Object.assign({
method: 'app.SpaceOrders.refundApply'
}, params));
};
/**
* 申请退款原因
*/
exports.refundReason = () => {
return api.get('', {
method: 'app.SpaceOrders.refundApplyReasons'
});
};