Compare commits

...

19 Commits

Author SHA1 Message Date
xichaoyin
20f0f41c22 fix:
王者荣耀发奖定时器容错修改
2024-01-03 15:47:02 +08:00
dy
6cc58ffd94 还原 2024-01-03 15:22:36 +08:00
dy
8d9ecf30b6 Merge remote-tracking branch 'origin/bugfix' into bugfix
# Conflicts:
#	src/api_s2c/event/leijichongzhi/ApiRec.ts
2024-01-03 14:46:30 +08:00
dy
ec85961633 累计充值轮次加校验 2024-01-03 14:45:51 +08:00
d490550abf 容错 2024-01-03 14:44:50 +08:00
38dca3a653 Merge branch 'bugfix' of http://git.legu.cc/qixin/HJ_Server into bugfix 2024-01-03 14:32:40 +08:00
7e589e23b3 容错 2024-01-03 14:31:47 +08:00
dy
22b577036f watchdog 2024-01-03 14:29:22 +08:00
6e9d65241e Merge branch 'bugfix' of http://git.legu.cc/qixin/HJ_Server into bugfix 2024-01-03 14:00:29 +08:00
43aeef2501 容错 2024-01-03 13:44:51 +08:00
dy
1a9f942297 还原 2024-01-03 11:38:06 +08:00
dy
8f0c24bc87 Merge branch 'feature/warning' into bugfix 2024-01-03 11:09:56 +08:00
dy
1fcedaff59 还原 2024-01-03 11:09:39 +08:00
dy
a1c7f2e4d0 监控init 2024-01-03 11:01:12 +08:00
78c306ce5e 数据监控 2024-01-03 10:58:09 +08:00
ad15cf73bf Merge branch 'bugfix' of http://git.legu.cc/qixin/HJ_Server into bugfix 2024-01-03 10:36:35 +08:00
3c380f1e55 数据监控 2024-01-03 10:36:17 +08:00
dy
953303d9a4 Merge branch 'master' into feature/warning 2024-01-03 10:18:20 +08:00
dy
d2ddc62752 fix round 2024-01-02 15:49:24 +08:00
18 changed files with 242 additions and 17 deletions

5
.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,5 @@
{
"recommendations": [
"ms-ceintl.vscode-language-pack-zh-hans"
]
}

4
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"editor.suggest.snippetsPreventQuickSuggestions": false,
"aiXcoder.showTrayIcon": true
}

View File

@ -32,7 +32,7 @@ export default async function (call: ApiCall<Reqdetails, Resdetails>) {
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)
}

View File

@ -23,10 +23,10 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
{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.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,

View File

@ -20,7 +20,7 @@ export default async function (call: ApiCall<ReqRec, ResRec>) {
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<ReqRec, ResRec>) {
{$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,9 +39,13 @@ export default async function (call: ApiCall<ReqRec, ResRec>) {
});
}
export async function checkNextRound(call: ApiCall, event, tasks) {
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}`
if ((event?.recIndex?.length || 0) < tasks.length) return event
return (await G.mongodb.cEvent(_dbType).findOneAndUpdate(
{uid: call.uid, type: _dbType},
{$set: {recIndex: []}, $inc: {round: 1}}, {returnDocument: 'after'}

View File

@ -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;

View File

@ -44,6 +44,7 @@ export default async function (call: ApiCall<ReqOnekeyReceive, ResOnekeyReceive>
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]) => {

View File

@ -251,7 +251,7 @@ BaseConnection.prototype.refreshPower = async function (this: BaseConnection<Ser
this.sendMsg('msg_s2c/PlayerChange', dbUpdate);
let rankKfjs = RankKfjs(7)
rankKfjs.setDataAndCheck({
rankKfjs?.setDataAndCheck({
player: this.gud,
valArr: [power]
});
@ -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;
}
};

View File

@ -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

72
src/oss/watchdog.json Normal file
View File

@ -0,0 +1,72 @@
[
{
"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万"
},
{
"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次"
}
]

View File

@ -230,7 +230,7 @@ export class EmailFun {
})).insertedId.toHexString();
sendEmail._id = _id;
G.server.broadcastMsg('msg_s2c/Email', sendEmail);
G.server?.broadcastMsg('msg_s2c/Email', sendEmail);
return _id;
}

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 = {
@ -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);

View File

@ -38,6 +38,7 @@ export type schedulerType =
| 'hbzb_zbs_group'
| 'wzry_zuanshi16to8'
| "cross_email_pull"
| "watch_dog"
| "xiaofeijingsai_local_ctor";
export class SchedulerManage {

View File

@ -0,0 +1,105 @@
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;
}
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: {$gte: G.time - 3600, $lte: G.time + 30}
}, {
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.length; j++) {
for (let i = 0; i < actionLogs.length; i++) {
let key = conf[j].key;
let myval = actionLogs[i]?.log?.[key] || 0
let uid = actionLogs[i].uid
if (myval > 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;
}
}

View File

@ -113,7 +113,7 @@ export class SchedulerWzryDlDjinji extends SchedulerWzryAutoBaoMing {
}
let _userList = []
//0号位 -1的这一条表示晋级奖励
let prize = G.gc.wangzherongyao.wangzhe.jiangli.dld[0].p
let prize = G.gc.wangzherongyao.wangzhe.jiangli.dld[0]?.p || []
for (let index = 0; index < _zuanshiUser.length; index++) {
const element = _zuanshiUser[index];
@ -306,7 +306,7 @@ export class SchedulerWzryZuanshiSendPrize extends SchedulerWzryAutoBaoMing {
_u.push(element.uid)
if (element.data.player.uid.indexOf('npc_') != -1) continue
if (element?.isprize?.[this.typeprzie]) continue
let prize = _prizeCon[this.idx[element.deep]].p
let prize = _prizeCon[this.idx[element.deep]]?.p || [];
//注意这里的调用addEmail时cross参数用的是true
//因为这个定时器是在跨服上执行的,邮件先临时放到跨服

View File

@ -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;
}

View File

@ -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});
}

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 { 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();