...
|
...
|
@@ -58,22 +58,24 @@ const formatPromotionOpt = (promo) => { |
|
|
* @param int $count 计商品件数
|
|
|
* @return array $arr 处理之后的加价购商品数据
|
|
|
*/
|
|
|
const formatAdvanceGoods = (advanceGood, isGift) => {
|
|
|
return {
|
|
|
promotionId: advanceGood.promotion_id,
|
|
|
promotionTitle: advanceGood.promotion_title,
|
|
|
status: advanceGood.status,
|
|
|
goods: _.get(advanceGood, 'goods_list').map(good => {
|
|
|
return {
|
|
|
id: good.product_skn,
|
|
|
name: good.product_name,
|
|
|
thumb: good.goods_images ? helpers.image(good.goods_images, 120, 160) : '',
|
|
|
price: transPrice(good.last_price),
|
|
|
marketPrice: isGift ? '0.00' : transPrice(good.market_price),
|
|
|
count: good.storage_number
|
|
|
};
|
|
|
})
|
|
|
};
|
|
|
const formatAdvanceGoods = (gifts, isGift) => {
|
|
|
return _.map(gifts, gift => {
|
|
|
return {
|
|
|
promotionId: gift.promotion_id,
|
|
|
promotionTitle: gift.promotion_title,
|
|
|
isGift: isGift,
|
|
|
goods: _.map(gift.goods_list, good => {
|
|
|
return {
|
|
|
id: good.product_skn,
|
|
|
name: good.product_name,
|
|
|
thumb: good.goods_images ? helpers.image(good.goods_images, 120, 160) : '',
|
|
|
price: transPrice(good.last_price),
|
|
|
marketPrice: isGift ? '0.00' : transPrice(good.market_price),
|
|
|
count: good.storage_number
|
|
|
};
|
|
|
})
|
|
|
};
|
|
|
});
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -153,15 +155,14 @@ const formatCartGoods = (goodData, isAdvanceCart, isValid, inValidLow) => { |
|
|
result.link = helpers.urlFormat(`/product/show_${goodData.product_skn}.html`);
|
|
|
return result;
|
|
|
};
|
|
|
const procPriceGiftData = (data) => {
|
|
|
const procPriceGiftData = (data, promotionType) => {
|
|
|
let result = {};
|
|
|
let arrays = _.get(data, 'arrays', []);
|
|
|
|
|
|
if (data.promotion_type === 'Gift') {
|
|
|
// 赠品
|
|
|
result.freebie = formatAdvanceGoods(data, true);
|
|
|
} else if (data.promotion_type === 'Needpaygift') {
|
|
|
// 加价购
|
|
|
result.advanceBuy = formatAdvanceGoods(data);
|
|
|
// 赠品和加价购
|
|
|
result.gifts = formatAdvanceGoods(arrays, promotionType === 'Gift');
|
|
|
if (result.gifts.length === 1) {
|
|
|
result.promotionTitle = result.gifts[0].promotionTitle;
|
|
|
}
|
|
|
return result;
|
|
|
};
|
...
|
...
|
@@ -235,27 +236,12 @@ const procGoodsDetail = (productData, num) => { |
|
|
return data;
|
|
|
};
|
|
|
|
|
|
const procCartData = (data, onlyGift, onlyAdvanceBuy, isAdvanceCart) => {
|
|
|
const procCartData = (data, isAdvanceCart) => {
|
|
|
if (isAdvanceCart === undefined) {
|
|
|
isAdvanceCart = true;
|
|
|
}
|
|
|
let result = {};
|
|
|
|
|
|
if (onlyGift) {
|
|
|
// 全场赠品
|
|
|
result.freebie = data.g_gift_list.map(good => {
|
|
|
return formatAdvanceGoods(good, true);
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
if (onlyAdvanceBuy) {
|
|
|
// 全场加价购
|
|
|
result.advanceBuy = data.g_price_gift_list.map(good => {
|
|
|
return formatAdvanceGoods(good);
|
|
|
});
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
// 购买的可用商品列表
|
|
|
result.goods = _.get(data, 'goods_list', []).map(good => {
|
|
|
let gr = formatCartGoods(good, isAdvanceCart);
|
...
|
...
|
@@ -309,14 +295,15 @@ const procCartData = (data, onlyGift, onlyAdvanceBuy, isAdvanceCart) => { |
|
|
|
|
|
// 赠品
|
|
|
result.freebie = data.g_gift_list.filter(freebie => freebie.status !== 30 && freebie.status !== 0);
|
|
|
result.giftCount = result.freebie.length;
|
|
|
result.selectFreebie = result.freebie.filter(freebie => freebie.status === 10);
|
|
|
result.giftHasStorage = _.some(result.freebie, freebie => freebie.status === 10);
|
|
|
|
|
|
// 加价购
|
|
|
result.advanceBuy = data.g_price_gift_list.filter(advanceBuy => advanceBuy.status !== 30 && advanceBuy.status !== 0);
|
|
|
result.advanceBuyCount = result.advanceBuy.length;
|
|
|
result.selectAdvanceBuy = result.advanceBuy.filter(advanceBuy => advanceBuy.status === 10);
|
|
|
result.advanceHasStorage = _.some(result.advanceBuy, advanceBuy => advanceBuy.status === 10);
|
|
|
}
|
|
|
result.matchGifts = _.get(data, 'match_gift_ids', []);
|
|
|
|
|
|
// 已参加的活动
|
|
|
if (data.promotion_info && data.promotion_info.length > 0) {
|
...
|
...
|
@@ -359,16 +346,12 @@ const procCartData = (data, onlyGift, onlyAdvanceBuy, isAdvanceCart) => { |
|
|
|
|
|
return result;
|
|
|
};
|
|
|
const processData = (data, cartType, onlyGift, onlyAdvanceBuy) => {
|
|
|
const processData = (data, cartType) => {
|
|
|
if (cartType === undefined) {
|
|
|
cartType = 'all';
|
|
|
}
|
|
|
let cart = data.data;
|
|
|
let result = {};
|
|
|
|
|
|
if (onlyGift || onlyAdvanceBuy) { // 加价购或者赠品数据
|
|
|
return procCartData(cart.ordinary_cart_data, onlyGift, onlyAdvanceBuy);
|
|
|
}
|
|
|
let ordinaryCount = _.get(cart, 'ordinary_cart_data.shopping_cart_data.goods_count', 0);
|
|
|
let advanceCount = _.get(cart, 'advance_cart_data.shopping_cart_data.goods_count', 0);
|
|
|
let ordinarySoldOut = _.get(cart, 'ordinary_cart_data.sold_out_goods_list', []);
|
...
|
...
|
@@ -383,12 +366,12 @@ const processData = (data, cartType, onlyGift, onlyAdvanceBuy) => { |
|
|
/* 普通购物车 */
|
|
|
result.commonGoodsCount = ordinaryCount;
|
|
|
result.ordinarySoldOut = ordinarySoldOut.length;
|
|
|
result.commonCart = procCartData(cart.ordinary_cart_data, onlyGift, onlyAdvanceBuy, false);
|
|
|
result.commonCart = procCartData(cart.ordinary_cart_data, false);
|
|
|
|
|
|
/* 预售购物车 */
|
|
|
result.presellGoodsCount = advanceCount;
|
|
|
result.advanceSoldOut = advanceSoldOut.length;
|
|
|
result.preSellCart = procCartData(cart.advance_cart_data, onlyGift, onlyAdvanceBuy);
|
|
|
result.preSellCart = procCartData(cart.advance_cart_data);
|
|
|
return result;
|
|
|
};
|
|
|
|
...
|
...
|
|