|
@@ -2,7 +2,6 @@ |
|
@@ -2,7 +2,6 @@ |
2
|
* @Author: Targaryen
|
2
|
* @Author: Targaryen
|
3
|
* @Date: 2017-06-21 10:15:38
|
3
|
* @Date: 2017-06-21 10:15:38
|
4
|
* @Last Modified by: Targaryen
|
4
|
* @Last Modified by: Targaryen
|
5
|
- * @Last Modified time: 2017-06-26 16:21:29
|
|
|
6
|
*/
|
5
|
*/
|
7
|
const _ = require('lodash');
|
6
|
const _ = require('lodash');
|
8
|
const co = require('bluebird').coroutine;
|
7
|
const co = require('bluebird').coroutine;
|
|
@@ -16,6 +15,7 @@ const paymentProcess = require(`${utils}/payment-process`); |
|
@@ -16,6 +15,7 @@ const paymentProcess = require(`${utils}/payment-process`); |
16
|
const crypto = global.yoho.crypto;
|
15
|
const crypto = global.yoho.crypto;
|
17
|
const logger = global.yoho.logger;
|
16
|
const logger = global.yoho.logger;
|
18
|
const helpers = global.yoho.helpers;
|
17
|
const helpers = global.yoho.helpers;
|
|
|
18
|
+const camelCase = global.yoho.camelCase;
|
19
|
|
19
|
|
20
|
// cookie 参数
|
20
|
// cookie 参数
|
21
|
const actCkOpthn = {
|
21
|
const actCkOpthn = {
|
|
@@ -53,13 +53,18 @@ class BuyNowController { |
|
@@ -53,13 +53,18 @@ class BuyNowController { |
53
|
product_sku: product_sku,
|
53
|
product_sku: product_sku,
|
54
|
sku_type: req.query.sku_type,
|
54
|
sku_type: req.query.sku_type,
|
55
|
buy_number: buy_number,
|
55
|
buy_number: buy_number,
|
|
|
56
|
+ yoho_coin_mode: parseInt(orderInfo.use_yoho_coin, 10) > 0 ? 1 : 0
|
56
|
});
|
57
|
});
|
57
|
let computeData = yield req.ctx(BuyNowModel).compute({
|
58
|
let computeData = yield req.ctx(BuyNowModel).compute({
|
58
|
uid: req.user.uid,
|
59
|
uid: req.user.uid,
|
59
|
product_sku: product_sku,
|
60
|
product_sku: product_sku,
|
60
|
sku_type: req.query.sku_type,
|
61
|
sku_type: req.query.sku_type,
|
61
|
buy_number: buy_number,
|
62
|
buy_number: buy_number,
|
62
|
- use_yoho_coin: parseInt(orderInfo.use_yoho_coin, 10)
|
63
|
+ payment_type: orderInfo.payment_type,
|
|
|
64
|
+ delivery_way: orderInfo.delivery_way,
|
|
|
65
|
+ use_yoho_coin: parseInt(orderInfo.use_yoho_coin, 10),
|
|
|
66
|
+ coupon_code: orderInfo.coupon_code,
|
|
|
67
|
+ promotion_code: orderInfo.promotion_code
|
63
|
});
|
68
|
});
|
64
|
let validCouponCount = yield req.ctx(BuyNowModel).countUsableCoupon({
|
69
|
let validCouponCount = yield req.ctx(BuyNowModel).countUsableCoupon({
|
65
|
uid: req.user.uid,
|
70
|
uid: req.user.uid,
|
|
@@ -71,6 +76,25 @@ class BuyNowController { |
|
@@ -71,6 +76,25 @@ class BuyNowController { |
71
|
navTitle: '确认订单',
|
76
|
navTitle: '确认订单',
|
72
|
navBtn: false
|
77
|
navBtn: false
|
73
|
});
|
78
|
});
|
|
|
79
|
+ let orderEnsure = _.assign(
|
|
|
80
|
+ paymentProcess.tranformPayment(result.data, orderInfo, null, null, computeData.data),
|
|
|
81
|
+ {
|
|
|
82
|
+ coupon: paymentProcess.coupon(
|
|
|
83
|
+ _.get(validCouponCount, 'data.count', 0),
|
|
|
84
|
+ orderInfo,
|
|
|
85
|
+ computeData.data
|
|
|
86
|
+ ),
|
|
|
87
|
+ selectAddressUrl: helpers.urlFormat('/cart/index/buynow/selectAddress', {
|
|
|
88
|
+ product_sku: product_sku,
|
|
|
89
|
+ buy_number: buy_number
|
|
|
90
|
+ }),
|
|
|
91
|
+ selectCouponUrl: helpers.urlFormat('/cart/index/buynow/selectCoupon', {
|
|
|
92
|
+ product_sku: product_sku,
|
|
|
93
|
+ buy_number: buy_number
|
|
|
94
|
+ }),
|
|
|
95
|
+ isOrdinaryCart: true
|
|
|
96
|
+ }
|
|
|
97
|
+ );
|
74
|
|
98
|
|
75
|
return res.render('buynow/order-ensure', {
|
99
|
return res.render('buynow/order-ensure', {
|
76
|
pageHeader: headerData,
|
100
|
pageHeader: headerData,
|
|
@@ -80,17 +104,7 @@ class BuyNowController { |
|
@@ -80,17 +104,7 @@ class BuyNowController { |
80
|
width750: true,
|
104
|
width750: true,
|
81
|
localCss: true,
|
105
|
localCss: true,
|
82
|
product_sku: product_sku,
|
106
|
product_sku: product_sku,
|
83
|
- orderEnsure: _.assign(
|
|
|
84
|
- paymentProcess.tranformPayment(result.data, orderInfo, null, null, computeData.data),
|
|
|
85
|
- {
|
|
|
86
|
- coupon: paymentProcess.coupon(_.get(validCouponCount, 'data.count', 0), orderInfo, computeData),
|
|
|
87
|
- selectAddressUrl: helpers.urlFormat('/cart/index/buynow/selectAddress', {
|
|
|
88
|
- product_sku: product_sku,
|
|
|
89
|
- buy_number: buy_number
|
|
|
90
|
- }),
|
|
|
91
|
- isOrdinaryCart: true
|
|
|
92
|
- }
|
|
|
93
|
- )
|
107
|
+ orderEnsure: orderEnsure
|
94
|
});
|
108
|
});
|
95
|
|
109
|
|
96
|
})().catch(next);
|
110
|
})().catch(next);
|
|
@@ -283,7 +297,9 @@ class BuyNowController { |
|
@@ -283,7 +297,9 @@ class BuyNowController { |
283
|
buy_number: req.query.buy_number
|
297
|
buy_number: req.query.buy_number
|
284
|
});
|
298
|
});
|
285
|
|
299
|
|
286
|
- res.json(result);
|
300
|
+ let finalResult = _.get(result, 'data', {});
|
|
|
301
|
+
|
|
|
302
|
+ res.json(camelCase(finalResult));
|
287
|
})().catch(next);
|
303
|
})().catch(next);
|
288
|
}
|
304
|
}
|
289
|
|
305
|
|