Authored by QC-L

添加拼团确认订单页面

... ... @@ -43,6 +43,14 @@ class BuyNowController {
let product_sku = req.query.product_sku;
let buy_number = req.query.buy_number;
let isGroup = req.query.is_group || '0';
if (isGroup === '1') {
isGroup = false;
} else {
isGroup = true;
}
if (!product_sku || !buy_number) {
return next();
}
... ... @@ -72,103 +80,208 @@ class BuyNowController {
});
}
co(function * () {
let [userProfile, address, result, computeData, validCouponCount, validGiftCardCount] =
yield Promise.all([
req.ctx(userModel).queryProfile(uid),
req.ctx(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
}),
computerPromise,
req.ctx(BuyNowModel).countUsableCoupon({
uid: uid,
product_sku: req.query.product_sku,
sku_type: req.query.sku_type,
buy_number: buy_number,
delivery_way: orderInfo.delivery_way
}),
req.ctx(shoppingModel).countUsableGiftCard(uid) // 可用礼品卡数量
]);
// 获取用户完整手机号
let mobile = _.get(userProfile, 'data.mobile', '');
let orderAddress = _.get(result, 'address', []);
let addressList = _.get(address, 'data', []);
let autoSelectCouponCodeStr = _.get(result, 'data.coupon_pay.coupon_code', '');
let orderEnsure = {};
if (result.code !== 200 && result.message) {
orderEnsure = {message: result.message};
} else {
orderAddress.length && _.forEach(addressList, address => { //eslint-disable-line
if (address.address_id === orderAddress.address_id) {
mobile = address.mobile;
return false;
if (isGroup) {
co(function * () {
let [userProfile, address, result, computeData, validCouponCount, validGiftCardCount] =
yield Promise.all([
req.ctx(userModel).queryProfile(uid),
req.ctx(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
}),
computerPromise,
req.ctx(BuyNowModel).countUsableCoupon({
uid: uid,
product_sku: req.query.product_sku,
sku_type: req.query.sku_type,
buy_number: buy_number,
delivery_way: orderInfo.delivery_way
}),
req.ctx(shoppingModel).countUsableGiftCard(uid) // 可用礼品卡数量
]);
// 获取用户完整手机号
let mobile = _.get(userProfile, 'data.mobile', '');
let orderAddress = _.get(result, 'address', []);
let addressList = _.get(address, 'data', []);
let autoSelectCouponCodeStr = _.get(result, 'data.coupon_pay.coupon_code', '');
let orderEnsure = {};
if (result.code !== 200 && result.message) {
orderEnsure = {message: result.message};
} else {
orderAddress.length && _.forEach(addressList, address => { //eslint-disable-line
if (address.address_id === orderAddress.address_id) {
mobile = address.mobile;
return false;
}
});
if (orderInfo.user_check_coupon !== 'Y' && autoSelectCouponCodeStr) {
orderInfo.coupon_code = autoSelectCouponCodeStr;
res.cookie('buynow_info', JSON.stringify(orderInfo), actCkOpthn);
}
});
if (orderInfo.user_check_coupon !== 'Y' && autoSelectCouponCodeStr) {
orderInfo.coupon_code = autoSelectCouponCodeStr;
res.cookie('buynow_info', JSON.stringify(orderInfo), actCkOpthn);
// 兼容原有的数据格式
orderInfo.deliveryId = orderInfo.delivery_way;
orderInfo.deliveryTimeId = orderInfo.delivery_time;
orderInfo.couponCode = orderInfo.coupon_code;
orderInfo.yohoCoin = orderInfo.use_yoho_coin;
orderInfo.paymentType = orderInfo.payment_type;
orderEnsure = _.assign(
paymentProcess.tranformPayment(
_.get(result, 'data', {}), orderInfo, null, null,
_.get(computeData, 'data', {})),
{
coupon: paymentProcess.handleCoupons({
paymentApiCouponData: _.get(result, 'data.coupon_pay', {}),
validCouponCount: _.get(validCouponCount, 'data.count', 0),
orderComputeCouponPay: _.get(computeData, 'data.coupon_pay'),
userCheckCoupon: orderInfo.user_check_coupon
}),
selectAddressUrl: helpers.urlFormat('/cart/index/buynow/selectAddress', {
product_sku: product_sku,
buy_number: buy_number
}),
selectCouponUrl: helpers.urlFormat('/cart/index/buynow/selectCoupon', {
product_sku: product_sku,
buy_number: buy_number
}),
isOrdinaryCart: true,
isGroupCart: true,
choseGiftCard: helpers.urlFormat('/cart/index/buynow/selectGiftcard'),
giftCards: paymentProcess.handleGiftCards({
validGiftCardCount: _.get(validGiftCardCount, 'data.count', 0),
orderCompute: _.get(computeData, 'data', {})
})
}
);
}
// 兼容原有的数据格式
orderInfo.deliveryId = orderInfo.delivery_way;
orderInfo.deliveryTimeId = orderInfo.delivery_time;
orderInfo.couponCode = orderInfo.coupon_code;
orderInfo.yohoCoin = orderInfo.use_yoho_coin;
orderInfo.paymentType = orderInfo.payment_type;
orderEnsure = _.assign(
paymentProcess.tranformPayment(
_.get(result, 'data', {}), orderInfo, null, null,
_.get(computeData, 'data', {})),
{
coupon: paymentProcess.handleCoupons({
paymentApiCouponData: _.get(result, 'data.coupon_pay', {}),
validCouponCount: _.get(validCouponCount, 'data.count', 0),
orderComputeCouponPay: _.get(computeData, 'data.coupon_pay'),
userCheckCoupon: orderInfo.user_check_coupon
}),
selectAddressUrl: helpers.urlFormat('/cart/index/buynow/selectAddress', {
return res.render('buynow/order-ensure', {
pageHeader: headerModel.setNav({
navTitle: '确认订单',
navBtn: false
}),
module: 'cart',
page: 'buynow-order-ensure',
title: '确认订单',
width750: true,
localCss: true,
product_sku: product_sku,
orderEnsure: orderEnsure,
userMobile: mobile
});
})().catch(next);
} else {
let activity_id = req.query.activity_id;
let group_no = req.query.group_no;
co(function * () {
let [userProfile, address, result, computeData, validCouponCount, validGiftCardCount] =
yield Promise.all([
req.ctx(userModel).queryProfile(uid),
req.ctx(addressModel).addressData(uid),
req.ctx(BuyNowModel).groupBuyPayment({
uid: uid,
product_sku: product_sku,
buy_number: buy_number
group_no,
activity_id: activity_id,
}),
selectCouponUrl: helpers.urlFormat('/cart/index/buynow/selectCoupon', {
product_sku: product_sku,
buy_number: buy_number
computerPromise,
req.ctx(BuyNowModel).countUsableCoupon({
uid: uid,
product_sku: req.query.product_sku,
sku_type: req.query.sku_type,
buy_number: buy_number,
delivery_way: orderInfo.delivery_way
}),
isOrdinaryCart: true,
choseGiftCard: helpers.urlFormat('/cart/index/buynow/selectGiftcard'),
giftCards: paymentProcess.handleGiftCards({
validGiftCardCount: _.get(validGiftCardCount, 'data.count', 0),
orderCompute: _.get(computeData, 'data', {})
})
req.ctx(shoppingModel).countUsableGiftCard(uid) // 可用礼品卡数量
]);
// 获取用户完整手机号
let mobile = _.get(userProfile, 'data.mobile', '');
let orderAddress = _.get(result, 'address', []);
let addressList = _.get(address, 'data', []);
let autoSelectCouponCodeStr = _.get(result, 'data.coupon_pay.coupon_code', '');
let orderEnsure = {};
if (result.code !== 200 && result.message) {
orderEnsure = {message: result.message};
} else {
orderAddress.length && _.forEach(addressList, address => { //eslint-disable-line
if (address.address_id === orderAddress.address_id) {
mobile = address.mobile;
return false;
}
});
if (orderInfo.user_check_coupon !== 'Y' && autoSelectCouponCodeStr) {
orderInfo.coupon_code = autoSelectCouponCodeStr;
res.cookie('buynow_info', JSON.stringify(orderInfo), actCkOpthn);
}
);
}
return res.render('buynow/order-ensure', {
pageHeader: headerModel.setNav({
navTitle: '确认订单',
navBtn: false
}),
module: 'cart',
page: 'buynow-order-ensure',
title: '确认订单',
width750: true,
localCss: true,
product_sku: product_sku,
orderEnsure: orderEnsure,
userMobile: mobile
});
// 兼容原有的数据格式
orderInfo.deliveryId = orderInfo.delivery_way;
orderInfo.deliveryTimeId = orderInfo.delivery_time;
orderInfo.couponCode = orderInfo.coupon_code;
orderInfo.yohoCoin = orderInfo.use_yoho_coin;
orderInfo.paymentType = orderInfo.payment_type;
orderEnsure = _.assign(
paymentProcess.tranformPayment(
_.get(result, 'data', {}), orderInfo, null, null,
_.get(computeData, 'data', {})),
{
coupon: paymentProcess.handleCoupons({
paymentApiCouponData: _.get(result, 'data.coupon_pay', {}),
validCouponCount: _.get(validCouponCount, 'data.count', 0),
orderComputeCouponPay: _.get(computeData, 'data.coupon_pay'),
userCheckCoupon: orderInfo.user_check_coupon
}),
selectAddressUrl: helpers.urlFormat('/cart/index/buynow/selectAddress', {
product_sku: product_sku,
buy_number: buy_number
}),
selectCouponUrl: helpers.urlFormat('/cart/index/buynow/selectCoupon', {
product_sku: product_sku,
buy_number: buy_number
}),
isOrdinaryCart: false,
isGroupCart: false,
choseGiftCard: helpers.urlFormat('/cart/index/buynow/selectGiftcard'),
giftCards: paymentProcess.handleGiftCards({
validGiftCardCount: _.get(validGiftCardCount, 'data.count', 0),
orderCompute: _.get(computeData, 'data', {})
})
}
);
}
return res.render('buynow/order-ensure', {
pageHeader: headerModel.setNav({
navTitle: '确认订单',
navBtn: false
}),
module: 'cart',
page: 'buynow-order-ensure',
title: '确认订单',
width750: true,
localCss: true,
product_sku: product_sku,
orderEnsure: orderEnsure,
userMobile: mobile
});
})().catch(next);
}
})().catch(next);
}
/**
... ...
... ... @@ -73,6 +73,32 @@ class BuyNowModel extends global.yoho.BaseModel {
return this.post(finalParams);
}
groupBuyPayment(params) {
let finalParams = {
data: {
method: 'app.GroupBuy.payment',
uid: params.uid,
product_sku: params.product_sku,
group_no: params.group_no || '',
buy_number: 1,
yoho_coin_mode: 0, // 是否使用有货币
yoho_bill_term: 0, // H5 不支持分期
is_support_apple_pay: 'N', // H5 不支持 APPLE PAY
activity_id: params.activity_id || 0,
enable_red_envelopes: 0 // H5 不支持使用红包
},
param: {
cache: false
}
};
if (params && params.group_no) {
finalParams.data.group_no = params.group_no;
}
return this.post(finalParams);
}
/**
* 数据改变,重新计算结算数据
* @param {*} params
... ...
... ... @@ -61,6 +61,7 @@
{{/each}}
</ul>
</div>
{{#if isGroupCart}}
<div class="sub-block dispatch-time">
<h3>
<p>送货时间</p>
... ... @@ -80,6 +81,7 @@
{{/each}}
</ul>
</div>
{{/if}}
</section>
{{#if isJit}}
... ... @@ -94,6 +96,7 @@
<section class="block">
<ul class="sale-invoice">
{{#if isGroupCart}}
{{!-- 优惠券 --}}
{{#if isOrdinaryCart}}
<li class="coupon">
... ... @@ -133,6 +136,7 @@
</a>
</li>
{{/if}}
{{/if}}
{{!-- 发票 --}}
{{#if invoice}}
... ...