|
@@ -7,7 +7,9 @@ const commentModel = require('./consult-comment'); |
|
@@ -7,7 +7,9 @@ const commentModel = require('./consult-comment'); |
7
|
const bundle = require('./bundle');
|
7
|
const bundle = require('./bundle');
|
8
|
const utils = '../../../utils';
|
8
|
const utils = '../../../utils';
|
9
|
const detailProcess = require(`${utils}/detail-process`);
|
9
|
const detailProcess = require(`${utils}/detail-process`);
|
|
|
10
|
+const redis = require(`${utils}/redis`);
|
10
|
const api = global.yoho.API;
|
11
|
const api = global.yoho.API;
|
|
|
12
|
+const helpers = global.yoho.helpers; // eslint-disable-line
|
11
|
|
13
|
|
12
|
const newDetail = {
|
14
|
const newDetail = {
|
13
|
/**
|
15
|
/**
|
|
@@ -42,7 +44,35 @@ const newDetail = { |
|
@@ -42,7 +44,35 @@ const newDetail = { |
42
|
result.data.goods_id = data.goodsId;
|
44
|
result.data.goods_id = data.goodsId;
|
43
|
result.data.shopId = _.get(result, 'data.shop_id', null);
|
45
|
result.data.shopId = _.get(result, 'data.shop_id', null);
|
44
|
|
46
|
|
45
|
- return detailProcess.prodessDetailData(result.data);
|
47
|
+ let finalResult = detailProcess.prodessDetailData(result.data);
|
|
|
48
|
+ let smallSort = _.get(result, 'data.smallSortId');
|
|
|
49
|
+
|
|
|
50
|
+ if (!smallSort) {
|
|
|
51
|
+ return finalResult;
|
|
|
52
|
+ }
|
|
|
53
|
+
|
|
|
54
|
+ return this.getRecomdKeywords(smallSort).then(res => {
|
|
|
55
|
+ let recomdKeywords = [];
|
|
|
56
|
+
|
|
|
57
|
+ res = res ? JSON.parse(res) : [];
|
|
|
58
|
+
|
|
|
59
|
+ _.forEach(_.slice(_.shuffle(res), 0, 12), val => {
|
|
|
60
|
+ recomdKeywords.push({
|
|
|
61
|
+ url: Helpers.urlFormat(`/chanpin/${val.id}.html`), // eslint-disable-line
|
|
|
62
|
+ keyword: val.keyword
|
|
|
63
|
+ });
|
|
|
64
|
+ });
|
|
|
65
|
+
|
|
|
66
|
+ finalResult.recommendKeywords = recomdKeywords;
|
|
|
67
|
+
|
|
|
68
|
+ return finalResult;
|
|
|
69
|
+ });
|
|
|
70
|
+ });
|
|
|
71
|
+ },
|
|
|
72
|
+
|
|
|
73
|
+ getRecomdKeywords(smallSort) {
|
|
|
74
|
+ return redis.all([['get', `global:yoho:seo:keywords:sortId:${smallSort}:page:1`]]).then(res => {
|
|
|
75
|
+ return res[0];
|
46
|
});
|
76
|
});
|
47
|
},
|
77
|
},
|
48
|
|
78
|
|