...
|
...
|
@@ -50,129 +50,90 @@ const _assignExpressInfo = (showLogistics, order) => { |
|
|
* @private
|
|
|
*/
|
|
|
const _getOrderStatus = (order, showLogistics) => {
|
|
|
let result = {};
|
|
|
let orderBtn = [];
|
|
|
|
|
|
if (order.isCancel === 'Y') {
|
|
|
return {
|
|
|
canceled: true
|
|
|
};
|
|
|
if (!order) {
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
order.status = parseInt(order.status, 10);
|
|
|
|
|
|
// 先判断订单付款方式,根据不同的付款方式计算订单状态。(注:货到付款没有待付款状态)
|
|
|
// 支付方式为非货到付款时,计算订单状态。
|
|
|
if (parseInt(order.paymentType, 10) !== 2) {
|
|
|
Object.assign(result, {
|
|
|
isPayonline: true
|
|
|
if (parseInt(order.attribute, 10) === 9) {
|
|
|
/* 预售商品,不能进行任何操作 */
|
|
|
orderBtn.push({
|
|
|
isAdvance: true
|
|
|
});
|
|
|
return {orderBtn: orderBtn};
|
|
|
}
|
|
|
|
|
|
let isPayaly = order.paymentName === '' ? false : true;
|
|
|
|
|
|
switch (order.status) {
|
|
|
case 0:
|
|
|
/* 倒计时时间 订单详情页倒计时不在同一级*/
|
|
|
if (order.counterFlag === 'Y' && parseInt(order.payLefttime, 10)) {
|
|
|
orderBtn.push({
|
|
|
leftTimeTop: order.payLefttime * 1000
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/* 待付款 */
|
|
|
Object.assign(result, {
|
|
|
unpaid: true,
|
|
|
payUrl: helpers.urlFormat('/home/orders/paynew', {order_code: order.orderCode})
|
|
|
_.each(order.links, function(val) {
|
|
|
switch (val) {
|
|
|
case 'refundApply':// 申请退款
|
|
|
orderBtn.push({
|
|
|
refundApply: true
|
|
|
});
|
|
|
break;
|
|
|
case 1:
|
|
|
case 2:
|
|
|
case 3:
|
|
|
|
|
|
/* 已付款状态不给查看物流 URL */
|
|
|
Object.assign(result, {
|
|
|
unreceived: true,
|
|
|
payAly: isPayaly
|
|
|
case 'modifyAddress':// 修改收货地址
|
|
|
orderBtn.push({
|
|
|
modifyAddress: true,
|
|
|
link: helpers.urlFormat('/home/orders/addressModify', {
|
|
|
orderCode: order.orderCode,
|
|
|
areaCode: _.get(order, 'delivery_address.area_code', ''),
|
|
|
provinceAreaCode: order.isSupportChangeProvince !== 'Y' &&
|
|
|
_.get(order, 'delivery_address.province_area_code', '') || ''// 如果不允许修改省
|
|
|
})
|
|
|
});
|
|
|
break;
|
|
|
case 4:
|
|
|
case 5:
|
|
|
|
|
|
/* 已发货状态,给查看物流或二维码URL */
|
|
|
Object.assign(result, {
|
|
|
unreceived: true,
|
|
|
payAly: isPayaly
|
|
|
case 'buyNow':// 立即付款
|
|
|
orderBtn.push({
|
|
|
buyNow: true,
|
|
|
link: helpers.urlFormat('/home/orders/paynew', {order_code: order.orderCode}),
|
|
|
});
|
|
|
|
|
|
/* 是否门票 */
|
|
|
if (order.virtualType && parseInt(order.virtualType, 10) === 3) {
|
|
|
Object.assign(result, {
|
|
|
qrcode: helpers.urlFormat(`/home/QRcode/${order.orderCode}`)
|
|
|
});
|
|
|
} else {
|
|
|
Object.assign(result, _assignExpressInfo(showLogistics, order));
|
|
|
}
|
|
|
break;
|
|
|
case 6:
|
|
|
|
|
|
/* 已成功订单,给查看物流或二维码URL */
|
|
|
Object.assign(result, {
|
|
|
completed: true,
|
|
|
payAly: isPayaly
|
|
|
case 'closeOrder':// 取消订单
|
|
|
orderBtn.push({
|
|
|
closeOrder: true
|
|
|
});
|
|
|
|
|
|
/* 是否门票 */
|
|
|
if (order.virtual_type && parseInt(order.virtual_type, 10) === 3) {
|
|
|
Object.assign(result, {
|
|
|
qrcode: helpers.urlFormat(`/home/QRcode/${order.orderCode}`)
|
|
|
});
|
|
|
} else {
|
|
|
Object.assign(result, _assignExpressInfo(showLogistics, order));
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
case 'confirm':// 订单确认
|
|
|
break;
|
|
|
}
|
|
|
} else {
|
|
|
Object.assign(result, {
|
|
|
payAly: true,
|
|
|
paymentName: (order.paymentName !== '') ? order.paymentName : '货到付款'
|
|
|
});
|
|
|
|
|
|
/* 订单为货到付款订单时,计算订单状态。(货到付款没有待付款状态) */
|
|
|
switch (order.status) {
|
|
|
case 0:
|
|
|
|
|
|
/* 备货中 */
|
|
|
Object.assign(result, {
|
|
|
unpaid: true
|
|
|
});
|
|
|
case 'getExpress':// 查看物流
|
|
|
orderBtn.push(Object.assign(
|
|
|
{getExpress: true},
|
|
|
_assignExpressInfo(showLogistics, order)
|
|
|
));
|
|
|
break;
|
|
|
case 1:
|
|
|
case 2:
|
|
|
case 3:
|
|
|
|
|
|
/* 已付款状态不给查看物流URL */
|
|
|
Object.assign(result, {
|
|
|
unreceived: true
|
|
|
case 'shareOrder':// 晒单评价
|
|
|
break;
|
|
|
case 'delOrder':// 删除订单
|
|
|
orderBtn.push({
|
|
|
delOrder: true,
|
|
|
});
|
|
|
break;
|
|
|
case 4:
|
|
|
case 5:
|
|
|
|
|
|
/* 待收货状态,给查看物流 url */
|
|
|
Object.assign(result, {
|
|
|
unreceived: true
|
|
|
case 'lookQrcode':// 查看二维码
|
|
|
orderBtn.push({
|
|
|
lookQrcode: true,
|
|
|
link: helpers.urlFormat(`/home/QRcode/${order.orderCode}`),
|
|
|
});
|
|
|
Object.assign(result, _assignExpressInfo(showLogistics, order));
|
|
|
break;
|
|
|
case 6:
|
|
|
|
|
|
/* 待收货状态,给查看物流 url */
|
|
|
Object.assign(result, {
|
|
|
completed: true
|
|
|
case 'afterService':// 售后服务
|
|
|
break;
|
|
|
case 'readd':// 再次购买
|
|
|
orderBtn.push({
|
|
|
readd: true
|
|
|
});
|
|
|
Object.assign(result, _assignExpressInfo(showLogistics, order));
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
return result;
|
|
|
return {orderBtn: orderBtn};
|
|
|
};
|
|
|
|
|
|
|
...
|
...
|
@@ -202,12 +163,6 @@ const orderDetailData = (uid, orderCode) => { |
|
|
addressAll: orderDetail.area + orderDetail.address
|
|
|
});
|
|
|
|
|
|
if (orderDetail.counterFlag && orderDetail.counterFlag === 'Y') {
|
|
|
orderDetail = _.assign(orderDetail, {
|
|
|
leftTime: parseInt(orderDetail.payLefttime, 10) * 1000
|
|
|
});
|
|
|
}
|
|
|
|
|
|
_.forEach(orderDetail.orderGoods, function(data) {
|
|
|
let obj = {};
|
|
|
let count = +data.buyNumber;
|
...
|
...
|
@@ -253,12 +208,6 @@ const orderDetailData = (uid, orderCode) => { |
|
|
|
|
|
orderDetail.goods = goods;
|
|
|
|
|
|
if (orderDetail.paymentStatus === 'Y') {
|
|
|
orderDetail = _.assign(orderDetail, {
|
|
|
isPay: true
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 判断是否可以修改地址
|
|
|
if (orderDetail.canUpdateDeliveryAddress === 'Y' && orderDetail.isSupportChangeProvince === 'Y') {
|
|
|
orderDetail = _.assign(orderDetail, {
|
...
|
...
|
@@ -272,24 +221,6 @@ const orderDetailData = (uid, orderCode) => { |
|
|
});
|
|
|
}
|
|
|
|
|
|
// 判断是否有关联订单
|
|
|
if (orderDetail.relateOrderCode === 'Y') {
|
|
|
orderDetail = _.assign(orderDetail, {
|
|
|
relation: true
|
|
|
});
|
|
|
} else {
|
|
|
orderDetail = _.assign(orderDetail, {
|
|
|
relation: false
|
|
|
});
|
|
|
}
|
|
|
|
|
|
// 定金预售
|
|
|
if (orderDetail.attribute * 1 === 9) {
|
|
|
orderDetail = _.assign(orderDetail, {
|
|
|
isDepositAdvance: true
|
|
|
});
|
|
|
}
|
|
|
|
|
|
orderDetail = _.assign(orderDetail, {
|
|
|
goodsAmount: orderDetail.paymentAmount,
|
|
|
newUrl: helpers.urlFormat('/home/orders/addressModify', {
|
...
|
...
|
@@ -308,18 +239,15 @@ const orderDetailData = (uid, orderCode) => { |
|
|
}
|
|
|
|
|
|
// 为支付的拆单配送信息
|
|
|
if (orderDetail.isMultiPackage && orderDetail.isMultiPackage === 'Y') {
|
|
|
let jitInfo = {
|
|
|
deliveryId: orderDetail.deliveryId,
|
|
|
paymentType: orderDetail.paymentType,
|
|
|
couponCode: orderDetail.couponCode,
|
|
|
yohoCoin: orderDetail.yohoCoin,
|
|
|
cartType: 'ordinary'
|
|
|
};
|
|
|
|
|
|
if (orderDetail.isMultiPackage === 'Y') {
|
|
|
orderDetail = _.assign(orderDetail, {
|
|
|
isJit: true,
|
|
|
jitDetailUrl: helpers.urlFormat('/cart/index/new/jitDetail', jitInfo)
|
|
|
jitDetailUrl: helpers.urlFormat('/cart/index/new/jitDetail', {
|
|
|
deliveryId: orderDetail.deliveryId,
|
|
|
paymentType: orderDetail.paymentType,
|
|
|
couponCode: orderDetail.couponCode,
|
|
|
yohoCoin: orderDetail.yohoCoin,
|
|
|
cartType: 'ordinary'
|
|
|
})
|
|
|
});
|
|
|
}
|
|
|
|
...
|
...
|
@@ -327,15 +255,6 @@ const orderDetailData = (uid, orderCode) => { |
|
|
orderDetail.invoice.type = (orderDetail.invoice.type + '' === '2');
|
|
|
}
|
|
|
|
|
|
/* 申请退款 */
|
|
|
if (_.find(orderDetail.links, o => {
|
|
|
return o === 'refundApply';
|
|
|
})) {
|
|
|
Object.assign(orderDetail, {
|
|
|
refundApply: true
|
|
|
});
|
|
|
}
|
|
|
|
|
|
return orderDetail;
|
|
|
} else {
|
|
|
logger.error('detail info return no 200');
|
...
|
...
|
|