Authored by 郝肖肖

套餐加入购物车 接口

... ... @@ -505,6 +505,35 @@ const queryUserPromotionGift = (req, res, next) => {
}).catch(next);
};
/**
* [套餐添加购物车]
* @param {[type]} req [description]
* @param {[type]} res [description]
* @param {Function} next [description]
* @return {[type]} [description]
*/
const addBundle = (req, res, next) => {
let params = {};
let uid = req.user.uid;
let shoppingKey = helper.getShoppingKeyByCookie(req);
let bundleId = req.body.bundleId || 0;
let pSkuList = req.body.pSkuList;
params = {
shopping_key: shoppingKey,
activity_id: bundleId,
product_sku_list: pSkuList
};
if (uid) {
params.uid = uid;
}
service.addBundleData(params).then(result => {
res.json(result);
}).catch(next);
};
module.exports = {
cartAddIndex,
getProductInfo,
... ... @@ -526,5 +555,6 @@ module.exports = {
queryUserPromotionGift,
getCoupons,
miniCart,
delCartGoods
delCartGoods,
addBundle
};
... ...
... ... @@ -9,6 +9,17 @@ const api = global.yoho.API;
const _ = require('lodash');
/**
* [套餐添加购物车]
* @param {[type]} params [description]
* @return {[type]} [description]
*/
const addBundle = (params) => {
return api.get('', Object.assign({
method: 'app.Shopping.addBundle'
}, params), {code: 200});
};
/**
* 获取购物车数据
* @param uid
* @param shoppingKey
... ... @@ -358,6 +369,7 @@ const queryPromotionGift = (promotionIds) => {
};
module.exports = {
addBundle,
cartData,
addToCart,
selectGoods,
... ...
... ... @@ -1054,6 +1054,14 @@ const getMiniCartData = (uid, shoppingKey) => {
})();
};
// 套餐添加购物车
const addBundleData = (params) => {
// params.productSkuList = _getLimitProductData(params);
return cartApi.addBundle(params).then(result => { // eslint-disable-line
return result;
});
};
module.exports = {
getProductInfoAsync, /** 获取商品信息 **/
getCartData, /** 购物车数据 **/
... ... @@ -1071,5 +1079,6 @@ module.exports = {
swapGift, /** 重选赠品或加价购商品 **/
queryUserPromotionGift, /** 查询指定优惠下的可选赠品或加价购 **/
getCoupons, /** 获取优惠券列表 **/
getMiniCartData /** 首页mini购物车数据 **/
getMiniCartData, /** 首页mini购物车数据 **/
addBundleData /** 套餐添加购物车 **/
};
... ...
... ... @@ -51,5 +51,6 @@ router.get('/cart/togetherProduct', cart.getTogetherProduct);
router.get('/cart/recommendProduct', cart.getRecommendProductAction);
router.get('/cart/minicart', cart.miniCart);
router.get('/cart/del', cart.delCartGoods);
router.get('/cart/addBundle', cart.addBundle);
module.exports = router;
... ...