定时任务:修复自动开服开关
This commit is contained in:
@@ -645,10 +645,15 @@ export async function stopMaintenance(batchCode: string, serverIds: number[]) {
|
|||||||
// —————————————— 自动开服 —————————————— //
|
// —————————————— 自动开服 —————————————— //
|
||||||
export async function initAutoCreateServer(region?: RegionType) {
|
export async function initAutoCreateServer(region?: RegionType) {
|
||||||
if(!region) region = await RegionModel.findRegionByEnv(pinus.app.get('env'));
|
if(!region) region = await RegionModel.findRegionByEnv(pinus.app.get('env'));
|
||||||
if(region && region.stategy) {
|
if(region && region.stategy && region.stategy.isOpen) {
|
||||||
for(let timer of region.stategy.timers) {
|
for(let timer of region.stategy.timers) {
|
||||||
setStategyTimer(timer, region)
|
setStategyTimer(timer, region)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if(scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`]) scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`].cancel();
|
||||||
|
if(scheduledJobs[`autoServer${SERVER_TIMER.TEN_HALF}`]) scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`].cancel();
|
||||||
|
if(scheduledJobs[`autoServer${SERVER_TIMER.FIFTEEN_HALF}`]) scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`].cancel();
|
||||||
|
if(scheduledJobs[`autoServer${SERVER_TIMER.NINETEEN_HALF}`]) scheduledJobs[`autoServer${SERVER_TIMER.FIVE_HALF}`].cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ export class GMMail {
|
|||||||
|
|
||||||
export default class ServerStategy {
|
export default class ServerStategy {
|
||||||
|
|
||||||
|
@prop({ required: true, default: false })
|
||||||
|
isOpen: boolean; // 是否开启
|
||||||
|
|
||||||
@prop({ required: true, default: 0 })
|
@prop({ required: true, default: 0 })
|
||||||
maxPlayerCnt: number; // 人数上限
|
maxPlayerCnt: number; // 人数上限
|
||||||
|
|
||||||
@@ -72,6 +75,7 @@ export default class ServerStategy {
|
|||||||
stopRegisterTime: number; // 关闭注册时间
|
stopRegisterTime: number; // 关闭注册时间
|
||||||
|
|
||||||
constructor(stategy: ServerStategyUpdate & { hasOpenMail: boolean, hasCircleMail: boolean}) {
|
constructor(stategy: ServerStategyUpdate & { hasOpenMail: boolean, hasCircleMail: boolean}) {
|
||||||
|
this.isOpen = stategy.isOpen;
|
||||||
this.maxPlayerCnt = stategy.maxPlayerCnt;
|
this.maxPlayerCnt = stategy.maxPlayerCnt;
|
||||||
this.timers = stategy.timers;
|
this.timers = stategy.timers;
|
||||||
this.activityGroupId = stategy.activityGroupId;
|
this.activityGroupId = stategy.activityGroupId;
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ export class UpdateRegionParams {
|
|||||||
openMail?: GMMail;
|
openMail?: GMMail;
|
||||||
circleMail?: GMMail;
|
circleMail?: GMMail;
|
||||||
stopRegisterTime: number = 0;
|
stopRegisterTime: number = 0;
|
||||||
|
isOpen: boolean = false;
|
||||||
|
|
||||||
hasOpenMail: boolean = false;
|
hasOpenMail: boolean = false;
|
||||||
hasCircleMail: boolean = false;
|
hasCircleMail: boolean = false;
|
||||||
@@ -95,7 +96,12 @@ export class UpdateRegionParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
checkParams() {
|
checkParams() {
|
||||||
if(!this.id || !this.name || !this.prefix || !this.maxPlayerCnt || !isArray(this.timers) || this.timers.length <= 0 || !isArray(this.activityGroupId) || this.activityGroupId.length <= 0 || !isString(this.versionCode) || !isString(this.curVersion) || !isString(this.updateResUrl)) {
|
if(!this.id || !this.name || !this.prefix || !isString(this.versionCode) || !isString(this.curVersion) || !isString(this.updateResUrl)) {
|
||||||
|
console.log('1111', !this.id, !this.name, !this.prefix, !isString(this.versionCode),!isString(this.curVersion), !isString(this.updateResUrl))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if(this.isOpen && (!this.maxPlayerCnt || !isArray(this.timers) || this.timers.length <= 0 || !isArray(this.activityGroupId) || this.activityGroupId.length <= 0 )) {
|
||||||
|
console.log('2222')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user