getShopInfo-to-shopModel
Showing
3 changed files
with
33 additions
and
5 deletions
@@ -37,9 +37,9 @@ const shop = { | @@ -37,9 +37,9 @@ const shop = { | ||
37 | 37 | ||
38 | return co(function*() { | 38 | return co(function*() { |
39 | if (shopId) { | 39 | if (shopId) { |
40 | - let shopInfo = (yield listModel.getShopInfo(shopId, uid)) || {}; | 40 | + let shopInfo = (yield shopModel.getShopInfo(shopId, uid)) || {}; |
41 | 41 | ||
42 | - if (shopInfo && shopInfo.is_red_shop === '1') { | 42 | + if (shopInfo && shopInfo.is_red_shop === 1) { |
43 | shopInfo.shopId = _.get(shopInfo, 'shops_id', ''); | 43 | shopInfo.shopId = _.get(shopInfo, 'shops_id', ''); |
44 | } | 44 | } |
45 | req.shopInfo = shopInfo; | 45 | req.shopInfo = shopInfo; |
@@ -47,7 +47,7 @@ const shop = { | @@ -47,7 +47,7 @@ const shop = { | ||
47 | let domainInfo = (yield listModel.getBrandLogoByDomain(domain)) || {}; // 通过域名查询店铺类型,或者品牌信息 | 47 | let domainInfo = (yield listModel.getBrandLogoByDomain(domain)) || {}; // 通过域名查询店铺类型,或者品牌信息 |
48 | 48 | ||
49 | if (domainInfo.shopId && domainInfo.type === '2') { // 红人店铺 | 49 | if (domainInfo.shopId && domainInfo.type === '2') { // 红人店铺 |
50 | - let shopInfo = yield listModel.getShopInfo(domainInfo.shopId, uid); | 50 | + let shopInfo = yield shopModel.getShopInfo(domainInfo.shopId, uid); |
51 | 51 | ||
52 | _.assign(req.shopInfo, domainInfo, shopInfo); | 52 | _.assign(req.shopInfo, domainInfo, shopInfo); |
53 | } else { // 品牌 | 53 | } else { // 品牌 |
@@ -997,7 +997,6 @@ module.exports = { | @@ -997,7 +997,6 @@ module.exports = { | ||
997 | getShopFav, | 997 | getShopFav, |
998 | searchProductBySkn, | 998 | searchProductBySkn, |
999 | getBrandFavStatus, | 999 | getBrandFavStatus, |
1000 | - getShopInfo: _getShopInfo, | ||
1001 | getShopDecorator: _getShopDecorator, | 1000 | getShopDecorator: _getShopDecorator, |
1002 | getShopCategoryApi: _getShopCategory, | 1001 | getShopCategoryApi: _getShopCategory, |
1003 | formShopData: _formShopData, | 1002 | formShopData: _formShopData, |
@@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
5 | const _ = require('lodash'); | 5 | const _ = require('lodash'); |
6 | const helpers = global.yoho.helpers; | 6 | const helpers = global.yoho.helpers; |
7 | const api = global.yoho.API; | 7 | const api = global.yoho.API; |
8 | +const stringProcess = require(`${global.utils}/string-process`); | ||
8 | 9 | ||
9 | /** | 10 | /** |
10 | * 店铺品牌列表 | 11 | * 店铺品牌列表 |
@@ -30,6 +31,34 @@ const getShopBrands = (shopId) => { | @@ -30,6 +31,34 @@ const getShopBrands = (shopId) => { | ||
30 | }); | 31 | }); |
31 | }; | 32 | }; |
32 | 33 | ||
34 | +/** | ||
35 | + * 获取店铺信息 | ||
36 | + * @param {int} shopId 店铺id | ||
37 | + * @param {int} uid 用户id 判断用户是否收藏店铺 | ||
38 | + * @return array | ||
39 | + */ | ||
40 | +const getShopInfo = (shopId, uid) => { | ||
41 | + let finalParams = { | ||
42 | + method: 'app.shops.getIntro', | ||
43 | + shop_id: shopId, | ||
44 | + }; | ||
45 | + | ||
46 | + if (!shopId || !stringProcess.isNumeric(shopId)) { | ||
47 | + return Promise.resolve({}); | ||
48 | + } | ||
49 | + | ||
50 | + if (uid && uid !== 'undefined') { | ||
51 | + Object.assign(finalParams, { | ||
52 | + uid: uid | ||
53 | + }); | ||
54 | + } | ||
55 | + | ||
56 | + return api.get('', finalParams, {code: 200}).then((result) => { | ||
57 | + return result && result.data; | ||
58 | + }); | ||
59 | +}; | ||
60 | + | ||
33 | module.exports = { | 61 | module.exports = { |
34 | - getShopBrands | 62 | + getShopBrands, |
63 | + getShopInfo | ||
35 | }; | 64 | }; |
-
Please register or login to post a comment