Authored by yyq

recomend list

@@ -16,7 +16,7 @@ const MINUTE_TIMES = 60; @@ -16,7 +16,7 @@ const MINUTE_TIMES = 60;
16 const PRODUCT_CACHE_TIMES = MINUTE_TIMES * 5; // 商品(列表&详情)缓存时间 16 const PRODUCT_CACHE_TIMES = MINUTE_TIMES * 5; // 商品(列表&详情)缓存时间
17 const RECENT_CODE_CACHE_TIME = MINUTE_TIMES; // 最近获取记录缓存时间 17 const RECENT_CODE_CACHE_TIME = MINUTE_TIMES; // 最近获取记录缓存时间
18 const MAX_JOIN_TIMES = 5; // 最大活动参与次数 18 const MAX_JOIN_TIMES = 5; // 最大活动参与次数
19 - 19 +const MAX_RECOMEND_NUM = 10; // 最大推荐活动数目
20 const PAGE_SIZE = 10; 20 const PAGE_SIZE = 10;
21 21
22 const userTimesCache = new MemoryCache(); 22 const userTimesCache = new MemoryCache();
@@ -140,13 +140,11 @@ module.exports = class extends global.yoho.BaseModel { @@ -140,13 +140,11 @@ module.exports = class extends global.yoho.BaseModel {
140 getListRecommend(actPrizeId, extra = {}) { 140 getListRecommend(actPrizeId, extra = {}) {
141 const actId = parseInt(extra.actId, 10) || 0; 141 const actId = parseInt(extra.actId, 10) || 0;
142 142
143 - let lid = parseInt(actPrizeId, 10) || 0;  
144 -  
145 return mysqlCli.query(`select * from ${TABLE_ACT_PRIZE_PRODUCT} 143 return mysqlCli.query(`select * from ${TABLE_ACT_PRIZE_PRODUCT}
146 - where act_id = :actId and id > :actPrizeId and status > 0  
147 - order by sort desc limit 5`, { 144 + where act_id = :actId and status > 0
  145 + order by sort desc limit ${MAX_RECOMEND_NUM + 1}`, {
148 actId, 146 actId,
149 - actPrizeId: lid - 3 147 + actPrizeId
150 }, { 148 }, {
151 cache: PRODUCT_CACHE_TIMES 149 cache: PRODUCT_CACHE_TIMES
152 }).then(result => { 150 }).then(result => {
@@ -154,7 +152,7 @@ module.exports = class extends global.yoho.BaseModel { @@ -154,7 +152,7 @@ module.exports = class extends global.yoho.BaseModel {
154 return +n.id === +actPrizeId; 152 return +n.id === +actPrizeId;
155 }); 153 });
156 154
157 - return handelResult(handelActivityList(_.takeRight(result, 2))); 155 + return handelResult(handelActivityList(_.take(result, MAX_RECOMEND_NUM)));
158 }); 156 });
159 } 157 }
160 158