消费竞赛定时器发奖,每天0点5分检测活动 结束

This commit is contained in:
dy 2023-12-22 16:49:21 +08:00
parent 8837ded042
commit c3ba3934d4
4 changed files with 20 additions and 17 deletions

View File

@ -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) || {}}))
// 活动结束前半小时缓存过期时间改为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));
@ -60,7 +60,7 @@ export function sortRankList(rank, list) {
if (list[k]?.total >= i.need[0].n) {
rankList.push({...list[k - ccc], rank: k})
} else {
rankList.push({_id: 'system', total: 0, rank: k, player: {}})
rankList.push({_id: 'system', total: i.need[0].n, rank: k, player: {}})
ccc += 1
}
}
@ -87,5 +87,5 @@ async function getMyData(call, rankList, _hd?) {
myCut = {_id: myUser.uid, total: 0}
}
return {player: myUser, ...myCut, rank: -1}
return {player: myUser, ...myCut, total: R.negate(myCut.total), rank: -1}
}

View File

@ -7,16 +7,19 @@ import {HuoDongFun} from "../huodongfun";
import {EmailFun} from "../email";
import {sortRankList} from "../../api_s2c/event/xiaofeijingsai/ApiOpen";
export class SchedulerXiaofeijingsaiLocalCtor extends Scheduler {
/**
*
* 05
*/
export class Scheduler_xfjs_Local_Ctor extends Scheduler {
id: schedulerType = 'xiaofeijingsai_local_ctor';
time = 300;
name = '消费竞赛定时器发奖';
name = '消费竞赛发奖定时器';
type: 'day' | 'week' = 'day';
// todo 测试
// get nextTime() {
// return G.time + 60;
// return G.time + 30;
// }
async read() {
@ -29,7 +32,7 @@ export class SchedulerXiaofeijingsaiLocalCtor extends Scheduler {
htype: 11,
ttype: 0,
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]
if (!_hd) return
@ -48,21 +51,19 @@ export class SchedulerXiaofeijingsaiLocalCtor extends Scheduler {
R.forEach(i => {
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({
uid: v._id,
type: 'system',
title: 'email.titel',
content: 'email.content',
title: _hd.data.mailTitle,
content: _hd.data.mailDes,
prize: i.prize,
// contentInsertArr: [conf.ph[0] + index]
contentInsertArr: [v.rank + 1]
});
})
})(_hd.data.rank)
await G.mongodb.collection('hdinfo').findOneAndUpdate({hdid: _hd.hdid}, {$set: {isSendPrize: true}})
console.log(_hd)
}
}

View File

@ -505,7 +505,7 @@ export async function setDbIndexes() {
index.key,
option
);
console.log('创建索引成功', coll, index);
// console.log('创建索引成功', coll, index);
} catch (error) {
if (error.codeName == 'IndexKeySpecsConflict') {
//当相同索引存在,但是配置(如unique expireAfterSeconds)不同时,会收到这个报错
@ -519,7 +519,7 @@ export async function setDbIndexes() {
index.key,
option
);
console.log('创建索引成功', coll, index);
// console.log('创建索引成功', coll, index);
} catch (error) {
console.log('创建索引失败==>', coll, index, error.message);
}

View File

@ -27,6 +27,7 @@ import { clusterRunOnce } from './clusterUtils';
import { addListener } from './globalListener';
import { SchedulerManage } from './public/scheduler/scheduler';
import {CrossEmailPull} from "./public/scheduler/scheduler_cross_email_pull";
import {Scheduler_xfjs_Local_Ctor} from "./public/scheduler/scheduler_xiaofeijingsai";
export async function startAfter() {
//事件监听和定时器初始化
@ -70,6 +71,7 @@ export async function startAfter() {
new Scheduler_hbzb_zbs_local_prize().init();
new Scheduler_hbzb_zbs_local_ready().init();
new SchedulerKbzzAutoApply().init();
new Scheduler_xfjs_Local_Ctor().init();
new SchedulerSlzdClean().init();
new SchedulerSlzdPrize().init();