Authored by yyq

recomend

... ... @@ -26,6 +26,10 @@ module.exports = {
req.ctx(zerobuyModel).getListMine(req.query.uid)
.then(res.json).catch(next);
},
listRecommend(req, res, next) {
req.ctx(zerobuyModel).getListRecommend(req.query.actPrizeId)
.then(res.json).catch(next);
},
codeRecent(req, res, next) {
req.ctx(zerobuyModel).getCodeRecent()
.then(res.json).catch(next);
... ...
... ... @@ -92,6 +92,26 @@ module.exports = class extends global.yoho.BaseModel {
}
/**
* 0元购用户推荐列表
* @param uid
* @param extra
* @returns {*}
*/
getListRecommend(actPrizeId, extra = {}) {
const actId = parseInt(extra.actId, 10) || 0;
actPrizeId = parseInt(actPrizeId, 10) || 0;
return mysqlCli.query(`select * from ${TABLE_ACT_PRIZE_PRODUCT}
where act_id = :actId and id > :actPrizeId and status > 0 limit 5`, {
actId,
actPrizeId: actPrizeId - 3
}, {
cache: PRODUCT_CACHE_TIMES
}).then(handelResult);
}
/**
* 0元购详情
* @param actPrizeId
* @returns {*}
... ... @@ -190,11 +210,14 @@ module.exports = class extends global.yoho.BaseModel {
return errorData;
}
if (uid === +extra.shareUid) {
delete extra.shareUid;
}
if (extra.shareUid) {
this.sendPrizeCode(extra.shareUid, actPrizeId, {isShareTake: true});
}
return this.sendPrizeCode(uid, actPrizeId, Object.assign(extra, {isShareTake: false}));
}
... ...
... ... @@ -19,6 +19,7 @@ router.post('/couponExp/friendHelp', couponExp.friendHelp);
router.get('/zerobuy/list', zeroBuy.list); // 0元购活动列表
router.get('/zerobuy/list/mine', zeroBuy.listMine); // 0元购用户参与列表
router.get('/zerobuy/list/recommend', zeroBuy.listRecommend); // 0元购活动推荐列表
router.get('/zerobuy/content', zeroBuy.content); // 0元购详情
router.get('/zerobuy/code/recent', zeroBuy.codeRecent); // 0元购抽奖码最近获取记录
router.get('/zerobuy/code/mine', zeroBuy.codeMine); // 0元购用户单个活动抽奖码
... ...
... ... @@ -72,7 +72,7 @@ class SqlHelper {
let cacheResult = this.memoryCache.get(cacheKey);
if (!_.isUndefined(cacheResult)) {
this.logger.debug('get success from memory cache.' + cacheString)
this.logger.debug('get success from memory cache.' + cacheString);
return Promise.resolve(cacheResult);
}
}
... ...