Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
周少峰
8 years ago
Commit
9129ec44efc7625a10fd201c3fcbc7a8aa0a0133
2 parents
3883eeb0
62715ec0
Merge branch 'hotfix/add-cache' into gray
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
17 deletions
apps/product/models/detail-product-api.js
apps/product/models/detail-service.js
apps/product/models/detail-product-api.js
View file @
9129ec4
...
...
@@ -10,11 +10,13 @@ const redis = global.yoho.redis;
const
cache
=
global
.
yoho
.
cache
;
const
logger
=
global
.
yoho
.
logger
;
const
uuid
=
require
(
'uuid'
);
const
helpers
=
global
.
yoho
.
helpers
;
const
_
=
require
(
'lodash'
);
function
_cacheGet
(
key
)
{
return
cache
.
get
(
key
).
then
((
data
)
=>
{
if
(
data
)
{
return
data
;
return
JSON
.
parse
(
data
)
;
}
return
Promise
.
reject
();
...
...
@@ -195,10 +197,25 @@ const getLikeAsync = (skn, limit) => {
},
{
cache
:
86400
});
};
// 返回6条推荐关键词页面
function
getKeywordsInfo
(
keywords
)
{
let
res
=
[];
_
.
forEach
(
_
.
slice
(
_
.
shuffle
(
keywords
),
0
,
12
),
val
=>
{
res
.
push
({
url
:
helpers
.
urlFormat
(
`
/
chanpin
/
$
{
val
.
id
}.
html
`
),
keyword
:
val
.
keyword
});
});
return
res
;
}
// 根据small_sort从redis获取分类下的关键词
function
_getRecommendKeywords
(
smallSort
)
{
return
redis
.
all
([[
'get'
,
`
global
:
yoho
:
seo
:
keywords
:
sortId
:
$
{
smallSort
}:
page
:
1
`
]]).
then
(
res
=>
{
return
res
[
0
];
}).
then
(
result
=>
{
return
getKeywordsInfo
(
JSON
.
parse
(
result
||
'[]'
));
});
}
...
...
apps/product/models/detail-service.js
View file @
9129ec4
...
...
@@ -36,7 +36,6 @@ const BUNDLE_PRODUCE = 2; // 量贩
const
BUNDLE_PACKAGE
=
1
;
// 套餐
const
tdk
=
require
(
'../../../utils/getTDK'
);
const
productProcess
=
require
(
'../../../utils/product-process'
);
const
Helpers
=
global
.
yoho
.
helpers
;
const
_getProductAdditionInfoAsync
=
(
data
)
=>
{
return
co
(
function
*
()
{
...
...
@@ -1010,19 +1009,6 @@ const _getIntroInfo = (productSkn, maxSortId, additionalData)=> {
return
result
;
};
// 返回6条推荐关键词页面
const
getKeywordsInfo
=
(
keywords
)
=>
{
let
res
=
[];
_
.
forEach
(
_
.
slice
(
_
.
shuffle
(
keywords
),
0
,
12
),
val
=>
{
res
.
push
({
url
:
Helpers
.
urlFormat
(
`
/
chanpin
/
$
{
val
.
id
}.
html
`
),
keyword
:
val
.
keyword
});
});
return
res
;
};
/**
* 获取seo信息
*
...
...
@@ -1194,13 +1180,12 @@ const _detailDataPkg = (origin, uid, vipLevel, cookies) => {
let
coupon
=
requestData
.
coupon
;
let
limitedInfo
=
requestData
.
limited
;
let
bundle
=
requestData
.
bundle
;
let
recommendKeywords
=
requestData
.
recommendKeywords
?
JSON
.
parse
(
requestData
.
recommendKeywords
)
:
[];
// 处理相似商品
result
.
alike
=
productProcess
.
processProductList
(
_
.
get
(
requestData
,
'alike.data.product_list'
,
''
));
// 推荐关键词页面
result
.
recommendKeywords
=
getKeywordsInfo
(
recommendKeywords
)
;
result
.
recommendKeywords
=
requestData
.
recommendKeywords
;
// 处理店铺推荐
result
.
shopRecommend
=
productProcess
.
processProductList
(
...
...
Please
register
or
login
to post a comment