监控init

This commit is contained in:
dy 2024-01-03 11:01:12 +08:00
parent 953303d9a4
commit a1c7f2e4d0
6 changed files with 96 additions and 9 deletions

View File

@ -72,7 +72,17 @@ async function getMyData(call: ApiCall, rankList) {
})
let myUser = await G.mongodb.collection('user').findOne({uid: call.uid})
G.crossmongodb.collection('huodong_user').updateOne({uid: call.uid}, {$set: myUser}, {upsert: true})
G.crossmongodb.collection('huodong_user').updateOne({uid: call.uid}, {
$set: {
lv: myUser.lv,
vip: myUser.vip,
name: myUser.name,
sid: myUser.sid,
nexp: myUser.nexp,
head: myUser.head,
headFrame: myUser.headFrame
}
}, {upsert: true})
if (!myCut) {
myCut = {_id: myUser.uid, total: 0}

View File

@ -14,6 +14,16 @@ export default async function (call: ApiCall<ReqhdGetList, ReshdGetList>) {
if (G.huodong.xfjs) {
G.huodong.xfjsId = _hdList.find(i => i.htype == 11).hdid
let myUser = await G.mongodb.collection('user').findOne({uid: call.uid})
G.crossmongodb.collection('huodong_user').updateOne({uid: call.uid}, {$set: myUser}, {upsert: true})
G.crossmongodb.collection('huodong_user').updateOne({uid: call.uid}, {
$set: {
lv: myUser.lv,
vip: myUser.vip,
name: myUser.name,
sid: myUser.sid,
nexp: myUser.nexp,
head: myUser.head,
headFrame: myUser.headFrame
}
}, {upsert: true})
}
}

View File

@ -18,6 +18,7 @@ import {getItemByItemId, getItemNum} from './item';
import {getGud, setGud} from './gud';
import {addGameLog} from "../gameLog";
import {PushGiftFun} from "./pushgift";
import { ActionLog } from './actionLog/actionLog';
export type call = {
@ -224,12 +225,16 @@ export class PlayerFun {
atn
}
G.mongodb.collection('rmbuse').insertOne(data);
// 消费竞赛开启时写入跨服数据库
if (G.huodong.xfjs && !data.isAdd && typeof data.change == 'number') {
G.crossmongodb.collection('rmbuse').updateOne({uid: data.uid, type: `xfjs_${G.huodong.xfjsId}`}, {
$set: {time: G.time},
$inc: {change: data.change}
}, {upsert: true});
if (data.isAdd){
ActionLog.addDayLog(uid, { key: 'addRmbmoney', val: atn.n });
}else {
// 消费竞赛开启时写入跨服数据库
if (G.huodong.xfjs && typeof data.change == 'number') {
G.crossmongodb.collection('rmbuse').updateOne({uid: data.uid, type: `xfjs_${G.huodong.xfjsId}`}, {
$set: {time: G.time},
$inc: {change: data.change}
}, {upsert: true});
}
}
}

View File

@ -38,7 +38,8 @@ export type schedulerType =
| 'hbzb_zbs_group'
| 'wzry_zuanshi16to8'
| "cross_email_pull"
| "xiaofeijingsai_local_ctor";
| "xiaofeijingsai_local_ctor"
| "local_data_warn"
export class SchedulerManage {
static logTime = false;

View File

@ -0,0 +1,58 @@
import {Scheduler, schedulerType} from "./scheduler";
import {EmailFun} from "../email";
import {ActionLog} from "../actionLog/actionLog";
export class Scheduler_dataWarn extends Scheduler {
id: schedulerType = "local_data_warn";
time = 30; // 10分钟检测一次数据异常
name = "玩家数据异常监测"
type = ""
async read() {
await this.ctorStartTime();
this.isReady = false;
this.startTime = this.nextTime;
}
async start() {
let users = (await G.mongodb.collection('user').find({newonlinetime: {$gte: G.time - 330, $lte: G.time + 30}},
{projection: {uid: 1, sid: 1, name: 1, lv: 1, vip: 1}}).toArray())
.map(i => {
let {_id, ...other} = i
return other
})
if (!users.length) return
let logs = await G.mongodb.collection('actionLog').find({
uid: {$in: users.map(i => i.uid)},
type: 'day'
}).toArray()
console.log(logs)
// ActionLog.addDayLog(player.uid, { key: 'pay', val: conf.payExp[0].n });
// ActionLog.addRetainLog(player.uid, { key: 'pay', val: conf.payExp[0].n });
await this.ctorStartTime()
}
get nextTime(): number {
return G.time + this.time;
}
async ctorStartTime() {
this.isStart = false;
this.startTime = this.nextTime;
}
}
function addWarnLog(user) {
}

View File

@ -29,6 +29,7 @@ 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";
import { RankKfjs_1, RankKfjs_2, RankKfjs_3, RankKfjs_4, RankKfjs_5, RankKfjs_6, RankKfjs_7 } from './public/rank/rank_kfjs';
import {Scheduler_dataWarn} from "./public/scheduler/scheduler_dataWarn";
export async function startAfter() {
//事件监听和定时器初始化
@ -90,6 +91,8 @@ export async function startAfter() {
new SchedulerWzryAutoBaoMing().init();
new SchedulerWzryjingcaiSendPrize().init();
new SchedulerWzryendDel().init();
new Scheduler_dataWarn().init()
// new SchedulerWzrycrossEmail();
new CrossEmailPull().init()