...
|
...
|
@@ -2,7 +2,7 @@ |
|
|
* @Author: Targaryen
|
|
|
* @Date: 2017-06-21 10:15:38
|
|
|
* @Last Modified by: Targaryen
|
|
|
* @Last Modified time: 2017-06-23 14:53:12
|
|
|
* @Last Modified time: 2017-06-23 17:53:27
|
|
|
*/
|
|
|
const _ = require('lodash');
|
|
|
const co = require('bluebird').coroutine;
|
...
|
...
|
@@ -37,7 +37,7 @@ class BuyNowController { |
|
|
} catch (e) {
|
|
|
logger.info(`orderEnsure: get buynow-order-info from cookie error:${JSON.stringify(e)}`);
|
|
|
orderInfo = {};
|
|
|
res.clearCookie('buynow-order-info', actCkOpthn);
|
|
|
res.clearCookie('buynow_info', actCkOpthn);
|
|
|
}
|
|
|
|
|
|
let product_sku = req.query.product_sku;
|
...
|
...
|
@@ -60,6 +60,12 @@ class BuyNowController { |
|
|
buy_number: req.query.buy_number,
|
|
|
use_yoho_coin: parseInt(orderInfo.use_yoho_coin, 10)
|
|
|
});
|
|
|
let validCouponCount = yield req.ctx(BuyNowModel).countUsableCoupon({
|
|
|
uid: req.user.uid,
|
|
|
product_sku: req.query.product_sku,
|
|
|
sku_type: req.query.sku_type,
|
|
|
buy_number: req.query.buy_number
|
|
|
});
|
|
|
let headerData = headerModel.setNav({
|
|
|
navTitle: '确认订单',
|
|
|
navBtn: false
|
...
|
...
|
@@ -72,7 +78,12 @@ class BuyNowController { |
|
|
title: '确认订单',
|
|
|
width750: true,
|
|
|
product_sku: product_sku,
|
|
|
orderEnsure: paymentProcess.tranformPayment(result.data, orderInfo, null, null, computeData.data)
|
|
|
orderEnsure: _.assign(
|
|
|
paymentProcess.tranformPayment(result.data, orderInfo, null, null, computeData.data),
|
|
|
{
|
|
|
coupon: paymentProcess.coupon(_.get(validCouponCount, 'data.count', 0), orderInfo, computeData)
|
|
|
}
|
|
|
)
|
|
|
});
|
|
|
|
|
|
})().catch(next);
|
...
|
...
|
@@ -92,6 +103,7 @@ class BuyNowController { |
|
|
delivery_way: req.body.delivery_way,
|
|
|
payment_type: req.body.payment_type,
|
|
|
product_sku: req.body.product_sku,
|
|
|
buy_number: req.body.buy_number,
|
|
|
coupon_code: req.body.coupon_code,
|
|
|
use_yoho_coin: req.body.use_yoho_coin,
|
|
|
});
|
...
|
...
|
@@ -142,6 +154,9 @@ class BuyNowController { |
|
|
co(function * () {
|
|
|
let result = yield req.ctx(BuyNowModel).submit(params);
|
|
|
|
|
|
// 提交成功清除Cookie
|
|
|
res.clearCookie('buynow_info', actCkOpthn);
|
|
|
|
|
|
return res.json(result);
|
|
|
})().catch(next);
|
|
|
}
|
...
|
...
|
@@ -219,7 +234,7 @@ class BuyNowController { |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 选择优惠券
|
|
|
* 选择优惠券页面
|
|
|
*/
|
|
|
selectCoupon(req, res) {
|
|
|
let headerData = headerModel.setNav({
|
...
|
...
|
@@ -237,6 +252,62 @@ class BuyNowController { |
|
|
localCss: true
|
|
|
});
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取用户可用和不可用优惠券列表
|
|
|
* @param {*} req
|
|
|
* @param {*} res
|
|
|
* @param {*} next
|
|
|
*/
|
|
|
listCoupon(req, res, next) {
|
|
|
co(function* () {
|
|
|
let result = yield req.ctx(BuyNowModel).listCoupon({
|
|
|
uid: req.user.uid,
|
|
|
product_sku: req.query.product_sku,
|
|
|
sku_type: req.query.sku_type,
|
|
|
buy_number: req.query.buy_number
|
|
|
});
|
|
|
|
|
|
res.json(result);
|
|
|
})().catch(next);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 使用优惠券
|
|
|
* @param {*} req
|
|
|
* @param {*} res
|
|
|
* @param {*} next
|
|
|
*/
|
|
|
useCoupon(req, res, next) {
|
|
|
co(function* () {
|
|
|
let result = yield req.ctx(BuyNowModel).useCoupon({
|
|
|
uid: req.user.uid,
|
|
|
product_sku: req.body.product_sku,
|
|
|
sku_type: req.body.sku_type,
|
|
|
buy_number: req.body.buy_number,
|
|
|
coupon_code: req.body.coupon_code
|
|
|
});
|
|
|
|
|
|
res.json(result);
|
|
|
})().catch(next);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 输入优惠券码使用优惠券
|
|
|
*/
|
|
|
usePromotionCode(req, res, next) {
|
|
|
co(function* () {
|
|
|
let result = yield req.ctx(BuyNowModel).usePromotionCode({
|
|
|
uid: req.user.uid,
|
|
|
product_sku: req.body.product_sku,
|
|
|
sku_type: req.body.sku_type,
|
|
|
buy_number: req.body.buy_number,
|
|
|
promotion_code: req.body.promotion_code
|
|
|
});
|
|
|
|
|
|
res.json(result);
|
|
|
})().catch(next);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
module.exports = new BuyNowController(); |
...
|
...
|
|