From d2ddc62752f28d0d438c9dadc9ffee981a6325b3 Mon Sep 17 00:00:00 2001 From: dy Date: Tue, 2 Jan 2024 15:49:24 +0800 Subject: [PATCH 01/11] fix round --- src/api_s2c/event/leijichongzhi/ApiOpen.ts | 4 ++-- src/api_s2c/event/leijichongzhi/ApiRec.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/api_s2c/event/leijichongzhi/ApiOpen.ts b/src/api_s2c/event/leijichongzhi/ApiOpen.ts index 801ee88..75a9c9b 100644 --- a/src/api_s2c/event/leijichongzhi/ApiOpen.ts +++ b/src/api_s2c/event/leijichongzhi/ApiOpen.ts @@ -25,8 +25,8 @@ export default async function (call: ApiCall) { } db = await checkNextRound(call, db, _hdinfo.data.tasks) - let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.rtime)) * 10 - payNum = payNum - (db.round || 0) * R.sort((a, b) => b.total - a.total)(_hdinfo.data.tasks)[0].total + let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.etime)) * 10 + payNum = payNum - (db?.round || 0) * R.sort((a, b) => b.total - a.total)(_hdinfo.data.tasks)[0].total call.succ({ sTime: sTime, diff --git a/src/api_s2c/event/leijichongzhi/ApiRec.ts b/src/api_s2c/event/leijichongzhi/ApiRec.ts index 55f9aef..5586907 100644 --- a/src/api_s2c/event/leijichongzhi/ApiRec.ts +++ b/src/api_s2c/event/leijichongzhi/ApiRec.ts @@ -40,8 +40,9 @@ export default async function (call: ApiCall) { } export async function checkNextRound(call: ApiCall, event, tasks) { - let _dbType: `leijichongzhi${number}` = `leijichongzhi${call.req.hdid}` if ((event?.recIndex?.length || 0) < tasks.length) return event + + let _dbType: `leijichongzhi${number}` = `leijichongzhi${call.req.hdid}` return (await G.mongodb.cEvent(_dbType).findOneAndUpdate( {uid: call.uid, type: _dbType}, {$set: {recIndex: []}, $inc: {round: 1}}, {returnDocument: 'after'} From 3c380f1e55e0384f52ab5abe31a602f260e77068 Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Wed, 3 Jan 2024 10:36:17 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gameLog.ts | 28 +++++- src/oss/watchdog.json | 7 ++ src/public/scheduler/scheduler.ts | 1 + src/public/scheduler/scheduler_watchdog.ts | 107 +++++++++++++++++++++ src/public/wzry.ts | 2 +- src/setStartAfther.ts | 2 + 6 files changed, 143 insertions(+), 4 deletions(-) create mode 100644 src/oss/watchdog.json create mode 100644 src/public/scheduler/scheduler_watchdog.ts diff --git a/src/gameLog.ts b/src/gameLog.ts index 9242fb2..6f1ca12 100644 --- a/src/gameLog.ts +++ b/src/gameLog.ts @@ -1,8 +1,8 @@ import { Db, MongoClient } from "mongodb"; import { Logger } from "tsrpc"; -let logDB:Db; -let errorLogDB:Db; +export let logDB:Db; +export let errorLogDB:Db; /** * 是否是G123的测试服 @@ -11,7 +11,7 @@ function isG123stg(){ return G.config.mongodbUrl.indexOf('.stg.')!=-1; } -async function connGameLogDB() { +export async function connGameLogDB() { console.log('connect gamelog mongodb ......'); let logDBUrl:string; if(G.config.isG123){ @@ -73,6 +73,28 @@ async function addErrorLog(errData:any){ } } +export async function addWatchDogLog(data:object[]){ + try{ + //g123测试版连接不上db,不抓取 + if(!data)return; + if(isG123stg())return; + let log = { + serverId : G.config.serverId, + pid : process.pid, + cTime : Math.floor(Date.now()/1000) + } + data.map(item=>{ + Object.assign(item,log) + }) + if(!errorLogDB){ + await connGameLogDB(); + } + errorLogDB.collection('nodeJsErrorLog').insertMany(data); + }catch(e){ + console.error('addWatchDogLog',e); + } +} + /** * 增加游戏日志 * @param uid 玩家uid diff --git a/src/oss/watchdog.json b/src/oss/watchdog.json new file mode 100644 index 0000000..9c21692 --- /dev/null +++ b/src/oss/watchdog.json @@ -0,0 +1,7 @@ +[ + { + "key":"task/Open", + "limit":0, + "tips":"任务打开次数超过3次" + } +] \ No newline at end of file diff --git a/src/public/scheduler/scheduler.ts b/src/public/scheduler/scheduler.ts index a8b93a7..071f19f 100644 --- a/src/public/scheduler/scheduler.ts +++ b/src/public/scheduler/scheduler.ts @@ -38,6 +38,7 @@ export type schedulerType = | 'hbzb_zbs_group' | 'wzry_zuanshi16to8' | "cross_email_pull" + | "watch_dog" | "xiaofeijingsai_local_ctor"; export class SchedulerManage { diff --git a/src/public/scheduler/scheduler_watchdog.ts b/src/public/scheduler/scheduler_watchdog.ts new file mode 100644 index 0000000..1b04b5c --- /dev/null +++ b/src/public/scheduler/scheduler_watchdog.ts @@ -0,0 +1,107 @@ +import { resolve } from "path"; +import { PublicShared } from "../../shared/public/public"; +import {Scheduler, schedulerType} from "./scheduler"; +import { existsSync, readFileSync } from "fs"; +import { addWatchDogLog, errorLogDB } from "../../gameLog"; + +export class WatchDog extends Scheduler { + id: schedulerType = "watch_dog"; + time = 420; // 监控频率,每x秒一次 + name = "数据看门狗" + type = "" + + async read() { + await this.ctorStartTime(); + this.isReady = false; + this.startTime = this.nextTime; + + this.start(); + } + + async start() { + let confFile = resolve(__dirname, '../../oss/watchdog.json'); + if (!existsSync(confFile)) { + //配置文件不存在 + await this.ctorStartTime() + return; + } + let conf; + try{ + conf = await JSON.parse(readFileSync(confFile, 'utf-8')); + }catch(e){ + //配置文件不是json + await this.ctorStartTime() + return; + } + //获取今天0点之后在线的玩家 + let users = await G.mongodb.collection("user").find({ + lv : {$gt:10}, + newonlinetime:{$gt: PublicShared.getToDayZeroTime() } + },{ + projection:{ + uid:1, + name:1, + lv:1, + vip:1, + sid:1 + } + }).toArray(); + + if(!users.length){ + //没有符合的玩家 + await this.ctorStartTime() + return; + } + + let uids = users.map(i => i.uid); + let uinfo = {}; + users.map(i => uinfo[i.uid] = i); + + let actionLogs = await G.mongodb.collection("actionLog").find({ + type:'day', + uid: {$in: uids}, + },{ + projection:{ + uid:1, + log:1 + } + }).toArray(); + + let warns = []; + for(let j=0;j= conf[j].limit ){ + //触发了警报 + warns.push({ + type:'watchDog', + uid: uid, + name: uinfo[uid]?.name, + lv: uinfo[uid]?.lv, + vip: uinfo[uid]?.vip, + key: key, + value: myval, + tips: conf[j].tips + }) + } + } + } + + if(warns.length>0){ + addWatchDogLog(warns); + } + + await this.ctorStartTime() + } + + get nextTime(): number { + return G.time + this.time; + } + + async ctorStartTime() { + this.isStart = false; + this.startTime = this.nextTime; + } +} \ No newline at end of file diff --git a/src/public/wzry.ts b/src/public/wzry.ts index 02e848b..efb036d 100644 --- a/src/public/wzry.ts +++ b/src/public/wzry.ts @@ -40,7 +40,7 @@ export class WangZheRongYaofun { /**获取报名人数 */ static async getBaoMingNum() { let zkey: string = PublicShared.getToWeek(); - let _num = G.mongodb.collection('playerInfo', 'wzry').countDocuments({ isbm: 1 }); + let _num = G.mongodb.collection('playerInfo', 'wzry').countDocuments({ type:'wzry', isbm: 1 }); return _num; } diff --git a/src/setStartAfther.ts b/src/setStartAfther.ts index f0ca5c4..7541cfb 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 { WatchDog } from './public/scheduler/scheduler_watchdog'; export async function startAfter() { //事件监听和定时器初始化 @@ -93,6 +94,7 @@ export async function startAfter() { // new SchedulerWzrycrossEmail(); new CrossEmailPull().init() + new WatchDog().init(); }); new SchedulerNewDayLocalCtor().init(); From 78c306ce5ed1064236c3ea38ccfa0ba9d8246a81 Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Wed, 3 Jan 2024 10:58:09 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9B=91=E6=8E=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/oss/watchdog.json | 21 ++++++++++++++++++--- src/public/player.ts | 7 +++++++ src/public/scheduler/scheduler_watchdog.ts | 2 -- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/oss/watchdog.json b/src/oss/watchdog.json index 9c21692..629f6b8 100644 --- a/src/oss/watchdog.json +++ b/src/oss/watchdog.json @@ -1,7 +1,22 @@ [ { - "key":"task/Open", - "limit":0, - "tips":"任务打开次数超过3次" + "key":"jiuba/Lottery", + "limit":300, + "tips":"酒馆抽取次数达到300次" + }, + { + "key":"got_jinbi", + "limit":200000000, + "tips":"jinbi获取达到20亿" + }, + { + "key":"got_rmbmoney", + "limit":30000, + "tips":"钻石获取达到3万" + }, + { + "key":"use_attr_rmbmoney", + "limit":100000, + "tips":"钻石消耗达到10万" } ] \ No newline at end of file diff --git a/src/public/player.ts b/src/public/player.ts index 9237363..2647bce 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 = { @@ -178,6 +179,12 @@ export class PlayerFun { G.emit("Class_task_156", 'Class_task_156', call, -atn.n, 0); } } + + if( (atn.t == 'rmbmoney' || atn.t == 'jinbi') && atn.n > 0 ){ + //统计今日获取的金币和钻石 + ActionLog.addDayLog(call.conn.uid, { key: 'got_'+atn.t, val: atn.n }); + } + // 增加vip经验的任务监听 if (atn.t == "payExp" && atn.n > 0) { G.emit("Class_task_157", 'Class_task_157', call, atn.n, 0); diff --git a/src/public/scheduler/scheduler_watchdog.ts b/src/public/scheduler/scheduler_watchdog.ts index 1b04b5c..8243d0c 100644 --- a/src/public/scheduler/scheduler_watchdog.ts +++ b/src/public/scheduler/scheduler_watchdog.ts @@ -14,8 +14,6 @@ export class WatchDog extends Scheduler { await this.ctorStartTime(); this.isReady = false; this.startTime = this.nextTime; - - this.start(); } async start() { From a1c7f2e4d05b9eff64e489414c61113ddc28a5eb Mon Sep 17 00:00:00 2001 From: dy Date: Wed, 3 Jan 2024 11:01:12 +0800 Subject: [PATCH 04/11] =?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() From 1fcedaff59dae764f11725ca21f6867cc0b70015 Mon Sep 17 00:00:00 2001 From: dy Date: Wed, 3 Jan 2024 11:09:39 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/scheduler/scheduler.ts | 3 +- src/public/scheduler/scheduler_dataWarn.ts | 58 ---------------------- src/setStartAfther.ts | 3 -- 3 files changed, 1 insertion(+), 63 deletions(-) delete mode 100644 src/public/scheduler/scheduler_dataWarn.ts diff --git a/src/public/scheduler/scheduler.ts b/src/public/scheduler/scheduler.ts index e8fa6b9..438360c 100644 --- a/src/public/scheduler/scheduler.ts +++ b/src/public/scheduler/scheduler.ts @@ -38,8 +38,7 @@ export type schedulerType = | 'hbzb_zbs_group' | 'wzry_zuanshi16to8' | "cross_email_pull" - | "xiaofeijingsai_local_ctor" - | "local_data_warn" + | "xiaofeijingsai_local_ctor"; export class SchedulerManage { static logTime = false; diff --git a/src/public/scheduler/scheduler_dataWarn.ts b/src/public/scheduler/scheduler_dataWarn.ts deleted file mode 100644 index d1d4f4f..0000000 --- a/src/public/scheduler/scheduler_dataWarn.ts +++ /dev/null @@ -1,58 +0,0 @@ -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 a67c0a5..25c609c 100644 --- a/src/setStartAfther.ts +++ b/src/setStartAfther.ts @@ -29,7 +29,6 @@ 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() { //事件监听和定时器初始化 @@ -91,8 +90,6 @@ export async function startAfter() { new SchedulerWzryAutoBaoMing().init(); new SchedulerWzryjingcaiSendPrize().init(); new SchedulerWzryendDel().init(); - - new Scheduler_dataWarn().init() // new SchedulerWzrycrossEmail(); new CrossEmailPull().init() From 1a9f942297381aabe3ea0898d8d03a782461e3f0 Mon Sep 17 00:00:00 2001 From: dy Date: Wed, 3 Jan 2024 11:38:06 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/public/player.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/public/player.ts b/src/public/player.ts index 44ba9d0..2647bce 100644 --- a/src/public/player.ts +++ b/src/public/player.ts @@ -231,16 +231,12 @@ export class PlayerFun { atn } G.mongodb.collection('rmbuse').insertOne(data); - 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}); - } + // 消费竞赛开启时写入跨服数据库 + 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}); } } From 43aeef25012de587a2c78f3eba4d51a003886a83 Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Wed, 3 Jan 2024 13:44:51 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E5=AE=B9=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_s2c/event/leijichongzhi/ApiOpen.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/api_s2c/event/leijichongzhi/ApiOpen.ts b/src/api_s2c/event/leijichongzhi/ApiOpen.ts index 801ee88..8d19dac 100644 --- a/src/api_s2c/event/leijichongzhi/ApiOpen.ts +++ b/src/api_s2c/event/leijichongzhi/ApiOpen.ts @@ -26,7 +26,7 @@ export default async function (call: ApiCall) { db = await checkNextRound(call, db, _hdinfo.data.tasks) let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.rtime)) * 10 - payNum = payNum - (db.round || 0) * R.sort((a, b) => b.total - a.total)(_hdinfo.data.tasks)[0].total + payNum = payNum - (db?.round || 0) * R.sort((a, b) => b.total - a.total)(_hdinfo.data.tasks)[0].total call.succ({ sTime: sTime, From 22b577036f7b8d8b61af8495272026c93fa2c4a8 Mon Sep 17 00:00:00 2001 From: dy Date: Wed, 3 Jan 2024 14:29:22 +0800 Subject: [PATCH 08/11] watchdog --- src/api_s2c/xstask/ApiOnekeyReceive.ts | 1 + src/oss/watchdog.json | 50 +++++++++++++++++++ src/public/scheduler/scheduler_watchdog.ts | 56 +++++++++++----------- src/public/xstask.ts | 2 + 4 files changed, 81 insertions(+), 28 deletions(-) diff --git a/src/api_s2c/xstask/ApiOnekeyReceive.ts b/src/api_s2c/xstask/ApiOnekeyReceive.ts index b8e4981..a776b77 100644 --- a/src/api_s2c/xstask/ApiOnekeyReceive.ts +++ b/src/api_s2c/xstask/ApiOnekeyReceive.ts @@ -44,6 +44,7 @@ export default async function (call: ApiCall if (star < taskConf.needStar) return call.error(globalThis.lng.xstask_8); change[receive._id] = { time: G.time, heros: receive.heroIds }; + XstaskFun.receiveNum(call.uid) } Object.entries(change).forEach(([k, v]) => { diff --git a/src/oss/watchdog.json b/src/oss/watchdog.json index 629f6b8..e60bb3e 100644 --- a/src/oss/watchdog.json +++ b/src/oss/watchdog.json @@ -18,5 +18,55 @@ "key":"use_attr_rmbmoney", "limit":100000, "tips":"钻石消耗达到10万" + }, + { + "key":"tanxian/FastGuaJi", + "limit":40, + "tips":"快速探险达到40次" + }, + { + "key":"xstask/Receive/Num", + "limit":8, + "tips":"接取悬赏任务超过8个" + }, + { + "key":"dixiaqianzhuang/Qf", + "limit":500, + "tips":"地下钱庄使用次数超过500次" + }, + { + "key":"shop/Buy/2", + "limit":50, + "tips":"势力商店购买某一商品超过50次" + }, + { + "key":"shop/Buy/1", + "limit":10, + "tips":"杂货商店购买某一商品超过10次" + }, + { + "key":"peijiancangku/Jump", + "limit":500, + "tips":"指定高级仓库超过50次" + }, + { + "key":"meirishilian/Fight", + "limit":30, + "tips":"物资缴获挑战和扫荡累计超过30次" + }, + { + "key":"pata/SaoDang", + "limit":5, + "tips":"黑暗塔扫荡次数超过5次" + }, + { + "key":"lingzhulaixi/PkBoss", + "limit":15, + "tips":"讨伐海盗挑战次数超过15次" + }, + { + "key":"gonghui/FbFight", + "limit":5, + "tips":"势力战斗boss超过5次" } ] \ No newline at end of file diff --git a/src/public/scheduler/scheduler_watchdog.ts b/src/public/scheduler/scheduler_watchdog.ts index 8243d0c..6ef9bb8 100644 --- a/src/public/scheduler/scheduler_watchdog.ts +++ b/src/public/scheduler/scheduler_watchdog.ts @@ -1,8 +1,8 @@ -import { resolve } from "path"; -import { PublicShared } from "../../shared/public/public"; +import {resolve} from "path"; +import {PublicShared} from "../../shared/public/public"; import {Scheduler, schedulerType} from "./scheduler"; -import { existsSync, readFileSync } from "fs"; -import { addWatchDogLog, errorLogDB } from "../../gameLog"; +import {existsSync, readFileSync} from "fs"; +import {addWatchDogLog, errorLogDB} from "../../gameLog"; export class WatchDog extends Scheduler { id: schedulerType = "watch_dog"; @@ -24,28 +24,28 @@ export class WatchDog extends Scheduler { return; } let conf; - try{ + try { conf = await JSON.parse(readFileSync(confFile, 'utf-8')); - }catch(e){ + } catch (e) { //配置文件不是json await this.ctorStartTime() return; } //获取今天0点之后在线的玩家 let users = await G.mongodb.collection("user").find({ - lv : {$gt:10}, - newonlinetime:{$gt: PublicShared.getToDayZeroTime() } - },{ - projection:{ - uid:1, - name:1, - lv:1, - vip:1, - sid:1 + lv: {$gt: 10}, + newonlinetime: {$gte: G.time - 3600, $lte: G.time + 30} + }, { + projection: { + uid: 1, + name: 1, + lv: 1, + vip: 1, + sid: 1 } }).toArray(); - if(!users.length){ + if (!users.length) { //没有符合的玩家 await this.ctorStartTime() return; @@ -56,25 +56,25 @@ export class WatchDog extends Scheduler { users.map(i => uinfo[i.uid] = i); let actionLogs = await G.mongodb.collection("actionLog").find({ - type:'day', + type: 'day', uid: {$in: uids}, - },{ - projection:{ - uid:1, - log:1 + }, { + projection: { + uid: 1, + log: 1 } }).toArray(); let warns = []; - for(let j=0;j= conf[j].limit ){ + if (myval > conf[j].limit) { //触发了警报 warns.push({ - type:'watchDog', + type: 'watchDog', uid: uid, name: uinfo[uid]?.name, lv: uinfo[uid]?.lv, @@ -87,10 +87,10 @@ export class WatchDog extends Scheduler { } } - if(warns.length>0){ + if (warns.length > 0) { addWatchDogLog(warns); } - + await this.ctorStartTime() } diff --git a/src/public/xstask.ts b/src/public/xstask.ts index ef277a9..cfdce3d 100644 --- a/src/public/xstask.ts +++ b/src/public/xstask.ts @@ -3,6 +3,7 @@ import {ApiCall} from 'tsrpc'; import {playerInfoType} from '../module/collection_palyerInfo'; import {CollectionXstask} from '../module/collection_xstask'; import {PublicShared} from '../shared/public/public'; +import {ActionLog} from "./actionLog/actionLog"; export class XstaskFun { @@ -166,6 +167,7 @@ export class XstaskFun { G.mongodb.cEvent('xstask').updateOne({uid: uid, type: 'xstask'}, {$set: {refreshTime: G.time, receiveNum: 0}}, {upsert: true}); } else { + ActionLog.addDayLog(uid, { key: "xstask/Receive/Num", val: 1 }); G.mongodb.cEvent('xstask').updateOne({uid: uid, type: 'xstask'}, {$inc: {receiveNum: 1}}, {upsert: true}); } From 7e589e23b3d35cb11e01e31c23c63d27f55de364 Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Wed, 3 Jan 2024 14:31:47 +0800 Subject: [PATCH 09/11] =?UTF-8?q?=E5=AE=B9=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/extends.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extends.ts b/src/extends.ts index ee937d5..bccfa10 100644 --- a/src/extends.ts +++ b/src/extends.ts @@ -333,7 +333,7 @@ ApiCall.prototype.addEventMsg = function (this: ApiCall) { if (Object.keys(this.otherBuff).intersection(Object.keys(msg)).length > 0) this.conn.refreshPower(); break; case 'msg_s2c/LshdChange': - this.conn.lshd[msgKey] && PublicShared.mergeProperty(this.conn.lshd[msgKey], msg); + this.conn?.lshd?.[msgKey] && PublicShared.mergeProperty(this.conn.lshd[msgKey], msg); break; } }; From d490550abf0c56b05a445fd546ede0806b9d09c1 Mon Sep 17 00:00:00 2001 From: ciniao <4041990@qq.com> Date: Wed, 3 Jan 2024 14:44:50 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E5=AE=B9=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/extends.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extends.ts b/src/extends.ts index bccfa10..79729c4 100644 --- a/src/extends.ts +++ b/src/extends.ts @@ -251,7 +251,7 @@ BaseConnection.prototype.refreshPower = async function (this: BaseConnection Date: Wed, 3 Jan 2024 14:45:51 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E7=B4=AF=E8=AE=A1=E5=85=85=E5=80=BC?= =?UTF-8?q?=E8=BD=AE=E6=AC=A1=E5=8A=A0=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api_o2s/hdinfo/Apidetails.ts | 2 +- src/api_s2c/event/leijichongzhi/ApiOpen.ts | 2 +- src/api_s2c/event/leijichongzhi/ApiRec.ts | 11 +++++++---- src/api_s2c/hongdian/fun.ts | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/api_o2s/hdinfo/Apidetails.ts b/src/api_o2s/hdinfo/Apidetails.ts index 3e26fba..d96e313 100644 --- a/src/api_o2s/hdinfo/Apidetails.ts +++ b/src/api_o2s/hdinfo/Apidetails.ts @@ -32,7 +32,7 @@ export default async function (call: ApiCall) { let _tmp = { ranking: index, participantId: elementUser.uid, - value: await (await PayFun.getPayDaysAllPayNum(elementUser.uid, element.stime, element.rtime)).toString() + value: await (await PayFun.getPayDaysAllPayNum(elementUser.uid, element.stime, element.etime)).toString() } accountingData.push(_tmp) } diff --git a/src/api_s2c/event/leijichongzhi/ApiOpen.ts b/src/api_s2c/event/leijichongzhi/ApiOpen.ts index 75a9c9b..e0a058d 100644 --- a/src/api_s2c/event/leijichongzhi/ApiOpen.ts +++ b/src/api_s2c/event/leijichongzhi/ApiOpen.ts @@ -23,7 +23,7 @@ export default async function (call: ApiCall) { {upsert: true} ); } - db = await checkNextRound(call, db, _hdinfo.data.tasks) + db = await checkNextRound(call, db, _hdinfo) let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.etime)) * 10 payNum = payNum - (db?.round || 0) * R.sort((a, b) => b.total - a.total)(_hdinfo.data.tasks)[0].total diff --git a/src/api_s2c/event/leijichongzhi/ApiRec.ts b/src/api_s2c/event/leijichongzhi/ApiRec.ts index 5586907..27d601b 100644 --- a/src/api_s2c/event/leijichongzhi/ApiRec.ts +++ b/src/api_s2c/event/leijichongzhi/ApiRec.ts @@ -20,7 +20,7 @@ export default async function (call: ApiCall) { let db = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType}); if (db.recIndex.includes(call.req.index)) return call.error('', {code: -2}); - let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.rtime)) * 10; + let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.etime)) * 10; payNum = payNum - (db.round || 0) * R.sort((a, b) => b.total - a.total)(_hdinfo.data.tasks)[0].total if (payNum < conf.total) return call.error('', {code: -3}); @@ -31,7 +31,7 @@ export default async function (call: ApiCall) { {$push: {recIndex: call.req.index}} ); - await checkNextRound(call, db, _hdinfo.data.tasks) + await checkNextRound(call, db, _hdinfo) HongDianChange.sendChangeKey(call.uid, ['huodonghd']) call.succ({ @@ -39,8 +39,11 @@ export default async function (call: ApiCall) { }); } -export async function checkNextRound(call: ApiCall, event, tasks) { - if ((event?.recIndex?.length || 0) < tasks.length) return event +export async function checkNextRound(call: ApiCall, event, _hdinfo) { + if ((event?.recIndex?.length || 0) < _hdinfo.data.tasks.length) return event + let payNum = (await PayFun.getPayDaysAllPayNum(call.uid, _hdinfo.stime, _hdinfo.etime)) * 10 + payNum = payNum - (event?.round || 0) * R.sort((a, b) => b.total - a.total)(_hdinfo.data.tasks)[0].total + if (payNum < 0) return event let _dbType: `leijichongzhi${number}` = `leijichongzhi${call.req.hdid}` return (await G.mongodb.cEvent(_dbType).findOneAndUpdate( diff --git a/src/api_s2c/hongdian/fun.ts b/src/api_s2c/hongdian/fun.ts index f8a301b..ec2094a 100644 --- a/src/api_s2c/hongdian/fun.ts +++ b/src/api_s2c/hongdian/fun.ts @@ -656,7 +656,7 @@ export class HuoDongHongDianFun { let _con = hdCon.data.tasks; let db = await G.mongodb.cEvent(_dbType).findOne({uid: call.uid, type: _dbType}); let _mydata = db || {sTime: PublicShared.getToDayZeroTime(G.time), recIndex: []}; - let payNum = await PayFun.getPayDaysAllPayNum(call.uid, hdCon.stime, hdCon.rtime); + let payNum = await PayFun.getPayDaysAllPayNum(call.uid, hdCon.stime, hdCon.etime); for (let index = 0; index < _con.length; index++) { const element = _con[index]; if (_mydata.recIndex.includes(index)) continue;