Authored by 郭成尧

cart-controller-ctx

... ... @@ -68,11 +68,11 @@ exports.orderEnsure = (req, res, next) => {
}
let activityInfo = JSON.parse(req.cookies['activity-info']);
orderPromise = cartModel.cartPay(_.assign(params, {
orderPromise = req.ctx(cartModel).cartPay(_.assign(params, {
activityInfo: activityInfo
}));
} else {
orderPromise = cartModel.cartPay(params);
orderPromise = req.ctx(cartModel).cartPay(params);
}
let allPromise = [
... ... @@ -169,20 +169,20 @@ exports.orderCompute = (req, res, next) => {
if (req.body.cartType === 'bundle') {
let activityInfo = JSON.parse(req.cookies['activity-info']);
cartModel.orderCompute(_.assign(params, {
req.ctx(cartModel).orderCompute(_.assign(params, {
activityInfo: activityInfo
})).then(result => {
res.json(result);
}).catch(next);
} else {
cartModel.orderCompute(_.assign(params, {
req.ctx(cartModel).orderCompute(_.assign(params, {
product_sku_list: skuList
})).then(result => {
res.json(result);
}).catch(next);
}
} else {
cartModel.ticketsOrderCompute(uid, productSku, buyNumber, yohoCoin).then(result => {
req.ctx(cartModel).ticketsOrderCompute(uid, productSku, buyNumber, yohoCoin).then(result => {
res.json(result);
}).catch(next);
}
... ... @@ -272,13 +272,13 @@ exports.orderSub = (req, res, next) => {
if (req.body.cartType === 'bundle') {
let activityInfo = JSON.parse(req.cookies['activity-info']);
result = yield cartModel.orderSub(_.assign(params, {
result = yield req.ctx(cartModel).orderSub(_.assign(params, {
cart_type: 'bundle',
times: times,
activityInfo: activityInfo
}));
} else {
result = yield cartModel.orderSub(_.assign(params, {
result = yield req.ctx(cartModel).orderSub(_.assign(params, {
cart_type: cartType,
product_sku_list: skuList
}));
... ... @@ -334,7 +334,7 @@ exports.couponList = (req, res, next) => {
let delivery_way = orderInfo.deliveryId || 1;
if (req.xhr) {
return cartModel.getCouponList({
return req.ctx(cartModel).getCouponList({
uid: req.user.uid,
delivery_way: delivery_way,
is_group_frees: 'Y', // 运费券是否分组
... ... @@ -356,7 +356,7 @@ exports.useCouponCode = (req, res, next) => {
co(function* () {
if (req.xhr) {
let result = yield cartModel.useCouponCode(uid, couponCode);
let result = yield req.ctx(cartModel).useCouponCode(uid, couponCode);
res.json(result);
} else {
... ... @@ -469,7 +469,7 @@ exports.jitDetail = (req, res, next) => {
result = paymentProcess.transformJit(_.get(resultFromApi, 'data.package_list', []));
} else {
result = yield cartModel.jitDetailData(
result = yield req.ctx(cartModel).jitDetailData(
uid,
cartType,
req.query.skuList,
... ...