Authored by 李奇

活动中奖用户key重新设定

@@ -137,6 +137,13 @@ const whSurfController = { @@ -137,6 +137,13 @@ const whSurfController = {
137 let actStatus = 2; // 1: 活动未开始 2: 活动进行中 3:活动已过期 137 let actStatus = 2; // 1: 活动未开始 2: 活动进行中 3:活动已过期
138 let now = parseInt(new Date().getTime() / 1000); 138 let now = parseInt(new Date().getTime() / 1000);
139 139
  140 + if (!actInfo) {
  141 + return res.json({
  142 + code: 404,
  143 + message: '活动不存在'
  144 + });
  145 + }
  146 +
140 if (now < actInfo.startTime) { 147 if (now < actInfo.startTime) {
141 actStatus = 1; 148 actStatus = 1;
142 } else if (now > actInfo.endTime) { 149 } else if (now > actInfo.endTime) {
@@ -40,6 +40,13 @@ const sendMessage = (type, tags, fields, isFail) => { @@ -40,6 +40,13 @@ const sendMessage = (type, tags, fields, isFail) => {
40 } 40 }
41 }; 41 };
42 42
  43 +const prizeType = {
  44 + 1: '谢谢惠顾',
  45 + 2: '红包',
  46 + 3: '优惠券',
  47 + 4: '实物奖品'
  48 +};
  49 +
43 class ActWheelSurfModelRedis extends global.yoho.BaseModel { 50 class ActWheelSurfModelRedis extends global.yoho.BaseModel {
44 constructor(ctx) { 51 constructor(ctx) {
45 super(ctx); 52 super(ctx);
@@ -53,6 +60,7 @@ class ActWheelSurfModelRedis extends global.yoho.BaseModel { @@ -53,6 +60,7 @@ class ActWheelSurfModelRedis extends global.yoho.BaseModel {
53 60
54 data.conf = await this.client.hgetallAsync(`turntable:${obj.act_id}`) 61 data.conf = await this.client.hgetallAsync(`turntable:${obj.act_id}`)
55 .then(conf => { 62 .then(conf => {
  63 + conf = conf || {};
56 Object.keys(conf).forEach(key => { 64 Object.keys(conf).forEach(key => {
57 if (conf[key] && !_.isNaN(Number(conf[key]))) { 65 if (conf[key] && !_.isNaN(Number(conf[key]))) {
58 conf[key] = Number(conf[key]) 66 conf[key] = Number(conf[key])
@@ -200,7 +208,7 @@ class ActWheelSurfModelRedis extends global.yoho.BaseModel { @@ -200,7 +208,7 @@ class ActWheelSurfModelRedis extends global.yoho.BaseModel {
200 let random = Math.random() * 100; 208 let random = Math.random() * 100;
201 209
202 // 判定随机数在奖品池子取件 选定中奖奖品 210 // 判定随机数在奖品池子取件 选定中奖奖品
203 - let getPrize, sendResult = {}, result, reduce; 211 + let getPrize, sendResult = {}, result;
204 212
205 for (let i in arr) { 213 for (let i in arr) {
206 if (arr[i].maxValue >= random && arr[i].leastValue < random) { 214 if (arr[i].maxValue >= random && arr[i].leastValue < random) {
@@ -299,13 +307,11 @@ class ActWheelSurfModelRedis extends global.yoho.BaseModel { @@ -299,13 +307,11 @@ class ActWheelSurfModelRedis extends global.yoho.BaseModel {
299 result = await Promise.all([ 307 result = await Promise.all([
300 this.client.zaddAsync( 308 this.client.zaddAsync(
301 `turntable:${obj.act_id}:user:${obj.uid}:prize`, score, `${JSON.stringify(getPrize)}:::${score}`), 309 `turntable:${obj.act_id}:user:${obj.uid}:prize`, score, `${JSON.stringify(getPrize)}:::${score}`),
302 - this.client.zaddAsync(  
303 - `turntable:${obj.act_id}:prize:${getPrize.prize_idx}:users`, score, `${JSON.stringify(getPrize)}:::${score},${obj.uid}`) 310 + this.client.lpushAsync(
  311 + `turntable:${obj.act_id}:prize:users`, `${obj.uid}:::${prizeType[getPrize.type]}:::${getPrize.name}:::${JSON.stringify(getPrize)}`)
304 ]); 312 ]);
305 313
306 - if (result  
307 - && result[0] === 1  
308 - && result[1] === 1) { 314 + if (result) {
309 delete getPrize.chance; 315 delete getPrize.chance;
310 delete getPrize.create_time; 316 delete getPrize.create_time;
311 delete getPrize.total; 317 delete getPrize.total;
@@ -2,24 +2,7 @@ @@ -2,24 +2,7 @@
2 <div class="list"> 2 <div class="list">
3 <div class="filter"> 3 <div class="filter">
4 <Row> 4 <Row>
5 - <Col span="6" class="field-col">  
6 - <Input v-model="uid" placeholder="用户UID" :maxlength="20"></Input>  
7 - </Col>  
8 - <Col span="6" class="field-col">  
9 - <Select v-model="type">  
10 - <Option :value="1">谢谢惠顾</Option>  
11 - <Option :value="2">红包</Option>  
12 - <Option :value="3">优惠券</Option>  
13 - <Option :value="4">实物奖品</Option>  
14 - </Select>  
15 - </Col>  
16 - <Col span="6" class="field-col">  
17 - <Input v-model="name" placeholder="奖品名称" :maxlength="100"></Input>  
18 - </Col>  
19 - <Col span="6">  
20 - <Button type="primary" @click="search">检索</Button>  
21 - <Button @click="reset" type="warning" style="margin-left: 10px;">重置  
22 - </Button></Col> 5 + <Button type="primary" @click="output">导出中奖记录</Button>
23 </Row> 6 </Row>
24 </div> 7 </div>
25 <Table :columns="columns1" :data="data"></Table> 8 <Table :columns="columns1" :data="data"></Table>
@@ -102,27 +85,6 @@ @@ -102,27 +85,6 @@
102 this.total = res.data.total; 85 this.total = res.data.total;
103 }); 86 });
104 }, 87 },
105 - search() {  
106 - let params = {  
107 - act_id: this.actId,  
108 - pageNo: 1,  
109 - pageSize: 10  
110 - };  
111 -  
112 - if (this.uid) {  
113 - params.uid = this.uid;  
114 - }  
115 -  
116 - if (this.type) {  
117 - params.type = this.type;  
118 - }  
119 -  
120 - if (this.name) {  
121 - params.name = this.name;  
122 - }  
123 -  
124 - this.list(params);  
125 - },  
126 pageChange(page) { 88 pageChange(page) {
127 this.pageNo = page; 89 this.pageNo = page;
128 90
@@ -146,12 +108,8 @@ @@ -146,12 +108,8 @@
146 108
147 this.list(params); 109 this.list(params);
148 }, 110 },
149 - reset() {  
150 - this.uid = '';  
151 - this.type = '';  
152 - this.name = '';  
153 - this.pageNo = 1;  
154 - this.list(); 111 + output() {
  112 + console.log('output')
155 } 113 }
156 }, 114 },
157 created() { 115 created() {