Authored by 郭成尧

'订单列表数据已出'

... ... @@ -48,9 +48,10 @@ exports.getOrders = (req, res, next) => {
yh_channel: req.query.channel || 1,
uid: req.user.uid || 8039759 // TODO 待删除
}).then(result => {
console.log(result);
res.render('order-content', {
layout: false,
order: result
orders: result
});
}).catch(next);
};
... ...
... ... @@ -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);
});
};
... ...
<div class="order-good" data-id="{{id}}">
<div class="thumb-wrap">
{{#if link}}
<a href="{{link}}"><img class="thumb lazy" data-original="{{image thumb 90 120}}"></a>
{{else}}
<img class="thumb lazy" data-original="{{image thumb 90 120}}">
{{/if}}
<p class="tag{{#if gift}} gift-tag{{/if}}{{#if advanceBuy}} advance-buy-tag{{/if}}"></p>
</div>
<div class="deps">
<p class="name row">{{name}}</p>
<p class="row">
{{#if color}}
<span class="color">
{{#if tickets}}日期{{else}}颜色{{/if}}:{{color}}
</span>
{{/if}}
{{#if size}}
<span class="size">
{{#if tickets}}区域{{else}}尺码{{/if}}:{{size}}
</span>
{{/if}}
</p>
<p class="row price-wrap">
<span class="price">
¥{{price}}
</span>
<span class="count">
×{{count}}
</span>
{{#if appearDate}}
<span class="appear-date">上市期:{{appearDate}}</span>
{{/if}}
</p>
</div>
</div>
... ...
... ... @@ -5,7 +5,7 @@
</header>
<section class="order-goods">
{{# goods}}
{{> me/order/good}}
{{> order/good}}
{{/ goods}}
</section>
<footer class="footer">
... ...