|
@@ -6,6 +6,78 @@ const camelCase = global.yoho.camelCase; |
|
@@ -6,6 +6,78 @@ const camelCase = global.yoho.camelCase; |
6
|
const _ = require('lodash');
|
6
|
const _ = require('lodash');
|
7
|
|
7
|
|
8
|
/**
|
8
|
/**
|
|
|
9
|
+ * 门票
|
|
|
10
|
+ * @type {{SINGLE_TICKETS_SKN: number}}
|
|
|
11
|
+ */
|
|
|
12
|
+const TICKETS = {
|
|
|
13
|
+ SINGLE_TICKETS_SKN: 51335912, // 展览票(单日票)skn
|
|
|
14
|
+ PACKAGE_TICKETS_SKN: 51335908 // 套票skn
|
|
|
15
|
+};
|
|
|
16
|
+
|
|
|
17
|
+/**
|
|
|
18
|
+ * 格式化订单商品
|
|
|
19
|
+ * @private
|
|
|
20
|
+ */
|
|
|
21
|
+const _formatOrderGoods = (orderGoods, count, haveLink, tickets) => {
|
|
|
22
|
+ let result = [];
|
|
|
23
|
+
|
|
|
24
|
+ _.forEach(orderGoods, value => {
|
|
|
25
|
+ let goods = {
|
|
|
26
|
+ thumb: value.goods_image,
|
|
|
27
|
+ name: value.product_name,
|
|
|
28
|
+ color: value.color_name,
|
|
|
29
|
+ size: value.size_name,
|
|
|
30
|
+ price: value.goods_price,
|
|
|
31
|
+ count: value.buy_number
|
|
|
32
|
+ };
|
|
|
33
|
+
|
|
|
34
|
+ /* gift=>是否赠品,advanceBuy=>是否加价购 */
|
|
|
35
|
+ if (value.goods_type === 'gift') {
|
|
|
36
|
+ Object.assign(goods, {
|
|
|
37
|
+ gift: true
|
|
|
38
|
+ });
|
|
|
39
|
+ } else if (value.goods_type === 'price_gift') {
|
|
|
40
|
+ Object.assign(goods, {
|
|
|
41
|
+ advanceBuy: true
|
|
|
42
|
+ });
|
|
|
43
|
+ }
|
|
|
44
|
+
|
|
|
45
|
+ /* 上市期 */
|
|
|
46
|
+ if (value.expect_arrival_time) {
|
|
|
47
|
+ Object.assign(goods, {
|
|
|
48
|
+ appearDate: value.expect_arrival_time
|
|
|
49
|
+ });
|
|
|
50
|
+ }
|
|
|
51
|
+
|
|
|
52
|
+ /* 商品链接 */
|
|
|
53
|
+ if (haveLink && value.product_skn) {
|
|
|
54
|
+ Object.assign(goods, {
|
|
|
55
|
+ link: helpers.urlFormat('/product/show_' + value.product_skn + '.html')
|
|
|
56
|
+ });
|
|
|
57
|
+ }
|
|
|
58
|
+
|
|
|
59
|
+ /* 累计购买数 */
|
|
|
60
|
+ count += parseInt(value.buy_number, 10);
|
|
|
61
|
+
|
|
|
62
|
+ /* 门票 */
|
|
|
63
|
+ if (tickets) {
|
|
|
64
|
+
|
|
|
65
|
+ /* 展览票不显示区域 */
|
|
|
66
|
+ if (value.product_skn === TICKETS.SINGLE_TICKETS_SKN) {
|
|
|
67
|
+ delete goods.size;
|
|
|
68
|
+ }
|
|
|
69
|
+ Object.assign(goods, {
|
|
|
70
|
+ tickets: true
|
|
|
71
|
+ });
|
|
|
72
|
+ }
|
|
|
73
|
+
|
|
|
74
|
+ result.push(goods);
|
|
|
75
|
+ });
|
|
|
76
|
+
|
|
|
77
|
+ return result;
|
|
|
78
|
+};
|
|
|
79
|
+
|
|
|
80
|
+/**
|
9
|
* 获取快递有关信息
|
81
|
* 获取快递有关信息
|
10
|
* @private
|
82
|
* @private
|
11
|
*/
|
83
|
*/
|
|
@@ -205,14 +277,46 @@ const getOrders = (params) => { |
|
@@ -205,14 +277,46 @@ const getOrders = (params) => { |
205
|
|
277
|
|
206
|
return _getOrderData(params).then(result => {
|
278
|
return _getOrderData(params).then(result => {
|
207
|
if (result.data && result.data.page_total && params.page <= result.data.page_total && result.data.order_list) {
|
279
|
if (result.data && result.data.page_total && params.page <= result.data.page_total && result.data.order_list) {
|
|
|
280
|
+ let count = 0;
|
|
|
281
|
+
|
208
|
_.forEach(result.data.order_list, value => {
|
282
|
_.forEach(result.data.order_list, value => {
|
|
|
283
|
+
|
|
|
284
|
+ /* 订单件数清零 */
|
|
|
285
|
+ count = 0;
|
209
|
let perOrder = _getOrderStatus(value);
|
286
|
let perOrder = _getOrderStatus(value);
|
210
|
|
287
|
|
|
|
288
|
+ /* 是否是虚拟商品 */
|
|
|
289
|
+ let isTickets = order.virtual_type && parseInt(order.virtual_type, 10) === 3;
|
|
|
290
|
+
|
|
|
291
|
+ Object.assign(perOrder, {
|
|
|
292
|
+ orderNum: value.order_code,
|
|
|
293
|
+ orderStatus: value.status_str,
|
|
|
294
|
+ sumCost: value.amount,
|
|
|
295
|
+ goods: _formatOrderGoods(value.order_goods, count, false, isTickets),
|
|
|
296
|
+ detailUrl: helpers.urlFormat('/home/orderdetail', {order_code: value.order_code}),
|
|
|
297
|
+ count: count,
|
|
|
298
|
+ isVirtual: isTickets
|
|
|
299
|
+ });
|
|
|
300
|
+
|
|
|
301
|
+ /* 如果运费大于0,会显示运费 */
|
|
|
302
|
+ if (parseFloat(value.shipping_cost) > 0) {
|
|
|
303
|
+ Object.assign(perOrder, {
|
|
|
304
|
+ shippingCost: value.shipping_cost
|
|
|
305
|
+ });
|
|
|
306
|
+ }
|
|
|
307
|
+
|
|
|
308
|
+ /* 倒计时时间 */
|
|
|
309
|
+ if (value.counter_flag && value.counter_flag === 'Y') {
|
|
|
310
|
+ Object.assign(perOrder, {
|
|
|
311
|
+ leftTime: parseInt(value.pay_lefttime, 10) * 1000
|
|
|
312
|
+ });
|
|
|
313
|
+ }
|
|
|
314
|
+
|
211
|
finalResult.push(perOrder);
|
315
|
finalResult.push(perOrder);
|
212
|
});
|
316
|
});
|
213
|
}
|
317
|
}
|
214
|
|
318
|
|
215
|
- return finalResult;
|
319
|
+ return camelCase(finalResult);
|
216
|
});
|
320
|
});
|
217
|
};
|
321
|
};
|
218
|
|
322
|
|