...
|
...
|
@@ -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;
|
...
|
...
|
|