From a1c7f2e4d05b9eff64e489414c61113ddc28a5eb Mon Sep 17 00:00:00 2001 From: dy Date: Wed, 3 Jan 2024 11:01:12 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E6=8E=A7init?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/event/xiaofeijingsai/ApiOpen.ts | 12 ++++- src/api_s2c/eventlist/ApihdGetList.ts | 12 ++++- src/public/player.ts | 17 +++--- src/public/scheduler/scheduler.ts | 3 +- src/public/scheduler/scheduler_dataWarn.ts | 58 +++++++++++++++++++++ src/setStartAfther.ts | 3 ++ 6 files changed, 96 insertions(+), 9 deletions(-) create mode 100644 src/public/scheduler/scheduler_dataWarn.ts diff --git a/src/api_s2c/event/xiaofeijingsai/ApiOpen.ts b/src/api_s2c/event/xiaofeijingsai/ApiOpen.ts index 388b550..81a903a 100644 --- a/src/api_s2c/event/xiaofeijingsai/ApiOpen.ts +++ b/src/api_s2c/event/xiaofeijingsai/ApiOpen.ts @@ -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} diff --git a/src/api_s2c/eventlist/ApihdGetList.ts b/src/api_s2c/eventlist/ApihdGetList.ts index dd2934b..3cbdfa4 100644 --- a/src/api_s2c/eventlist/ApihdGetList.ts +++ b/src/api_s2c/eventlist/ApihdGetList.ts @@ -14,6 +14,16 @@ export default async function (call: ApiCall) { 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}) } } \ No newline at end of file diff --git a/src/public/player.ts b/src/public/player.ts index 9237363..ea61271 100644 --- a/src/public/player.ts +++ b/src/public/player.ts @@ -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}); + } } } diff --git a/src/public/scheduler/scheduler.ts b/src/public/scheduler/scheduler.ts index 438360c..e8fa6b9 100644 --- a/src/public/scheduler/scheduler.ts +++ b/src/public/scheduler/scheduler.ts @@ -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; diff --git a/src/public/scheduler/scheduler_dataWarn.ts b/src/public/scheduler/scheduler_dataWarn.ts new file mode 100644 index 0000000..d1d4f4f --- /dev/null +++ b/src/public/scheduler/scheduler_dataWarn.ts @@ -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) { + + +} \ No newline at end of file diff --git a/src/setStartAfther.ts b/src/setStartAfther.ts index 25c609c..a67c0a5 100644 --- a/src/setStartAfther.ts +++ b/src/setStartAfther.ts @@ -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()