Authored by 郭成尧

computer

... ... @@ -52,6 +52,26 @@ class BuyNowController {
res.clearCookie('buynow_info', actCkOpthn);
}
// 是否需要重新计算
let needReComputer = orderInfo && !_.isEmpty(orderInfo) &&
(orderInfo.yohoCoin || orderInfo.coupon_code);
let computerPromise = null;
if (needReComputer) {
computerPromise = 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
});
}
co(function * () {
let [userProfile, address, result, computeData, validCouponCount, validGiftCardCount] =
yield Promise.all([
... ... @@ -64,18 +84,7 @@ class BuyNowController {
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
}),
computerPromise,
req.ctx(BuyNowModel).countUsableCoupon({
uid: uid,
product_sku: req.query.product_sku,
... ... @@ -120,7 +129,7 @@ class BuyNowController {
coupon: paymentProcess.handleCoupons({
paymentApiCouponData: _.get(result, 'data.coupon_pay', {}),
validCouponCount: _.get(validCouponCount, 'data.count', 0),
orderComputeCouponPay: _.get(computeData, 'coupon_pay')
orderComputeCouponPay: _.get(computeData, 'data.coupon_pay')
}),
selectAddressUrl: helpers.urlFormat('/cart/index/buynow/selectAddress', {
product_sku: product_sku,
... ...