order.js
3.81 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
/**
* 订单.
* @author hgwang
* @date 2016-07-20
*/
'use strict';
const api = global.yoho.API;
const _ = require('lodash');
/**
* 获取订单列表数据
* @param param
* uid uid,
* page 页数
* type 订单类型 1:全部订单,2:待付款,3:待发货,4:待收货,5:待评论/成功订单,7:失败/取消
* limit 每页大小
* app_type 0:yohobuy,1:blk
* @returns {Promise.<T>|*}
*/
exports.getOrders = (param) => {
param = Object.assign({
method: 'app.SpaceOrders.get'
}, param);
return api.get('', param);
};
/**
* 获取订单详情
* @param uid
* @param orderCode
* @returns {Promise.<T>|*}
*/
exports.getOrderDetail = (uid, orderCode) => {
return api.get('', {
method: 'app.SpaceOrders.detail',
order_code: orderCode,
uid: uid
});
};
/**
* 取消订单
* @param orderCode 订单号
* @param reasonId 原因id
* @param reason 原因描述
* @returns {Promise.<T>|*}
*/
exports.cancelOrder = (uid, orderCode, reasonId, reason) => {
return api.post('', {
method: 'app.SpaceOrders.close',
uid,
order_code: orderCode,
reason_id: reasonId,
reason: reason ? reason : ''
});
};
// 再次购买
exports.readdData = (orderCode, uid) => {
return api.get('', {
method: 'app.Shopping.readd',
uid: uid,
order_code: orderCode
}).then((result) => {
if (result && result.code === 200) {
result.message = '商品已重新加入购物车';
} else if (result.code === '400') {
result.message = '缺失参数';
} else {
result.message = '商品加入购物车失败';
result.datat = {};
}
return result;
});
};
/**
* 确认订单
* @param orderCode 订单号
* @returns {Promise.<T>|*}
*/
exports.confirmOrder = (uid, orderCode) => {
return api.post('', {
method: 'app.SpaceOrders.confirm',
uid: uid,
order_code: orderCode
}).then(result => {
return result;
});
};
/**
* 删除订单
* @param orderCode 订单号
* @param uid uid
* @returns {Promise.<T>|*}
*/
exports.deleteOrder = (orderCode, uid) => {
return api.post('', {
method: 'app.SpaceOrders.delOrderByCode',
order_code: orderCode,
uid: uid
}).then(result => {
return result;
});
};
/**
* 查看订单物流详情
* @param {[int]} order_code 订单号
* @param {[int]} uid 用户uid
* @param {[string]} type 退换货物流(退货:refund,换货:change)
* @param {[int]} id 退换货申请ID(type为refund | change,才有效)
* @return {[array]}
*/
exports.getOrderLogisticdate = (params) => {
let method;
if (_.isEmpty(params.order_code)) {
return Promise.resolve([]);
}
// getNewExpress:退换货物流,li:订单物流
method = _.indexOf(['refund', 'change'], params.type) >= 0 ?
'app.express.getNewExpress' : 'app.express.li';
return api.get('', Object.assign({
method: method
}, params)).then(result => {
if (result.code === 200) {
return result.data;
}
return [];
});
};
/**
* 获取yoho币数量
* @param uid
* @returns {*|Promise.<T>}
*/
exports.getCoins = (uid) => {
return api.get('', {
uid: uid,
method: 'app.yohocoin.total'
});
};
/**
* 获取yoho币明细
* @param uid
* @param page
* @param limit
* @returns {*|Promise.<T>}
*/
exports.getCoinDetail = (uid, page, limit) => {
return api.get('', {
uid: uid,
page: page,
limit: limit,
method: 'app.yohocoin.lists'
});
};
/**
* 获取退换货原因
* @returns {*|Promise.<T>}
*/
exports.getCancelReason = () => {
return api.get('', {
method: 'app.SpaceOrders.closeReasons'
});
};