...
|
...
|
@@ -6,6 +6,8 @@ const _ = require('lodash'); |
|
|
const crypto = global.yoho.crypto;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const co = Promise.coroutine;
|
|
|
const userModel = require('../models/user');
|
|
|
const addressModel = require('../models/address');
|
|
|
const seckillModel = require('../models/seckill');
|
|
|
const headerModel = require('../../../doraemon/models/header'); // 头部model
|
|
|
const orderModel = require('../models/order');
|
...
|
...
|
@@ -85,13 +87,27 @@ exports.ensure = (req, res, next) => { |
|
|
}));
|
|
|
}
|
|
|
|
|
|
let [paymentInfo, validGiftCardCountData] = yield Promise.all([
|
|
|
let [userProfile, address, paymentInfo, validGiftCardCountData] = yield Promise.all([
|
|
|
req.ctx(userModel).queryProfile(uid),
|
|
|
req.ctx(addressModel).addressData(uid),
|
|
|
req.ctx(seckillModel).payment(paymentOption, orderInfo, _.get(orderComputerData, 'data')),
|
|
|
req.ctx(shoppingModel).countUsableGiftCard(uid) // 可用礼品卡数量
|
|
|
]);
|
|
|
|
|
|
let validGiftCardCount = _.get(validGiftCardCountData, 'data.count', 0);
|
|
|
|
|
|
// 获取用户完整手机号
|
|
|
let mobile = _.get(userProfile, 'data.mobile', '');
|
|
|
let orderAddress = _.get(paymentInfo, '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;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (paymentInfo.code !== 200) {
|
|
|
view = {
|
|
|
orderEnsure: false,
|
...
|
...
|
@@ -127,7 +143,7 @@ exports.ensure = (req, res, next) => { |
|
|
}),
|
|
|
width750: true,
|
|
|
localCss: true,
|
|
|
userMobile: view.phoneNum,
|
|
|
userMobile: mobile,
|
|
|
cartToken: crypto.encryption(SLAT, [sku, activityId].join(''))
|
|
|
}, view));
|
|
|
})().catch(next);
|
...
|
...
|
|