Merge branch 'bugfix' into release
This commit is contained in:
commit
1ec21d71e0
@ -1,6 +1,4 @@
|
|||||||
import {ApiCall} from "tsrpc";
|
import {ApiCall} from "tsrpc";
|
||||||
import {EventFun} from '../public/event/event';
|
|
||||||
import {PayFun} from '../public/pay';
|
|
||||||
import {ReqSyncBtn, ResSyncBtn, syncBtnKeys} from "../shared/protocols/PtlSyncBtn";
|
import {ReqSyncBtn, ResSyncBtn, syncBtnKeys} from "../shared/protocols/PtlSyncBtn";
|
||||||
import {PublicShared} from '../shared/public/public';
|
import {PublicShared} from '../shared/public/public';
|
||||||
import {HuoDongFun} from "../public/huodongfun";
|
import {HuoDongFun} from "../public/huodongfun";
|
||||||
@ -8,7 +6,6 @@ import {HuoDongFun} from "../public/huodongfun";
|
|||||||
const defaultKeys: syncBtnKeys[] = [
|
const defaultKeys: syncBtnKeys[] = [
|
||||||
'huobanzhaomu', 'yibaichou', 'shouchong',
|
'huobanzhaomu', 'yibaichou', 'shouchong',
|
||||||
'dayjijin', 'dengjijijin', 'guanqiajijin', 'tianshujijin',
|
'dayjijin', 'dengjijijin', 'guanqiajijin', 'tianshujijin',
|
||||||
'zhanling',
|
|
||||||
'xianshilibao',
|
'xianshilibao',
|
||||||
'xianshizhaomu',
|
'xianshizhaomu',
|
||||||
'G123Gift',
|
'G123Gift',
|
||||||
@ -65,39 +62,40 @@ export default async function (call: ApiCall<ReqSyncBtn, ResSyncBtn>) {
|
|||||||
break;
|
break;
|
||||||
case 'zhanling':
|
case 'zhanling':
|
||||||
//30天一轮循环,不管奖励。常驻活动
|
//30天一轮循环,不管奖励。常驻活动
|
||||||
if (!PublicShared.getEventIsOpen(G.gc.zhanling.eventOpen, call.conn.gud)) {
|
// if (!PublicShared.getEventIsOpen(G.gc.zhanling.eventOpen, call.conn.gud)) {
|
||||||
data[key] = {active: false};
|
// data[key] = {active: false};
|
||||||
} else {
|
// } else {
|
||||||
let zls = await G.mongodb.collection('scheduler').findOne({type: 'zhanling'});
|
// let zls = await G.mongodb.collection('scheduler').findOne({type: 'zhanling'});
|
||||||
if (!data[key] || data[key].round != zls?.round) {
|
// if (!data[key] || data[key].round != (zls?.round || 0)) {
|
||||||
let lastRunTime = zls && zls.lastRunTime? zls.lastRunTime : G.time
|
// let lastRunTime = zls && zls.lastRunTime? zls.lastRunTime : G.time
|
||||||
let round = zls && zls.lastRunTime? zls.round : 1
|
// let round = zls && zls.lastRunTime? zls.round : 1
|
||||||
data[key] = {active: true, sTime: lastRunTime, round: round};
|
|
||||||
change[key] = data[key];
|
|
||||||
|
|
||||||
PayFun.delPayLog(call.uid, {payId: G.gc.zhanling.payId, val: []});
|
// data[key] = {active: true, sTime: lastRunTime, round: round};
|
||||||
|
// change[key] = data[key];
|
||||||
|
|
||||||
G.mongodb.cEvent('zhanling').findOne({uid: call.uid, type: 'zhanling'}).then(data => {
|
// PayFun.delPayLog(call.uid, {payId: G.gc.zhanling.payId, val: []});
|
||||||
//新一轮战令 不管玩家多久没上线 只补发玩家上一轮没有领取的奖励
|
|
||||||
data && EventFun.reissueZhanLingPrize(data, call.conn.gud);
|
|
||||||
|
|
||||||
G.mongodb.cEvent('zhanling').updateOne(
|
// G.mongodb.cEvent('zhanling').findOne({uid: call.uid, type: 'zhanling'}).then(data => {
|
||||||
{uid: call.uid, type: 'zhanling'},
|
// //新一轮战令 不管玩家多久没上线 只补发玩家上一轮没有领取的奖励
|
||||||
{
|
// data && EventFun.reissueZhanLingPrize(data, call.conn.gud);
|
||||||
$set: {
|
|
||||||
lv: 1,
|
// G.mongodb.cEvent('zhanling').updateOne(
|
||||||
exp: 0,
|
// {uid: call.uid, type: 'zhanling'},
|
||||||
rec: {},
|
// {
|
||||||
isPay: false,
|
// $set: {
|
||||||
taskRec: [],
|
// lv: 1,
|
||||||
refreshTime: G.time
|
// exp: 0,
|
||||||
}
|
// rec: {},
|
||||||
},
|
// isPay: false,
|
||||||
{upsert: true}
|
// taskRec: [],
|
||||||
);
|
// refreshTime: G.time
|
||||||
});
|
// }
|
||||||
}
|
// },
|
||||||
}
|
// {upsert: true}
|
||||||
|
// );
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
break;
|
break;
|
||||||
case 'xianshilibao':
|
case 'xianshilibao':
|
||||||
// 到时间消失
|
// 到时间消失
|
||||||
|
@ -3,12 +3,13 @@ import {ZhanLingTasks} from '../../../public/zhanling';
|
|||||||
import { ReqOpen, ResOpen } from "../../../shared/protocols/event/zhanling/PtlOpen";
|
import { ReqOpen, ResOpen } from "../../../shared/protocols/event/zhanling/PtlOpen";
|
||||||
import { player } from '../../../shared/protocols/user/type';
|
import { player } from '../../../shared/protocols/user/type';
|
||||||
import { PublicShared } from '../../../shared/public/public';
|
import { PublicShared } from '../../../shared/public/public';
|
||||||
|
import { PayFun } from "../../../public/pay";
|
||||||
|
|
||||||
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
||||||
let zls = await G.mongodb.collection('scheduler').findOne({ type: 'zhanling' });
|
let zls = await G.mongodb.collection('scheduler').findOne({ type: 'zhanling' });
|
||||||
let data = await G.mongodb.cEvent('zhanling').findOne({ uid: call.uid, type: 'zhanling' });
|
let data = await G.mongodb.cEvent('zhanling').findOne({ uid: call.uid, type: 'zhanling' });
|
||||||
|
|
||||||
if (!data || data.round != (zls?.round | 0)) {
|
if (!data || data.round != (zls?.round || 0)) {
|
||||||
let set = {
|
let set = {
|
||||||
lv: 1,
|
lv: 1,
|
||||||
exp: 0,
|
exp: 0,
|
||||||
@ -20,6 +21,10 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
|
|||||||
refreshTime: G.time,
|
refreshTime: G.time,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await PayFun.delPayLog(
|
||||||
|
call.uid, { payId: G.gc.zhanling.payId, val: [] }
|
||||||
|
);
|
||||||
|
|
||||||
data = (await G.mongodb.cEvent('zhanling').findOneAndUpdate({
|
data = (await G.mongodb.cEvent('zhanling').findOneAndUpdate({
|
||||||
uid: call.uid,
|
uid: call.uid,
|
||||||
type: 'zhanling'
|
type: 'zhanling'
|
||||||
|
@ -211,7 +211,8 @@ export function addListener() {
|
|||||||
|
|
||||||
// 签到增加天数
|
// 签到增加天数
|
||||||
SignFun.updateLogin(gud.uid);
|
SignFun.updateLogin(gud.uid);
|
||||||
ActionLog.initDayLog(gud.uid);
|
//移到定时器里统一执行
|
||||||
|
//ActionLog.initDayLog(gud.uid);
|
||||||
ActionLog.addRetainLog(gud.uid, { key: 'login_day', val: 1 });
|
ActionLog.addRetainLog(gud.uid, { key: 'login_day', val: 1 });
|
||||||
ZhanLingTasks.clearLog(gud.uid, 'day');
|
ZhanLingTasks.clearLog(gud.uid, 'day');
|
||||||
PayFun.checkGiftDayEmail(gud, lastTime, curTime);
|
PayFun.checkGiftDayEmail(gud, lastTime, curTime);
|
||||||
|
3
src/oss/blackapi.json
Normal file
3
src/oss/blackapi.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
[
|
||||||
|
|
||||||
|
]
|
@ -1,9 +1,33 @@
|
|||||||
|
import { PublicShared } from "../../shared/public/public";
|
||||||
|
|
||||||
|
|
||||||
export class ActionLog {
|
export class ActionLog {
|
||||||
static async initDayLog(uid: string) {
|
/**
|
||||||
G.mongodb.cActionLog('day').updateOne({ uid: uid, type: 'day' }, { $set: { log: {} } }, { upsert: true });
|
* 每天0点的时候,重置所有的统计数据
|
||||||
|
*/
|
||||||
|
static async initAllDayLog() {
|
||||||
|
await G.mongodb.cActionLog('day').updateMany({type: 'day' }, {
|
||||||
|
$set: {
|
||||||
|
log: {},
|
||||||
|
//增加刷新时间
|
||||||
|
lastTime: PublicShared.getToDayZeroTime(G.time)
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重置某个玩家的统计信息
|
||||||
|
* @param uid
|
||||||
|
*/
|
||||||
|
// static async initDayLog(uid: string) {
|
||||||
|
// G.mongodb.cActionLog('day').updateOne({ uid: uid, type: 'day' }, {
|
||||||
|
// $set: {
|
||||||
|
// log: {},
|
||||||
|
// //增加刷新时间
|
||||||
|
// lastTime: PublicShared.getToDayZeroTime(G.time)
|
||||||
|
// }
|
||||||
|
// }, { upsert: true });
|
||||||
|
// }
|
||||||
static async addDayLog(uid: string, ...args: { key: string, val: number; }[]) {
|
static async addDayLog(uid: string, ...args: { key: string, val: number; }[]) {
|
||||||
const addObj = G.mongodb.createTreeObj(...args.map(a => { return { key: 'log', k: a.key, val: a.val }; }));
|
const addObj = G.mongodb.createTreeObj(...args.map(a => { return { key: 'log', k: a.key, val: a.val }; }));
|
||||||
G.mongodb.cActionLog('day').updateOne({ uid: uid, type: 'day' }, { $inc: addObj });
|
G.mongodb.cActionLog('day').updateOne({ uid: uid, type: 'day' }, { $inc: addObj });
|
||||||
|
@ -4,11 +4,14 @@ import { Wjjl } from "../../module/collection_wjjl";
|
|||||||
import { ZhanLingTasks } from "../zhanling";
|
import { ZhanLingTasks } from "../zhanling";
|
||||||
import { setGud } from '../gud';
|
import { setGud } from '../gud';
|
||||||
import { EmailFun } from '../email';
|
import { EmailFun } from '../email';
|
||||||
|
import { ActionLog } from '../actionLog/actionLog';
|
||||||
|
import { clusterFun } from '../../clusterFunction';
|
||||||
|
import { clusterRunOnce } from '../../clusterUtils';
|
||||||
|
|
||||||
|
|
||||||
export class SchedulerNewDayLocalCtor extends Scheduler {
|
export class SchedulerNewDayLocalCtor extends Scheduler {
|
||||||
id: schedulerType = 'newDay_local_ctor';
|
id: schedulerType = 'newDay_local_ctor';
|
||||||
time = 0;
|
time = 1;
|
||||||
name = '定时推送跨天通知';
|
name = '定时推送跨天通知';
|
||||||
type: 'day' | 'week' = 'day';
|
type: 'day' | 'week' = 'day';
|
||||||
|
|
||||||
@ -23,6 +26,41 @@ export class SchedulerNewDayLocalCtor extends Scheduler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async start() {
|
async start() {
|
||||||
|
|
||||||
|
clusterRunOnce(async ()=>{
|
||||||
|
//这个定时器会被每个进程都启动,这是这部分逻辑,应该只执行1次
|
||||||
|
|
||||||
|
//重置所有的ActionLog
|
||||||
|
await ActionLog.initAllDayLog();
|
||||||
|
|
||||||
|
// 每周一,发放终身卡
|
||||||
|
(async () => {
|
||||||
|
if (PublicShared.getWeek(G.time) == 1) {
|
||||||
|
let logs = await G.mongodb.collection("payLogNew").find(
|
||||||
|
{ key: "zhongshenka", del_time: { $exists: false } }, { projection: { _id: 0, } }
|
||||||
|
).toArray();
|
||||||
|
|
||||||
|
if (logs.length == 0) {
|
||||||
|
console.log("没有终身卡数据,不发放终身卡");
|
||||||
|
}
|
||||||
|
let con = G.gc.payEmail.zhongshenka.filter(e => e.day == 7)[0];
|
||||||
|
for (let i = 0; i < logs.length; i++) {
|
||||||
|
console.log("发放终身卡", logs[i].uid);
|
||||||
|
// 发送邮件
|
||||||
|
EmailFun.addEmail({
|
||||||
|
uid: logs[i].uid,
|
||||||
|
type: "system",
|
||||||
|
title: con.title,
|
||||||
|
content: con.content,
|
||||||
|
contentInsertArr: [],
|
||||||
|
createTime: G.time,
|
||||||
|
prize:con.prize,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
})
|
||||||
|
|
||||||
let users = Object.values(G.server.uid_connections)
|
let users = Object.values(G.server.uid_connections)
|
||||||
if (users.length) {
|
if (users.length) {
|
||||||
for (let item of users) {
|
for (let item of users) {
|
||||||
@ -56,34 +94,6 @@ export class SchedulerNewDayLocalCtor extends Scheduler {
|
|||||||
G.server.broadcastClusterMsg('msg_s2c/NewDay', { time: this.zeroTime });
|
G.server.broadcastClusterMsg('msg_s2c/NewDay', { time: this.zeroTime });
|
||||||
}
|
}
|
||||||
|
|
||||||
(async () => {
|
await this.record();
|
||||||
// 每周一,发放终身卡
|
|
||||||
if (PublicShared.getWeek(G.time) != 1) {
|
|
||||||
console.log("不是周一,不发放终身卡", PublicShared.getWeek(G.time));
|
|
||||||
return
|
|
||||||
};
|
|
||||||
|
|
||||||
let logs = await G.mongodb.collection("payLogNew").find(
|
|
||||||
{ key: "zhongshenka", del_time: { $exists: false } }, { projection: { _id: 0, } }
|
|
||||||
).toArray();
|
|
||||||
|
|
||||||
if (logs.length == 0) {
|
|
||||||
console.log("没有终身卡数据,不发放终身卡");
|
|
||||||
}
|
|
||||||
let con = G.gc.payEmail.zhongshenka.filter(e => e.day == 7)[0];
|
|
||||||
for (let i = 0; i < logs.length; i++) {
|
|
||||||
console.log("发放终身卡", logs[i].uid);
|
|
||||||
// 发送邮件
|
|
||||||
EmailFun.addEmail({
|
|
||||||
uid: logs[i].uid,
|
|
||||||
type: "system",
|
|
||||||
title: con.title,
|
|
||||||
content: con.content,
|
|
||||||
contentInsertArr: [],
|
|
||||||
createTime: G.time,
|
|
||||||
prize:con.prize,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ export class SchedulerZhanLing extends Scheduler {
|
|||||||
let data = await this.db.findOne({ type: this.id });
|
let data = await this.db.findOne({ type: this.id });
|
||||||
if (!data) {
|
if (!data) {
|
||||||
// 开服时间整除战令周期
|
// 开服时间整除战令周期
|
||||||
let round = Math.floor(PublicShared.getOpenServerDay() / G.gc.zhanling.eventOpen.day)
|
let round = Math.floor((PublicShared.getOpenServerDay() - 1) / G.gc.zhanling.eventOpen.day)
|
||||||
let prev_run_time = PublicShared.getToDayZeroTime(G.openTime) + round * G.gc.zhanling.eventOpen.day * 86400
|
let prev_run_time = PublicShared.getToDayZeroTime(G.openTime) + round * G.gc.zhanling.eventOpen.day * 86400
|
||||||
this.db.updateOne({ type: this.id }, { $set: { lastRunTime: prev_run_time, round: round } }, { upsert: true });
|
this.db.updateOne({ type: this.id }, { $set: { lastRunTime: prev_run_time, round: round } }, { upsert: true });
|
||||||
}
|
}
|
||||||
|
41
src/setWs.ts
41
src/setWs.ts
@ -47,6 +47,12 @@ export async function createWs() {
|
|||||||
|
|
||||||
G.argv.serverType == 'msg' && G.config.corssWsUrl && await createWsClient();
|
G.argv.serverType == 'msg' && G.config.corssWsUrl && await createWsClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**每分钟刷新一次黑名单API接口 */
|
||||||
|
setInterval(()=>{
|
||||||
|
getBlackList();
|
||||||
|
},60000);
|
||||||
|
getBlackList();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWssFile() {
|
function getWssFile() {
|
||||||
@ -63,6 +69,21 @@ function getWssFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const writeList = ['hongdian/Get']
|
const writeList = ['hongdian/Get']
|
||||||
|
/**当前锁定的API接口 */
|
||||||
|
let blackApi = [];
|
||||||
|
|
||||||
|
async function getBlackList(){
|
||||||
|
let confFile = resolve(__dirname, 'oss/blackapi.json');
|
||||||
|
if (existsSync(confFile)) {
|
||||||
|
try {
|
||||||
|
blackApi = await JSON.parse(readFileSync(confFile, 'utf-8'));
|
||||||
|
} catch (e) {
|
||||||
|
blackApi = [];
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
blackApi = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function setWs(server: WsServer<ServiceType>) {
|
function setWs(server: WsServer<ServiceType>) {
|
||||||
|
|
||||||
@ -101,15 +122,17 @@ function setWs(server: WsServer<ServiceType>) {
|
|||||||
|
|
||||||
//执行 API 接口实现之前
|
//执行 API 接口实现之前
|
||||||
server.flows.preApiCallFlow.push(async call => {
|
server.flows.preApiCallFlow.push(async call => {
|
||||||
// 临时停服维护方案
|
//判断是否是被关闭的API
|
||||||
// let lng = {
|
if (blackApi.includes(call.service.name) || blackApi.includes("all")) {
|
||||||
// "zh-TW": "停服維護中,請等待!",
|
let lng = {
|
||||||
// "ko": "서버 점검 중, 잠시만 기다려 주세요.",
|
"zh-TW": "維護中,請等待",
|
||||||
// "ja": "サーバーメンテナンス中、しばらくお待ちください。",
|
"ko": "유지 보수 중, 대기 중",
|
||||||
// "en": "Server under maintenance. Please wait.",
|
"ja": "メンテナンス中ですので、お待ちください",
|
||||||
// }
|
"en": "Maintenance in progress, please wait",
|
||||||
// call.error("", {code: -1, message: lng[call.req.lng] || lng["ja"]})
|
}
|
||||||
// return null;
|
call.error("", {code: -1, message: lng[call.req.lng] || lng["ja"]})
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
//是否短时间内重复请求某个api
|
//是否短时间内重复请求某个api
|
||||||
// let timeIntervalLimit = call.service.conf?.timeIntervalLimit == undefined ? 500 : call.service.conf?.timeIntervalLimit;
|
// let timeIntervalLimit = call.service.conf?.timeIntervalLimit == undefined ? 500 : call.service.conf?.timeIntervalLimit;
|
||||||
|
Loading…
Reference in New Issue
Block a user