...
|
...
|
@@ -526,6 +526,7 @@ const getBaseShopData = (params, shopInfo) => { |
|
|
const getShopData = (req, shopId, uid, isApp) => {
|
|
|
let shopData = {};
|
|
|
let channel = req.yoho.channel;
|
|
|
let brandData = [];
|
|
|
|
|
|
return _getShopInfo(shopId, uid).then(shopInfoResult => {
|
|
|
|
...
|
...
|
@@ -536,56 +537,73 @@ const getShopData = (req, shopId, uid, isApp) => { |
|
|
};
|
|
|
}
|
|
|
|
|
|
return Promise.all([
|
|
|
_getShopDecorator(shopId),
|
|
|
searchModel.getFilterSearchData({
|
|
|
shop_id: shopId,
|
|
|
channel: channel
|
|
|
}),
|
|
|
_shopCouponsList(shopId, uid)
|
|
|
]).then((result) => {
|
|
|
shopData = {
|
|
|
decorator: result[0], // 店铺装修资源数据
|
|
|
shopInfo: shopInfoResult // 店铺信息
|
|
|
};
|
|
|
return _getShopDecorator(shopId).then(shopDeco => {
|
|
|
return shopDeco;
|
|
|
}).then(shopDeco => {
|
|
|
let brandBrowseData;
|
|
|
|
|
|
// 取店铺下的brand, id
|
|
|
_.forEach(shopDeco.list, floor => {
|
|
|
if (floor.resource_name === 'brandBrowse') {
|
|
|
brandBrowseData = JSON.parse(floor.resource_data);
|
|
|
_.forEach(brandBrowseData, brandBrowse => {
|
|
|
brandData.push(brandBrowse.id);
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/* 获取一次分类和商品数据 */
|
|
|
let shopFilterSearchData = {
|
|
|
filter: [],
|
|
|
goods: []
|
|
|
};
|
|
|
return Promise.all([
|
|
|
searchModel.getFilterSearchData({
|
|
|
shop_id: shopId,
|
|
|
brand: brandData.join(','),
|
|
|
order: '0',
|
|
|
channel: channel
|
|
|
}),
|
|
|
_shopCouponsList(shopId, uid)
|
|
|
]).then((result) => {
|
|
|
shopData = {
|
|
|
decorator: shopDeco, // 店铺装修资源数据
|
|
|
shopInfo: shopInfoResult // 店铺信息
|
|
|
};
|
|
|
|
|
|
if (result[1]) {
|
|
|
shopFilterSearchData.filter = productProcess.processFilter(result[1].filter || []);
|
|
|
shopFilterSearchData.goods = productProcess.processProductList(result[1].product_list || [], {isApp: isApp});
|
|
|
}
|
|
|
/* 获取一次分类和商品数据 */
|
|
|
let shopFilterSearchData = {
|
|
|
filter: [],
|
|
|
goods: []
|
|
|
};
|
|
|
|
|
|
/* 店鋪優惠券 */
|
|
|
let shopCoupons = result[2] || [];
|
|
|
|
|
|
// 店铺分类
|
|
|
return _getShopCategory(shopId, channel).then(shopCategory => {
|
|
|
|
|
|
shopData = _.assign({
|
|
|
shopCategory: shopCategory
|
|
|
}, shopData);
|
|
|
|
|
|
// noinspection JSCheckFunctionSignatures
|
|
|
return Object.assign(
|
|
|
_formShopData(shopData, shopId, isApp),
|
|
|
shopFilterSearchData,
|
|
|
{
|
|
|
shopId: shopId,
|
|
|
uid: uid ? crypto.encryption('', uid + '') : '',
|
|
|
coverChannel: channel,
|
|
|
shopCoupons: shopCoupons,
|
|
|
shopCouponsOne: shopCoupons.length === 1
|
|
|
}
|
|
|
);
|
|
|
if (result[0]) {
|
|
|
shopFilterSearchData.filter = productProcess.processFilter(result[0].filter || []);
|
|
|
shopFilterSearchData.goods = productProcess.processProductList(result[0].product_list || [], {isApp: isApp});
|
|
|
}
|
|
|
|
|
|
/* 店铺优惠券 */
|
|
|
let shopCoupons = result[1] || [];
|
|
|
|
|
|
// 店铺分类
|
|
|
return _getShopCategory(shopId, channel).then(shopCategory => {
|
|
|
|
|
|
shopData = _.assign({
|
|
|
shopCategory: shopCategory
|
|
|
}, shopData);
|
|
|
|
|
|
// noinspection JSCheckFunctionSignatures
|
|
|
return Object.assign(
|
|
|
_formShopData(shopData, shopId, isApp),
|
|
|
shopFilterSearchData,
|
|
|
{
|
|
|
shopId: shopId,
|
|
|
uid: uid ? crypto.encryption('', uid + '') : '',
|
|
|
coverChannel: channel,
|
|
|
shopCoupons: shopCoupons,
|
|
|
shopCouponsOne: shopCoupons.length === 1
|
|
|
}
|
|
|
);
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
/**
|
...
|
...
|
|