Authored by 郭成尧

view-show-out

... ... @@ -42,14 +42,14 @@ exports.orderEnsure = (req, res, next) => {
headerData.backUrl = req.get('Referer') || returnUrl;
}
let order = cartModel.cartPay(uid, cartType, orderInfo, sku, skn, buyNumber, req.xhr);
let userProfile = userModel.queryProfile(uid);
let address = addressModel.addressData(uid);
let orderPromise = cartModel.cartPay(uid, cartType, orderInfo, sku, skn, buyNumber, req.xhr);
let userProfilePromise = userModel.queryProfile(uid);
let addressPromise = addressModel.addressData(uid);
return Promise.all([order, userProfile, address]).then(result => {
order = result[0];
userProfile = result[1];
address = result[2];
return Promise.all([orderPromise, userProfilePromise, addressPromise]).then(result => {
let order = result[0];
let userProfile = result[1];
let address = result[2];
if (order.cartUrl) { // TODO? 普通或者预售商品为空时, BUT WHEN AJAX?
return res.redirect(order.cartUrl);
... ... @@ -74,16 +74,15 @@ exports.orderEnsure = (req, res, next) => {
orderEnsurePage: true,
isOrdinaryCart: cartType !== 'advance',
orderEnsure: order,
userMobile: mobile
userMobile: mobile,
pageHeader: headerData,
pageFooter: true,
module: 'cart',
page: 'order-ensure',
width750: true,
title: '确认订单',
};
viewData.pageHeader = headerData;
viewData.pageFooter = true;
viewData.module = 'cart';
viewData.page = 'order-ensure';
viewData.width750 = true;
viewData.title = '确认订单';
res.render('order-ensure', viewData);
}).catch(next);
};
... ... @@ -96,16 +95,42 @@ exports.fastPay = (req, res, next) => {
navTitle: '确认订单',
navBtn: false
});
let uid = req.user.uid;
let orderPromise = cartModel.easyPayment(uid, req.query.skuList);
let userProfilePromise = userModel.queryProfile(uid);
let addressPromise = addressModel.addressData(uid);
let viewData = {
pageHeader: headerData,
module: 'cart',
page: 'order-ensure',
width750: true,
title: '确认订单'
};
Promise.all([orderPromise, userProfilePromise, addressPromise]).then(result => {
let order = result[0];
let userProfile = result[1];
let address = result[2];
// 获取用户完整手机号
let mobile = _.get(userProfile, 'data.mobile', '');
let orderAddress = _.get(order, 'address', []);
let addressList = _.get(address, 'data', []);
orderAddress.length && addressList.forEach(address => { //eslint-disable-line
if (address.address_id === orderAddress.address_id) {
mobile = address.mobile;
}
});
let viewData = {
orderEnsurePage: true,
isOrdinaryCart: true,
orderEnsure: order,
userMobile: mobile,
pageHeader: headerData,
pageFooter: true,
module: 'cart',
page: 'order-ensure',
width750: true,
title: '确认订单',
};
res.render('order-ensure', viewData);
res.render('order-ensure', viewData);
}).catch(next);
};
/**
... ...
... ... @@ -89,6 +89,15 @@ exports.cartPay = (uid, cartType, orderInfo, limitProductCode, sku, skn, buyNumb
};
/**
* 快速结算数据处理
*/
exports.easyPayment = (uid, skuList) => {
return shoppingAPI.easyPayment(uid, skuList).then(result => {
return result;
});
};
/**
* 处理优惠券列表数据
*
* @param int $uid 用户ID
... ...
... ... @@ -28,6 +28,23 @@ exports.cartPayAPI = (uid, cartType, isUseYohoCoin, skuList) => {
return api.get('', param);
};
/**
* 立即购买接口,仅支持套餐
*/
exports.easyPayment = (uid, skuList) => {
let param = {
method: 'app.Shopping.easyPayment',
enable_red_envelopes: 0,
cart_type: 'bundle',
yoho_coin_mode: 0,
uid: uid,
activity_id: 'activity_id',
product_sku_list: skuList
};
return api.get('', param);
};
/**
* 购物车结算--支付方式和配送方式选择以及是否使用有货币接口返回的数据处理
... ...