后台:停止维护逻辑

This commit is contained in:
luying
2021-07-16 17:36:16 +08:00
parent 5dba5632c2
commit d780f8e5b4
4 changed files with 13 additions and 5 deletions

View File

@@ -203,7 +203,7 @@ export class GmHandler {
const uid = session.get('uid');
const maintenance = await MaintenanceModel.updateStatusByCode(code, false, uid);
if(!maintenance) return resResult(STATUS.WRONG_PARMS);
await stopMaintenance(maintenance);
await stopMaintenance(maintenance, uid);
return resResult(STATUS.SUCCESS,);
}

View File

@@ -9,6 +9,8 @@ import { pinus } from "pinus";
import { getWorldChannelSid } from "./chatChannelService";
import { ServerlistModel } from "../db/Serverlist";
import { NoticeModel, NoticeType } from "../db/Notice";
import { SendMailFun } from "./mailService";
import { GMMailType } from '../db/GMMail';
// —————————————— 跑马灯 —————————————— //
// 初始
@@ -146,8 +148,8 @@ async function startMaintenance(maintenance: MaintenanceType, startJob?: Job) {
}
// 停止维护
export async function stopMaintenance(maintenance: MaintenanceType) {
let { serverIds, notice, marquee } = maintenance;
export async function stopMaintenance(maintenance: MaintenanceType, uid: number) {
let { serverIds, notice, marquee, mail } = maintenance;
// 更新serverlist上的status
await ServerlistModel.updateByServerIds(serverIds, { serverStatus: SERVER_STATUS.HOT });
// 更新notice的isEnable
@@ -164,4 +166,11 @@ export async function stopMaintenance(maintenance: MaintenanceType) {
if(marquee) {
await cancelMarquee((<MarqueeType>marquee).code);
}
console.log('*****', JSON.stringify(mail));
if(mail) {
let f = new SendMailFun();
await f.setWithGmMail((<GMMailType>mail)._id);
await f.sendToServer(serverIds);
await f.saveRecord(uid);
}
}

View File

@@ -42,7 +42,6 @@ export default class GameController extends Controller {
ctx.body = ctx.service.utils.resResult(STATUS.GM_JSON_FORMAT_ERR);
return
}
console.log(goods)
ctx.body = await ctx.service.game.updateMaintenance(
{...values, startTime: new Date(values.startTime)},

View File

@@ -81,7 +81,7 @@ export default class Game extends Service {
let curEnv = serverEnv.find(cur => cur.env == this.app.config.env);
let marqueeResult = await MarqueeModel.createData({ ...marquee, serverIds: values.serverIds, type: MARQUEE_TYPE.SCHEDULE, isRunning: false }, ctx.user?.uid);
let noticeResult = await NoticeModel.updateNotice('new', { ...notice, type: 1, sort: 1000, serverType: curEnv?.serverType, isEnable: true }, ctx.user?.uid);
let noticeResult = await NoticeModel.updateNotice('new', { ...notice, type: 1, sort: 1000, serverType: curEnv?.serverType, isEnable: false }, ctx.user?.uid);
let mailResult = await GMMailModel.addMail({ ...mail, useTempTime: true }, ctx.user?.uid);
await MaintenanceModel.createData(values, marqueeResult, noticeResult, mailResult);
} else {