Authored by 李奇

活动中奖用户key重新设定

... ... @@ -137,6 +137,13 @@ const whSurfController = {
let actStatus = 2; // 1: 活动未开始 2: 活动进行中 3:活动已过期
let now = parseInt(new Date().getTime() / 1000);
if (!actInfo) {
return res.json({
code: 404,
message: '活动不存在'
});
}
if (now < actInfo.startTime) {
actStatus = 1;
} else if (now > actInfo.endTime) {
... ...
... ... @@ -40,6 +40,13 @@ const sendMessage = (type, tags, fields, isFail) => {
}
};
const prizeType = {
1: '谢谢惠顾',
2: '红包',
3: '优惠券',
4: '实物奖品'
};
class ActWheelSurfModelRedis extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
... ... @@ -53,6 +60,7 @@ class ActWheelSurfModelRedis extends global.yoho.BaseModel {
data.conf = await this.client.hgetallAsync(`turntable:${obj.act_id}`)
.then(conf => {
conf = conf || {};
Object.keys(conf).forEach(key => {
if (conf[key] && !_.isNaN(Number(conf[key]))) {
conf[key] = Number(conf[key])
... ... @@ -200,7 +208,7 @@ class ActWheelSurfModelRedis extends global.yoho.BaseModel {
let random = Math.random() * 100;
// 判定随机数在奖品池子取件 选定中奖奖品
let getPrize, sendResult = {}, result, reduce;
let getPrize, sendResult = {}, result;
for (let i in arr) {
if (arr[i].maxValue >= random && arr[i].leastValue < random) {
... ... @@ -299,13 +307,11 @@ class ActWheelSurfModelRedis extends global.yoho.BaseModel {
result = await Promise.all([
this.client.zaddAsync(
`turntable:${obj.act_id}:user:${obj.uid}:prize`, score, `${JSON.stringify(getPrize)}:::${score}`),
this.client.zaddAsync(
`turntable:${obj.act_id}:prize:${getPrize.prize_idx}:users`, score, `${JSON.stringify(getPrize)}:::${score},${obj.uid}`)
this.client.lpushAsync(
`turntable:${obj.act_id}:prize:users`, `${obj.uid}:::${prizeType[getPrize.type]}:::${getPrize.name}:::${JSON.stringify(getPrize)}`)
]);
if (result
&& result[0] === 1
&& result[1] === 1) {
if (result) {
delete getPrize.chance;
delete getPrize.create_time;
delete getPrize.total;
... ...
... ... @@ -2,24 +2,7 @@
<div class="list">
<div class="filter">
<Row>
<Col span="6" class="field-col">
<Input v-model="uid" placeholder="用户UID" :maxlength="20"></Input>
</Col>
<Col span="6" class="field-col">
<Select v-model="type">
<Option :value="1">谢谢惠顾</Option>
<Option :value="2">红包</Option>
<Option :value="3">优惠券</Option>
<Option :value="4">实物奖品</Option>
</Select>
</Col>
<Col span="6" class="field-col">
<Input v-model="name" placeholder="奖品名称" :maxlength="100"></Input>
</Col>
<Col span="6">
<Button type="primary" @click="search">检索</Button>
<Button @click="reset" type="warning" style="margin-left: 10px;">重置
</Button></Col>
<Button type="primary" @click="output">导出中奖记录</Button>
</Row>
</div>
<Table :columns="columns1" :data="data"></Table>
... ... @@ -102,27 +85,6 @@
this.total = res.data.total;
});
},
search() {
let params = {
act_id: this.actId,
pageNo: 1,
pageSize: 10
};
if (this.uid) {
params.uid = this.uid;
}
if (this.type) {
params.type = this.type;
}
if (this.name) {
params.name = this.name;
}
this.list(params);
},
pageChange(page) {
this.pageNo = page;
... ... @@ -146,12 +108,8 @@
this.list(params);
},
reset() {
this.uid = '';
this.type = '';
this.name = '';
this.pageNo = 1;
this.list();
output() {
console.log('output')
}
},
created() {
... ...