Authored by 郭成尧

getShopInfo-to-shopModel

... ... @@ -37,9 +37,9 @@ const shop = {
return co(function*() {
if (shopId) {
let shopInfo = (yield listModel.getShopInfo(shopId, uid)) || {};
let shopInfo = (yield shopModel.getShopInfo(shopId, uid)) || {};
if (shopInfo && shopInfo.is_red_shop === '1') {
if (shopInfo && shopInfo.is_red_shop === 1) {
shopInfo.shopId = _.get(shopInfo, 'shops_id', '');
}
req.shopInfo = shopInfo;
... ... @@ -47,7 +47,7 @@ const shop = {
let domainInfo = (yield listModel.getBrandLogoByDomain(domain)) || {}; // 通过域名查询店铺类型,或者品牌信息
if (domainInfo.shopId && domainInfo.type === '2') { // 红人店铺
let shopInfo = yield listModel.getShopInfo(domainInfo.shopId, uid);
let shopInfo = yield shopModel.getShopInfo(domainInfo.shopId, uid);
_.assign(req.shopInfo, domainInfo, shopInfo);
} else { // 品牌
... ...
... ... @@ -997,7 +997,6 @@ module.exports = {
getShopFav,
searchProductBySkn,
getBrandFavStatus,
getShopInfo: _getShopInfo,
getShopDecorator: _getShopDecorator,
getShopCategoryApi: _getShopCategory,
formShopData: _formShopData,
... ...
... ... @@ -5,6 +5,7 @@
const _ = require('lodash');
const helpers = global.yoho.helpers;
const api = global.yoho.API;
const stringProcess = require(`${global.utils}/string-process`);
/**
* 店铺品牌列表
... ... @@ -30,6 +31,34 @@ const getShopBrands = (shopId) => {
});
};
/**
* 获取店铺信息
* @param {int} shopId 店铺id
* @param {int} uid 用户id 判断用户是否收藏店铺
* @return array
*/
const getShopInfo = (shopId, uid) => {
let finalParams = {
method: 'app.shops.getIntro',
shop_id: shopId,
};
if (!shopId || !stringProcess.isNumeric(shopId)) {
return Promise.resolve({});
}
if (uid && uid !== 'undefined') {
Object.assign(finalParams, {
uid: uid
});
}
return api.get('', finalParams, {code: 200}).then((result) => {
return result && result.data;
});
};
module.exports = {
getShopBrands
getShopBrands,
getShopInfo
};
... ...