...
|
...
|
@@ -1629,53 +1629,60 @@ const recommendAsync = (skn, page, limit) => { |
|
|
})();
|
|
|
};
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取套餐
|
|
|
* 处理单个套餐
|
|
|
*/
|
|
|
const getPackage = (skn) => {
|
|
|
const isPackage = (type) => type === BUNDLE_PACKAGE;
|
|
|
function handlePackage(pack) {
|
|
|
const isPackage = type => type === BUNDLE_PACKAGE;
|
|
|
|
|
|
return co(function * () {
|
|
|
let data = yield productAPI.getBundleAsync(skn);
|
|
|
let resData = {code: data.code},
|
|
|
packageList = [];
|
|
|
|
|
|
if (data.code === 200 && !_.isEmpty(data.data) && isPackage(_.get(data, 'data.bundleInfo.discountType'))) {
|
|
|
let bundleInfo = data.data.bundleInfo || {};
|
|
|
let productList = data.data.productList || {};
|
|
|
|
|
|
resData.data = {
|
|
|
bundleId: bundleInfo.bundleId,
|
|
|
salesPrice: bundleInfo.salesPriceStr,
|
|
|
pkgPrice: bundleInfo.discountPriceStr,
|
|
|
savePrice: bundleInfo.subPrice
|
|
|
};
|
|
|
_.forEach(productList, function(value) {
|
|
|
// sku商品信息
|
|
|
let skuData = _getSkuDataByProductBaseInfo(value);
|
|
|
|
|
|
let pkgData = {
|
|
|
skn: value.product_skn,
|
|
|
url: helpers.urlFormat(url.parse(value.product_url).pathname, null, 'item'),
|
|
|
src: value.default_images,
|
|
|
productName: value.product_name,
|
|
|
productPrice: value.format_sales_price,
|
|
|
colors: skuData.skuGoods
|
|
|
};
|
|
|
let bundleInfo = pack.bundleInfo || {};
|
|
|
let productList = pack.productList || [];
|
|
|
|
|
|
packageList.push(pkgData);
|
|
|
});
|
|
|
if (!isPackage(bundleInfo.discountType)) {
|
|
|
return {};
|
|
|
}
|
|
|
|
|
|
resData.data.packageData = packageList;
|
|
|
} else {
|
|
|
resData.code = 400;
|
|
|
resData.message = '没有数据';
|
|
|
}
|
|
|
let item = {
|
|
|
name: bundleInfo.tabName,
|
|
|
bundleId: bundleInfo.bundleId,
|
|
|
salesPrice: bundleInfo.salesPriceStr,
|
|
|
pkgPrice: bundleInfo.discountPriceStr,
|
|
|
savePrice: bundleInfo.subPrice
|
|
|
};
|
|
|
|
|
|
return resData;
|
|
|
})();
|
|
|
};
|
|
|
item.productList = _.map(productList, function(value) {
|
|
|
// sku商品信息
|
|
|
let skuData = _getSkuDataByProductBaseInfo(value);
|
|
|
|
|
|
return {
|
|
|
skn: value.product_skn,
|
|
|
url: helpers.urlFormat(url.parse(value.product_url).pathname, null, 'item'),
|
|
|
src: value.default_images,
|
|
|
productName: value.product_name,
|
|
|
productPrice: value.format_sales_price,
|
|
|
colors: skuData.skuGoods
|
|
|
};
|
|
|
});
|
|
|
|
|
|
return item;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取套餐
|
|
|
*/
|
|
|
const getPackage = co(function * (skn) {
|
|
|
let reqData = yield productAPI.getBundleAsync(skn);
|
|
|
let resData = {code: reqData.code};
|
|
|
|
|
|
if (reqData.code === 200 && !_.isEmpty(reqData.data)) {
|
|
|
resData.data = _.map(reqData.data, handlePackage);
|
|
|
} else {
|
|
|
resData.code = 400;
|
|
|
resData.message = '没有数据';
|
|
|
}
|
|
|
|
|
|
return resData;
|
|
|
});
|
|
|
|
|
|
|
|
|
module.exports = {
|
...
|
...
|
|