Showing
1 changed file
with
22 additions
and
13 deletions
@@ -52,6 +52,26 @@ class BuyNowController { | @@ -52,6 +52,26 @@ class BuyNowController { | ||
52 | res.clearCookie('buynow_info', actCkOpthn); | 52 | res.clearCookie('buynow_info', actCkOpthn); |
53 | } | 53 | } |
54 | 54 | ||
55 | + // 是否需要重新计算 | ||
56 | + let needReComputer = orderInfo && !_.isEmpty(orderInfo) && | ||
57 | + (orderInfo.yohoCoin || orderInfo.coupon_code); | ||
58 | + let computerPromise = null; | ||
59 | + | ||
60 | + if (needReComputer) { | ||
61 | + computerPromise = req.ctx(BuyNowModel).compute({ | ||
62 | + uid: uid, | ||
63 | + product_sku: product_sku, | ||
64 | + sku_type: req.query.sku_type, | ||
65 | + buy_number: buy_number, | ||
66 | + payment_type: orderInfo.payment_type, | ||
67 | + delivery_way: orderInfo.delivery_way, | ||
68 | + use_yoho_coin: parseInt(orderInfo.use_yoho_coin, 10), | ||
69 | + coupon_code: orderInfo.coupon_code, | ||
70 | + gift_card_code: orderInfo.gift_card_code, | ||
71 | + promotion_code: orderInfo.promotion_code | ||
72 | + }); | ||
73 | + } | ||
74 | + | ||
55 | co(function * () { | 75 | co(function * () { |
56 | let [userProfile, address, result, computeData, validCouponCount, validGiftCardCount] = | 76 | let [userProfile, address, result, computeData, validCouponCount, validGiftCardCount] = |
57 | yield Promise.all([ | 77 | yield Promise.all([ |
@@ -64,18 +84,7 @@ class BuyNowController { | @@ -64,18 +84,7 @@ class BuyNowController { | ||
64 | buy_number: buy_number, | 84 | buy_number: buy_number, |
65 | yoho_coin_mode: parseInt(orderInfo.use_yoho_coin, 10) > 0 ? 1 : 0 | 85 | yoho_coin_mode: parseInt(orderInfo.use_yoho_coin, 10) > 0 ? 1 : 0 |
66 | }), | 86 | }), |
67 | - req.ctx(BuyNowModel).compute({ | ||
68 | - uid: uid, | ||
69 | - product_sku: product_sku, | ||
70 | - sku_type: req.query.sku_type, | ||
71 | - buy_number: buy_number, | ||
72 | - payment_type: orderInfo.payment_type, | ||
73 | - delivery_way: orderInfo.delivery_way, | ||
74 | - use_yoho_coin: parseInt(orderInfo.use_yoho_coin, 10), | ||
75 | - coupon_code: orderInfo.coupon_code, | ||
76 | - gift_card_code: orderInfo.gift_card_code, | ||
77 | - promotion_code: orderInfo.promotion_code | ||
78 | - }), | 87 | + computerPromise, |
79 | req.ctx(BuyNowModel).countUsableCoupon({ | 88 | req.ctx(BuyNowModel).countUsableCoupon({ |
80 | uid: uid, | 89 | uid: uid, |
81 | product_sku: req.query.product_sku, | 90 | product_sku: req.query.product_sku, |
@@ -120,7 +129,7 @@ class BuyNowController { | @@ -120,7 +129,7 @@ class BuyNowController { | ||
120 | coupon: paymentProcess.handleCoupons({ | 129 | coupon: paymentProcess.handleCoupons({ |
121 | paymentApiCouponData: _.get(result, 'data.coupon_pay', {}), | 130 | paymentApiCouponData: _.get(result, 'data.coupon_pay', {}), |
122 | validCouponCount: _.get(validCouponCount, 'data.count', 0), | 131 | validCouponCount: _.get(validCouponCount, 'data.count', 0), |
123 | - orderComputeCouponPay: _.get(computeData, 'coupon_pay') | 132 | + orderComputeCouponPay: _.get(computeData, 'data.coupon_pay') |
124 | }), | 133 | }), |
125 | selectAddressUrl: helpers.urlFormat('/cart/index/buynow/selectAddress', { | 134 | selectAddressUrl: helpers.urlFormat('/cart/index/buynow/selectAddress', { |
126 | product_sku: product_sku, | 135 | product_sku: product_sku, |
-
Please register or login to post a comment