...
|
...
|
@@ -8,11 +8,12 @@ const config = global.yoho.config; |
|
|
const redis = global.yoho.redis;
|
|
|
const cache = global.yoho.cache;
|
|
|
const logger = global.yoho.logger;
|
|
|
const helpers = global.yoho.helpers;
|
|
|
const _ = require('lodash');
|
|
|
|
|
|
const SearchServiceModel = require('./search-api');
|
|
|
const GuangServiceModel = require('../../guang/models/guang-service');
|
|
|
const productProcess = require('../../../utils/product-process');
|
|
|
const _ = require('lodash');
|
|
|
const uuid = require('uuid');
|
|
|
|
|
|
function _cacheGet(key) {
|
...
|
...
|
@@ -34,7 +35,7 @@ function _cacheSave(key, value) { |
|
|
}
|
|
|
|
|
|
function _cached(fn, ctx) {
|
|
|
const pre = (fn.name || 'random:' + uuid.v4()) + ':';
|
|
|
const pre = 'recommend-cache:' + (fn.name || 'random:' + uuid.v4()) + ':';
|
|
|
|
|
|
return function() {
|
|
|
const args = Array.prototype.slice.call(arguments);
|
...
|
...
|
@@ -252,7 +253,22 @@ module.exports = class extends global.yoho.BaseModel { |
|
|
getRecommendKeywords(smallSort) {
|
|
|
return redis.all([['get', `global:yoho:seo:keywords:sortId:${smallSort}:page:1`]]).then(res => {
|
|
|
return res[0];
|
|
|
}).then(result => {
|
|
|
return this._getKeywordsInfo(JSON.parse(result || '[]'));
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 返回6条推荐关键词页面
|
|
|
_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;
|
|
|
}
|
|
|
|
|
|
_getNewProduct(sort) {
|
...
|
...
|
|