消费竞赛定时器发奖,每天0点5分检测活动 结束
This commit is contained in:
parent
8837ded042
commit
c3ba3934d4
@ -38,7 +38,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
rankList = rankList.map(i => ({...i, player: users.find(v => v.uid == i._id) || {}}))
|
rankList = rankList.map(i => ({...i, player: users.find(v => v.uid == i._id) || {}}))
|
||||||
|
|
||||||
// 活动结束前半小时,缓存过期时间改为10秒
|
// 活动结束前半小时,缓存过期时间改为10秒
|
||||||
let exTime = (G.time + 1800) > _hd.etime ? 10 : 180
|
let exTime = (G.time + 1800) > _hd.etime ? 10 : 120
|
||||||
|
|
||||||
G.ioredis.setex(`rank:xiaofeijingsai`, exTime, JSON.stringify(rankList));
|
G.ioredis.setex(`rank:xiaofeijingsai`, exTime, JSON.stringify(rankList));
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ export function sortRankList(rank, list) {
|
|||||||
if (list[k]?.total >= i.need[0].n) {
|
if (list[k]?.total >= i.need[0].n) {
|
||||||
rankList.push({...list[k - ccc], rank: k})
|
rankList.push({...list[k - ccc], rank: k})
|
||||||
} else {
|
} else {
|
||||||
rankList.push({_id: 'system', total: 0, rank: k, player: {}})
|
rankList.push({_id: 'system', total: i.need[0].n, rank: k, player: {}})
|
||||||
ccc += 1
|
ccc += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,5 +87,5 @@ async function getMyData(call, rankList, _hd?) {
|
|||||||
myCut = {_id: myUser.uid, total: 0}
|
myCut = {_id: myUser.uid, total: 0}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {player: myUser, ...myCut, rank: -1}
|
return {player: myUser, ...myCut, total: R.negate(myCut.total), rank: -1}
|
||||||
}
|
}
|
@ -7,16 +7,19 @@ import {HuoDongFun} from "../huodongfun";
|
|||||||
import {EmailFun} from "../email";
|
import {EmailFun} from "../email";
|
||||||
import {sortRankList} from "../../api_s2c/event/xiaofeijingsai/ApiOpen";
|
import {sortRankList} from "../../api_s2c/event/xiaofeijingsai/ApiOpen";
|
||||||
|
|
||||||
|
/**
|
||||||
export class SchedulerXiaofeijingsaiLocalCtor extends Scheduler {
|
* 消费竞赛发奖定时器
|
||||||
|
* 每天0点5分检测活动结束
|
||||||
|
*/
|
||||||
|
export class Scheduler_xfjs_Local_Ctor extends Scheduler {
|
||||||
id: schedulerType = 'xiaofeijingsai_local_ctor';
|
id: schedulerType = 'xiaofeijingsai_local_ctor';
|
||||||
time = 300;
|
time = 300;
|
||||||
name = '消费竞赛定时器发奖';
|
name = '消费竞赛发奖定时器';
|
||||||
type: 'day' | 'week' = 'day';
|
type: 'day' | 'week' = 'day';
|
||||||
|
|
||||||
// todo 测试
|
// todo 测试
|
||||||
// get nextTime() {
|
// get nextTime() {
|
||||||
// return G.time + 60;
|
// return G.time + 30;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
async read() {
|
async read() {
|
||||||
@ -29,7 +32,7 @@ export class SchedulerXiaofeijingsaiLocalCtor extends Scheduler {
|
|||||||
htype: 11,
|
htype: 11,
|
||||||
ttype: 0,
|
ttype: 0,
|
||||||
etime: {$lt: G.time, $gt: 99999999},
|
etime: {$lt: G.time, $gt: 99999999},
|
||||||
isSendPrize: {$or: [{$exists: false}, {$eq: false}]},
|
$or: [{isSendPrize: {$exists: false}}, {isSendPrize: false}],
|
||||||
}).sort({etime: -1}).limit(1).toArray())[0]
|
}).sort({etime: -1}).limit(1).toArray())[0]
|
||||||
|
|
||||||
if (!_hd) return
|
if (!_hd) return
|
||||||
@ -49,20 +52,18 @@ export class SchedulerXiaofeijingsaiLocalCtor extends Scheduler {
|
|||||||
R.forEach(i => {
|
R.forEach(i => {
|
||||||
let users = R.slice(i.rank[0] - 1, i.rank[1])(ranklist)
|
let users = R.slice(i.rank[0] - 1, i.rank[1])(ranklist)
|
||||||
users.map(v => {
|
users.map(v => {
|
||||||
|
if (v._id == 'system') return
|
||||||
EmailFun.addEmail({
|
EmailFun.addEmail({
|
||||||
uid: v._id,
|
uid: v._id,
|
||||||
type: 'system',
|
type: 'system',
|
||||||
title: 'email.titel',
|
title: _hd.data.mailTitle,
|
||||||
content: 'email.content',
|
content: _hd.data.mailDes,
|
||||||
prize: i.prize,
|
prize: i.prize,
|
||||||
// contentInsertArr: [conf.ph[0] + index]
|
contentInsertArr: [v.rank + 1]
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
})(_hd.data.rank)
|
})(_hd.data.rank)
|
||||||
|
|
||||||
await G.mongodb.collection('hdinfo').findOneAndUpdate({hdid: _hd.hdid}, {$set: {isSendPrize: true}})
|
await G.mongodb.collection('hdinfo').findOneAndUpdate({hdid: _hd.hdid}, {$set: {isSendPrize: true}})
|
||||||
|
|
||||||
console.log(_hd)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -505,7 +505,7 @@ export async function setDbIndexes() {
|
|||||||
index.key,
|
index.key,
|
||||||
option
|
option
|
||||||
);
|
);
|
||||||
console.log('创建索引成功', coll, index);
|
// console.log('创建索引成功', coll, index);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.codeName == 'IndexKeySpecsConflict') {
|
if (error.codeName == 'IndexKeySpecsConflict') {
|
||||||
//当相同索引存在,但是配置(如:unique expireAfterSeconds)不同时,会收到这个报错
|
//当相同索引存在,但是配置(如:unique expireAfterSeconds)不同时,会收到这个报错
|
||||||
@ -519,7 +519,7 @@ export async function setDbIndexes() {
|
|||||||
index.key,
|
index.key,
|
||||||
option
|
option
|
||||||
);
|
);
|
||||||
console.log('创建索引成功', coll, index);
|
// console.log('创建索引成功', coll, index);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('创建索引失败==>', coll, index, error.message);
|
console.log('创建索引失败==>', coll, index, error.message);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import { clusterRunOnce } from './clusterUtils';
|
|||||||
import { addListener } from './globalListener';
|
import { addListener } from './globalListener';
|
||||||
import { SchedulerManage } from './public/scheduler/scheduler';
|
import { SchedulerManage } from './public/scheduler/scheduler';
|
||||||
import {CrossEmailPull} from "./public/scheduler/scheduler_cross_email_pull";
|
import {CrossEmailPull} from "./public/scheduler/scheduler_cross_email_pull";
|
||||||
|
import {Scheduler_xfjs_Local_Ctor} from "./public/scheduler/scheduler_xiaofeijingsai";
|
||||||
export async function startAfter() {
|
export async function startAfter() {
|
||||||
|
|
||||||
//事件监听和定时器初始化
|
//事件监听和定时器初始化
|
||||||
@ -70,6 +71,7 @@ export async function startAfter() {
|
|||||||
new Scheduler_hbzb_zbs_local_prize().init();
|
new Scheduler_hbzb_zbs_local_prize().init();
|
||||||
new Scheduler_hbzb_zbs_local_ready().init();
|
new Scheduler_hbzb_zbs_local_ready().init();
|
||||||
new SchedulerKbzzAutoApply().init();
|
new SchedulerKbzzAutoApply().init();
|
||||||
|
new Scheduler_xfjs_Local_Ctor().init();
|
||||||
|
|
||||||
new SchedulerSlzdClean().init();
|
new SchedulerSlzdClean().init();
|
||||||
new SchedulerSlzdPrize().init();
|
new SchedulerSlzdPrize().init();
|
||||||
|
Loading…
Reference in New Issue
Block a user