Authored by 李奇

修改

@@ -107,7 +107,6 @@ const whSurfController = { @@ -107,7 +107,6 @@ const whSurfController = {
107 status: {type: 'number', empty: true} 107 status: {type: 'number', empty: true}
108 }); 108 });
109 109
110 - // let result = await req.ctx(wheelSurfModel).configModify(data);  
111 let result = await req.ctx(wheelSurfModelRedis).setActConf(data.act_id, data); 110 let result = await req.ctx(wheelSurfModelRedis).setActConf(data.act_id, data);
112 111
113 return res.json({ 112 return res.json({
@@ -134,7 +133,6 @@ const whSurfController = { @@ -134,7 +133,6 @@ const whSurfController = {
134 }); 133 });
135 } 134 }
136 let actInfo = await req.ctx(wheelSurfModel).actInfo(actId); 135 let actInfo = await req.ctx(wheelSurfModel).actInfo(actId);
137 - // let result = await req.ctx(wheelSurfModel).configFindOne(actId);  
138 let result = await req.ctx(wheelSurfModelRedis).getActConf(actId); 136 let result = await req.ctx(wheelSurfModelRedis).getActConf(actId);
139 137
140 let actStatus = 2; // 1: 活动未开始 2: 活动进行中 3:活动已过期 138 let actStatus = 2; // 1: 活动未开始 2: 活动进行中 3:活动已过期
@@ -174,7 +172,7 @@ const whSurfController = { @@ -174,7 +172,7 @@ const whSurfController = {
174 prize_idx: {type: 'number', empty: true}, 172 prize_idx: {type: 'number', empty: true},
175 }); 173 });
176 }); 174 });
177 - // let result = await req.ctx(wheelSurfModel).prizeCreate(arr); 175 +
178 let result = await req.ctx(wheelSurfModelRedis).createActPrize(arr[0].act_id, arr); 176 let result = await req.ctx(wheelSurfModelRedis).createActPrize(arr[0].act_id, arr);
179 177
180 return res.json({ 178 return res.json({
@@ -218,13 +216,7 @@ const whSurfController = { @@ -218,13 +216,7 @@ const whSurfController = {
218 }); 216 });
219 }); 217 });
220 218
221 - let result;  
222 - try {  
223 - // let result = await req.ctx(wheelSurfModel).prizeUpdate(arr);  
224 - result = await req.ctx(wheelSurfModelRedis).updateActPrize(arr[0].act_id, arr);  
225 - } catch (e) {  
226 - console.log(e)  
227 - } 219 + let result = await req.ctx(wheelSurfModelRedis).updateActPrize(arr[0].act_id, arr);
228 220
229 return res.json({ 221 return res.json({
230 code: 200, 222 code: 200,
@@ -257,7 +249,6 @@ const whSurfController = { @@ -257,7 +249,6 @@ const whSurfController = {
257 }); 249 });
258 } 250 }
259 251
260 - // let result = await req.ctx(wheelSurfModel).prizeFindByActId(actId);  
261 let result = await req.ctx(wheelSurfModelRedis).getActPrize(actId); 252 let result = await req.ctx(wheelSurfModelRedis).getActPrize(actId);
262 253
263 return res.json({ 254 return res.json({
  1 +const _ = require('lodash');
  2 +
1 class ActWheelSurfRedis extends global.yoho.BaseModel { 3 class ActWheelSurfRedis extends global.yoho.BaseModel {
2 constructor(ctx) { 4 constructor(ctx) {
3 super(ctx); 5 super(ctx);
@@ -5,9 +7,17 @@ class ActWheelSurfRedis extends global.yoho.BaseModel { @@ -5,9 +7,17 @@ class ActWheelSurfRedis extends global.yoho.BaseModel {
5 this.client = this.redis.client; 7 this.client = this.redis.client;
6 } 8 }
7 getActConf(actId) { 9 getActConf(actId) {
8 - return this.client.hgetallAsync(`turntable:${actId}`); 10 + return this.client.hgetallAsync(`turntable:${actId}`).then(conf => {
  11 + Object.keys(conf).forEach(key => {
  12 + if (conf[key] && !_.isNaN(Number(conf[key]))) {
  13 + conf[key] = Number(conf[key])
  14 + }
  15 + });
  16 + return conf;
  17 + });
9 } 18 }
10 setActConf(actId, confObj) { 19 setActConf(actId, confObj) {
  20 + confObj.id = 1;
11 return this.client.HMSET(`turntable:${actId}`, confObj); 21 return this.client.HMSET(`turntable:${actId}`, confObj);
12 } 22 }
13 getActPrize(actId, len = 7) { 23 getActPrize(actId, len = 7) {