...
|
...
|
@@ -53,38 +53,48 @@ class BuyNowController { |
|
|
}
|
|
|
|
|
|
co(function * () {
|
|
|
let [result, computeData, validCouponCount, validGiftCardCount] = yield Promise.all([
|
|
|
req.ctx(BuyNowModel).payment({
|
|
|
uid: uid,
|
|
|
product_sku: product_sku,
|
|
|
sku_type: req.query.sku_type,
|
|
|
buy_number: buy_number,
|
|
|
yoho_coin_mode: parseInt(orderInfo.use_yoho_coin, 10) > 0 ? 1 : 0
|
|
|
}),
|
|
|
req.ctx(BuyNowModel).compute({
|
|
|
uid: uid,
|
|
|
product_sku: product_sku,
|
|
|
sku_type: req.query.sku_type,
|
|
|
buy_number: buy_number,
|
|
|
payment_type: orderInfo.payment_type,
|
|
|
delivery_way: orderInfo.delivery_way,
|
|
|
use_yoho_coin: parseInt(orderInfo.use_yoho_coin, 10),
|
|
|
coupon_code: orderInfo.coupon_code,
|
|
|
gift_card_code: orderInfo.gift_card_code,
|
|
|
promotion_code: orderInfo.promotion_code
|
|
|
}),
|
|
|
req.ctx(BuyNowModel).countUsableCoupon({
|
|
|
uid: uid,
|
|
|
product_sku: req.query.product_sku,
|
|
|
sku_type: req.query.sku_type,
|
|
|
buy_number: buy_number
|
|
|
}),
|
|
|
shoppingAPI.countUsableGiftCard(uid) // 可用礼品卡数量
|
|
|
]);
|
|
|
|
|
|
let headerData = headerModel.setNav({
|
|
|
navTitle: '确认订单',
|
|
|
navBtn: false
|
|
|
let [userProfile, address, result, computeData, validCouponCount, validGiftCardCount] =
|
|
|
yield Promise.all([
|
|
|
userModel.queryProfile(uid),
|
|
|
addressModel.addressData(uid),
|
|
|
req.ctx(BuyNowModel).payment({
|
|
|
uid: uid,
|
|
|
product_sku: product_sku,
|
|
|
sku_type: req.query.sku_type,
|
|
|
buy_number: buy_number,
|
|
|
yoho_coin_mode: parseInt(orderInfo.use_yoho_coin, 10) > 0 ? 1 : 0
|
|
|
}),
|
|
|
req.ctx(BuyNowModel).compute({
|
|
|
uid: uid,
|
|
|
product_sku: product_sku,
|
|
|
sku_type: req.query.sku_type,
|
|
|
buy_number: buy_number,
|
|
|
payment_type: orderInfo.payment_type,
|
|
|
delivery_way: orderInfo.delivery_way,
|
|
|
use_yoho_coin: parseInt(orderInfo.use_yoho_coin, 10),
|
|
|
coupon_code: orderInfo.coupon_code,
|
|
|
gift_card_code: orderInfo.gift_card_code,
|
|
|
promotion_code: orderInfo.promotion_code
|
|
|
}),
|
|
|
req.ctx(BuyNowModel).countUsableCoupon({
|
|
|
uid: uid,
|
|
|
product_sku: req.query.product_sku,
|
|
|
sku_type: req.query.sku_type,
|
|
|
buy_number: buy_number
|
|
|
}),
|
|
|
shoppingAPI.countUsableGiftCard(uid) // 可用礼品卡数量
|
|
|
]);
|
|
|
|
|
|
// 获取用户完整手机号
|
|
|
let mobile = _.get(userProfile, 'data.mobile', '');
|
|
|
let orderAddress = _.get(result, 'address', []);
|
|
|
let addressList = _.get(address, 'data', []);
|
|
|
|
|
|
orderAddress.length && _.forEach(addressList, address => { //eslint-disable-line
|
|
|
if (address.address_id === orderAddress.address_id) {
|
|
|
mobile = address.mobile;
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 兼容原有的数据格式
|
...
|
...
|
@@ -95,7 +105,7 @@ class BuyNowController { |
|
|
orderInfo.paymentType = orderInfo.payment_type;
|
|
|
|
|
|
let orderEnsure = _.assign(
|
|
|
paymentProcess.tranformPayment(result.data, orderInfo, null, null, computeData.data),
|
|
|
paymentProcess.tranformPayment(_.get(result, 'data', {}), orderInfo, null, null, computeData.data),
|
|
|
{
|
|
|
coupon: paymentProcess.coupon(
|
|
|
_.get(validCouponCount, 'data.count', 0),
|
...
|
...
|
@@ -120,7 +130,10 @@ class BuyNowController { |
|
|
);
|
|
|
|
|
|
return res.render('buynow/order-ensure', {
|
|
|
pageHeader: headerData,
|
|
|
pageHeader: headerModel.setNav({
|
|
|
navTitle: '确认订单',
|
|
|
navBtn: false
|
|
|
}),
|
|
|
module: 'cart',
|
|
|
page: 'buynow-order-ensure',
|
|
|
title: '确认订单',
|
...
|
...
|
@@ -128,7 +141,7 @@ class BuyNowController { |
|
|
localCss: true,
|
|
|
product_sku: product_sku,
|
|
|
orderEnsure: orderEnsure,
|
|
|
userMobile: _.get(orderEnsure, 'phoneNum', '')
|
|
|
userMobile: mobile
|
|
|
});
|
|
|
|
|
|
})().catch(next);
|
...
|
...
|
|