Authored by 李奇

修改

... ... @@ -107,7 +107,6 @@ const whSurfController = {
status: {type: 'number', empty: true}
});
// let result = await req.ctx(wheelSurfModel).configModify(data);
let result = await req.ctx(wheelSurfModelRedis).setActConf(data.act_id, data);
return res.json({
... ... @@ -134,7 +133,6 @@ const whSurfController = {
});
}
let actInfo = await req.ctx(wheelSurfModel).actInfo(actId);
// let result = await req.ctx(wheelSurfModel).configFindOne(actId);
let result = await req.ctx(wheelSurfModelRedis).getActConf(actId);
let actStatus = 2; // 1: 活动未开始 2: 活动进行中 3:活动已过期
... ... @@ -174,7 +172,7 @@ const whSurfController = {
prize_idx: {type: 'number', empty: true},
});
});
// let result = await req.ctx(wheelSurfModel).prizeCreate(arr);
let result = await req.ctx(wheelSurfModelRedis).createActPrize(arr[0].act_id, arr);
return res.json({
... ... @@ -218,13 +216,7 @@ const whSurfController = {
});
});
let result;
try {
// let result = await req.ctx(wheelSurfModel).prizeUpdate(arr);
result = await req.ctx(wheelSurfModelRedis).updateActPrize(arr[0].act_id, arr);
} catch (e) {
console.log(e)
}
let result = await req.ctx(wheelSurfModelRedis).updateActPrize(arr[0].act_id, arr);
return res.json({
code: 200,
... ... @@ -257,7 +249,6 @@ const whSurfController = {
});
}
// let result = await req.ctx(wheelSurfModel).prizeFindByActId(actId);
let result = await req.ctx(wheelSurfModelRedis).getActPrize(actId);
return res.json({
... ...
const _ = require('lodash');
class ActWheelSurfRedis extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
... ... @@ -5,9 +7,17 @@ class ActWheelSurfRedis extends global.yoho.BaseModel {
this.client = this.redis.client;
}
getActConf(actId) {
return this.client.hgetallAsync(`turntable:${actId}`);
return this.client.hgetallAsync(`turntable:${actId}`).then(conf => {
Object.keys(conf).forEach(key => {
if (conf[key] && !_.isNaN(Number(conf[key]))) {
conf[key] = Number(conf[key])
}
});
return conf;
});
}
setActConf(actId, confObj) {
confObj.id = 1;
return this.client.HMSET(`turntable:${actId}`, confObj);
}
getActPrize(actId, len = 7) {
... ...