...
|
...
|
@@ -6,6 +6,78 @@ const camelCase = global.yoho.camelCase; |
|
|
const _ = require('lodash');
|
|
|
|
|
|
/**
|
|
|
* 门票
|
|
|
* @type {{SINGLE_TICKETS_SKN: number}}
|
|
|
*/
|
|
|
const TICKETS = {
|
|
|
SINGLE_TICKETS_SKN: 51335912, // 展览票(单日票)skn
|
|
|
PACKAGE_TICKETS_SKN: 51335908 // 套票skn
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 格式化订单商品
|
|
|
* @private
|
|
|
*/
|
|
|
const _formatOrderGoods = (orderGoods, count, haveLink, tickets) => {
|
|
|
let result = [];
|
|
|
|
|
|
_.forEach(orderGoods, value => {
|
|
|
let goods = {
|
|
|
thumb: value.goods_image,
|
|
|
name: value.product_name,
|
|
|
color: value.color_name,
|
|
|
size: value.size_name,
|
|
|
price: value.goods_price,
|
|
|
count: value.buy_number
|
|
|
};
|
|
|
|
|
|
/* gift=>是否赠品,advanceBuy=>是否加价购 */
|
|
|
if (value.goods_type === 'gift') {
|
|
|
Object.assign(goods, {
|
|
|
gift: true
|
|
|
});
|
|
|
} else if (value.goods_type === 'price_gift') {
|
|
|
Object.assign(goods, {
|
|
|
advanceBuy: true
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/* 上市期 */
|
|
|
if (value.expect_arrival_time) {
|
|
|
Object.assign(goods, {
|
|
|
appearDate: value.expect_arrival_time
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/* 商品链接 */
|
|
|
if (haveLink && value.product_skn) {
|
|
|
Object.assign(goods, {
|
|
|
link: helpers.urlFormat('/product/show_' + value.product_skn + '.html')
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/* 累计购买数 */
|
|
|
count += parseInt(value.buy_number, 10);
|
|
|
|
|
|
/* 门票 */
|
|
|
if (tickets) {
|
|
|
|
|
|
/* 展览票不显示区域 */
|
|
|
if (value.product_skn === TICKETS.SINGLE_TICKETS_SKN) {
|
|
|
delete goods.size;
|
|
|
}
|
|
|
Object.assign(goods, {
|
|
|
tickets: true
|
|
|
});
|
|
|
}
|
|
|
|
|
|
result.push(goods);
|
|
|
});
|
|
|
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
* 获取快递有关信息
|
|
|
* @private
|
|
|
*/
|
...
|
...
|
@@ -205,14 +277,46 @@ const getOrders = (params) => { |
|
|
|
|
|
return _getOrderData(params).then(result => {
|
|
|
if (result.data && result.data.page_total && params.page <= result.data.page_total && result.data.order_list) {
|
|
|
let count = 0;
|
|
|
|
|
|
_.forEach(result.data.order_list, value => {
|
|
|
|
|
|
/* 订单件数清零 */
|
|
|
count = 0;
|
|
|
let perOrder = _getOrderStatus(value);
|
|
|
|
|
|
|
|
|
/* 是否是虚拟商品 */
|
|
|
let isTickets = order.virtual_type && parseInt(order.virtual_type, 10) === 3;
|
|
|
|
|
|
Object.assign(perOrder, {
|
|
|
orderNum: value.order_code,
|
|
|
orderStatus: value.status_str,
|
|
|
sumCost: value.amount,
|
|
|
goods: _formatOrderGoods(value.order_goods, count, false, isTickets),
|
|
|
detailUrl: helpers.urlFormat('/home/orderdetail', {order_code: value.order_code}),
|
|
|
count: count,
|
|
|
isVirtual: isTickets
|
|
|
});
|
|
|
|
|
|
/* 如果运费大于0,会显示运费 */
|
|
|
if (parseFloat(value.shipping_cost) > 0) {
|
|
|
Object.assign(perOrder, {
|
|
|
shippingCost: value.shipping_cost
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/* 倒计时时间 */
|
|
|
if (value.counter_flag && value.counter_flag === 'Y') {
|
|
|
Object.assign(perOrder, {
|
|
|
leftTime: parseInt(value.pay_lefttime, 10) * 1000
|
|
|
});
|
|
|
}
|
|
|
|
|
|
finalResult.push(perOrder);
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return finalResult;
|
|
|
return camelCase(finalResult);
|
|
|
});
|
|
|
};
|
|
|
|
...
|
...
|
|