|
|
'use strict'
|
|
|
|
|
|
import { getImageUrlWithWH } from './util';
|
|
|
|
|
|
function toDecimal2(x) {
|
|
|
var f = parseFloat(x);
|
|
|
if (isNaN(f)) {
|
|
|
return false;
|
|
|
}
|
|
|
var f = Math.round(x * 100) / 100;
|
|
|
var s = f.toString();
|
|
|
var rs = s.indexOf('.');
|
|
|
if (rs < 0) {
|
|
|
rs = s.length;
|
|
|
s += '.';
|
|
|
}
|
|
|
while (s.length <= rs + 2) {
|
|
|
s += '0';
|
|
|
}
|
|
|
return s;
|
|
|
}
|
|
|
|
|
|
function processGiftOrPriceGift(giftList, isGift) {
|
|
|
let selledOutGiftTypeCount = 0;
|
|
|
giftList.map((item, index) => {
|
|
|
let statusString = "";
|
|
|
if (item.status == 0) {
|
|
|
statusString = "去凑单";
|
|
|
} else if (item.status == 10) {
|
|
|
if (item.promotion_type == "Gift") {//Cashreduce,Degressdiscount,Cheapestfree,Discount,Gift,Needpaygift,SpecifiedAmount
|
|
|
statusString = "领赠品";
|
|
|
} else if (item.promotion_type == "Needpaygift") {
|
|
|
statusString = "去换购";
|
|
|
}
|
|
|
} else if (item.status == 20) {
|
|
|
selledOutGiftTypeCount++;
|
|
|
statusString = "已抢光";
|
|
|
} else if (item.status == 30) {
|
|
|
statusString = "更换";
|
|
|
}
|
|
|
item.statusString = statusString;
|
|
|
item.isGift = isGift;
|
|
|
});
|
|
|
if (selledOutGiftTypeCount == giftList.height) {
|
|
|
giftList.map((item, index) => {
|
|
|
item.statusString = "已抢光";
|
|
|
});
|
|
|
};
|
|
|
return giftList;
|
|
|
}
|
|
|
|
|
|
function processGoodsItem(goodsItem) {
|
|
|
let imagesUrl = getImageUrlWithWH(goodsItem.goods_images, 75, 100);
|
|
|
goodsItem.goods_images = imagesUrl;
|
|
|
goodsItem.goodColorSizeString = "颜色:" + goodsItem.factory_goods_name + " " + "尺码:" + goodsItem.size_name;
|
|
|
let isShowOldPrice = true;
|
|
|
let priceString = '';
|
|
|
let shoppingProductType = goodsItem.goods_type;
|
|
|
if (shoppingProductType == 'price_gift') {
|
|
|
priceString = goodsItem.last_price;
|
|
|
} else if (shoppingProductType == 'gift') {
|
|
|
priceString = '0.00';
|
|
|
} else {
|
|
|
if (goodsItem.last_vip_price < goodsItem.sales_price) {
|
|
|
priceString = goodsItem.last_vip_price;
|
|
|
} else {
|
|
|
priceString = goodsItem.sales_price;
|
|
|
}
|
|
|
isShowOldPrice = false;
|
|
|
}
|
|
|
priceString = '¥' + toDecimal2(priceString);
|
|
|
let oldPricString = goodsItem.sales_price;
|
|
|
oldPricString = '¥' + toDecimal2(oldPricString);
|
|
|
if (goodsItem.price_down > 0) {
|
|
|
goodsItem.price_down = toDecimal2(goodsItem.price_down);
|
|
|
}
|
|
|
if (parseInt(goodsItem.buy_number) > parseInt(goodsItem.storage_number)) {
|
|
|
goodsItem.bLackStorage = true;
|
|
|
}
|
|
|
if (goodsItem.selected == "Y") {
|
|
|
goodsItem.bSelected = true;
|
|
|
}
|
|
|
goodsItem.priceString = priceString;
|
|
|
goodsItem.oldPricString = oldPricString;
|
|
|
goodsItem.isShowOldPrice = isShowOldPrice;
|
|
|
var unique_identifier = goodsItem.product_sku + goodsItem.batch_no.toString() + goodsItem.bundle_activity_id.toString();
|
|
|
goodsItem.unique_identifier = unique_identifier;
|
|
|
return goodsItem;
|
|
|
}
|
|
|
|
|
|
function isGoodsSelectAll(goodsList) {
|
|
|
if (!goodsList || !goodsList.length) {
|
|
|
return false;
|
|
|
}
|
|
|
let allGoodsSelect = true;
|
|
|
goodsList.map((goodsItem, index) => {
|
|
|
if (!goodsItem.bLackStorage && goodsItem.goods_type !== 'gift') {
|
|
|
if (goodsItem.selected !== 'Y') {
|
|
|
allGoodsSelect = false;
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
return allGoodsSelect;
|
|
|
}
|
|
|
|
|
|
function processPromotionItem(promotionItem, isSubPromotion) {
|
|
|
let promotionStatusString = "";
|
|
|
if (promotionItem.status == 0) {
|
|
|
promotionStatusString = "去凑单";
|
|
|
} else if (promotionItem.status == 10) {
|
|
|
if (promotionItem.promotion_type == "Gift") {//Cashreduce,Degressdiscount,Cheapestfree,Discount,Gift,Needpaygift,SpecifiedAmount
|
|
|
promotionStatusString = "领赠品";
|
|
|
} else if (promotionItem.promotion_type == "Needpaygift") {
|
|
|
promotionStatusString = "去换购";
|
|
|
}
|
|
|
} else if (promotionItem.status == 20) {
|
|
|
promotionStatusString = "已抢光";
|
|
|
} else if (promotionItem.status == 30) {
|
|
|
promotionStatusString = "更换";
|
|
|
}
|
|
|
if (promotionStatusString == "已抢光") {
|
|
|
promotionItem.seldoutStyle = true;
|
|
|
}
|
|
|
promotionItem.statuString = promotionStatusString;
|
|
|
if (isSubPromotion) {
|
|
|
let typeString = '';
|
|
|
if (promotionItem.promotion_type == "Gift") {
|
|
|
typeString = '赠品';
|
|
|
} else if (promotionItem.promotion_type == 'Needpaygift') {
|
|
|
typeString = '加价购';
|
|
|
} else if (promotionItem.promotion_type == 'Cashreduce') {
|
|
|
typeString = '满减';
|
|
|
} else {
|
|
|
typeString = '折扣';
|
|
|
}
|
|
|
promotionItem.typeString = typeString;
|
|
|
}
|
|
|
return promotionItem;
|
|
|
}
|
|
|
|
|
|
function curShoppingCartDataAddExpandedFlag(curShoppingCartData) {
|
|
|
let goodsList = curShoppingCartData.goods_list;
|
|
|
let validGoodsList = [];
|
|
|
if (goodsList) {
|
|
|
goodsList.map((goodsItem, index) => {
|
|
|
goodsItem = processGoodsItem(goodsItem);
|
|
|
validGoodsList.push(goodsItem);
|
|
|
})
|
|
|
}
|
|
|
curShoppingCartData.goods_list = goodsList;
|
|
|
|
|
|
let goodsPoolList = curShoppingCartData.goods_pool_list;
|
|
|
if (goodsPoolList) {
|
|
|
goodsPoolList.map((item, index) => {
|
|
|
|
|
|
if (item.pool_batch_no && item.pool_id) {
|
|
|
//套餐商品参数转换
|
|
|
item.int_pool_buy_number = parseInt(item.pool_buy_number);
|
|
|
item.int_pool_storage_number = parseInt(item.pool_storage_number);
|
|
|
}
|
|
|
|
|
|
let goodsPoolGoodsList = item.goods_list;
|
|
|
if (goodsPoolGoodsList) {
|
|
|
goodsPoolGoodsList.map((goodsItem, index) => {
|
|
|
goodsItem = processGoodsItem(goodsItem);
|
|
|
validGoodsList.push(goodsItem);
|
|
|
})
|
|
|
}
|
|
|
item.isPromotionExpanded = false;
|
|
|
let promotionList = item.promotion_list;
|
|
|
if (promotionList) {
|
|
|
promotionList.map((promotionItem, promotionIndex) => {
|
|
|
promotionItem = processPromotionItem(promotionItem, false);
|
|
|
})
|
|
|
item.promotion_list = promotionList;
|
|
|
}
|
|
|
|
|
|
let subPool = item.sub_pool;
|
|
|
if (subPool) {
|
|
|
subPool.map((subPoolItem, index) => {
|
|
|
let promotionList = subPoolItem.promotion_list;
|
|
|
if (promotionList) {
|
|
|
promotionList.map((promotionItem, promotionIndex) => {
|
|
|
promotionItem = processPromotionItem(promotionItem, true);
|
|
|
})
|
|
|
subPoolItem.promotion_list = promotionList;
|
|
|
}
|
|
|
let subPoolGoodsList = subPoolItem.goods_list;
|
|
|
if (subPoolGoodsList) {
|
|
|
subPoolGoodsList.map((subPoolGoodsItem, index) => {
|
|
|
subPoolGoodsItem = processGoodsItem(subPoolGoodsItem);
|
|
|
validGoodsList.push(subPoolGoodsItem);
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
item.sub_pool = subPool;
|
|
|
});
|
|
|
}
|
|
|
curShoppingCartData.validGoodsList = validGoodsList;
|
|
|
curShoppingCartData.isValidGoodsSelectAll = isGoodsSelectAll(validGoodsList);
|
|
|
|
|
|
// let newgPriceGiftList = [];
|
|
|
let gPriceGiftList = curShoppingCartData.g_price_gift_list;
|
|
|
// if (gPriceGiftList && gPriceGiftList.length && canShowGiftEntrance(gPriceGiftList)) {
|
|
|
// newgPriceGiftList = processGiftOrPriceGift(gPriceGiftList, false);
|
|
|
// }
|
|
|
// curShoppingCartData.g_price_gift_list = newgPriceGiftList;
|
|
|
|
|
|
// let newgGiftList = [];
|
|
|
let gGiftList = curShoppingCartData.g_gift_list;
|
|
|
// if (gGiftList && gGiftList.length && canShowGiftEntrance(gGiftList)) {
|
|
|
// newgGiftList = processGiftOrPriceGift(gGiftList, true);
|
|
|
// }
|
|
|
// curShoppingCartData.g_gift_list = newgGiftList;
|
|
|
|
|
|
|
|
|
let gGiftAndPriceGiftList = [];
|
|
|
if (gGiftList && gGiftList.length) {
|
|
|
let giftItem = transformToGiftModelWithGiftList(gGiftList,true);
|
|
|
if (giftItem.canShow) {
|
|
|
gGiftAndPriceGiftList.push(giftItem);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (gPriceGiftList && gPriceGiftList.length) {
|
|
|
let priceGiftItem = transformToGiftModelWithGiftList(gPriceGiftList,false);
|
|
|
if (priceGiftItem.canShow) {
|
|
|
gGiftAndPriceGiftList.push(priceGiftItem);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// if (newgPriceGiftList.length && newgGiftList.length) {
|
|
|
// gGiftAndPriceGiftList = [newgGiftList[0], newgPriceGiftList[0]];
|
|
|
// } else if (newgPriceGiftList.length) {
|
|
|
// gGiftAndPriceGiftList = [newgPriceGiftList[0]];
|
|
|
// } else if (newgGiftList.length) {
|
|
|
// gGiftAndPriceGiftList = [newgGiftList[0]];
|
|
|
// }
|
|
|
curShoppingCartData.gGiftAndPriceGiftList = gGiftAndPriceGiftList;
|
|
|
|
|
|
|
|
|
//失效商品
|
|
|
let offShelvesGoodsList = curShoppingCartData.off_shelves_goods_list;
|
|
|
let soldOutGoodsList = curShoppingCartData.sold_out_goods_list;
|
|
|
let invalidGoodsList = [...offShelvesGoodsList, ...soldOutGoodsList];
|
|
|
if (invalidGoodsList && invalidGoodsList.length) {
|
|
|
invalidGoodsList.map((invalidGoodsItem, index) => {
|
|
|
let imagesUrl = getImageUrlWithWH(invalidGoodsItem.goods_images, 75, 100);;
|
|
|
invalidGoodsItem.goods_images = imagesUrl;
|
|
|
})
|
|
|
}
|
|
|
let last_order_amount = curShoppingCartData.shopping_cart_data.last_order_amount;
|
|
|
last_order_amount = '¥' + toDecimal2(last_order_amount);
|
|
|
curShoppingCartData.shopping_cart_data.last_order_amount = last_order_amount;
|
|
|
|
|
|
curShoppingCartData.invalidGoodsList = invalidGoodsList;
|
|
|
|
|
|
let has_product_in_shop_cart = (curShoppingCartData.goods_list.length + curShoppingCartData.goods_pool_list.length + curShoppingCartData.off_shelves_goods_list.length + curShoppingCartData.sold_out_goods_list.length > 0);
|
|
|
curShoppingCartData.has_product_in_shop_cart = has_product_in_shop_cart;
|
|
|
|
|
|
return curShoppingCartData;
|
|
|
}
|
|
|
|
|
|
function canShowGiftEntrance(items) {
|
|
|
let result = false;
|
|
|
|
|
|
let statusCount_10 = 0;//已满足
|
|
|
let statusCount_20 = 0;//已售罄
|
|
|
items.map((item, index) => {
|
|
|
if (item.status == 10) {
|
|
|
statusCount_10++;
|
|
|
} else if (item.status == 20) {
|
|
|
statusCount_20++;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
if (statusCount_10 > 0 || (items.length > 0 && statusCount_20 == items.length)) {
|
|
|
result = true;
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
function transformToGiftModelWithGiftList(list,isGift) {
|
|
|
let resultItem = {};
|
|
|
resultItem.isGift = isGift;
|
|
|
resultItem.title = isGift ? '赠品' : '全场加价购';
|
|
|
let promotion_ids = '';
|
|
|
list.map((item, index) => {
|
|
|
if (item.status == 10) {
|
|
|
promotion_ids = promotion_ids + (promotion_ids.length == 0 ? '' : ',') + item.promotion_id;
|
|
|
}
|
|
|
});
|
|
|
resultItem.promotion_ids = promotion_ids;
|
|
|
if (promotion_ids.length > 0) {
|
|
|
if (isGift) {
|
|
|
resultItem.statusString = '领赠品';
|
|
|
} else {
|
|
|
resultItem.statusString = '去换购';
|
|
|
}
|
|
|
resultItem.showArrow = true;
|
|
|
} else {
|
|
|
resultItem.statusString = '已抢光';
|
|
|
resultItem.showArrow = false;
|
|
|
}
|
|
|
|
|
|
resultItem.canShow = canShowGiftEntrance(list);
|
|
|
return resultItem;
|
|
|
}
|
|
|
|
|
|
function curPageDataAllSelectWhenEditing(curShoppingCartData,allSelect) {
|
|
|
let goodsList = curShoppingCartData.goods_list;
|
|
|
let validGoodsList = [];
|
|
|
if (goodsList) {
|
|
|
goodsList.map((goodsItem, index) => {
|
|
|
goodsItem = processGoodsItem(goodsItem);
|
|
|
if(allSelect){
|
|
|
goodsItem.selected = 'Y';
|
|
|
goodsItem.bSelected = true;
|
|
|
}else {
|
|
|
goodsItem.selected = 'N';
|
|
|
goodsItem.bSelected = false;
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
let goodsPoolList = curShoppingCartData.goods_pool_list;
|
|
|
if (goodsPoolList) {
|
|
|
goodsPoolList.map((item, index) => {
|
|
|
|
|
|
if (item.pool_type == '3' && item.pool_batch_no) {
|
|
|
item.selected = allSelect ? 'Y' : 'N';
|
|
|
}
|
|
|
|
|
|
let goodsPoolGoodsList = item.goods_list;
|
|
|
if (goodsPoolGoodsList) {
|
|
|
goodsPoolGoodsList.map((goodsItem, index) => {
|
|
|
goodsItem = processGoodsItem(goodsItem);
|
|
|
if (allSelect) {
|
|
|
goodsItem.selected = 'Y';
|
|
|
goodsItem.bSelected = true;
|
|
|
} else {
|
|
|
goodsItem.selected = 'N';
|
|
|
goodsItem.bSelected = false;
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
let subPool = item.sub_pool;
|
|
|
if (subPool) {
|
|
|
subPool.map((subPoolItem, index) => {
|
|
|
let subPoolGoodsList = subPoolItem.goods_list;
|
|
|
if (subPoolGoodsList) {
|
|
|
subPoolGoodsList.map((subPoolGoodsItem, index) => {
|
|
|
subPoolGoodsItem = processGoodsItem(subPoolGoodsItem);
|
|
|
if (allSelect) {
|
|
|
subPoolGoodsItem.selected = 'Y';
|
|
|
subPoolGoodsItem.bSelected = true;
|
|
|
} else {
|
|
|
subPoolGoodsItem.selected = 'N';
|
|
|
subPoolGoodsItem.bSelected = false;
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
item.sub_pool = subPool;
|
|
|
});
|
|
|
}
|
|
|
return curShoppingCartData;
|
|
|
}
|
|
|
|
|
|
function curPageDataSingleSelectWhenEditing(curShoppingCartData, selectItem) {
|
|
|
let isValidGoodsSelectAll = true;
|
|
|
let goodsList = curShoppingCartData.goods_list;
|
|
|
let validGoodsList = [];
|
|
|
if (goodsList) {
|
|
|
goodsList.map((goodsItem, index) => {
|
|
|
goodsItem = processGoodsItem(goodsItem);
|
|
|
if (goodsItem.unique_identifier == selectItem.unique_identifier) {
|
|
|
if (goodsItem.selected == 'Y'){
|
|
|
goodsItem.selected = 'N';
|
|
|
goodsItem.bSelected = false;
|
|
|
}else {
|
|
|
goodsItem.selected = 'Y';
|
|
|
goodsItem.bSelected = true;
|
|
|
}
|
|
|
}
|
|
|
if (isValidGoodsSelectAll && (!goodsItem.bSelected)) {
|
|
|
isValidGoodsSelectAll = false;
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
curShoppingCartData.goods_list = goodsList;
|
|
|
let goodsPoolList = curShoppingCartData.goods_pool_list;
|
|
|
if (goodsPoolList) {
|
|
|
goodsPoolList.map((item, index) => {
|
|
|
let goodsPoolGoodsList = item.goods_list;
|
|
|
if (goodsPoolGoodsList) {
|
|
|
goodsPoolGoodsList.map((goodsItem, index) => {
|
|
|
goodsItem = processGoodsItem(goodsItem);
|
|
|
if (goodsItem.unique_identifier == selectItem.unique_identifier) {
|
|
|
if (goodsItem.selected == 'Y') {
|
|
|
goodsItem.selected = 'N';
|
|
|
goodsItem.bSelected = false;
|
|
|
} else {
|
|
|
goodsItem.selected = 'Y';
|
|
|
goodsItem.bSelected = true;
|
|
|
}
|
|
|
}
|
|
|
if (isValidGoodsSelectAll && (!goodsItem.bSelected)) {
|
|
|
isValidGoodsSelectAll = false;
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
|
|
|
let subPool = item.sub_pool;
|
|
|
if (subPool) {
|
|
|
subPool.map((subPoolItem, index) => {
|
|
|
let subPoolGoodsList = subPoolItem.goods_list;
|
|
|
if (subPoolGoodsList) {
|
|
|
subPoolGoodsList.map((subPoolGoodsItem, index) => {
|
|
|
subPoolGoodsItem = processGoodsItem(subPoolGoodsItem);
|
|
|
if (subPoolGoodsItem.unique_identifier == selectItem.unique_identifier) {
|
|
|
if (subPoolGoodsItem.selected == 'Y') {
|
|
|
subPoolGoodsItem.selected = 'N';
|
|
|
subPoolGoodsItem.bSelected = false;
|
|
|
} else {
|
|
|
subPoolGoodsItem.selected = 'Y';
|
|
|
subPoolGoodsItem.bSelected = true;
|
|
|
}
|
|
|
}
|
|
|
if (isValidGoodsSelectAll && (!subPoolGoodsItem.bSelected)) {
|
|
|
isValidGoodsSelectAll = false;
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
item.sub_pool = subPool;
|
|
|
});
|
|
|
curShoppingCartData.goods_pool_list = goodsPoolList;
|
|
|
}
|
|
|
curShoppingCartData.isValidGoodsSelectAll = isValidGoodsSelectAll;
|
|
|
return curShoppingCartData;
|
|
|
}
|
|
|
|
|
|
function curPageDataSingleSelectBundleProductWhenEditing(curShoppingCartData, selectBundleItem) {
|
|
|
|
|
|
if (curShoppingCartData.goods_pool_list) {
|
|
|
curShoppingCartData.goods_pool_list.map((item, index) => {
|
|
|
|
|
|
if (item.pool_type == 3 && item.pool_batch_no) {
|
|
|
item.selected = selectBundleItem.selected;
|
|
|
let goodsPoolGoodsList = item.goods_list;
|
|
|
if (goodsPoolGoodsList) {
|
|
|
goodsPoolGoodsList.map((goodsItem, index) => {
|
|
|
goodsItem = processGoodsItem(goodsItem);
|
|
|
if (item.selected == 'Y') {
|
|
|
goodsItem.selected = 'Y';
|
|
|
goodsItem.bSelected = true;
|
|
|
} else {
|
|
|
goodsItem.selected = 'N';
|
|
|
goodsItem.bSelected = false;
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
return curShoppingCartData;
|
|
|
}
|
|
|
|
|
|
function editInfoDicFromGoodsList(goodsList, isSelectAll){
|
|
|
if (!goodsList || !goodsList.length) {
|
|
|
return [];
|
|
|
}
|
|
|
let editInfoDicArray = [];
|
|
|
goodsList.map((goodsItem, index) => {
|
|
|
if (!goodsItem.bLackStorage && goodsItem.goods_type !== 'gift') {
|
|
|
editInfoDicArray.push({
|
|
|
buy_number: goodsItem.buy_number ? goodsItem.buy_number : 0,
|
|
|
goods_type: goodsItem.goods_type ? goodsItem.goods_type : "",
|
|
|
product_sku: goodsItem.product_sku ? goodsItem.product_sku : "",
|
|
|
promotion_id: goodsItem.promotion_id ? goodsItem.promotion_id : 0,
|
|
|
selected: isSelectAll ? "Y" : "N",
|
|
|
activity_id: goodsItem.bundle_activity_id ? goodsItem.bundle_activity_id : 0,
|
|
|
batch_no: goodsItem.batch_no ? goodsItem.batch_no : 0,
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
return editInfoDicArray;
|
|
|
}
|
|
|
|
|
|
function editInfoDicFromBundleItem(bundleItem) {
|
|
|
if (!bundleItem || !bundleItem.goods_list.length) {
|
|
|
return [];
|
|
|
}
|
|
|
let editInfoDicArray = [];
|
|
|
bundleItem.goods_list.map((goodsItem, index) => {
|
|
|
editInfoDicArray.push({
|
|
|
buy_number: goodsItem.buy_number ? goodsItem.buy_number : 0,
|
|
|
goods_type: goodsItem.goods_type ? goodsItem.goods_type : "",
|
|
|
product_sku: goodsItem.product_sku ? goodsItem.product_sku : "",
|
|
|
promotion_id: goodsItem.promotion_id ? goodsItem.promotion_id : 0,
|
|
|
selected: bundleItem.selected,
|
|
|
activity_id: goodsItem.bundle_activity_id ? goodsItem.bundle_activity_id : 0,
|
|
|
batch_no: goodsItem.batch_no ? goodsItem.batch_no : 0,
|
|
|
})
|
|
|
});
|
|
|
return editInfoDicArray;
|
|
|
}
|
|
|
|
|
|
function editInfoSelectedGoodsList(goodsList) {
|
|
|
if (!goodsList || !goodsList.length) {
|
|
|
return [];
|
|
|
}
|
|
|
let editInfoDicArray = [];
|
|
|
goodsList.map((goodsItem, index) => {
|
|
|
if (!goodsItem.bLackStorage && goodsItem.goods_type !== 'gift') {
|
|
|
if (goodsItem.selected == 'Y') {
|
|
|
editInfoDicArray.push({
|
|
|
buy_number: goodsItem.buy_number ? goodsItem.buy_number : 0,
|
|
|
goods_type: goodsItem.goods_type ? goodsItem.goods_type : "",
|
|
|
product_sku: goodsItem.product_sku ? goodsItem.product_sku : "",
|
|
|
promotion_id: goodsItem.promotion_id ? goodsItem.promotion_id : 0,
|
|
|
selected: "Y",
|
|
|
activity_id: goodsItem.bundle_activity_id ? goodsItem.bundle_activity_id : 0,
|
|
|
batch_no: goodsItem.batch_no ? goodsItem.batch_no : 0,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
return editInfoDicArray;
|
|
|
}
|
|
|
|
|
|
function editInfoOfAllGoods(goodsList) {
|
|
|
if (!goodsList || !goodsList.length) {
|
|
|
return [];
|
|
|
}
|
|
|
let editInfoDicArray = [];
|
|
|
goodsList.map((goodsItem, index) => {
|
|
|
editInfoDicArray.push({
|
|
|
buy_number: goodsItem.buy_number ? goodsItem.buy_number:0,
|
|
|
goods_type: goodsItem.goods_type ? goodsItem.goods_type:"",
|
|
|
product_sku: goodsItem.product_sku ? goodsItem.product_sku:"",
|
|
|
promotion_id: goodsItem.promotion_id ? goodsItem.promotion_id:0,
|
|
|
selected: goodsItem.selected,
|
|
|
activity_id: goodsItem.bundle_activity_id ? goodsItem.bundle_activity_id:0,
|
|
|
batch_no: goodsItem.batch_no ? goodsItem.batch_no:0,
|
|
|
})
|
|
|
});
|
|
|
return editInfoDicArray;
|
|
|
}
|
|
|
|
|
|
function hasLackStorageGoodsInList(goodsList) {
|
|
|
if (!goodsList || !goodsList.length) {
|
|
|
return false;
|
|
|
}
|
|
|
let hasLackStorageGoods = false;
|
|
|
goodsList.map((goodsItem, index) => {
|
|
|
if (goodsItem.bLackStorage) {
|
|
|
hasLackStorageGoods = true;
|
|
|
}
|
|
|
});
|
|
|
return hasLackStorageGoods;
|
|
|
}
|
|
|
|
|
|
module.exports = {
|
|
|
curShoppingCartDataAddExpandedFlag,
|
|
|
editInfoDicFromGoodsList,
|
|
|
hasLackStorageGoodsInList,
|
|
|
curPageDataAllSelectWhenEditing,
|
|
|
curPageDataSingleSelectWhenEditing,
|
|
|
editInfoOfAllGoods,
|
|
|
editInfoSelectedGoodsList,
|
|
|
curPageDataSingleSelectBundleProductWhenEditing,
|
|
|
editInfoDicFromBundleItem,
|
|
|
} |
|
|
\ No newline at end of file |