From 8c6c44bcde03195aba69fad1d196ca2c229c8187 Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 24 Nov 2021 20:19:17 +0800 Subject: [PATCH 01/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E5=85=AC?= =?UTF-8?q?=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app.ts | 8 ++- .../servers/connector/handler/entryHandler.ts | 3 +- game-server/config/database.ts | 7 +++ game-server/config/servers.ts | 3 +- gm-server/app/controller/game.ts | 13 ++-- gm-server/app/router.ts | 2 +- gm-server/app/service/Game.ts | 40 ++++++------- gm-server/config/config.default.ts | 5 +- shared/consts/constModules/sysConst.ts | 1 + shared/db/Notice.ts | 11 +--- shared/db/Region.ts | 60 +++++++++++++++++++ shared/db/Serverlist.ts | 27 ++++++--- shared/db/index.ts | 4 ++ 13 files changed, 130 insertions(+), 54 deletions(-) create mode 100644 shared/db/Region.ts diff --git a/game-server/app.ts b/game-server/app.ts index 81f2ae4f2..e385a21da 100644 --- a/game-server/app.ts +++ b/game-server/app.ts @@ -28,6 +28,7 @@ import { updateTeamStatus } from './app/services/comBattleService'; import { resResult, genCode } from './app/pubUtils/util'; import { errlogger, infologger } from './app/util/logger'; import { connectThinkingData, getTire } from './app/services/sdkService'; +import { loadGmDb } from './app/db'; const filePath = (_pinus as any).FILEPATH; filePath.MASTER = '/config/master'; @@ -158,14 +159,17 @@ export function globalErrorHandler(err: Error, msg: any, resp: any, } } -function initMongodb(app: _pinus.Application) { - mongoose.connect(app.get('database').mongo, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false }, (err) => { +async function initMongodb(app: _pinus.Application) { + await mongoose.connect(app.get('database').mongo, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false }, (err) => { if (err) { errlogger.error('mongodb connect err', err); } else { console.log('mongodb connect suc'); } }); + + let gmconnect = await mongoose.createConnection(app.get('database').gmmongo, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false }); + loadGmDb(gmconnect); } function initRedis(app: _pinus.Application) { diff --git a/game-server/app/servers/connector/handler/entryHandler.ts b/game-server/app/servers/connector/handler/entryHandler.ts index f4f416311..d1be3ab63 100644 --- a/game-server/app/servers/connector/handler/entryHandler.ts +++ b/game-server/app/servers/connector/handler/entryHandler.ts @@ -251,7 +251,8 @@ export class EntryHandler { // put user into channel return resResult(STATUS.SUCCESS, { - serverType: this.app.get('serverName') + serverType: this.app.get('serverName'), + env: this.app.get('env') }); } diff --git a/game-server/config/database.ts b/game-server/config/database.ts index 2238063f9..432ddce4e 100644 --- a/game-server/config/database.ts +++ b/game-server/config/database.ts @@ -1,37 +1,44 @@ module.exports = { 'development': { 'mongo': 'mongodb://127.0.0.1/zyz', + 'gmmongo': 'mongodb://127.0.0.1/zyzgm', 'redis': '127.0.0.1', 'redispw': 'zyz_2020' }, 'production': { 'mongo': 'mongodb://dbop:zyzdbopbantu@dds-8vbdb47c6fb58a541.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vbdb47c6fb58a542.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-500808098', + 'gmmongo': 'mongodb://dbop:zyzGm2021@dds-8vb9964bb4cc7f241.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb9964bb4cc7f242.mongodb.zhangbei.rds.aliyuncs.com:3717/zyzgm?replicaSet=mgset-507933150', 'redis': 'r-8vb4i2kgl91886fkxd.redis.zhangbei.rds.aliyuncs.com', 'redispw': 'zyz_2020' }, 'alpha': { 'mongo': 'mongodb://dbop:zyzDev2021@dds-8vb5c74ba4263da41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb5c74ba4263da42.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb5c74ba4263da43.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?readPreference=secondary&replicaSet=mgset-506991391', + 'gmmongo': 'mongodb://dbop:zyzGm2021@dds-8vb9964bb4cc7f241.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb9964bb4cc7f242.mongodb.zhangbei.rds.aliyuncs.com:3717/zyzgm?replicaSet=mgset-507933150', 'redis': 'r-8vbl8okinxn1zhkwh2.redis.zhangbei.rds.aliyuncs.com', 'redispw': 'zyz_alpha_2021' }, 'dev': { 'mongo': 'mongodb://dbop:zyzDev2021@dds-8vb5c74ba4263da41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb5c74ba4263da42.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb5c74ba4263da43.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?readPreference=secondary&replicaSet=mgset-506991391', + 'gmmongo': 'mongodb://dbop:zyzGm2021@dds-8vb9964bb4cc7f241.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb9964bb4cc7f242.mongodb.zhangbei.rds.aliyuncs.com:3717/zyzgm?replicaSet=mgset-507933150', 'redis': 'r-8vb418l8kkju9sis8k.redis.zhangbei.rds.aliyuncs.com', 'redispw': 'zyz_dev_2021' }, 'isbn': { 'mongo': 'mongodb://root:Bantus123@dds-8vb74337eab84d641.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb74337eab84d642.mongodb.zhangbei.rds.aliyuncs.com:3717/admin?replicaSet=mgset-504694158', + 'gmmongo': 'mongodb://dbop:zyzGm2021@dds-8vb9964bb4cc7f241.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb9964bb4cc7f242.mongodb.zhangbei.rds.aliyuncs.com:3717/zyzgm?replicaSet=mgset-507933150', 'redis': 'r-8vbekkbb3z8ru2ckuj.redis.zhangbei.rds.aliyuncs.com', 'redispw': 'zyz_isbn_2021' }, 'monitor': { 'mongo': 'mongodb://dbop:zyzMon2021@dds-8vb7474e31ba7ed41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb7474e31ba7ed42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-505529944', + 'gmmongo': 'mongodb://dbop:zyzGm2021@dds-8vb9964bb4cc7f241.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb9964bb4cc7f242.mongodb.zhangbei.rds.aliyuncs.com:3717/zyzgm?replicaSet=mgset-507933150', 'redis': 'r-8vb130185rp2ir3lqn.redis.zhangbei.rds.aliyuncs.com', 'redispw': 'zyz_monitor_2021' }, 'distribute': { 'mongo': 'mongodb://dbop:zyzDev2021@dds-8vb5c74ba4263da41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb5c74ba4263da42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-506991391', + 'gmmongo': 'mongodb://dbop:zyzGm2021@dds-8vb9964bb4cc7f241.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb9964bb4cc7f242.mongodb.zhangbei.rds.aliyuncs.com:3717/zyzgm?replicaSet=mgset-507933150', 'redis': 'r-8vb418l8kkju9sis8k.redis.zhangbei.rds.aliyuncs.com', 'redispw': 'zyz_dev_2021' } diff --git a/game-server/config/servers.ts b/game-server/config/servers.ts index 2fc1d6c5b..cd4089a63 100644 --- a/game-server/config/servers.ts +++ b/game-server/config/servers.ts @@ -3,7 +3,8 @@ module.exports = { 'connector': [ { 'id': 'connector-server-1', 'port': 4050, 'clientHost': '127.0.0.1', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true }, { 'id': 'connector-server-2', 'port': 4051, 'clientHost': '127.0.0.1', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true }, - { 'id': 'connector-server-3', 'port': 4052, 'clientHost': '127.0.0.1', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true } + { 'id': 'connector-server-3', 'port': 4052, 'clientHost': '127.0.0.1', 'host': '127.0.0.1', 'clientPort': 3052, 'frontend': true }, + { 'id': 'connector-server-gm', 'port': 4099, 'clientHost': '127.0.0.1', 'host': '127.0.0.1', 'clientPort': 3099, 'frontend': true } ], 'chat': [ { 'id': 'chat-server-1', 'host': '127.0.0.1', 'port': 6050, "args": " --inspect=9237" } diff --git a/gm-server/app/controller/game.ts b/gm-server/app/controller/game.ts index 45c0087c4..e4626c312 100644 --- a/gm-server/app/controller/game.ts +++ b/gm-server/app/controller/game.ts @@ -3,12 +3,6 @@ import { STATUS } from '@consts'; export default class GameController extends Controller { - public async getServerEnv() { - const { ctx } = this; - ctx.body = await ctx.service.game.getServerEnv(); - return - } - public async getServerListByEnv() { const { ctx } = this; ctx.body = await ctx.service.game.getServerListByEnv(); @@ -23,6 +17,13 @@ export default class GameController extends Controller { return } + public async getRegions() { + const { ctx } = this; + + ctx.body = await ctx.service.game.getRegions(); + return + } + public async getMaintenanceList() { const { ctx } = this; const {page, pageSize, sortField, sortOrder, form} = ctx.request.body; diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index 7aee4e084..af3d0a471 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -50,9 +50,9 @@ export default (app: Application) => { // router.post('/api/users/delgiftCode', controller.users.delGiftCode); router.get('/api/users/getgiftcodedetails/:id/:filename', controller.users.getGiftCodeDetails); - router.post('/api/game/getserverenv', tokenParser, controller.game.getServerEnv); router.post('/api/game/getserverlistbyenv', tokenParser, controller.game.getServerListByEnv); router.post('/api/game/getserverlist', controller.game.getServerList); + router.post('/api/game/getregions', controller.game.getRegions); router.post('/api/game/getmaintenancelist', controller.game.getMaintenanceList); router.post('/api/game/updatemaintenance', controller.game.updateMaintenance); diff --git a/gm-server/app/service/Game.ts b/gm-server/app/service/Game.ts index 182c66c68..b994ba8f9 100644 --- a/gm-server/app/service/Game.ts +++ b/gm-server/app/service/Game.ts @@ -13,25 +13,13 @@ import { MarqueeModel, MarqueeParam, MarqueeType } from '@db/Marquee'; import { MaintenanceModel, MaintenanceTypeParam } from '@db/Maintenance'; import { GMMailTypeParam, GMMailModel, GMMailType } from '@db/GMMail'; import { AccuseRecModel } from '@db/AccuseRec'; +import { RegionModel } from '@db/Region'; /** * Test Service */ export default class Game extends Service { - /** - * 获取正式服,测试服,开发服等环境 - */ - public async getServerEnv() { - const { ctx, app } = this; - const list = await GameModel.getServerEnvList(); - - return ctx.service.utils.resResult(STATUS.SUCCESS, { - list, - env: app.config.env - }); - } - /** * 获取正式服,测试服,开发服等环境 */ @@ -57,6 +45,16 @@ export default class Game extends Service { }); } + + public async getRegions() { + const { ctx } = this; + + const list = await RegionModel.getAllRegion(); + return ctx.service.utils.resResult(STATUS.SUCCESS, { + list + }); + } + public async getMaintenanceList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { isOpen?: boolean } = {}) { const { ctx } = this; @@ -69,7 +67,7 @@ export default class Game extends Service { return { ...cur, startTime: cur.startTime.getTime(), marquee: marquee?{...marquee, startTime: marquee.startTime.getTime(), endTime: marquee.endTime.getTime()}:null, - notice: notice?{...notice, startTime: notice.startTime.getTime(), endTime: notice.endTime.getTime(), showStartTime: notice.showStartTime.getTime(), showEndTime: notice.showEndTime.getTime()}:null + notice: notice?{...notice, showStartTime: notice.showStartTime.getTime(), showEndTime: notice.showEndTime.getTime()}:null } }), total }); @@ -115,7 +113,7 @@ export default class Game extends Service { await ServerStategyModel.updateServerStategy(values, ctx.user?.uid); } catch(e) { - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack); + return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (e).stack); } return ctx.service.utils.resResult(STATUS.SUCCESS); } @@ -130,7 +128,7 @@ export default class Game extends Service { await ServerlistModel.newServer({ name, openTime: new Date(openTime), serverType }, stategy, ctx.user?.uid); } catch(e) { - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack); + return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (e).stack); } return ctx.service.utils.resResult(STATUS.SUCCESS); } @@ -153,7 +151,7 @@ export default class Game extends Service { await ServerlistModel.updateByServerId(id, update); } catch(e) { - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack); + return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (e).stack); } return ctx.service.utils.resResult(STATUS.SUCCESS); } @@ -206,21 +204,21 @@ export default class Game extends Service { }) } - public async getNoticeList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { type?: number, content?: string }) { + public async getNoticeList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { content?: string }) { const { ctx } = this; const list = await NoticeModel.findByCondition(page, pageSize, sortField, sortOrder, form); const total = await NoticeModel.countByCondition( form ) return ctx.service.utils.resResult(STATUS.SUCCESS, { list: list.map(cur => { - return { ...cur, startTime: cur.startTime.getTime(), endTime: cur.endTime.getTime(), showEndTime: cur.showEndTime.getTime(), showStartTime: cur.showStartTime.getTime()} + let env = this.app.config.env; + if(env == 'local') env = 'development'; + return { ...cur, showEndTime: cur.showEndTime.getTime(), showStartTime: cur.showStartTime.getTime(), env} }), total }); } public async updateNotice(id: string|number, params: NoticeTypeParam) { const { ctx } = this; - if(params.startTime) params.startTime = new Date(params.startTime); - if(params.endTime) params.endTime = new Date(params.endTime); if(params.showStartTime) params.showStartTime = new Date(params.showStartTime); if(params.showEndTime) params.showEndTime = new Date(params.showEndTime); let result = await NoticeModel.updateNotice(id, params); diff --git a/gm-server/config/config.default.ts b/gm-server/config/config.default.ts index 7fde84f9d..83153c182 100644 --- a/gm-server/config/config.default.ts +++ b/gm-server/config/config.default.ts @@ -72,14 +72,14 @@ export default (appInfo: EggAppInfo) => { maxFileSize: 1024, }; - config.bigServers = [ // 大区数据 + let regions = [ // 大区数据 { id: 1, env: 'stable', name: "常山少年", domain: 'http://pinus_gm_test.trgame.cn' }, { id: 2, env: 'alpha', name: "测试服", domain: 'http://zyz_gm.trgame.cn' }, { id: 3, env: 'dev', name: "开发服", domain: 'http://zyzdev_gm.trgame.cn' } ]; let httpProxy: any = {}; - for(let { env, domain } of config.bigServers) { + for(let { env, domain } of regions) { httpProxy[`/api/${env}`] = { target: domain, changeOrigin: true, @@ -90,7 +90,6 @@ export default (appInfo: EggAppInfo) => { } } } - config.proxy = httpProxy; // the return config will combines to EggAppConfig return { diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index 8fbafede1..23477c89c 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -47,6 +47,7 @@ export const COUNTER = { NOTICE: { name: 'notice', def: 1 }, GIFT_CODE: { name: 'giftCode', def: 1 }, PVP_SEASON_NUM: { name: 'pvpSeason', def: 1 }, + REGION: { name: 'region', def: 1 } }; export const DEFAULT_HEROES = [19, 53,]; diff --git a/shared/db/Notice.ts b/shared/db/Notice.ts index 04563c953..7aca704a1 100644 --- a/shared/db/Notice.ts +++ b/shared/db/Notice.ts @@ -2,7 +2,6 @@ import BaseModel from './BaseModel'; import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose'; import { COUNTER } from '../consts' import { CounterModel } from './Counter'; -import moment = require('moment'); /** * 游戏字段接口 @@ -24,15 +23,8 @@ export default class Notice extends BaseModel { @prop({ required: true }) timeStr: string; // 时间显示 - @prop({ required: true }) - startTime: Date; // 活动开始时间 - @prop({ required: true }) - endTime: Date; // 活动结束时间 public get time() { - let startTime = moment(this.startTime).format('YYYY/MM/DD'); - let endTime = moment(this.endTime).format('YYYY/MM/DD'); - - return this.timeStr.replace(/%startTime/g, startTime).replace(/%endTime/g, endTime); + return this.timeStr; } @prop({ required: true, select: false }) @@ -73,7 +65,6 @@ export default class Notice extends BaseModel { private static getSearchObj(form: { type?: number, content?: string }) { let searchObj = {}; - if(form['type']) searchObj['type'] = form.type; if(form['content']) searchObj['content'] = { $regex: new RegExp(form.content.toString(), 'i') }; return searchObj } diff --git a/shared/db/Region.ts b/shared/db/Region.ts new file mode 100644 index 000000000..401e4762d --- /dev/null +++ b/shared/db/Region.ts @@ -0,0 +1,60 @@ +import { COUNTER } from './../consts'; +import { CounterModel } from './Counter'; +import BaseModel from './BaseModel'; +import { index, getModelForClass, prop, DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose'; + + +/** + * 大区数据 +*/ +@index({ id: 1 }) + +export default class Region extends BaseModel { + @prop({ required: true }) + id: number; // 大区id + + @prop({ required: true }) + name: string; // 大区名 + + @prop({ required: true }) + prefix: string; // 区名前缀 + + @prop({ required: true }) + env: string; // 环境变量 + + @prop({ required: true }) + gmLink: string; // 短链接地址 + + @prop({ required: true }) + gameHost: string; // 长链接地址 + + @prop({ required: true }) + gamePort: number; // 长链接地址 + + public static async createNewRegion(params: RegionUpdate) { + let id = await CounterModel.getNewCounter(COUNTER.REGION); + + const rec: RegionType = await RegionModel.findOneAndUpdate({ id }, { $setOnInsert: params }, { new: true, upsert: true }).lean(); + return rec; + } + + public static async getAllRegion() { + const rec: RegionType[] = await RegionModel.find().select('-_id').lean(); + return rec; + } + + public static async findRegionById(id: number) { + const rec: RegionType = await RegionModel.findOne({ id }).lean(); + return rec; + } +} + +export let RegionModel: ReturnModelType; +export function loadRegionModel(connect: mongoose.Connection) { + RegionModel = getModelForClass(Region, { + existingConnection: connect + }); +} + +export interface RegionType extends Pick, keyof Region> { }; +export type RegionUpdate = Partial; // 将所有字段变成可选项 diff --git a/shared/db/Serverlist.ts b/shared/db/Serverlist.ts index a4c593518..8157357b8 100644 --- a/shared/db/Serverlist.ts +++ b/shared/db/Serverlist.ts @@ -1,13 +1,11 @@ import BaseModel from './BaseModel'; -import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose'; +import { index, getModelForClass, prop, DocumentType, modelOptions, ReturnModelType, mongoose } from '@typegoose/typegoose'; import { GameModel } from './Game'; import { CounterModel } from './Counter'; import { COUNTER, SERVER_STATUS } from '../consts'; import { ServerStategyTypeParam } from './ServerStategy'; import { getServerName, getServerGroupName } from '../pubUtils/data'; -// 暂时服务器列表是从game表取的,之后会转移到使用这张表,目前用作查询该服战力中位数 - /** * 游戏字段接口 */ @@ -18,6 +16,15 @@ export default class Serverlist extends BaseModel { @prop({ required: true, default: 1 }) gameId: number; // 游戏id Game表的id + @prop({ required: true, default: 1 }) + regionId: number; // 大区id + + @prop({ required: true }) + env: string; // 环境变量 + + @prop({ required: true }) + serverType: string; + @prop({ required: true }) id: number; // 小区id 自增 @@ -28,10 +35,10 @@ export default class Serverlist extends BaseModel { name: string; // 小区区名 @prop({ required: true }) - groupId: number; // 大区id + groupId: number; // 战区id @prop({ required: true }) - groupName: string; // 大区区名 + groupName: string; // 战区区名 @prop({ required: true }) host: string; // pinus连接地址 @@ -57,9 +64,6 @@ export default class Serverlist extends BaseModel { @prop({ required: true }) openTime: Date; - @prop({ required: true }) - serverType: string; - @prop({ required: true, default: 0 }) maxPlayerCnt: number; // 最大玩家人数 @@ -183,7 +187,12 @@ export default class Serverlist extends BaseModel { } -export const ServerlistModel = getModelForClass(Serverlist); +export let ServerlistModel: ReturnModelType; +export function loadServerlistModel(connect: mongoose.Connection) { + ServerlistModel = getModelForClass(Serverlist, { + existingConnection: connect + }); +} export interface ServerlistType extends Pick, keyof Serverlist> { id: number; diff --git a/shared/db/index.ts b/shared/db/index.ts index 2a554d3b4..e39f504b1 100644 --- a/shared/db/index.ts +++ b/shared/db/index.ts @@ -4,6 +4,8 @@ import { loadGMGroupModel } from "./GMGroup"; import { loadGMRecordModel } from "./GMRecord"; import { loadGMUserModel } from './GMUser' import { loadGMUserGroupModel } from "./GMUserGroup"; +import { loadRegionModel } from "./Region"; +import { loadServerlistModel } from "./Serverlist"; export function loadGmDb(connect: mongoose.Connection) { loadApiModel(connect); @@ -11,4 +13,6 @@ export function loadGmDb(connect: mongoose.Connection) { loadGMUserModel(connect); loadGMUserGroupModel(connect); loadGMRecordModel(connect); + loadRegionModel(connect); + loadServerlistModel(connect); } \ No newline at end of file From cc819c48a7691d9a7130fc6abf495ed8c0d42236 Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 25 Nov 2021 14:12:14 +0800 Subject: [PATCH 02/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9Aweb-server?= =?UTF-8?q?=E8=BF=9E=E6=8E=A5=E6=95=B0=E6=8D=AE=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gm-server/app/router.ts | 4 +- gm-server/config/config.default.ts | 1 + shared/db/Notice.ts | 5 +-- web-server/app.ts | 27 ++++++++++-- web-server/config/config.alpha.ts | 63 ++-------------------------- web-server/config/config.default.ts | 10 ++--- web-server/config/config.dev.ts | 64 ++-------------------------- web-server/config/config.isbn.ts | 64 ++-------------------------- web-server/config/config.local.ts | 65 +++-------------------------- web-server/config/config.monitor.ts | 64 ++-------------------------- web-server/config/config.stable.ts | 64 ++-------------------------- 11 files changed, 53 insertions(+), 378 deletions(-) diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index af3d0a471..f91c01f76 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -25,8 +25,8 @@ export default (app: Application) => { router.post('/api/users/getuserlist',tokenParser, controller.users.getuserlist); - router.post('/api/users/createrole',tokenParser, controller.users.createRole); - router.post('/api/users/addauth', tokenParser, controller.users.addAuth); + // router.post('/api/users/createrole',tokenParser, controller.users.createRole); + // router.post('/api/users/addauth', tokenParser, controller.users.addAuth); router.post('/api/users/fixsms', tokenParser, controller.users.fixSms); router.post('/api/users/deleterole',tokenParser, controller.users.deleteRole); router.post('/api/users/getrolelist',tokenParser, controller.users.getrolelist); diff --git a/gm-server/config/config.default.ts b/gm-server/config/config.default.ts index 83153c182..0c8eedbd6 100644 --- a/gm-server/config/config.default.ts +++ b/gm-server/config/config.default.ts @@ -90,6 +90,7 @@ export default (appInfo: EggAppInfo) => { } } } + config.proxy = httpProxy; // the return config will combines to EggAppConfig return { diff --git a/shared/db/Notice.ts b/shared/db/Notice.ts index 7aca704a1..683e9643b 100644 --- a/shared/db/Notice.ts +++ b/shared/db/Notice.ts @@ -22,10 +22,7 @@ export default class Notice extends BaseModel { content: string; // 公告内容 @prop({ required: true }) - timeStr: string; // 时间显示 - public get time() { - return this.timeStr; - } + time: string; // 时间显示 @prop({ required: true, select: false }) sort: number; diff --git a/web-server/app.ts b/web-server/app.ts index 48c6d8a18..98722b94e 100644 --- a/web-server/app.ts +++ b/web-server/app.ts @@ -2,6 +2,7 @@ import 'reflect-metadata' import * as mongoose from 'mongoose'; import { Application, IBoot } from 'egg'; import { connectRedis } from './app/pubUtils/redis'; +import { loadGmDb } from '@db/index'; export default class FooBoot implements IBoot { private readonly app: Application; @@ -15,6 +16,7 @@ export default class FooBoot implements IBoot { // Config, plugin files are referred,` // this is the last chance to modify the config. await this.connectDB(this.app); + await this.connectGMDB(this.app); await this.connectRedis(this.app); } @@ -51,9 +53,28 @@ export default class FooBoot implements IBoot { public async connectDB(app: Application) { const { url, options } = app.config.mongoose - if (url) { - const connection = await mongoose.connect(url, options) - app.context.connection = connection + try { + if (url) { + const connection = await mongoose.connect(url, options) + console.log('******connectDB suc', url, options) + app.context.connection = connection + } + } catch(e) { + console.log(e) + } + } + + public async connectGMDB(app: Application) { + const { url, options } = app.config.gmmongoose + try { + if (url) { + const connection = await mongoose.createConnection(url, options) + app.context.connectionGM = connection; + loadGmDb(connection); + console.log('******connectGMDB suc', url, options) + } + } catch(e) { + console.log(e) } } diff --git a/web-server/config/config.alpha.ts b/web-server/config/config.alpha.ts index 094ef0024..cc1df7dfc 100644 --- a/web-server/config/config.alpha.ts +++ b/web-server/config/config.alpha.ts @@ -1,25 +1,9 @@ import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; -const path = require('path'); +import defaultConfig from './config.default'; export default (appInfo: EggAppInfo) => { const config = {} as PowerPartial; - // override config from framework / plugin - // use for cookie sign key, should change to your own and keep security - config.keys = appInfo.name + '_1597499383757_3508'; - config.security = { - csrf: { - enable: false, - }, - domainWhiteList: [ '*' ], - }; - config.cors = { - origin: '*', // 匹配规则 域名+端口 *则为全匹配 - allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH', - }; - // add your egg config in here - config.middleware = [ 'parmsDecode' ]; - config.mongoose = { url: 'mongodb://dbop:zyzDev2021@dds-8vb5c74ba4263da41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb5c74ba4263da42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-506991391', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, @@ -29,51 +13,10 @@ export default (appInfo: EggAppInfo) => { url: 'r-8vbl8okinxn1zhkwh2.redis.zhangbei.rds.aliyuncs.com', // 内网 pw: 'zyz_alpha_2021' }; - // config.alinode = { - // appid: '86043', - // secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a', - // error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ], - // packages: [ '/root/zyz/web-server/package.json' ], - // }; - - config.view = { - root: path.join(appInfo.baseDir, '/app/public'), - defaultViewEngine: 'nunjucks', - mapping: { - '.html': 'nunjucks' //左边写成.html后缀,会自动渲染.html文件 - }, - }; - - config.decodeParm = true; - - config.static = { - prefix: '/', - dir: path.join(appInfo.baseDir, '/app/public'), - }; - - config.customLogger = { - linkLogger: { - file: path.join(appInfo.root, 'logs/web-server/link-log.log'), - formatter(meta) { - return `[${meta.level}] [${meta.date}] ${meta.message}`; - }, - }, - }; - - config.logrotator = { - filesRotateBySize: [ - path.join(appInfo.root, 'logs/link-log.log'), - ], - maxFileSize: 1024, - }; - // add your special config in here - const bizConfig = { - sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, - }; // the return config will combines to EggAppConfig return { - ...config, - ...bizConfig, + ...defaultConfig(appInfo), + ...config }; }; diff --git a/web-server/config/config.default.ts b/web-server/config/config.default.ts index e91a9fa16..abbd7cb13 100644 --- a/web-server/config/config.default.ts +++ b/web-server/config/config.default.ts @@ -24,6 +24,10 @@ export default (appInfo: EggAppInfo) => { url: 'mongodb://dbop:zyzMon2021@dds-8vb7474e31ba7ed41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb7474e31ba7ed42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-505529944', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, }; + config.gmmongoose = { + url: 'mongodb://dbop:zyzGm2021@dds-8vb9964bb4cc7f241.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb9964bb4cc7f242.mongodb.zhangbei.rds.aliyuncs.com:3717/zyzgm?replicaSet=mgset-507933150', // 内网 + options: { useNewUrlParser: true, useUnifiedTopology: true }, + }; config.redis = { url: 'r-8vb130185rp2ir3lqn.redis.zhangbei.rds.aliyuncs.com', // 内网 pw: 'zyz_monitor_2021' @@ -44,12 +48,6 @@ export default (appInfo: EggAppInfo) => { }, }; - exports.xtransit = { - server: 'ws://127.0.0.1:9092', - appId: 3, - appSecret: 'a48ad5ca44e2d02cbd7f4c0326fa3101' - }; - config.decodeParm = true; config.static = { diff --git a/web-server/config/config.dev.ts b/web-server/config/config.dev.ts index 0a37904b9..b6249fff4 100644 --- a/web-server/config/config.dev.ts +++ b/web-server/config/config.dev.ts @@ -1,25 +1,9 @@ import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; -const path = require('path'); +import defaultConfig from './config.default'; export default (appInfo: EggAppInfo) => { const config = {} as PowerPartial; - // override config from framework / plugin - // use for cookie sign key, should change to your own and keep security - config.keys = appInfo.name + '_1597499383757_3508'; - config.security = { - csrf: { - enable: false, - }, - domainWhiteList: [ '*' ], - }; - config.cors = { - origin: '*', // 匹配规则 域名+端口 *则为全匹配 - allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH', - }; - // add your egg config in here - config.middleware = [ 'parmsDecode' ]; - config.mongoose = { url: 'mongodb://dbop:zyzDev2021@dds-8vb5c74ba4263da41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb5c74ba4263da42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-506991391', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, @@ -29,51 +13,9 @@ export default (appInfo: EggAppInfo) => { pw: 'zyz_dev_2021' }; - // config.alinode = { - // appid: '86043', - // secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a', - // error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ], - // packages: [ '/root/zyz/web-server/package.json' ], - // }; - - config.view = { - root: path.join(appInfo.baseDir, '/app/public'), - defaultViewEngine: 'nunjucks', - mapping: { - '.html': 'nunjucks' //左边写成.html后缀,会自动渲染.html文件 - }, - }; - - config.decodeParm = true; - - config.static = { - prefix: '/', - dir: path.join(appInfo.baseDir, '/app/public'), - }; - config.customLogger = { - linkLogger: { - file: path.join(appInfo.root, 'logs/web-server/link-log.log'), - formatter(meta) { - return `[${meta.level}] [${meta.date}] ${meta.message}`; - }, - }, - }; - - config.logrotator = { - filesRotateBySize: [ - path.join(appInfo.root, 'logs/link-log.log'), - ], - maxFileSize: 1024, - }; - - // add your special config in here - const bizConfig = { - sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, - }; - // the return config will combines to EggAppConfig return { - ...config, - ...bizConfig, + ...defaultConfig(appInfo), + ...config }; }; diff --git a/web-server/config/config.isbn.ts b/web-server/config/config.isbn.ts index 61caba350..d85aa736c 100644 --- a/web-server/config/config.isbn.ts +++ b/web-server/config/config.isbn.ts @@ -1,25 +1,9 @@ import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; -const path = require('path'); +import defaultConfig from './config.default'; export default (appInfo: EggAppInfo) => { const config = {} as PowerPartial; - // override config from framework / plugin - // use for cookie sign key, should change to your own and keep security - config.keys = appInfo.name + '_1597499383757_3508'; - config.security = { - csrf: { - enable: false, - }, - domainWhiteList: [ '*' ], - }; - config.cors = { - origin: '*', // 匹配规则 域名+端口 *则为全匹配 - allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH', - }; - // add your egg config in here - config.middleware = [ 'parmsDecode' ]; - config.mongoose = { url: 'mongodb://root:Bantus123@dds-8vb74337eab84d641.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb74337eab84d642.mongodb.zhangbei.rds.aliyuncs.com:3717/admin?replicaSet=mgset-504694158', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, @@ -29,51 +13,9 @@ export default (appInfo: EggAppInfo) => { pw: 'zyz_isbn_2021' }; - // config.alinode = { - // appid: '86043', - // secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a', - // error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ], - // packages: [ '/root/zyz/web-server/package.json' ], - // }; - - config.view = { - root: path.join(appInfo.baseDir, '/app/public'), - defaultViewEngine: 'nunjucks', - mapping: { - '.html': 'nunjucks' //左边写成.html后缀,会自动渲染.html文件 - }, - }; - - config.decodeParm = true; - - config.static = { - prefix: '/', - dir: path.join(appInfo.baseDir, '/app/public'), - }; - - config.customLogger = { - linkLogger: { - file: path.join(appInfo.root, 'logs/web-server/link-log.log'), - formatter(meta) { - return `[${meta.level}] [${meta.date}] ${meta.message}`; - }, - }, - }; - - config.logrotator = { - filesRotateBySize: [ - path.join(appInfo.root, 'logs/link-log.log'), - ], - maxFileSize: 1024, - }; - // add your special config in here - const bizConfig = { - sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, - }; - // the return config will combines to EggAppConfig return { - ...config, - ...bizConfig, + ...defaultConfig(appInfo), + ...config }; }; diff --git a/web-server/config/config.local.ts b/web-server/config/config.local.ts index da66bfc4a..9aee1e9fe 100644 --- a/web-server/config/config.local.ts +++ b/web-server/config/config.local.ts @@ -1,80 +1,27 @@ import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; -const path = require('path'); +import defaultConfig from './config.default'; export default (appInfo: EggAppInfo) => { const config = {} as PowerPartial; - // override config from framework / plugin - // use for cookie sign key, should change to your own and keep security - config.keys = appInfo.name + '_1597499383757_3508'; - config.security = { - csrf: { - enable: false, - }, - domainWhiteList: [ '*' ], - }; - config.cors = { - origin: '*', // 匹配规则 域名+端口 *则为全匹配 - allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH', - }; - // add your egg config in here - config.middleware = [ 'parmsDecode' ]; - config.mongoose = { url: 'mongodb://127.0.0.1/zyz', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, }; + config.gmmongoose = { + url: 'mongodb://127.0.0.1:27017/zyzgm', // 内网 + options: { useNewUrlParser: true, useUnifiedTopology: true }, + }; config.redis = { url: '127.0.0.1', // 内网 pw: '' }; - // config.alinode = { - // appid: '86043', - // secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a', - // error_log: [ '${appInfo.root}/logs/${appInfo.name}/zyz-web.log', '${appInfo.root}/logs/${appInfo.name}/common-error.log', '${appInfo.root}/logs/${appInfo.name}/egg-agent.log' ], - // packages: [ '${appInfo.baseDir}/package.json' ], - // }; - - config.view = { - root: path.join(appInfo.baseDir, '/app/public'), - defaultViewEngine: 'nunjucks', - mapping: { - '.html': 'nunjucks' //左边写成.html后缀,会自动渲染.html文件 - }, - }; - config.decodeParm = true; - - config.static = { - prefix: '/', - dir: path.join(appInfo.baseDir, '/app/public'), - }; - - config.customLogger = { - linkLogger: { - file: path.join(appInfo.root, 'logs/web-server/link-log.log'), - formatter(meta) { - return `[${meta.level}] [${meta.date}] ${meta.message}`; - }, - }, - }; - - config.logrotator = { - filesRotateBySize: [ - path.join(appInfo.root, 'logs/link-log.log'), - ], - maxFileSize: 1024, - }; - - // add your special config in here - const bizConfig = { - sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, - }; // the return config will combines to EggAppConfig return { + ...defaultConfig(appInfo), ...config, - ...bizConfig, }; }; diff --git a/web-server/config/config.monitor.ts b/web-server/config/config.monitor.ts index e91a9fa16..56eeeb048 100644 --- a/web-server/config/config.monitor.ts +++ b/web-server/config/config.monitor.ts @@ -1,25 +1,9 @@ import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; -const path = require('path'); +import defaultConfig from './config.default'; export default (appInfo: EggAppInfo) => { const config = {} as PowerPartial; - // override config from framework / plugin - // use for cookie sign key, should change to your own and keep security - config.keys = appInfo.name + '_1597499383757_3508'; - config.security = { - csrf: { - enable: false, - }, - domainWhiteList: [ '*' ], - }; - config.cors = { - origin: '*', // 匹配规则 域名+端口 *则为全匹配 - allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH', - }; - // add your egg config in here - config.middleware = [ 'parmsDecode' ]; - config.mongoose = { url: 'mongodb://dbop:zyzMon2021@dds-8vb7474e31ba7ed41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb7474e31ba7ed42.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-505529944', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, @@ -29,57 +13,15 @@ export default (appInfo: EggAppInfo) => { pw: 'zyz_monitor_2021' }; - // config.alinode = { - // appid: '86043', - // secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a', - // error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ], - // packages: [ '/root/zyz/web-server/package.json' ], - // }; - - config.view = { - root: path.join(appInfo.baseDir, '/app/public'), - defaultViewEngine: 'nunjucks', - mapping: { - '.html': 'nunjucks' //左边写成.html后缀,会自动渲染.html文件 - }, - }; - exports.xtransit = { server: 'ws://127.0.0.1:9092', appId: 3, appSecret: 'a48ad5ca44e2d02cbd7f4c0326fa3101' }; - - config.decodeParm = true; - - config.static = { - prefix: '/', - dir: path.join(appInfo.baseDir, '/app/public'), - }; - - config.customLogger = { - linkLogger: { - file: path.join(appInfo.root, 'logs/web-server/link-log.log'), - formatter(meta) { - return `[${meta.level}] [${meta.date}] ${meta.message}`; - }, - }, - }; - - config.logrotator = { - filesRotateBySize: [ - path.join(appInfo.root, 'logs/link-log.log'), - ], - maxFileSize: 1024, - }; - // add your special config in here - const bizConfig = { - sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, - }; // the return config will combines to EggAppConfig return { - ...config, - ...bizConfig, + ...defaultConfig(appInfo), + ...config }; }; diff --git a/web-server/config/config.stable.ts b/web-server/config/config.stable.ts index 241fe1ec1..7ae29f720 100644 --- a/web-server/config/config.stable.ts +++ b/web-server/config/config.stable.ts @@ -1,25 +1,9 @@ import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; -const path = require('path'); +import defaultConfig from './config.default'; export default (appInfo: EggAppInfo) => { const config = {} as PowerPartial; - // override config from framework / plugin - // use for cookie sign key, should change to your own and keep security - config.keys = appInfo.name + '_1597499383757_3508'; - config.security = { - csrf: { - enable: false, - }, - domainWhiteList: [ '*' ], - }; - config.cors = { - origin: '*', // 匹配规则 域名+端口 *则为全匹配 - allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH', - }; - // add your egg config in here - config.middleware = [ 'parmsDecode' ]; - config.mongoose = { url: 'mongodb://dbop:zyzdbopbantu@dds-8vbdb47c6fb58a541.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vbdb47c6fb58a542.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-500808098', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, @@ -29,58 +13,16 @@ export default (appInfo: EggAppInfo) => { pw: 'zyz_2020' }; - // config.alinode = { - // appid: '86043', - // secret: '54ef0364995b0c4f2ab42150e29ad30df8327a3a', - // error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ], - // packages: [ '/root/zyz/web-server/package.json' ], - // }; - - config.view = { - root: path.join(appInfo.baseDir, '/app/public'), - defaultViewEngine: 'nunjucks', - mapping: { - '.html': 'nunjucks' //左边写成.html后缀,会自动渲染.html文件 - }, - }; - - config.decodeParm = true; - - config.static = { - prefix: '/', - dir: path.join(appInfo.baseDir, '/app/public'), - }; - config.xtransit = { server: 'ws://172.26.117.35:9092', appId: 3, appSecret: 'a48ad5ca44e2d02cbd7f4c0326fa3101', error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ], }; - - config.customLogger = { - linkLogger: { - file: path.join(appInfo.root, 'logs/web-server/link-log.log'), - formatter(meta) { - return `[${meta.level}] [${meta.date}] ${meta.message}`; - }, - }, - }; - - config.logrotator = { - filesRotateBySize: [ - path.join(appInfo.root, 'logs/link-log.log'), - ], - maxFileSize: 1024, - }; - // add your special config in here - const bizConfig = { - sourceUrl: `https://github.com/eggjs/examples/tree/master/${appInfo.name}`, - }; // the return config will combines to EggAppConfig return { - ...config, - ...bizConfig, + ...defaultConfig(appInfo), + ...config }; }; From e7566b8af5e1ce1c67920b819e445af42d97f4ca Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 25 Nov 2021 16:11:46 +0800 Subject: [PATCH 03/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gm-server/app.ts | 5 +++ gm-server/app/controller/users.ts | 4 +- gm-server/app/service/Game.ts | 4 +- gm-server/app/service/users.ts | 56 ++++++++-------------------- shared/db/User.ts | 47 +++++++++++++++-------- shared/domain/backEndField/search.ts | 5 +++ shared/pubUtils/util.ts | 9 ++--- 7 files changed, 63 insertions(+), 67 deletions(-) create mode 100644 shared/domain/backEndField/search.ts diff --git a/gm-server/app.ts b/gm-server/app.ts index 08abb9888..7e3ab82ac 100644 --- a/gm-server/app.ts +++ b/gm-server/app.ts @@ -16,6 +16,11 @@ export default class FooBoot implements IBoot { // this is the last chance to modify the config. await this.connectDB(this.app) await this.connectGMDB(this.app); + + this.app.config.realEnv = this.app.config.env; + if(this.app.config.env == 'local') { + this.app.config.realEnv = 'development'; + } } configDidLoad() { diff --git a/gm-server/app/controller/users.ts b/gm-server/app/controller/users.ts index 03e6a717d..26bd60ce7 100644 --- a/gm-server/app/controller/users.ts +++ b/gm-server/app/controller/users.ts @@ -5,8 +5,8 @@ export default class UserController extends Controller { public async getuserlist() { const { ctx } = this; - const { field, value } = ctx.request.body; - ctx.body = await ctx.service.users.getuserlist(field, value); + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.users.getuserlist(page, pageSize, sortField, sortOrder, form); } public async createRole() { diff --git a/gm-server/app/service/Game.ts b/gm-server/app/service/Game.ts index b994ba8f9..2e54b45b9 100644 --- a/gm-server/app/service/Game.ts +++ b/gm-server/app/service/Game.ts @@ -210,9 +210,7 @@ export default class Game extends Service { const total = await NoticeModel.countByCondition( form ) return ctx.service.utils.resResult(STATUS.SUCCESS, { list: list.map(cur => { - let env = this.app.config.env; - if(env == 'local') env = 'development'; - return { ...cur, showEndTime: cur.showEndTime.getTime(), showStartTime: cur.showStartTime.getTime(), env} + return { ...cur, showEndTime: cur.showEndTime.getTime(), showStartTime: cur.showStartTime.getTime(), env: this.app.config.realEnv } }), total }); } diff --git a/gm-server/app/service/users.ts b/gm-server/app/service/users.ts index 365828233..c1ce3e817 100644 --- a/gm-server/app/service/users.ts +++ b/gm-server/app/service/users.ts @@ -21,6 +21,7 @@ import { CreateHeroes, deletRole } from '@pubUtils/roleUtil'; import { RScriptRecordModel } from '@db/RScriptRecord'; import { DicWar } from '@pubUtils/dictionary/DicWar'; import { SkinModel } from '@db/Skin'; +import { SearchUserParam } from '@domain/backEndField/search'; // import { resResult } from '@pubUtils/util'; @@ -34,49 +35,22 @@ export default class GMUsers extends Service { /** * 根据类型等搜索玩家 */ - public async getuserlist(field: string = 'all', value: string = '') { + public async getuserlist(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchUserParam) { const { ctx } = this; - let arr = new Array(), flag = 0; - if (value == '') field = 'all'; - let valueArr = value.split(','); - for (let i of valueArr) { - if (field == 'uid') { - let d = parseInt(i); - if (isNaN(d)) { - flag = 1; break; - } else { - arr.push(d); - } - } else if (field == 'username' || field == 'tel') { - arr.push(i); - } else if (field == 'all') { - break; - } else { - flag = 1; break; - } + const users = await UserModel.findByCondition(page, pageSize, sortField, sortOrder, form); + const total = await UserModel.countByCondition( form ) + + let list = []; + for (let user of users) { + let role = await RoleModel.findAllByUid(user.uid); + let sms = await smsModel.findByTel(user.tel); + + list.push({ ...user, role, isFixed: sms ? sms.isFixed : false, code: sms ? sms.code : "", env: ctx.app.config.realEnv }); } - if (flag) { - return ctx.service.utils.resResult(STATUS.WRONG_PARMS); - } + return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total }) - let users = await UserModel.findUserByField(field, valueArr); - - if (users) { - let list = new Array(); - for (let user of users) { - let role = await RoleModel.findAllByUid(user.uid); - let sms = await smsModel.findByTel(user.tel); - - list.push({ ...user, role, isFixed: sms ? sms.isFixed : false, code: sms ? sms.code : "" }); - } - - return ctx.service.utils.resResult(STATUS.SUCCESS, { list }) - } else { - console.error('userlist not found'); - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR); - } } public async createRole(uid: number, serverId: number, roleName: string) { @@ -602,7 +576,7 @@ export default class GMUsers extends Service { return ctx.service.utils.resResult(STATUS.SUCCESS); } catch (e) { - console.error(e.stack) + console.error((e).stack) } } @@ -625,7 +599,7 @@ export default class GMUsers extends Service { return ctx.service.utils.resResult(STATUS.SUCCESS); } catch (e) { - console.error(e.stack) + console.error((e).stack) } } @@ -649,7 +623,7 @@ export default class GMUsers extends Service { return ctx.service.utils.resResult(STATUS.SUCCESS); } catch (e) { - console.error(e.stack) + console.error((e).stack) } } diff --git a/shared/db/User.ts b/shared/db/User.ts index 54bc87c94..c400664f4 100644 --- a/shared/db/User.ts +++ b/shared/db/User.ts @@ -4,6 +4,7 @@ import BaseModel from './BaseModel'; import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose'; import { genCode, aesEncryptcfb, aesDecryptcfb } from '../pubUtils/util'; import { LoginValidateData37, ChannelInfo } from '../domain/sdk'; +import { SearchUserParam } from '@domain/backEndField/search'; const bcrypt = require('bcrypt'); const SALT_WORK_FACTOR = 5 @@ -107,10 +108,6 @@ export default class User extends BaseModel { @prop({ required: true, default: false }) blocked: boolean; - // 用户权限:0-普通用户,1-测试用户 - @prop({ required: true, default: 0 }) - auth: number; - // 个推CID @prop({ required: false, default: "" }) getuiCID: string; @@ -278,21 +275,41 @@ export default class User extends BaseModel { return user; } - public static async findUserByField(field: string, value?: Array) { - let searchObj = {}; - if (field != 'all') { - searchObj[field] = { - $in: value - }; - } - const user: UserType[] = await UserModel.find(searchObj).select('uid tel username serverType auth').lean({ getters: true }); + public static async updatePlayTime(userCode: string, isGuest: boolean, todayPlayTime: number, playTime: number) { + const user: UserType = await UserModel.findOneAndUpdate({ userCode }, { $set: { guestTime: isGuest?playTime: 0, todayPlayTime: todayPlayTime, playTime } }, { new: true }).lean({ getters: true }); return user; } - public static async updatePlayTime(userCode: string, isGuest: boolean, todayPlayTime: number, playTime: number) { - const user: UserType = await UserModel.findOneAndUpdate({ userCode }, { $set: { guestTime: isGuest?playTime: 0, todayPlayTime: todayPlayTime, playTime } }, { new: true }).lean({ getters: true }); - return user; + private static getSearchObj(form: SearchUserParam) { + let searchObj = {}; + if(form['uid']) searchObj['uid'] = form.uid; + if(form['tel']) searchObj['tel'] = form.tel; + if(form.channelType && form.channelType != 'normal') searchObj['channelType'] = form.channelType; + return searchObj + } + + public static async findByCondition(page: number, pageSize: number, sortField: string = 'updatedAt', sortOrder: string = 'descend', form: SearchUserParam = {}) { + + let searchObj = this.getSearchObj(form); + let sort = {}; + if(sortField && sortOrder) { + if(sortOrder == 'ascend') { + sort[sortField] = 1; + } else if (sortOrder == 'descend') { + sort[sortField] = -1; + } + } + const result: UserType[] = await UserModel.find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort).select('-_id -__v -password -salt -token').lean({ getters: true, virtuals: true }); + return result; + + } + + public static async countByCondition(form: SearchUserParam = {}) { + + let searchObj = this.getSearchObj(form); + const result = await UserModel.count(searchObj); + return result; } } diff --git a/shared/domain/backEndField/search.ts b/shared/domain/backEndField/search.ts new file mode 100644 index 000000000..7c6847b8b --- /dev/null +++ b/shared/domain/backEndField/search.ts @@ -0,0 +1,5 @@ +export interface SearchUserParam { + uid?: number; + tel?: string; + channelType?: string; +} \ No newline at end of file diff --git a/shared/pubUtils/util.ts b/shared/pubUtils/util.ts index 54b335f24..191b8a1af 100644 --- a/shared/pubUtils/util.ts +++ b/shared/pubUtils/util.ts @@ -662,14 +662,11 @@ export function getFloorStatus(gachaId: number, floor: Floor[]) { export async function checkWhiteListWithUid(uid: number) { let user = await UserModel.findUserByUid(uid); if(!user) return false; - let { tel, ip, auth } = user; - return await checkWhiteList(tel, ip, auth); + let { tel, ip } = user; + return await checkWhiteList(tel, ip); } -export async function checkWhiteList(tel: string, ip: string, auth: number) { - if(auth == 1) { - return true; - } +export async function checkWhiteList(tel: string, ip: string) { if(tel) { let result = await WhiteListModel.checkTel(tel); if(!!result) return true; From 4d6b87ce97f704cf1ea2fbc64a044ce686931287 Mon Sep 17 00:00:00 2001 From: luying Date: Fri, 26 Nov 2021 14:54:51 +0800 Subject: [PATCH 04/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E9=81=93?= =?UTF-8?q?=E5=85=B7=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app.ts | 18 +++- .../servers/activity/remote/activityRemote.ts | 4 +- .../battle/handler/comBattleHandler.ts | 2 +- .../app/servers/gm/handler/gmHandler.ts | 52 ----------- .../app/servers/gm/handler/gmRoleHandler.ts | 45 ++++++++++ .../app/servers/guild/handler/guildHandler.ts | 2 +- .../app/services/activity/activityService.ts | 1 + game-server/app/services/chatService.ts | 2 +- game-server/app/services/roleService.ts | 2 +- game-server/app/services/timeTaskService.ts | 2 +- gm-server/app/controller/users.ts | 14 +-- gm-server/app/router.ts | 2 +- gm-server/app/service/users.ts | 89 ++++++------------- shared/db/Role.ts | 51 ++++++++--- shared/db/User.ts | 2 +- shared/domain/backEndField/search.ts | 6 ++ web-server/app/middleware/checkMainten.ts | 2 +- web-server/app/middleware/tokenParser.ts | 1 - 18 files changed, 149 insertions(+), 148 deletions(-) create mode 100644 game-server/app/servers/gm/handler/gmRoleHandler.ts diff --git a/game-server/app.ts b/game-server/app.ts index e385a21da..9cc8b6505 100644 --- a/game-server/app.ts +++ b/game-server/app.ts @@ -68,6 +68,7 @@ app.configure(function () { console.log('serverName:', app.get('serverName')) initMongodb(app); + initGmMongodb(app); initRedis(app); setupRoutes(app); setupFilters(app); @@ -136,7 +137,14 @@ app.configure(ALL_ENVS, 'chat', function() { app.event.on('start_all', () => { getTire(); }); -}) +}); + +app.configure(ALL_ENVS, 'activity', function () { + app.event.on('start_all', () => { + app.rpc.activity.activityRemote.loadActivities.toServer(app.getServerId()); + }); +}); + function errorHandler(err: Error, msg: any, resp: any, session: FrontendOrBackendSession, cb: HandlerCallback) { @@ -167,11 +175,13 @@ async function initMongodb(app: _pinus.Application) { console.log('mongodb connect suc'); } }); - - let gmconnect = await mongoose.createConnection(app.get('database').gmmongo, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false }); - loadGmDb(gmconnect); } +async function initGmMongodb(app: _pinus.Application) { + let gmconnect = await mongoose.createConnection(app.get('database').gmmongo, { useNewUrlParser: true, useUnifiedTopology: true, useCreateIndex: true, useFindAndModify: false }); + loadGmDb(gmconnect); + console.log('mongoGmDb connect suc') +} function initRedis(app: _pinus.Application) { const redisClient = connectRedis(app.get('database').redis, app.get('database').redispw); app.set('redis', redisClient); diff --git a/game-server/app/servers/activity/remote/activityRemote.ts b/game-server/app/servers/activity/remote/activityRemote.ts index 97a9ea7f6..e17efc18c 100644 --- a/game-server/app/servers/activity/remote/activityRemote.ts +++ b/game-server/app/servers/activity/remote/activityRemote.ts @@ -14,7 +14,6 @@ export class ActivityRemote { constructor(private app: Application) { this.app = app; this.channelService = app.get('channelService'); - this.loadActivities(); } private channelService: ChannelService; @@ -30,7 +29,7 @@ export class ActivityRemote { reloadResources(); } - private async loadActivities() { + public async loadActivities() { let servers = await ServerlistModel.getAllServerList(); for(let { serverId, activityGroupId } of servers) { for(let groupId of activityGroupId) { @@ -52,6 +51,7 @@ export class ActivityRemote { this.app.set('activityByServer', this.activityByServer); this.app.set('activityByType', this.activityByType); this.app.set('activities', this.activities); + console.log('****** loadActivities') } private setActivityTypeAndServer() { diff --git a/game-server/app/servers/battle/handler/comBattleHandler.ts b/game-server/app/servers/battle/handler/comBattleHandler.ts index babbb1bad..f34d46df3 100644 --- a/game-server/app/servers/battle/handler/comBattleHandler.ts +++ b/game-server/app/servers/battle/handler/comBattleHandler.ts @@ -746,7 +746,7 @@ export class ComBattleHandler { if(r != roleId) roleIdList.push(r); } } - const roles = await RoleModel.findRoleByField('roleId', roleIdList, ROLE_SELECT.SHOW_SIMPLE, true); + const roles = await RoleModel.findByRoleIds(roleIdList, ROLE_SELECT.SHOW_SIMPLE, true); let result = new Array(); for(let role of roles) { if(role.quitTime == role.loginTime) { diff --git a/game-server/app/servers/gm/handler/gmHandler.ts b/game-server/app/servers/gm/handler/gmHandler.ts index efab147c1..dd6034fb3 100644 --- a/game-server/app/servers/gm/handler/gmHandler.ts +++ b/game-server/app/servers/gm/handler/gmHandler.ts @@ -31,58 +31,6 @@ export class GmHandler { constructor(private app: Application) { } - async pushEvent(msg: { uid: number, serverId: number }, session: BackendSession) { - - let { uid, serverId } = msg; - let role = await RoleModel.findByUid(uid, serverId); - if (!role) return resResult(STATUS.GM_ROLE_NOT_FOUND); - let { roleId, roleName, eventStatus } = role; - - let channelService = this.app.get('channelService'); - let event = await getEvent(eventStatus, roleId, roleName); - let hisOnlineInfo = await getRoleOnlineInfo(role.roleId); - if (hisOnlineInfo.isOnline) { - channelService.pushMessageByUids('onSpecialEvent', resResult(STATUS.SUCCESS, { event }), [{ - uid: roleId, - sid: hisOnlineInfo.sid - }]); - } - return resResult(STATUS.SUCCESS, { list: event }); - } - - async clearEvent(msg: {}, session: BackendSession) { - let roleId = session.get('roleId'); - - await EventRecordModel.deleteAccount(roleId); - return resResult(STATUS.SUCCESS); - } - - - async pushMessage(msg: { uid: number, serverId: number, eventName: string, message: string }, session: BackendSession) { - - let { uid, serverId, eventName, message } = msg; - - let content = {}; - try { - content = JSON.parse(message); - } catch (e) { - return resResult(STATUS.GM_JSON_FORMAT_ERR); - } - // console.log(uid, serverId) - let role = await RoleModel.findByUid(uid, serverId); - if (!role) return resResult(STATUS.GM_ROLE_NOT_FOUND); - let { roleId } = role; - - let hisOnlineInfo = await getRoleOnlineInfo(role.roleId); - if (hisOnlineInfo.isOnline) { - let sid = hisOnlineInfo.sid; - if (!!sid) {//下发邮件,对应前端红点提示 - pinus.app.channelService.pushMessageByUids(eventName, resResult(STATUS.SUCCESS, content), [{ uid: roleId, sid }]); - } - } - return resResult(STATUS.SUCCESS, { msg: content }); - } - //对接gm后台,下发邮件 async addMail(msg: { endTime: number, sendName: string, content: string, goods: RewardInter[], sendTime: number }) { let { endTime, content, sendName, sendTime, goods } = msg; diff --git a/game-server/app/servers/gm/handler/gmRoleHandler.ts b/game-server/app/servers/gm/handler/gmRoleHandler.ts new file mode 100644 index 000000000..f0dfb46f6 --- /dev/null +++ b/game-server/app/servers/gm/handler/gmRoleHandler.ts @@ -0,0 +1,45 @@ +import { Application, BackendSession, pinus } from 'pinus'; +import { resResult } from '../../../pubUtils/util'; +import { STATUS } from '../../../consts/statusCode'; +import { getRoleOnlineInfo } from '../../../services/redisService'; +import { addItems, createHeroes } from '../../../services/rewardService'; +import { RewardInter } from '../../../pubUtils/interface'; +import { getExpByLv } from '../../../pubUtils/data'; +import { RoleModel } from '../../../db/Role'; +let timer: NodeJS.Timer; +export default function (app: Application) { + return new GmRoleHandler(app); +} + +export class GmRoleHandler { + constructor(private app: Application) { + } + + async addItems(msg: { roleId: string, roleName: string, serverId: number, values: { reward: RewardInter[], heroes: number[], lv: number }}, session: BackendSession) { + let { roleId, roleName, serverId, values } = msg; + + let { reward, heroes, lv } = values; + if (reward == undefined && heroes == undefined && lv == undefined) { + return resResult(STATUS.WRONG_PARMS); + } + let connect = await getRoleOnlineInfo(roleId); + let sid = connect.isOnline?connect.sid: null; + + if(reward &&reward.length > 0) { + await addItems(roleId, roleName, sid, values.reward); + } + if(heroes && heroes.length > 0) { + await createHeroes(roleId, roleName, sid, serverId, heroes.map(hid => { return { hid, count: 1 }})) + } + if(lv && lv > 0) { + let exp = getExpByLv(lv)?.sum||0; + await RoleModel.updateRoleInfo(roleId, { lv, exp }) + let uids = [{ uid: roleId, sid }]; + pinus.app.get('channelService').pushMessageByUids('onPlayerExpChange', resResult(STATUS.SUCCESS, { + isLvUp: false, lv, exp + }), uids); + } + return resResult(STATUS.SUCCESS); + } + +} \ No newline at end of file diff --git a/game-server/app/servers/guild/handler/guildHandler.ts b/game-server/app/servers/guild/handler/guildHandler.ts index 2d3d7021b..d3211e885 100644 --- a/game-server/app/servers/guild/handler/guildHandler.ts +++ b/game-server/app/servers/guild/handler/guildHandler.ts @@ -418,7 +418,7 @@ export class GuildHandler { const guild = await GuildModel.findByCode(code, serverId, GUILD_SELECT.INVITED_MEMBER); if (guild.isMemberMax) return resResult(STATUS.GUILD_MEMBER_MAX); - const roleList = await RoleModel.findRoleByField('roleId', roleIds); + const roleList = await RoleModel.findByRoleIds(roleIds); let result = new Array(); let uids = []; for (let role of roleList) { diff --git a/game-server/app/services/activity/activityService.ts b/game-server/app/services/activity/activityService.ts index 7a03b8073..9216ab75e 100644 --- a/game-server/app/services/activity/activityService.ts +++ b/game-server/app/services/activity/activityService.ts @@ -31,6 +31,7 @@ import { getRandSingleEelm } from '../../pubUtils/util'; import { SignInData } from '../../domain/activityField/signInField'; import { ActivityGroupModel } from '../../db/ActivityGroup'; import { ActivityGroupTypeModel } from '../../db/ActivityGroupType'; +import { ServerlistModel } from '../../db/Serverlist'; /** * 获取活动数据 diff --git a/game-server/app/services/chatService.ts b/game-server/app/services/chatService.ts index c5ef05ac7..3737f13b1 100644 --- a/game-server/app/services/chatService.ts +++ b/game-server/app/services/chatService.ts @@ -297,7 +297,7 @@ export async function recentPrivateChatInfos(roleId: string, roleName: string) { .splice(CHAT_SYSTEM.RECENT_PRIVATE_CHATS_CNT); if (!recentPrivateChats || !recentPrivateChats.length) return null; - const roleInfos = await RoleModel.findRoleByField('roleId', recentPrivateChats.map(chat => { return chat.targetRoleId })); + const roleInfos = await RoleModel.findByRoleIds(recentPrivateChats.map(chat => { return chat.targetRoleId })); const chatInfos = recentPrivateChats.map( chat => { for (let { roleId: targetRoleId, quitTime, loginTime, roleName: targetRoleName, title, guildName, head, frame, spine, lv } of roleInfos) { if (targetRoleId === chat.targetRoleId) { diff --git a/game-server/app/services/roleService.ts b/game-server/app/services/roleService.ts index 43ceafa19..d41bfa1a4 100644 --- a/game-server/app/services/roleService.ts +++ b/game-server/app/services/roleService.ts @@ -84,7 +84,7 @@ export async function getSimpleRoleInfo(roleId: string) { export async function getSimpleRoleInfos(roleIds: string[]) { if (!roleIds || !roleIds.length) return null; - let roles = await RoleModel.findRoleByField('roleId', roleIds, ROLE_SELECT.SHOW_SIMPLE, true); + let roles = await RoleModel.findByRoleIds(roleIds, ROLE_SELECT.SHOW_SIMPLE, true); return roles; } diff --git a/game-server/app/services/timeTaskService.ts b/game-server/app/services/timeTaskService.ts index 08f88a465..2d6110c0e 100644 --- a/game-server/app/services/timeTaskService.ts +++ b/game-server/app/services/timeTaskService.ts @@ -51,7 +51,7 @@ export async function init() { await setPvpSeason(); // 周功勋结算任务 - guildWeeklyJobId = scheduleJob('settleGuildWeekly', '0 0 0 * * 1', settleGuildWeekly); + guildWeeklyJobId = scheduleJob('settleGuildWeekly', '0 0 ? * * 1', settleGuildWeekly); // 每5分钟汇报在线玩家在线情况 scheduleJob('reportOnline', '0 0/5 * * * *', reportOnlineSchedule); diff --git a/gm-server/app/controller/users.ts b/gm-server/app/controller/users.ts index 26bd60ce7..1ee629b8d 100644 --- a/gm-server/app/controller/users.ts +++ b/gm-server/app/controller/users.ts @@ -15,11 +15,11 @@ export default class UserController extends Controller { ctx.body = await ctx.service.users.createRole(uid, serverId, roleName); } - public async addAuth() { - const { ctx } = this; - const { uid, auth } = ctx.request.body; - ctx.body = await ctx.service.users.addAuth(uid, auth); - } + // public async addAuth() { + // const { ctx } = this; + // const { uid, auth } = ctx.request.body; + // ctx.body = await ctx.service.users.addAuth(uid, auth); + // } public async fixSms() { const { ctx } = this; @@ -35,8 +35,8 @@ export default class UserController extends Controller { public async getrolelist() { const { ctx } = this; - const { field, value } = ctx.request.body; - ctx.body = await ctx.service.users.getrolelist(field, value); + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.users.getrolelist(page, pageSize, sortField, sortOrder, form); } public async createRoleData() { diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index f91c01f76..d0ac4d612 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -28,8 +28,8 @@ export default (app: Application) => { // router.post('/api/users/createrole',tokenParser, controller.users.createRole); // router.post('/api/users/addauth', tokenParser, controller.users.addAuth); router.post('/api/users/fixsms', tokenParser, controller.users.fixSms); - router.post('/api/users/deleterole',tokenParser, controller.users.deleteRole); router.post('/api/users/getrolelist',tokenParser, controller.users.getrolelist); + router.post('/api/users/deleterole',tokenParser, controller.users.deleteRole); router.post('/api/users/createroledata',tokenParser, controller.users.createRoleData); router.post('/api/users/getpvpdefense',tokenParser, controller.users.getPveDefense); router.post('/api/users/getherolist',tokenParser, controller.users.getHeroList); diff --git a/gm-server/app/service/users.ts b/gm-server/app/service/users.ts index c1ce3e817..f323bdc6a 100644 --- a/gm-server/app/service/users.ts +++ b/gm-server/app/service/users.ts @@ -69,18 +69,18 @@ export default class GMUsers extends Service { } } - public async addAuth(uid: number, auth: number) { - console.log('enter Auth addAuth'); - const ctx = this.ctx; + // public async addAuth(uid: number, auth: number) { + // console.log('enter Auth addAuth'); + // const ctx = this.ctx; - const user = await UserModel.addAuth(uid, auth); - if (user) { - return ctx.service.utils.resResult(STATUS.SUCCESS); - } else { - console.error('add auth error'); - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR); - } - } + // const user = await UserModel.addAuth(uid, auth); + // if (user) { + // return ctx.service.utils.resResult(STATUS.SUCCESS); + // } else { + // console.error('add auth error'); + // return ctx.service.utils.resResult(STATUS.INTERNAL_ERR); + // } + // } public checkTelNo(telNo: string) { if (!isString(telNo)) { @@ -121,60 +121,27 @@ export default class GMUsers extends Service { /** * 根据类型等搜索玩家 */ - public async getrolelist(field: string = 'all', value: string = '') { + public async getrolelist(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchUserParam) { const { ctx } = this; - let arr = new Array(), flag = 0; - let valueArr = value.split(','); - if (value == '') field = 'all'; - for (let i of valueArr) { - if (field == 'uid') { - let d = parseInt(i); - if (isNaN(d)) { - flag = 1; break; - } else { - arr.push(d); - } - field = 'userInfo.uid'; - } else if (field == 'roleName') { - arr.push(i); - } else if (field == 'tel') { - arr.push(i); - field = 'userInfo.tel'; - } else if (field == 'all') { - break; - } else { - flag = 1; break; - } + const roles = await RoleModel.findByCondition(page, pageSize, sortField, sortOrder, form); + const total = await RoleModel.countByCondition( form ) + + let list = []; + for (let role of roles) { + let heroCount = await HeroModel.count({ roleId: role.roleId }).lean(); + let equipCount = await EquipModel.count({ roleId: role.roleId }).lean(); + let itemCount = await ItemModel.count({ roleId: role.roleId }).lean(); + + let { roleId, roleName, serverId, lv, vLv, gold, coin, ce } = role; + let { uid, tel } = role.userInfo; + list.push({ + key: roleId, roleId, roleName, serverId, lv, vLv, uid, tel, heroCount, equipCount, itemCount, gold, coin, ce, + env: ctx.app.config.realEnv + }); } - if (flag) { - return ctx.service.utils.resResult(STATUS.WRONG_PARMS); - } - - let roles = await RoleModel.findRoleByField(field, valueArr); - - if (roles) { - - let result = new Array(); - for (let role of roles) { - let heroCount = await HeroModel.count({ roleId: role.roleId }).lean(); - let equipCount = await EquipModel.count({ roleId: role.roleId }).lean(); - let itemCount = await ItemModel.count({ roleId: role.roleId }).lean(); - let defense = await PvpDefenseModel.findByRoleId(role.roleId); - - let { roleId, roleName, serverId, lv, vLv, gold, coin } = role; - let { uid, tel } = role.userInfo; - result.push({ - key: roleId, roleId, roleName, serverId, lv, vLv, uid, tel, heroCount, equipCount, itemCount, gold, coin, - hasDefense: defense ? '是' : '否', defCe: 0 - }); - } - return ctx.service.utils.resResult(STATUS.SUCCESS, { list: result }); - } else { - console.error('role list not found'); - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR); - } + return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total }) } public async createHero(uids: Array, _hid: string, _hlv: string) { diff --git a/shared/db/Role.ts b/shared/db/Role.ts index a7d35a3ba..e9aaa7580 100644 --- a/shared/db/Role.ts +++ b/shared/db/Role.ts @@ -7,6 +7,7 @@ import { nowSeconds, getTimeFunD } from '../pubUtils/timeUtil'; import { Figure } from '../domain/dbGeneral'; import * as dicParam from '../pubUtils/dicParam'; import Hero from './Hero'; +import { SearchRoleParam } from '../domain/backEndField/search'; type CeAttrUpdate = Partial; // role表属性格式 @@ -360,6 +361,11 @@ export default class Role extends BaseModel { return role; } + public static async findByRoleIds(roleIds: string[], select?: string, getters = false, virtuals = true) { + const role: RoleType[] = await RoleModel.find({ roleId: { $in: roleIds } }).select(select).lean({ getters, virtuals }); + return role; + } + public static async createRole(uid: number, serverId: number, roleInfo: { roleId: string; roleName: string; seqId: number; code: string, lv?: number, exp?: number }, lean = true) { const user = await User.findUserByUid(uid); if (!user) return null; @@ -370,19 +376,6 @@ export default class Role extends BaseModel { return role; } - public static async findRoleByField(field: string, value?: Array, select?: string, getters = false) { - let searchObj = {}; - if (field != 'all') { - searchObj[field] = { - $in: value - }; - } - - const user: RoleType[] = await RoleModel.find(searchObj).select(select).lean({ getters, virtuals: true }); - return user; - } - - public static async setEventStatus(roleId: string, eventStatus: number, lean = true) { let role: RoleType = await RoleModel.findOneAndUpdate({ roleId }, { eventStatus }, { new: true }).lean(lean); return role; @@ -742,6 +735,38 @@ export default class Role extends BaseModel { return role; } + + private static getSearchObj(form: SearchRoleParam) { + let searchObj = {}; + if(form.uid) searchObj['userInfo.uid'] = form.uid; + if(form.roleId) searchObj['roleId'] = form.roleId; + if(form.roleName) searchObj['roleName'] = { $regex: new RegExp(form.roleName.toString(), 'i') }; + return searchObj + } + + public static async findByCondition(page: number, pageSize: number, sortField: string = 'updatedAt', sortOrder: string = 'descend', form: SearchRoleParam = {}) { + + let searchObj = this.getSearchObj(form); + let sort = {}; + if(sortField && sortOrder) { + if(sortOrder == 'ascend') { + sort[sortField] = 1; + } else if (sortOrder == 'descend') { + sort[sortField] = -1; + } + } + const result: RoleType[] = await RoleModel.find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort).lean({ getters: true, virtuals: true }); + return result; + + } + + public static async countByCondition(form: SearchRoleParam = {}) { + + let searchObj = this.getSearchObj(form); + const result = await RoleModel.count(searchObj); + return result; + } + } export const RoleModel = getModelForClass(Role); diff --git a/shared/db/User.ts b/shared/db/User.ts index c400664f4..da911217b 100644 --- a/shared/db/User.ts +++ b/shared/db/User.ts @@ -4,7 +4,7 @@ import BaseModel from './BaseModel'; import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose'; import { genCode, aesEncryptcfb, aesDecryptcfb } from '../pubUtils/util'; import { LoginValidateData37, ChannelInfo } from '../domain/sdk'; -import { SearchUserParam } from '@domain/backEndField/search'; +import { SearchUserParam } from '../domain/backEndField/search'; const bcrypt = require('bcrypt'); const SALT_WORK_FACTOR = 5 diff --git a/shared/domain/backEndField/search.ts b/shared/domain/backEndField/search.ts index 7c6847b8b..f10893b60 100644 --- a/shared/domain/backEndField/search.ts +++ b/shared/domain/backEndField/search.ts @@ -2,4 +2,10 @@ export interface SearchUserParam { uid?: number; tel?: string; channelType?: string; +} + +export interface SearchRoleParam { + uid?: number; // 玩家id + roleId?: string; // 角色id + roleName?: string; // 昵称 } \ No newline at end of file diff --git a/web-server/app/middleware/checkMainten.ts b/web-server/app/middleware/checkMainten.ts index 70801bea7..03a95f6c6 100644 --- a/web-server/app/middleware/checkMainten.ts +++ b/web-server/app/middleware/checkMainten.ts @@ -7,7 +7,7 @@ module.exports = () => { if (serverId) { let maintenServers = await ctx.service.game.getServerMainten(); if (maintenServers.indexOf(serverId) != -1) { - let isWhiteList = await checkWhiteList(ctx.tel, ctx.request.ip, ctx.auth); + let isWhiteList = await checkWhiteList(ctx.tel, ctx.request.ip); if (isWhiteList) { await next(); } else { diff --git a/web-server/app/middleware/tokenParser.ts b/web-server/app/middleware/tokenParser.ts index ba96712f8..3b0aa1120 100644 --- a/web-server/app/middleware/tokenParser.ts +++ b/web-server/app/middleware/tokenParser.ts @@ -16,7 +16,6 @@ module.exports = () => { } ctx.uid = user.uid; ctx.serverType = ctx.request.body.serverType||user.serverType; - ctx.auth = user.auth; ctx.userCode = user.userCode; ctx.pkgName = user.pkgName; ctx.tel = user.tel; From 2e48a4dfc1fd57c7ad4534bb5ed18da87a2adba0 Mon Sep 17 00:00:00 2001 From: luying Date: Fri, 26 Nov 2021 16:50:29 +0800 Subject: [PATCH 05/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E5=B0=81=E7=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/connector/filter/global.ts | 39 +++++++++++++------ .../servers/connector/handler/entryHandler.ts | 2 + .../connector/remote/connectorRemote.ts | 16 +++++++- .../app/servers/gm/handler/gmRoleHandler.ts | 17 +++++++- .../app/servers/guild/handler/guildHandler.ts | 11 +++--- game-server/app/services/connectorService.ts | 4 +- game-server/app/services/guildService.ts | 3 +- gm-server/app/service/users.ts | 6 +-- shared/consts/constModules/sysConst.ts | 9 ++++- shared/consts/statusCode.ts | 2 + shared/db/Role.ts | 8 ++-- web-server/app/service/Auth.ts | 5 ++- 12 files changed, 90 insertions(+), 32 deletions(-) diff --git a/game-server/app/servers/connector/filter/global.ts b/game-server/app/servers/connector/filter/global.ts index c939fa2f7..1d6cd7c62 100644 --- a/game-server/app/servers/connector/filter/global.ts +++ b/game-server/app/servers/connector/filter/global.ts @@ -3,7 +3,7 @@ import {Application, RouteRecord, FrontendOrBackendSession, HandlerCallback, pin import { refresh } from '../../../services/refreshService'; import { checkPrivateChat, checkGuildChat, checkOtherChat, checkRoleName, checkGuildName } from "../../../services/sdkService"; import { resResult, checkWhiteListWithUid, genCode } from "../../../pubUtils/util"; -import { CHANNEL_PREFIX, STATUS } from "../../../consts"; +import { BLOCK_TYPE, CHANNEL_PREFIX, STATUS } from "../../../consts"; import { UserModel } from "../../../db/User"; import { SERVER_DEBUG_MODE } from "../../../pubUtils/dicParam"; export function globalFilter(app: Application) { @@ -20,7 +20,21 @@ Filter.prototype.before = async function (routeRecord: RouteRecord, msg: any, se const roleId: string = session.get('roleId'); const uid: number = session.get('userid'); let guildCode = session.get('guildCode'); - + let blockType = session.get('blockType'); + if(blockType == BLOCK_TYPE.BLOCK) return next(new Error(), resResult(STATUS.BLOCKED)); + if(blockType == BLOCK_TYPE.BAN) { + if([ + 'chat.chatHandler.sendPrivateMessage', + 'chat.chatHandler.sendGroupMessage', + 'battle.barrageHandler.sendBarrage', + 'guild.guildHandler.sendMail', + 'guild.guildHandler.setGuildInfo', + ].indexOf(routeRecord.route) != -1) { + return next(new Error(), resResult(STATUS.BANNED)); + } + } + + session.push('teamCode', () => {}); const maintenServers = this.app.get('maintenServers'); @@ -33,15 +47,6 @@ Filter.prototype.before = async function (routeRecord: RouteRecord, msg: any, se } let hasBlockWords = false; - // if(pinus.app.get('env') == 'production') { - // if(routeRecord.route == 'guild.guildHandler.createGuild') { - // hasBlockWords = await checkFilterWords(msg.name); - // } else if (routeRecord.route == 'role.roleHandler.initRole') { - // hasBlockWords = await checkFilterWords(msg.roleName); - // } else if (routeRecord.route == 'role.roleHandler.rename') { - // hasBlockWords = await checkFilterWords(msg.roleName); - // } - // } if(SERVER_DEBUG_MODE.CHECK_WORD == 1) { switch(routeRecord.route) { case 'chat.chatHandler.sendPrivateMessage': @@ -62,6 +67,18 @@ Filter.prototype.before = async function (routeRecord: RouteRecord, msg: any, se break; } } + case 'battle.barrageHandler.sendBarrage': + { + let result = await checkOtherChat(roleId, CHANNEL_PREFIX.WORLD, msg.content); + if(!result) hasBlockWords = true; + break; + } + case 'guild.guildHandler.sendMail': + { + let result = await checkGuildChat(roleId, guildCode, msg.info); + if(!result) hasBlockWords = true; + break; + } case 'role.roleHandler.rename': case 'role.roleHandler.initRole': { diff --git a/game-server/app/servers/connector/handler/entryHandler.ts b/game-server/app/servers/connector/handler/entryHandler.ts index d1be3ab63..cbfc1e63f 100644 --- a/game-server/app/servers/connector/handler/entryHandler.ts +++ b/game-server/app/servers/connector/handler/entryHandler.ts @@ -128,6 +128,7 @@ export class EntryHandler { session.set('updatedMailAt', updatedMailAt); session.set('roleName', role.roleName); session.set('eventStatus', role.eventStatus); + session.set('blockType', role.blockType); session.set('sid', self.app.get('serverId')); session.set('serverId', role.serverId); session.set('guildCode', role.guildCode); @@ -139,6 +140,7 @@ export class EntryHandler { session.push('serverId', () => { }); session.push('updatedMailAt', () => { }); session.push('guildCode', () => { }); + session.push('blockType', () => { }); // console.log(role.guildCode) // session.push('rid', function (err) { // if (err) { diff --git a/game-server/app/servers/connector/remote/connectorRemote.ts b/game-server/app/servers/connector/remote/connectorRemote.ts index 16dfdc68a..c5c1d943a 100644 --- a/game-server/app/servers/connector/remote/connectorRemote.ts +++ b/game-server/app/servers/connector/remote/connectorRemote.ts @@ -18,8 +18,8 @@ export class ConnectorRemote { } private maintenServers: number[] = []; // 维护中的服务器 - public async remoteLogin(uid: string) { - await kickUser(this.app, uid); + public async remoteLogin(uid: string, message?: any) { + await kickUser(this.app, uid, message); } public async setOtherUserGuildSession(params: { roleId: string, userGuild: UserGuildType}[]) { @@ -50,6 +50,18 @@ export class ConnectorRemote { } } + public async setOtherUseBlockTypeSession(params: { roleId: string, blockType: string}[]) { + let sessionService = this.app.get('sessionService'); + for(let {roleId, blockType} of params) { + let sessions = sessionService.getByUid(roleId); + if(!!sessions) { + sessions.forEach(session => { + sessionService.aimportAll(session.id, { blockType }); + }); + } + } + } + /** * 重载json资源 */ diff --git a/game-server/app/servers/gm/handler/gmRoleHandler.ts b/game-server/app/servers/gm/handler/gmRoleHandler.ts index f0dfb46f6..5affed99c 100644 --- a/game-server/app/servers/gm/handler/gmRoleHandler.ts +++ b/game-server/app/servers/gm/handler/gmRoleHandler.ts @@ -6,6 +6,7 @@ import { addItems, createHeroes } from '../../../services/rewardService'; import { RewardInter } from '../../../pubUtils/interface'; import { getExpByLv } from '../../../pubUtils/data'; import { RoleModel } from '../../../db/Role'; +import { BLOCK_TYPE } from '../../../consts'; let timer: NodeJS.Timer; export default function (app: Application) { return new GmRoleHandler(app); @@ -32,7 +33,7 @@ export class GmRoleHandler { await createHeroes(roleId, roleName, sid, serverId, heroes.map(hid => { return { hid, count: 1 }})) } if(lv && lv > 0) { - let exp = getExpByLv(lv)?.sum||0; + let exp = getExpByLv(lv - 1)?.sum||0; await RoleModel.updateRoleInfo(roleId, { lv, exp }) let uids = [{ uid: roleId, sid }]; pinus.app.get('channelService').pushMessageByUids('onPlayerExpChange', resResult(STATUS.SUCCESS, { @@ -42,4 +43,18 @@ export class GmRoleHandler { return resResult(STATUS.SUCCESS); } + async handleBlock(msg: { roleId: string, blockType: BLOCK_TYPE, blockReason: string }, session: BackendSession) { + let { roleId, blockType, blockReason } = msg; + if(roleId == undefined || blockType == undefined || blockReason == undefined) return resResult(STATUS.WRONG_PARMS); + let role = await RoleModel.updateRoleInfo(roleId, { blockType, blockReason }); + if(!role) return resResult(STATUS.ROLE_NOT_FOUND); + let { isOnline, sid } = await getRoleOnlineInfo(roleId); + if(isOnline) { + await this.app.rpc.connector.connectorRemote.setOtherUseBlockTypeSession.toServer(sid,[{ roleId, blockType }]); + if(blockType == BLOCK_TYPE.BLOCK) { // 踢走 + await this.app.rpc.connector.connectorRemote.remoteLogin.toServer(sid, roleId, STATUS.BLOCKED); + } + } + return resResult(STATUS.SUCCESS); + } } \ No newline at end of file diff --git a/game-server/app/servers/guild/handler/guildHandler.ts b/game-server/app/servers/guild/handler/guildHandler.ts index d3211e885..3556bfca2 100644 --- a/game-server/app/servers/guild/handler/guildHandler.ts +++ b/game-server/app/servers/guild/handler/guildHandler.ts @@ -558,7 +558,7 @@ export class GuildHandler { await RoleModel.dissmissGuild(members); await UserGuildApplyModel.deleteApplyByGuild(code); - await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.toServer(sid, members.map(roleId => { return { roleId, userGuild: null } })); // 更新session + await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.broadcast(members.map(roleId => { return { roleId, userGuild: null } })); // 更新session // 删除channel @@ -629,13 +629,14 @@ export class GuildHandler { await removeTrainRank(code, roleId, guild.trainId); let chatSid = await getGuildChannelSid(code); - const { sid } = await getRoleOnlineInfo(roleId); + const { isOnline, sid } = await getRoleOnlineInfo(roleId); this.app.rpc.chat.guildRemote.memberQuit.toServer(chatSid, code, roleId, guild, sid); // 添加动态 const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.QUIT_GUILD, [role.roleName]); this.app.rpc.chat.guildRemote.addRec.toServer(chatSid, rec); - await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.toServer(sid,[{ roleId: memberRoleId, userGuild }]); + if(isOnline) + await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.toServer(sid,[{ roleId: memberRoleId, userGuild }]); await sendMailByContent(MAIL_TYPE.GUILD_BE_KICK, memberRoleId, { sendName: roleName, params: [guild.name] }); @@ -683,10 +684,10 @@ export class GuildHandler { // 交换 let oldLeaderUserGuild = await UserGuildModel.updateInfo(leaderRoleId, { auth: GUILD_AUTH.MEMBER, job: GUILD_JOB.SHIBING }, {}, 'auth'); // 团长撤 - await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.toServer(sid,[{ roleId: leaderRoleId, oldLeaderUserGuild }]); // 更新session + await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.broadcast([{ roleId: leaderRoleId, userGuild: oldLeaderUserGuild }]); // 更新session let newLeaderUserGuild = await UserGuildModel.updateInfo(topUserGuild.roleId, { auth: GUILD_AUTH.LEADER, job: GUILD_JOB.JIANGJUN }, {}, 'auth'); // 最高功勋人升 - await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.toServer(sid,[{ roleId: topUserGuild.roleId, newLeaderUserGuild }]); // 更新session + await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.broadcast([{ roleId: topUserGuild.roleId, userGuild: newLeaderUserGuild }]); // 更新session let managerCntInc = topUserGuild.auth == GUILD_AUTH.MANAGER ? -1 : 0; // 管理人数 diff --git a/game-server/app/services/connectorService.ts b/game-server/app/services/connectorService.ts index 51eb5c048..6cc3883d7 100644 --- a/game-server/app/services/connectorService.ts +++ b/game-server/app/services/connectorService.ts @@ -247,7 +247,7 @@ export async function everydayRefresh() { setMedianCe(); } -export async function kickUser(app: Application, uid: string) { +export async function kickUser(app: Application, uid: string, message = STATUS.LOGIN_ERR) { let sessionService = app.get('sessionService'); let sessions = sessionService.getByUid(uid); if (!!sessions) { @@ -255,7 +255,7 @@ export async function kickUser(app: Application, uid: string) { let roleId = session.get('roleId'); let sid = session.get('sid'); let uids = [{ uid: roleId, sid }]; - app.get('channelService').pushMessageByUids('onRemoteLogin', resResult(STATUS.LOGIN_ERR), uids); + app.get('channelService').pushMessageByUids('onRemoteLogin', resResult(message), uids); }); } await sessionService.akick(uid); diff --git a/game-server/app/services/guildService.ts b/game-server/app/services/guildService.ts index dafa45533..d653e3be1 100644 --- a/game-server/app/services/guildService.ts +++ b/game-server/app/services/guildService.ts @@ -112,13 +112,12 @@ export async function joinGuild(code: string, guildName: string, lv: number, rol const { sid } = await getRoleOnlineInfo(roleId); if (sid) { await addRoleToGuildChannel(roleId, sid, code); + await pinus.app.rpc.connector.connectorRemote.setOtherUserGuildSession.toServer(sid,[{ roleId, userGuild }]); } //成长任务-加入军团 await checkActivityTask(serverId, sid, roleId, TASK_TYPE.GUILD_JOIN, 1); - await pinus.app.rpc.connector.connectorRemote.setOtherUserGuildSession.toServer(sid,[{ roleId, userGuild }]); - return { status: 0, guild, userGuild, roleName: role.roleName, memberCnt: guild.memberCnt, guildCe: guild.guildCe } } diff --git a/gm-server/app/service/users.ts b/gm-server/app/service/users.ts index f323bdc6a..52d751fe3 100644 --- a/gm-server/app/service/users.ts +++ b/gm-server/app/service/users.ts @@ -116,8 +116,6 @@ export default class GMUsers extends Service { return ctx.service.utils.resResult(STATUS.SUCCESS); } - - /** * 根据类型等搜索玩家 */ @@ -133,10 +131,10 @@ export default class GMUsers extends Service { let equipCount = await EquipModel.count({ roleId: role.roleId }).lean(); let itemCount = await ItemModel.count({ roleId: role.roleId }).lean(); - let { roleId, roleName, serverId, lv, vLv, gold, coin, ce } = role; + let { roleId, roleName, serverId, lv, vLv, gold, coin, ce, blockType = 0, blockReason = '' } = role; let { uid, tel } = role.userInfo; list.push({ - key: roleId, roleId, roleName, serverId, lv, vLv, uid, tel, heroCount, equipCount, itemCount, gold, coin, ce, + key: roleId, roleId, roleName, serverId, lv, vLv, uid, tel, heroCount, equipCount, itemCount, gold, coin, ce, blockType, blockReason, env: ctx.app.config.realEnv }); } diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index 23477c89c..774b01ac3 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -747,4 +747,11 @@ export enum THINKING_DATA_MODE_LIST { BATCH = 'batch', LOGGING = 'logging', } -export let THINKING_DATA_MODE = THINKING_DATA_MODE_LIST.DEBUG; \ No newline at end of file +export let THINKING_DATA_MODE = THINKING_DATA_MODE_LIST.DEBUG; + + +export enum BLOCK_TYPE { + NOT = 0, + BAN = 1, + BLOCK = 2, +} \ No newline at end of file diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index 2523807ba..0095f28e0 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -10,6 +10,8 @@ export const STATUS = { SERVER_MAINTENANCE: { code: 7, simStr: '服务器维护中' }, VERSION_ERR: { code: 8, simStr: '版本号太低,请更新' }, BLOCK_WORDS: { code: 9, simStr: '内容有不合法词汇' }, + BLOCKED: { code: 10, simStr: '您已被封禁' }, + BANNED: { code: 11, simStr: '您已被禁言' }, GLOBAL_ERR: { code: 1003, simStr: '服务器内部错误' }, // http请求 REQUEST_TIME_OUT: { code: 2000, simStr: '请求超时' }, diff --git a/shared/db/Role.ts b/shared/db/Role.ts index e9aaa7580..24b2e3515 100644 --- a/shared/db/Role.ts +++ b/shared/db/Role.ts @@ -1,4 +1,4 @@ -import { ROLE_TERAPH, ROLE_SELECT, ABI_TYPE, HERO_CE_RATIO } from './../consts'; +import { ROLE_TERAPH, ROLE_SELECT, ABI_TYPE, HERO_CE_RATIO, BLOCK_TYPE } from './../consts'; import BaseModel from './BaseModel'; import { index, getModelForClass, prop, DocumentType, Ref, mongoose } from '@typegoose/typegoose'; import User from './User'; @@ -147,8 +147,10 @@ export default class Role extends BaseModel { serverType: string; // 服务器类型 @prop({ required: true }) serverId: number; // 区服 id - @prop({ required: true, default: false }) - blocked: boolean; // 是否屏蔽 + @prop({ required: true, default: 0 }) + blockType: BLOCK_TYPE; // 封禁类型 1-封言 2-封禁 + @prop({ required: true, default: '' }) + blockReason: string; // 封禁理由 @prop({ required: true }) code: string; // 邀请码 @prop({ required: true, default: false }) diff --git a/web-server/app/service/Auth.ts b/web-server/app/service/Auth.ts index 87e685545..f4aa6b28a 100644 --- a/web-server/app/service/Auth.ts +++ b/web-server/app/service/Auth.ts @@ -1,5 +1,5 @@ -import { COUNTER, DEFAULT_LV, ADULT_AGE, GUEST_MAX_TIME, TASK_TYPE } from '@consts'; +import { COUNTER, DEFAULT_LV, ADULT_AGE, GUEST_MAX_TIME, TASK_TYPE, BLOCK_TYPE } from '@consts'; import { RoleModel } from '@db/Role'; import { UserModel, UserType } from '@db/User'; import { STATUS, GET_SMS_TYPE, ADDICTION_PREVENTION_CODE } from '@consts'; @@ -291,6 +291,9 @@ export default class Auth extends Service { const ctx = this.ctx; const { uid } = ctx; const role = await RoleModel.findByUid(uid, serverId); + if(role.blockType == BLOCK_TYPE.BLOCK) { + return ctx.service.utils.resResult(STATUS.BLOCKED); + } if (role) { return ctx.service.utils.resResult(STATUS.SUCCESS, { roleId: role.roleId }); } From 7e466638682b55fbd3ae04fdfa8a37874ba4a83c Mon Sep 17 00:00:00 2001 From: luying Date: Fri, 26 Nov 2021 19:02:18 +0800 Subject: [PATCH 06/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E6=AD=A6?= =?UTF-8?q?=E5=B0=86=E3=80=81=E8=A3=85=E5=A4=87=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gm-server/app/controller/users.ts | 12 ++--- gm-server/app/router.ts | 6 +-- gm-server/app/service/users.ts | 81 ++++++++++++++-------------- shared/db/Equip.ts | 31 +++++++++++ shared/db/Hero.ts | 46 +++++++++++----- shared/domain/backEndField/search.ts | 12 +++++ 6 files changed, 123 insertions(+), 65 deletions(-) diff --git a/gm-server/app/controller/users.ts b/gm-server/app/controller/users.ts index 1ee629b8d..c2cb973e3 100644 --- a/gm-server/app/controller/users.ts +++ b/gm-server/app/controller/users.ts @@ -72,14 +72,14 @@ export default class UserController extends Controller { public async getHeroList() { const { ctx } = this; - const { field, value } = ctx.request.body; - ctx.body = await ctx.service.users.getHeroList(field, value); + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.users.getHeroList(page, pageSize, sortField, sortOrder, form); } public async deleteHero() { const { ctx } = this; - const { selectedRowKeys: roleIdAndHids } = ctx.request.body; - ctx.body = await ctx.service.users.deleteHero(roleIdAndHids); + const { roleId, hid } = ctx.request.body; + ctx.body = await ctx.service.users.deleteHero(roleId, parseInt(hid)); } public async setHeroLv() { @@ -114,8 +114,8 @@ export default class UserController extends Controller { public async getEquipList() { const { ctx } = this; - const { field, value } = ctx.request.body; - ctx.body = await ctx.service.users.getEquipList(field, value); + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.users.getEquipList(page, pageSize, sortField, sortOrder, form); } public async getItemList() { diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index d0ac4d612..d0065236a 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -34,9 +34,9 @@ export default (app: Application) => { router.post('/api/users/getpvpdefense',tokenParser, controller.users.getPveDefense); router.post('/api/users/getherolist',tokenParser, controller.users.getHeroList); router.post('/api/users/deletehero', tokenParser, controller.users.deleteHero); - router.post('/api/users/setherolv', tokenParser, controller.users.setHeroLv); - router.post('/api/users/setheroparam', controller.users.setHeroParam); - router.post('/api/users/setherojob', controller.users.setHeroJob); + // router.post('/api/users/setherolv', tokenParser, controller.users.setHeroLv); + // router.post('/api/users/setheroparam', controller.users.setHeroParam); + // router.post('/api/users/setherojob', controller.users.setHeroJob); // router.post('/api/users/saveherotodefense',tokenParser, controller.users.saveHeroToDefense); // router.post('/api/users/removeherofromdefense',tokenParser, controller.users.removeHeroFromDefense); router.post('/api/users/getequiplist', tokenParser, controller.users.getEquipList); diff --git a/gm-server/app/service/users.ts b/gm-server/app/service/users.ts index 52d751fe3..dcfae150a 100644 --- a/gm-server/app/service/users.ts +++ b/gm-server/app/service/users.ts @@ -21,7 +21,7 @@ import { CreateHeroes, deletRole } from '@pubUtils/roleUtil'; import { RScriptRecordModel } from '@db/RScriptRecord'; import { DicWar } from '@pubUtils/dictionary/DicWar'; import { SkinModel } from '@db/Skin'; -import { SearchUserParam } from '@domain/backEndField/search'; +import { SearchEquipParam, SearchHeroParam, SearchUserParam } from '@domain/backEndField/search'; // import { resResult } from '@pubUtils/util'; @@ -390,51 +390,42 @@ export default class GMUsers extends Service { /** * 根据类型等搜索玩家 */ - public async getHeroList(field: string, value: (string | number)) { + public async getHeroList(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchHeroParam) { const { ctx } = this; - let heroes = await HeroModel.findByField(field, value); + const heroes = await HeroModel.findByCondition(page, pageSize, sortField, sortOrder, form); + const total = await HeroModel.countByCondition( form ) - if (heroes) { - let roleMap = new Map(); - for(let { roleId } of heroes) { - if(!roleMap.has(roleId)) { - let role = await RoleModel.findByRoleId(roleId, 'attr'); - roleMap.set(roleId, role.attr); - } + let roleMap = new Map(); + for(let { roleId } of heroes) { + if(!roleMap.has(roleId)) { + let role = await RoleModel.findByRoleId(roleId, 'attr'); + roleMap.set(roleId, role.attr); } - let list = heroes.map(cur => { - let cal = new AttributeCal(); - cal.setByDbData(roleMap.get(cur.roleId), cur.attr); - return {...cur, calculatedAttr: cal.getReduceAttributesToArr()} - }) - - return ctx.service.utils.resResult(STATUS.SUCCESS, { list }); - } else { - console.error('role list not found'); - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR); } + let list = heroes.map(cur => { + let cal = new AttributeCal(); + cal.setByDbData(roleMap.get(cur.roleId), cur.attr); + return {...cur, calculatedAttr: cal.getReduceAttributesToArr(), env: ctx.app.config.realEnv} + }) + + return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total }) } - public async deleteHero(roleIdAndHids: string[]) { + public async deleteHero(roleId: string, hid: number) { console.log('enter Auth deleteRole'); const ctx = this.ctx; - for (let roleIdAndHid of roleIdAndHids) { - let [roleId, hidStr] = roleIdAndHid.split('|'); - if (isNaN(parseInt(hidStr))) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); - let hid = parseInt(hidStr); + let hero = await HeroModel.findByHidAndRole(hid, roleId); + if (!hero) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); - let hero = await HeroModel.findByHidAndRole(hid, roleId); - if (!hero) continue; - await HeroModel.deleteHero(roleId, hid); - await SkinModel.deleteByHero(roleId, hid); - let role = await RoleModel.findByRoleId(roleId); - await calculatetopLineup(role, hid, 0, null); - await PvpDefenseModel.deleteHero(roleId, hid); - await RoleModel.updateRoleInfo(roleId, { topLineup: role.topLineup, topLineupCe: role.topLineupCe, ce: role.ce - hero.ce }); - } + await HeroModel.deleteHero(roleId, hid); + await SkinModel.deleteByHero(roleId, hid); + let role = await RoleModel.findByRoleId(roleId); + await calculatetopLineup(role, hid, 0, null); + await PvpDefenseModel.deleteHero(roleId, hid); + await RoleModel.updateRoleInfo(roleId, { topLineup: role.topLineup, topLineupCe: role.topLineupCe, ce: role.ce - hero.ce }); return ctx.service.utils.resResult(STATUS.SUCCESS); } @@ -595,18 +586,24 @@ export default class GMUsers extends Service { /** * 根据类型等搜索装备 */ - public async getEquipList(field: string, value: (string | number)) { + public async getEquipList(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchEquipParam) { const { ctx } = this; - let equips = await EquipModel.findByField(field, value); + const heroes = await EquipModel.findByCondition(page, pageSize, sortField, sortOrder, form); + const total = await EquipModel.countByCondition( form ) - if (equips) { - - return ctx.service.utils.resResult(STATUS.SUCCESS, { list: equips }); - } else { - console.error('role list not found'); - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR); + let roleMap = new Map(); + for(let { roleId } of heroes) { + if(!roleMap.has(roleId)) { + let role = await RoleModel.findByRoleId(roleId, 'attr'); + roleMap.set(roleId, role.attr); + } } + let list = heroes.map(cur => { + return {...cur, env: ctx.app.config.realEnv} + }) + + return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total }) } diff --git a/shared/db/Equip.ts b/shared/db/Equip.ts index 9e879aa4a..ecb51babd 100644 --- a/shared/db/Equip.ts +++ b/shared/db/Equip.ts @@ -4,6 +4,7 @@ import { COUNTER } from '../consts'; import { CounterModel } from './Counter'; import { HeroModel } from './Hero'; import { RoleModel } from './Role'; +import { SearchEquipParam } from '@domain/backEndField/search'; export class RandSe { @prop({ required: true }) @@ -192,6 +193,36 @@ export default class Equip extends BaseModel { return result; } + private static getSearchObj(form: SearchEquipParam) { + let searchObj = {}; + if(form.roleId) searchObj['roleId'] = form.roleId; + if(form.roleName) searchObj['roleName'] = { $regex: new RegExp(form.roleName.toString(), 'i') }; + if(form.id) searchObj['id'] = form.id; + return searchObj + } + + public static async findByCondition(page: number, pageSize: number, sortField: string = 'updatedAt', sortOrder: string = 'descend', form: SearchEquipParam = {}) { + + let searchObj = this.getSearchObj(form); + let sort = {}; + if(sortField && sortOrder) { + if(sortOrder == 'ascend') { + sort[sortField] = 1; + } else if (sortOrder == 'descend') { + sort[sortField] = -1; + } + } + const result: EquipType[] = await EquipModel.find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort).lean({ getters: true, virtuals: true }); + return result; + + } + + public static async countByCondition(form: SearchEquipParam = {}) { + + let searchObj = this.getSearchObj(form); + const result = await EquipModel.count(searchObj); + return result; + } } export const EquipModel = getModelForClass(Equip); diff --git a/shared/db/Hero.ts b/shared/db/Hero.ts index a6fcce344..689b532e4 100644 --- a/shared/db/Hero.ts +++ b/shared/db/Hero.ts @@ -5,6 +5,7 @@ import { CounterModel } from './Counter'; import { COUNTER, EQUIP_TYPE, HERO_CE_RATIO } from '../consts'; import { reduceCe } from '../pubUtils/util'; import Skin from './Skin'; +import { SearchHeroParam } from '@domain/backEndField/search'; type CeAttrUpdate = Partial; export class CeAttrData { @@ -300,20 +301,6 @@ export default class Hero extends BaseModel { return hero; } - public static async findByField(field: string, value?: number | string, lean = true) { - let searchObj = {}; - if (field != 'all') { - if (field == 'roleName') { - searchObj['roleName'] = { $regex: new RegExp(value.toString(), 'i') } - } else { - searchObj[field] = value; - } - } - //.select('uid tel username') - const user: HeroType[] = await HeroModel.find(searchObj, {_id: 0}).lean(lean); - return user; - } - public static async getAllRank(serverId: number, select?: string, limit = 200) { let result: HeroType[] = await HeroModel.find({ serverId }, { _id: false }).select(select).limit(limit).sort({ ce: -1, updatedAt: 1 }).lean({ getters: true }); return result; @@ -328,6 +315,37 @@ export default class Hero extends BaseModel { let result: HeroType[] = await HeroModel.find({ serverId, hid }, { _id: false }).select(select).limit(limit).lean({ getters: true }); return result; } + + private static getSearchObj(form: SearchHeroParam) { + let searchObj = {}; + if(form.roleId) searchObj['roleId'] = form.roleId; + if(form.roleName) searchObj['roleName'] = { $regex: new RegExp(form.roleName.toString(), 'i') }; + if(form.hid) searchObj['hid'] = form.hid; + return searchObj + } + + public static async findByCondition(page: number, pageSize: number, sortField: string = 'updatedAt', sortOrder: string = 'descend', form: SearchHeroParam = {}) { + + let searchObj = this.getSearchObj(form); + let sort = {}; + if(sortField && sortOrder) { + if(sortOrder == 'ascend') { + sort[sortField] = 1; + } else if (sortOrder == 'descend') { + sort[sortField] = -1; + } + } + const result: HeroType[] = await HeroModel.find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort).lean({ getters: true, virtuals: true }); + return result; + + } + + public static async countByCondition(form: SearchHeroParam = {}) { + + let searchObj = this.getSearchObj(form); + const result = await HeroModel.count(searchObj); + return result; + } } export const HeroModel = getModelForClass(Hero); diff --git a/shared/domain/backEndField/search.ts b/shared/domain/backEndField/search.ts index f10893b60..4d90fab20 100644 --- a/shared/domain/backEndField/search.ts +++ b/shared/domain/backEndField/search.ts @@ -8,4 +8,16 @@ export interface SearchRoleParam { uid?: number; // 玩家id roleId?: string; // 角色id roleName?: string; // 昵称 +} + +export interface SearchHeroParam { + roleId?: string; + roleName?: string; + hid?: number; +} + +export interface SearchEquipParam { + roleId?: string; + roleName?: string; + id?: number; } \ No newline at end of file From c4e4e472d13f45478de90c75fe4afa5db6c5231b Mon Sep 17 00:00:00 2001 From: luying Date: Mon, 29 Nov 2021 20:33:36 +0800 Subject: [PATCH 07/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gm-server/app/controller/game.ts | 7 ++ gm-server/app/controller/mail.ts | 55 +++++++++++++- gm-server/app/router.ts | 10 ++- gm-server/app/service/Game.ts | 11 ++- gm-server/app/service/Mail.ts | 9 ++- shared/consts/constModules/mailConst.ts | 14 +++- shared/db/GMMail.ts | 80 +++++++++++++++++--- shared/db/Hero.ts | 2 +- shared/db/MailTemp.ts | 13 ++-- shared/db/Serverlist.ts | 11 ++- shared/db/index.ts | 2 + shared/domain/backEndField/search.ts | 14 ++++ shared/resource/jsons/dic_email_content.json | 52 ++++++++++--- 13 files changed, 236 insertions(+), 44 deletions(-) diff --git a/gm-server/app/controller/game.ts b/gm-server/app/controller/game.ts index e4626c312..f972bc393 100644 --- a/gm-server/app/controller/game.ts +++ b/gm-server/app/controller/game.ts @@ -24,6 +24,13 @@ export default class GameController extends Controller { return } + public async getServers() { + const { ctx } = this; + + ctx.body = await ctx.service.game.getServers(); + return + } + public async getMaintenanceList() { const { ctx } = this; const {page, pageSize, sortField, sortOrder, form} = ctx.request.body; diff --git a/gm-server/app/controller/mail.ts b/gm-server/app/controller/mail.ts index f69e47e49..5e694e930 100644 --- a/gm-server/app/controller/mail.ts +++ b/gm-server/app/controller/mail.ts @@ -1,7 +1,56 @@ import { Controller } from 'egg'; -import { STATUS } from '@consts'; +import { GM_MAIL_STATUS, GM_MAIL_TYPE, STATUS } from '@consts'; export default class MailController extends Controller { + + public async getCreateSingleMail() { + const { ctx } = this; + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SINGLE, status: GM_MAIL_STATUS.CREATE, hasGoods: true }); + return + } + public async getCreateSingleMailTxt() { + const { ctx } = this; + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SINGLE, status: GM_MAIL_STATUS.CREATE, hasGoods: false }); + return + } + public async getCreateServerMail() { + const { ctx } = this; + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SERVER, status: GM_MAIL_STATUS.CREATE, hasGoods: true }); + return + } + public async getCreateServerMailTxt() { + const { ctx } = this; + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SERVER, status: GM_MAIL_STATUS.CREATE, hasGoods: false }); + return + } + public async getViewSingleMail() { + const { ctx } = this; + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SINGLE, hasGoods: true }); + return + } + public async getViewSingleMailTxt() { + const { ctx } = this; + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SINGLE, hasGoods: false }); + return + } + public async getViewServerMail() { + const { ctx } = this; + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SERVER, hasGoods: true }); + return + } + public async getViewServerMailTxt() { + const { ctx } = this; + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SERVER, hasGoods: false }); + return + } public async getGMMailList() { const { ctx } = this; const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; @@ -11,7 +60,7 @@ export default class MailController extends Controller { public async updateGMMail() { const { ctx } = this; - const { _id, content, sendName, sendTime, endTime, useTempTime, continueHour, goods } = ctx.request.body; + const { _id, sendTime, endTime, useTempTime, continueHour, goods } = ctx.request.body; if(!_id) return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); if(useTempTime) { if(!sendTime || !endTime) return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); @@ -24,7 +73,7 @@ export default class MailController extends Controller { } catch(e) { return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); } - ctx.body = await ctx.service.mail.updateGMMail(_id, content, sendName, useTempTime, sendTime, endTime, continueHour, updateGoods); + ctx.body = await ctx.service.mail.updateGMMail(_id, updateGoods); return } diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index d0065236a..b51304201 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -53,6 +53,7 @@ export default (app: Application) => { router.post('/api/game/getserverlistbyenv', tokenParser, controller.game.getServerListByEnv); router.post('/api/game/getserverlist', controller.game.getServerList); router.post('/api/game/getregions', controller.game.getRegions); + router.post('/api/game/getservers', controller.game.getServers); router.post('/api/game/getmaintenancelist', controller.game.getMaintenanceList); router.post('/api/game/updatemaintenance', controller.game.updateMaintenance); @@ -94,7 +95,14 @@ export default (app: Application) => { router.post('/api/activity/updateactivitytaskpoint', controller.activity.updateActivityTaskPoint); router.post('/api/activity/delactivitytaskpoint', controller.activity.delActivityTaskPoint); - router.post('/api/mail/getgmmaillist', controller.mail.getGMMailList); + router.post('/api/mail/getcreatesinglemail', controller.mail.getCreateSingleMail); + router.post('/api/mail/getcreatesinglemailtxt', controller.mail.getCreateSingleMailTxt); + router.post('/api/mail/getcreateservermail', controller.mail.getCreateServerMail); + router.post('/api/mail/getcreateservermailtxt', controller.mail.getCreateServerMailTxt); + router.post('/api/mail/getviewsinglemail', controller.mail.getViewSingleMail); + router.post('/api/mail/getviewsinglemailtxt', controller.mail.getViewSingleMailTxt); + router.post('/api/mail/getviewservermail', controller.mail.getViewServerMail); + router.post('/api/mail/getviewservermailtxt', controller.mail.getViewServerMailTxt); router.post('/api/mail/updategmmail', controller.mail.updateGMMail); router.post('/api/mail/getgmmailrecords', controller.mail.getGMMailRecords); }; diff --git a/gm-server/app/service/Game.ts b/gm-server/app/service/Game.ts index 2e54b45b9..a3f15c683 100644 --- a/gm-server/app/service/Game.ts +++ b/gm-server/app/service/Game.ts @@ -55,6 +55,15 @@ export default class Game extends Service { }); } + public async getServers() { + const { ctx } = this; + + const list = await ServerlistModel.getAllServerList(); + return ctx.service.utils.resResult(STATUS.SUCCESS, { + list + }); + } + public async getMaintenanceList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { isOpen?: boolean } = {}) { const { ctx } = this; @@ -81,7 +90,7 @@ export default class Game extends Service { 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: false }, ctx.user?.uid); - let mailResult = await GMMailModel.addMail({ ...mail, useTempTime: true }, ctx.user?.uid); + let mailResult = await GMMailModel.addMail({ ...mail, }, ctx.user?.uid); await MaintenanceModel.createData(values, marqueeResult, noticeResult, mailResult); } else { let maintenanceResult = await MaintenanceModel.updateData(values.code, values, ctx.user?.uid); diff --git a/gm-server/app/service/Mail.ts b/gm-server/app/service/Mail.ts index ee28eb0ba..b86b20028 100644 --- a/gm-server/app/service/Mail.ts +++ b/gm-server/app/service/Mail.ts @@ -4,10 +4,11 @@ import { GMMailModel } from '@db/GMMail'; import { STATUS } from '@consts'; import { GMMailRecordModel } from '@db/GMMailRecord'; import { RewardInter } from '@pubUtils/interface'; +import { SearchMailParam } from '@domain/backEndField/search'; export default class Mail extends Service { - public async getGMMailList(page: number, pageSize: number, sortField: string, sortOrder: string, form: {}) { + public async getGMMailList(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchMailParam) { const { ctx } = this; const list = await GMMailModel.findByCondition(page, pageSize, sortField, sortOrder, form); const total = await GMMailModel.countByCondition( form ) @@ -16,12 +17,12 @@ export default class Mail extends Service { }); } - public async updateGMMail(_id: string, content: string, sendName: string, useTempTime: boolean, sendTime: number, endTime: number, continueHour: number, goods: RewardInter[]) { + public async updateGMMail(_id: string, goods: RewardInter[]) { const { ctx } = this; if(_id == 'new') { - await GMMailModel.addMail({ content, sendName, useTempTime, sendTime, endTime, continueHour, goods }); + await GMMailModel.addMail({ goods }); } else { - await GMMailModel.updateMailById(_id, { content, sendName, useTempTime, sendTime, endTime, continueHour, goods }); + await GMMailModel.updateMailById(_id, { goods }); } return ctx.service.utils.resResult(STATUS.SUCCESS); } diff --git a/shared/consts/constModules/mailConst.ts b/shared/consts/constModules/mailConst.ts index 2daba2dda..99960798e 100644 --- a/shared/consts/constModules/mailConst.ts +++ b/shared/consts/constModules/mailConst.ts @@ -5,9 +5,17 @@ export enum MAIL_STATUS { RECEIVED = 2, }; -export const MAIL_TEM_TYPE = { - GAMEMAIL: 1, - GMTYPE: 2, +export enum MAIL_TIME_TYPE { + IMMEDIATE = 1, // 即时邮件 + DELAY = 2, // 延时邮件 + CIRCLE = 3, // 循环邮件 +}; + + +export enum GM_MAIL_STATUS { + CREATE = 0, // 创建 + PASS = 1, // 审批通过 + NOT_PASS = -1, // 审批不通过 }; export enum GM_MAIL_TYPE { diff --git a/shared/db/GMMail.ts b/shared/db/GMMail.ts index d85215028..7db3895a9 100644 --- a/shared/db/GMMail.ts +++ b/shared/db/GMMail.ts @@ -2,8 +2,10 @@ * 邮件的模板,在GM后台能看到的邮件列表 */ import BaseModel from './BaseModel'; -import { getModelForClass, prop, DocumentType } from '@typegoose/typegoose'; +import { getModelForClass, prop, DocumentType, mongoose } from '@typegoose/typegoose'; import { nowSeconds } from '../pubUtils/timeUtil'; +import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE } from '../consts'; +import { SearchMailParam } from '@domain/backEndField/search'; class Reward { @prop({ required: true }) @@ -12,28 +14,72 @@ class Reward { count: number; } +class Receiver { + @prop({ required: true }) + env: string; + @prop({ required: true }) + serverId: number; + @prop({ required: true }) + roleId?: string; + @prop({ required: true }) + roleName?: string; +} + export default class GMMail extends BaseModel { + @prop({ required: false}) + hasGoods: boolean; // 有效时间,单位小时 + @prop({ required: true, type: Reward, default: [], _id: false }) goods: Reward[]; @prop({ required: true, default: true }) - useTempTime: boolean; // 生成邮件是否按照模板时间 + timeType: MAIL_TIME_TYPE; // 邮件时间类型 @prop({ required: false}) - continueHour: number; // 如果不按模板时间,sendTime为生成单独邮件的时候,endTime为sendTime+continueHour,单位小时 + expire: number; // 有效时间,单位小时 @prop({ required: true }) - sendTime: number; // 如果按照模板时间,发送时间,10位时间戳 + startTime: number; // 发送时间,延时邮件使用 @prop({ required: true }) - endTime: number; // 如果按照模板时间,过期时间,10位时间戳 + circleStart: number; // 循环邮件开始循环时间 + + @prop({ required: true }) + circleEnd: number; // 循环邮件结束循环时间 + + @prop({ required: true }) + circleDay: number; // 循环时间,每周几,0表示每天 + + @prop({ required: true }) + circleHour: number; // 几点发送 + + @prop({ required: true }) + title: string; @prop({ required: true }) content: string; @prop({ required: true }) sendName: string; + + @prop({ required: true }) + mailType: GM_MAIL_TYPE; // 收件人类型 + + @prop({ required: true }) + env: string; // 大区环境变量 + + @prop({ required: true, type: Receiver, _id: false }) + receivers: Receiver[]; + + @prop({ required: true }) + reason: string; // 原因 + + @prop({ required: true }) + isSp: boolean; // 特殊邮件 + + @prop({ required: true }) + status: GM_MAIL_STATUS; // 邮件状态 public static async addMail(params: GMMailTypeParam, uid = 1) { const doc = new GMMailModel(); @@ -63,14 +109,21 @@ export default class GMMail extends BaseModel { } - private static getSearchObj(form: {_id?: string, content?: string}) { + private static getSearchObj(form: SearchMailParam) { let searchObj = {}; - if(form['_id']) searchObj['_id'] = form._id; - if(form['content']) searchObj['context'] = { $regex: new RegExp(form.content.toString(), 'i') } + if(form.createTimeStart) searchObj['createdAt'] = { $gt: new Date(form.createTimeStart) }; + if(form.createTimeEnd) searchObj['createdAt'] = { $lt: new Date(form.createTimeEnd) }; + if(form.serverId) searchObj['receivers.serverId'] = form.serverId; + if(form.roleId) searchObj['receivers.roleId'] = form.roleId; + if(form.roleName) searchObj['receivers.roleName'] = { $regex: new RegExp(form.roleName.toString(), 'i') } + if(form.status) searchObj['status'] = form.status; + if(form.mailType) searchObj['mailType'] = form.mailType; + if(form.hasGoods != undefined) searchObj['hasGoods'] = form.hasGoods; + if(form.title) searchObj['title'] = { $regex: new RegExp(form.title.toString(), 'i') } return searchObj } - public static async findByCondition(page: number, pageSize: number, sortField: string, sortOrder: string, form: {_id?: string, content?: string} = {}) { + public static async findByCondition(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchMailParam = {}) { let searchObj = this.getSearchObj(form); let sort = {}; @@ -86,7 +139,7 @@ export default class GMMail extends BaseModel { } - public static async countByCondition(form: {_id?: string, content?: string} = {}) { + public static async countByCondition(form: SearchMailParam = {}) { let searchObj = this.getSearchObj(form); const result = await GMMailModel.count(searchObj); @@ -96,7 +149,12 @@ export default class GMMail extends BaseModel { } -export const GMMailModel = getModelForClass(GMMail); +export let GMMailModel = getModelForClass(GMMail); +export function loadGMMailModel(connect: mongoose.Connection) { + GMMailModel = getModelForClass(GMMail, { + existingConnection: connect + }); +} export interface GMMailType extends Pick, keyof GMMail> { }; diff --git a/shared/db/Hero.ts b/shared/db/Hero.ts index 689b532e4..8415657d2 100644 --- a/shared/db/Hero.ts +++ b/shared/db/Hero.ts @@ -5,7 +5,7 @@ import { CounterModel } from './Counter'; import { COUNTER, EQUIP_TYPE, HERO_CE_RATIO } from '../consts'; import { reduceCe } from '../pubUtils/util'; import Skin from './Skin'; -import { SearchHeroParam } from '@domain/backEndField/search'; +import { SearchHeroParam } from '../domain/backEndField/search'; type CeAttrUpdate = Partial; export class CeAttrData { diff --git a/shared/db/MailTemp.ts b/shared/db/MailTemp.ts index fa28fe40b..cf5c0ae40 100644 --- a/shared/db/MailTemp.ts +++ b/shared/db/MailTemp.ts @@ -1,6 +1,5 @@ import BaseModel from './BaseModel'; -import { prop, Ref, mongoose } from '@typegoose/typegoose'; -import GMMail from './GMMail'; +import { prop } from '@typegoose/typegoose'; class Reward { @prop({ required: true }) @@ -14,21 +13,21 @@ export default class MailTemp extends BaseModel { @prop({ required: true }) contentId: number; // dic_email_content.json中的id - @prop({ ref: 'GMMail', type: mongoose.Schema.Types.ObjectId }) - mail: Ref; - @prop({ required: true }) sendTime: number; @prop({ required: true }) endTime: number; - @prop({ required: true, type: String, _id: false}) - params: string[]; + @prop({ required: true }) + title: string; // 标题 @prop({ required: true }) sendName: string; // 发件人 + @prop({ required: true }) + content: string; // 内容 + @prop({ required: true }) hasGoods: boolean; diff --git a/shared/db/Serverlist.ts b/shared/db/Serverlist.ts index 8157357b8..de33f3e68 100644 --- a/shared/db/Serverlist.ts +++ b/shared/db/Serverlist.ts @@ -71,8 +71,15 @@ export default class Serverlist extends BaseModel { medianCe: number; // 中位数武将战力、缩小10000倍后的结果 public static async getAllServerList() { - let servers: ServerlistType[] = await ServerlistModel.find().lean({ getters: true, virtuals: true }); - return servers; + let id = await CounterModel.getCounter(COUNTER.SERVER); + let result: ServerlistType[] = []; + let n = Math.ceil(id/1000); + console.log('****', id, n) + for(let i = 0; i < n; i++) { + let servers: ServerlistType[] = await ServerlistModel.find().limit(1000).skip(i * 1000).lean({ getters: true, virtuals: true }); + result.push(...servers); + } + return result; } public static async findByServerId(serverId: number) { diff --git a/shared/db/index.ts b/shared/db/index.ts index e39f504b1..ffacc8a31 100644 --- a/shared/db/index.ts +++ b/shared/db/index.ts @@ -6,6 +6,7 @@ import { loadGMUserModel } from './GMUser' import { loadGMUserGroupModel } from "./GMUserGroup"; import { loadRegionModel } from "./Region"; import { loadServerlistModel } from "./Serverlist"; +import { loadGMMailModel } from './GMMail'; export function loadGmDb(connect: mongoose.Connection) { loadApiModel(connect); @@ -15,4 +16,5 @@ export function loadGmDb(connect: mongoose.Connection) { loadGMRecordModel(connect); loadRegionModel(connect); loadServerlistModel(connect); + loadGMMailModel(connect); } \ No newline at end of file diff --git a/shared/domain/backEndField/search.ts b/shared/domain/backEndField/search.ts index 4d90fab20..8eeff68cb 100644 --- a/shared/domain/backEndField/search.ts +++ b/shared/domain/backEndField/search.ts @@ -1,3 +1,5 @@ +import { GM_MAIL_STATUS, GM_MAIL_TYPE } from "@consts"; + export interface SearchUserParam { uid?: number; tel?: string; @@ -20,4 +22,16 @@ export interface SearchEquipParam { roleId?: string; roleName?: string; id?: number; +} + +export interface SearchMailParam { + createTimeStart?: number; + createTimeEnd?: number; + serverId?: number; + roleId?: string; + roleName?: string; + title?: string; + status?: GM_MAIL_STATUS; + mailType?: GM_MAIL_TYPE; + hasGoods?: boolean; } \ No newline at end of file diff --git a/shared/resource/jsons/dic_email_content.json b/shared/resource/jsons/dic_email_content.json index 0461436d7..d78712746 100644 --- a/shared/resource/jsons/dic_email_content.json +++ b/shared/resource/jsons/dic_email_content.json @@ -1,119 +1,149 @@ [ { "id": 0, - "title": "邮件标题", + "title": "&", "sendName": "&", "content": "%d", "time": 24 }, { "id": 1, + "title": "&", + "sendName": "&", "content": "您对军团%d的申请被拒绝", "time": 24 }, { "id": 2, + "title": "&", + "sendName": "&", "content": "由于被弹劾,您在军团%d的大将军职务已卸任", "time": 24 }, { "id": 3, + "title": "&", + "sendName": "&", "content": "您被任命为军团%d的大将军", "time": 24 }, { "id": 4, + "title": "&", + "sendName": "&", "content": "您被军团%d踢出", "time": 24 }, { "id": 5, + "title": "&", + "sendName": "&", "content": "亲爱的小将军,您昨日的军团活跃奖励忘记领取了,现已通过邮件发放,请查收", "time": 24 }, { "id": 6, + "title": "&", + "sendName": "&", "content": "您被任命为军团%d的管理", "time": 24 }, { "id": 7, + "title": "&", + "sendName": "&", "content": "您已卸任军团%d的管理", "time": 24 }, { "id": 8, + "title": "&", + "sendName": "&", "content": "小将军,您的军团已开启boss%d,请赶往支援", "time": 24 }, { "id": 9, + "title": "&", + "sendName": "&", "content": "恭喜小将军,军团上下一心,已成功压制boss%d,您在此次压制中获得如下奖励:", "time": 24 }, { "id": 10, + "title": "&", + "sendName": "&", "content": "小将军,您在上周军团练兵场中有奖励尚未领取,奖励如下:", "time": 24 }, { "id": 11, + "title": "&", + "sendName": "&", "content": "小将军,%d赠送您一个%d,请查收:", "time": 24 }, { "id": 12, + "title": "&", + "sendName": "&", "content": "亲爱的小将军,您在%d赛季结算奖励如下:", "time": 24 }, { "id": 13, + "title": "&", + "sendName": "&", "content": "恭喜小将军,您在%d赛季最终获得了第%d名,获得如下奖励:", "time": 24 }, { "id": 14, + "title": "&", + "sendName": "&", "content": "亲爱的小将军,您参与军团活动奖励已通过邮件发放,请查收:", "time": 24 }, { "id": 15, + "title": "&", + "sendName": "&", "content": "小将军很抱歉,您在拍卖行的出价已被超过,元宝退还给您,请查收:", "time": 24 }, { "id": 16, + "title": "&", + "sendName": "&", "content": "恭喜小将军,您已在拍卖行成功拍下以下物品,请查收:", "time": 24 }, { "id": 17, + "title": "&", + "sendName": "&", "content": "亲爱的小将军,您昨日的拍卖分红忘记领取了,现已通过邮件发放,请查收", "time": 24 }, { "id": 18, + "title": "&", + "sendName": "&", "content": "亲爱的小将军,您的背包中装备数量已满,请及时清理背包哦。溢出装备已通过邮件发放,请查收", "time": 24 }, { "id": 19, + "title": "&", + "sendName": "&", "content": "亲爱的小将军,派遣任务已开始下一天的任务,前一天未完成的派遣任务已通过邮件发放,请查收", "time": 24 }, { "id": 20, + "title": "&", + "sendName": "&", "content": "亲爱的小将军,以下是您未领取的【月卡】每日奖励,请查收", "time": 24 - }, - { - "id": 21, - "content": "修改账号名", - "time": 24 - }, - { - "id": 22, - "content": "修改公会名或公会公告", - "time": 24 } ] \ No newline at end of file From 53e55b288fd20f25f8f6451af1000e0622cd5f14 Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 1 Dec 2021 11:30:25 +0800 Subject: [PATCH 08/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E9=82=AE?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/gm/handler/gmHandler.ts | 33 ---------- .../app/servers/gm/handler/gmMailHandler.ts | 48 ++++++++++++++ game-server/app/servers/gm/remote/gmRemote.ts | 6 -- .../app/servers/role/handler/mailHandler.ts | 2 +- game-server/app/services/mailService.ts | 24 +++---- gm-server/app/controller/mail.ts | 30 +++++---- gm-server/app/router.ts | 1 + gm-server/app/service/Game.ts | 4 +- gm-server/app/service/Mail.ts | 33 ++++++++-- shared/db/Equip.ts | 2 +- shared/db/GMMail.ts | 11 ++-- shared/db/Role.ts | 6 +- shared/db/Serverlist.ts | 5 ++ shared/domain/backEndField/params.ts | 65 +++++++++++++++++++ shared/domain/backEndField/search.ts | 2 +- shared/domain/roleField/mail.ts | 3 +- 16 files changed, 192 insertions(+), 83 deletions(-) create mode 100644 game-server/app/servers/gm/handler/gmMailHandler.ts create mode 100644 shared/domain/backEndField/params.ts diff --git a/game-server/app/servers/gm/handler/gmHandler.ts b/game-server/app/servers/gm/handler/gmHandler.ts index dd6034fb3..cc68e3081 100644 --- a/game-server/app/servers/gm/handler/gmHandler.ts +++ b/game-server/app/servers/gm/handler/gmHandler.ts @@ -31,39 +31,6 @@ export class GmHandler { constructor(private app: Application) { } - //对接gm后台,下发邮件 - async addMail(msg: { endTime: number, sendName: string, content: string, goods: RewardInter[], sendTime: number }) { - let { endTime, content, sendName, sendTime, goods } = msg; - let mail = await GMMailModel.addMail({ endTime, content, sendName, sendTime, goods }); - return resResult(STATUS.SUCCESS, { mail }); - } - - async sendMail(msg: { id: string, mailType: number, roleIds?: string[], serverIds?: number[] }, session: BackendSession) { - const uid: number = session.get('uid') - let { id, mailType, roleIds, serverIds } = msg; - let f = new SendMailFun(); - await f.setWithGmMail(id); - if (mailType == GM_MAIL_TYPE.SINGLE || mailType == GM_MAIL_TYPE.GROUP) { - await f.sendToUsers(mailType, roleIds); - } else { - await f.sendToServer(serverIds); - } - await f.saveRecord(uid); - return resResult(STATUS.SUCCESS); - } - - async sendWithContent(msg: { contentId: number, mailType: number, params: { params?: string[], sendName?: string, goods?: RewardInter[], endTime?: number }, roleIds?: string[], serverIds?: number[] }, session: BackendSession) { - let { contentId, mailType, roleIds, serverIds, params } = msg; - let f = new SendMailFun(); - f.setWithContentId(contentId, params); - if (mailType == GM_MAIL_TYPE.SINGLE || mailType == GM_MAIL_TYPE.GROUP) { - await f.sendToUsers(mailType, roleIds); - } else { - await f.sendToServer(serverIds); - } - return resResult(STATUS.SUCCESS); - } - async reloadResource(msg: {}, session: BackendSession) { try { let activityServers = this.app.getServersByType('activity'); diff --git a/game-server/app/servers/gm/handler/gmMailHandler.ts b/game-server/app/servers/gm/handler/gmMailHandler.ts new file mode 100644 index 000000000..7bf866b98 --- /dev/null +++ b/game-server/app/servers/gm/handler/gmMailHandler.ts @@ -0,0 +1,48 @@ +import { Application, BackendSession, pinus } from 'pinus'; +import { RoleModel } from '../../../db/Role'; +import { EventRecordModel } from '../../../db/EventRecord'; +import { getEvent } from '../../../services/eventSercive'; +import { getRandSingleEelm, resResult } from '../../../pubUtils/util'; +import { STATUS } from '../../../consts/statusCode'; +import { GMMailModel } from '../../../db/GMMail'; +import { delGuildActivityRank, getRoleOnlineInfo } from '../../../services/redisService'; +import { SendMailFun } from '../../../services/mailService'; +import { GM_MAIL_TYPE } from '../../../consts'; +import { RewardInter } from '../../../pubUtils/interface'; +import { CreateMailParams } from '../../../domain/backEndField/params'; + +export default function (app: Application) { + return new GmMailHandler(app); +} + +export class GmMailHandler { + constructor(private app: Application) { + } + + //对接gm后台,下发邮件 + async sendMail(msg: { id: string, mailType: number, roleIds?: string[], serverIds?: number[] }, session: BackendSession) { + const uid: number = session.get('uid') + let { id, mailType, roleIds, serverIds } = msg; + let f = new SendMailFun(); + await f.setWithGmMail(id); + if (mailType == GM_MAIL_TYPE.SINGLE || mailType == GM_MAIL_TYPE.GROUP) { + await f.sendToUsers(mailType, roleIds); + } else { + await f.sendToServer(serverIds); + } + await f.saveRecord(uid); + return resResult(STATUS.SUCCESS); + } + + async sendWithContent(msg: { contentId: number, mailType: number, params: { params?: string[], sendName?: string, goods?: RewardInter[], endTime?: number }, roleIds?: string[], serverIds?: number[] }, session: BackendSession) { + let { contentId, mailType, roleIds, serverIds, params } = msg; + let f = new SendMailFun(); + f.setWithContentId(contentId, params); + if (mailType == GM_MAIL_TYPE.SINGLE || mailType == GM_MAIL_TYPE.GROUP) { + await f.sendToUsers(mailType, roleIds); + } else { + await f.sendToServer(serverIds); + } + return resResult(STATUS.SUCCESS); + } +} \ No newline at end of file diff --git a/game-server/app/servers/gm/remote/gmRemote.ts b/game-server/app/servers/gm/remote/gmRemote.ts index 37d7c9248..4d5e52268 100644 --- a/game-server/app/servers/gm/remote/gmRemote.ts +++ b/game-server/app/servers/gm/remote/gmRemote.ts @@ -2,12 +2,6 @@ import { Application, ChannelService, HandlerService, } from 'pinus'; import { resResult } from '../../../pubUtils/util'; import { STATUS } from '../../../consts'; import { setGmMails, getGmMailById, getGmMails, getGmUseMails } from '../../../pubUtils/gmData/gmDataUtil'; -import { MAIL_TYPE, MAIL_TEM_TYPE, MAIL_STATUS } from "../../../consts/constModules/mailConst"; -import { mailData } from "../../../pubUtils/interface"; -import { findWhere } from 'underscore'; -import { nowSeconds } from '../../../pubUtils/timeUtil'; -import { GroupMailType } from '../../../db/GroupMail'; -import { MailType } from '../../../db/Mail'; import { mongoose } from '@typegoose/typegoose'; const { ObjectId } = mongoose.Types; export default function (app: Application) { diff --git a/game-server/app/servers/role/handler/mailHandler.ts b/game-server/app/servers/role/handler/mailHandler.ts index e811fbb19..29a3d8d41 100644 --- a/game-server/app/servers/role/handler/mailHandler.ts +++ b/game-server/app/servers/role/handler/mailHandler.ts @@ -3,7 +3,7 @@ import { MailModel, MailType } from '../../../db/Mail'; import { GroupMailModel, GroupMailType } from '../../../db/GroupMail'; import { resResult } from '../../../pubUtils/util'; import { STATUS } from '../../../consts/statusCode'; -import { MAIL_STATUS, MAIL_TEM_TYPE, GM_MAIL_TYPE } from '../../../consts/constModules/mailConst'; +import { MAIL_STATUS, GM_MAIL_TYPE } from '../../../consts/constModules/mailConst'; import { addItems } from '../../../services/rewardService'; import { checkMailGoods, getMails } from '../../../services/mailService'; import { ServerMailModel, ServerMailType } from '../../../db/ServerMail'; diff --git a/game-server/app/services/mailService.ts b/game-server/app/services/mailService.ts index 31464ddcf..e4c12aee4 100644 --- a/game-server/app/services/mailService.ts +++ b/game-server/app/services/mailService.ts @@ -96,18 +96,18 @@ export class SendMailFun { // 从GMMail表读取数据 public async setWithGmMail(gmmailId: string) { - let gmmail = await GMMailModel.getGmMailById(gmmailId); - if(gmmail) { - this.gmmail = gmmail; - if(gmmail.useTempTime) { - this.sendTime = gmmail.sendTime; - this.endTime = gmmail.endTime; - } else { - this.sendTime = nowSeconds(); - this.endTime = this.sendTime + (gmmail.continueHour||0) * 60 * 60; - } - this.setParam({ ...gmmail }); - } + // let gmmail = await GMMailModel.getGmMailById(gmmailId); + // if(gmmail) { + // this.gmmail = gmmail; + // if(gmmail.useTempTime) { + // this.sendTime = gmmail.sendTime; + // this.endTime = gmmail.endTime; + // } else { + // this.sendTime = nowSeconds(); + // this.endTime = this.sendTime + (gmmail.continueHour||0) * 60 * 60; + // } + // this.setParam({ ...gmmail }); + // } } private setParam(params: { sendName?: string, endTime?: number, params?: string[], goods?: RewardInter[], content?: string }) { diff --git a/gm-server/app/controller/mail.ts b/gm-server/app/controller/mail.ts index 5e694e930..ca3d70611 100644 --- a/gm-server/app/controller/mail.ts +++ b/gm-server/app/controller/mail.ts @@ -1,5 +1,6 @@ import { Controller } from 'egg'; import { GM_MAIL_STATUS, GM_MAIL_TYPE, STATUS } from '@consts'; +import { UpdateMailParams } from '@domain/backEndField/params'; export default class MailController extends Controller { @@ -58,22 +59,25 @@ export default class MailController extends Controller { return } + public async findRoleByIdOrName() { + const { ctx } = this; + const { serverId, roleId, roleName }: { serverId: number, roleId?: string, roleName?: string } = ctx.request.body; + if(!serverId || (!roleId && !roleName)) return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); + ctx.body = await ctx.service.mail.findRoleByIdOrName(serverId, roleId, roleName); + + return + } + public async updateGMMail() { const { ctx } = this; - const { _id, sendTime, endTime, useTempTime, continueHour, goods } = ctx.request.body; - if(!_id) return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); - if(useTempTime) { - if(!sendTime || !endTime) return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); - } else { - if(!continueHour) return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); + const msg = ctx.request.body; + if(msg._id == 'new') { + let params = new UpdateMailParams(msg); + let check = params.checkParams(); + if(!check) return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); + ctx.body = await ctx.service.mail.createGmMail(params); } - let updateGoods = []; - try{ - updateGoods = JSON.parse(goods); - } catch(e) { - return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); - } - ctx.body = await ctx.service.mail.updateGMMail(_id, updateGoods); + return } diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index b51304201..fffa2fbd9 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -103,6 +103,7 @@ export default (app: Application) => { router.post('/api/mail/getviewsinglemailtxt', controller.mail.getViewSingleMailTxt); router.post('/api/mail/getviewservermail', controller.mail.getViewServerMail); router.post('/api/mail/getviewservermailtxt', controller.mail.getViewServerMailTxt); + router.post('/api/mail/findrolebyidorname', controller.mail.findRoleByIdOrName); router.post('/api/mail/updategmmail', controller.mail.updateGMMail); router.post('/api/mail/getgmmailrecords', controller.mail.getGMMailRecords); }; diff --git a/gm-server/app/service/Game.ts b/gm-server/app/service/Game.ts index a3f15c683..2e8dd8de0 100644 --- a/gm-server/app/service/Game.ts +++ b/gm-server/app/service/Game.ts @@ -90,8 +90,8 @@ export default class Game extends Service { 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: false }, ctx.user?.uid); - let mailResult = await GMMailModel.addMail({ ...mail, }, ctx.user?.uid); - await MaintenanceModel.createData(values, marqueeResult, noticeResult, mailResult); + // let mailResult = await GMMailModel.addMail(mail, ctx.user?.uid); + await MaintenanceModel.createData(values, marqueeResult, noticeResult, null); } else { let maintenanceResult = await MaintenanceModel.updateData(values.code, values, ctx.user?.uid); if(!maintenanceResult) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); diff --git a/gm-server/app/service/Mail.ts b/gm-server/app/service/Mail.ts index b86b20028..6e4dd5614 100644 --- a/gm-server/app/service/Mail.ts +++ b/gm-server/app/service/Mail.ts @@ -1,10 +1,11 @@ import { Service } from 'egg'; -import { GMMailModel } from '@db/GMMail'; +import { GMMailModel, } from '@db/GMMail'; import { STATUS } from '@consts'; import { GMMailRecordModel } from '@db/GMMailRecord'; -import { RewardInter } from '@pubUtils/interface'; import { SearchMailParam } from '@domain/backEndField/search'; +import { UpdateMailParams } from '@domain/backEndField/params'; +import { RoleModel, RoleType } from '@db/Role'; export default class Mail extends Service { @@ -17,12 +18,32 @@ export default class Mail extends Service { }); } - public async updateGMMail(_id: string, goods: RewardInter[]) { + public async findRoleByIdOrName(serverId: number, roleId: string, roleName: string) { + let role: RoleType; + if(roleId) { + role = await RoleModel.findByRoleId(roleId); + } + if(roleName) { + role = await RoleModel.findByRoleName(roleName); + } + if(!role || role.serverId != serverId) return this.ctx.service.utils.resResult(STATUS.WRONG_PARMS); + return this.ctx.service.utils.resResult(STATUS.SUCCESS, { env: this.ctx.app.config.realEnv, serverId, roleId: role.roleId, roleName: role.roleName }) + + } + + public async createGmMail(params: UpdateMailParams) { const { ctx } = this; - if(_id == 'new') { - await GMMailModel.addMail({ goods }); + await GMMailModel.addMail(params); + + return ctx.service.utils.resResult(STATUS.SUCCESS); + } + + public async updateGMMail(isCreate: boolean, params: UpdateMailParams) { + const { ctx } = this; + if(isCreate) { + await GMMailModel.addMail(params); } else { - await GMMailModel.updateMailById(_id, { goods }); + // await GMMailModel.updateMailById(params._id, params); } return ctx.service.utils.resResult(STATUS.SUCCESS); } diff --git a/shared/db/Equip.ts b/shared/db/Equip.ts index ecb51babd..9d84648ad 100644 --- a/shared/db/Equip.ts +++ b/shared/db/Equip.ts @@ -4,7 +4,7 @@ import { COUNTER } from '../consts'; import { CounterModel } from './Counter'; import { HeroModel } from './Hero'; import { RoleModel } from './Role'; -import { SearchEquipParam } from '@domain/backEndField/search'; +import { SearchEquipParam } from '../domain/backEndField/search'; export class RandSe { @prop({ required: true }) diff --git a/shared/db/GMMail.ts b/shared/db/GMMail.ts index 7db3895a9..efd334cc5 100644 --- a/shared/db/GMMail.ts +++ b/shared/db/GMMail.ts @@ -5,7 +5,8 @@ import BaseModel from './BaseModel'; import { getModelForClass, prop, DocumentType, mongoose } from '@typegoose/typegoose'; import { nowSeconds } from '../pubUtils/timeUtil'; import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE } from '../consts'; -import { SearchMailParam } from '@domain/backEndField/search'; +import { SearchMailParam } from '../domain/backEndField/search'; +import { UpdateMailParams } from '../domain/backEndField/params'; class Reward { @prop({ required: true }) @@ -14,7 +15,7 @@ class Reward { count: number; } -class Receiver { +export class Receiver { @prop({ required: true }) env: string; @prop({ required: true }) @@ -66,9 +67,6 @@ export default class GMMail extends BaseModel { @prop({ required: true }) mailType: GM_MAIL_TYPE; // 收件人类型 - @prop({ required: true }) - env: string; // 大区环境变量 - @prop({ required: true, type: Receiver, _id: false }) receivers: Receiver[]; @@ -81,7 +79,8 @@ export default class GMMail extends BaseModel { @prop({ required: true }) status: GM_MAIL_STATUS; // 邮件状态 - public static async addMail(params: GMMailTypeParam, uid = 1) { + + public static async addMail(params: UpdateMailParams, uid = 1) { const doc = new GMMailModel(); let mail = Object.assign(doc.toJSON(), params); let result: GMMailType = await GMMailModel.findOneAndUpdate({ _id: mail._id }, { $set: {...mail, updatedBy: uid}, $setOnInsert: { createdBy: uid } }, {upsert: true, new: true}).lean(); diff --git a/shared/db/Role.ts b/shared/db/Role.ts index 24b2e3515..4c428b7ec 100644 --- a/shared/db/Role.ts +++ b/shared/db/Role.ts @@ -362,12 +362,16 @@ export default class Role extends BaseModel { const role: RoleType = await RoleModel.findOne({ roleId }).select(select).lean({ getters, virtuals }); return role; } - public static async findByRoleIds(roleIds: string[], select?: string, getters = false, virtuals = true) { const role: RoleType[] = await RoleModel.find({ roleId: { $in: roleIds } }).select(select).lean({ getters, virtuals }); return role; } + public static async findByRoleName(roleName: string, select?: string, getters = false, virtuals = true) { + const role: RoleType = await RoleModel.findOne({ roleName }).select(select).lean({ getters, virtuals }); + return role; + } + public static async createRole(uid: number, serverId: number, roleInfo: { roleId: string; roleName: string; seqId: number; code: string, lv?: number, exp?: number }, lean = true) { const user = await User.findUserByUid(uid); if (!user) return null; diff --git a/shared/db/Serverlist.ts b/shared/db/Serverlist.ts index de33f3e68..f0ec201df 100644 --- a/shared/db/Serverlist.ts +++ b/shared/db/Serverlist.ts @@ -87,6 +87,11 @@ export default class Serverlist extends BaseModel { return server; } + public static async findByServerIds(serverIds: number[]) { + let servers: ServerlistType[] = await ServerlistModel.find({ id: { $in: serverIds } }).select('medianCe activityGroupId').lean({ getters: true, virtuals: true }); + return servers; + } + public static async updateByServerId(serverId: number, update: ServerlistUpdate) { let server: ServerlistType = await ServerlistModel.findOneAndUpdate({ id: serverId }, { $set: update }).lean({ getters: true, virtuals: true }); return server; diff --git a/shared/domain/backEndField/params.ts b/shared/domain/backEndField/params.ts new file mode 100644 index 000000000..e0ab86ad1 --- /dev/null +++ b/shared/domain/backEndField/params.ts @@ -0,0 +1,65 @@ +import { GM_MAIL_TYPE, MAIL_TIME_TYPE } from "../../consts"; +import { isArray } from 'underscore'; + +export class UpdateMailParams { + hasGoods: boolean = false; // 是否有道具 + goods: {id: number; count: number}[]; + timeType: MAIL_TIME_TYPE; // 邮件时间类型 + expire: number; // 有效时间,单位小时 + startTime: number; // 发送时间,延时邮件使用 + circleStart: number; // 循环邮件开始循环时间 + circleEnd: number; // 循环邮件结束循环时间 + circleDay: number; // 循环时间,每周几,0表示每天 + circleHour: string; // 几点发送 + title: string; + content: string; + sendName: string; + mailType: GM_MAIL_TYPE; // 收件人类型 + receivers: {env: string; serverId: number; roleId: string; roleName: string; }[]; + reason: string; // 原因 + isSp: boolean = false; // 特殊邮件 + isSingle: boolean; + + constructor(obj: UpdateMailParams) { + this.goods = obj.goods; + this.hasGoods = obj.goods?.length > 0; + this.timeType = obj.timeType; + this.expire = obj.expire; + this.startTime = obj.startTime; + this.circleStart = obj.circleStart; + this.circleEnd = obj.circleEnd; + this.circleDay = obj.circleDay; + this.circleHour = obj.circleHour; + this.title = obj.title; + this.content = obj.content; + this.sendName = obj.sendName; + if(obj.isSingle == true) { + this.mailType = GM_MAIL_TYPE.SINGLE; + } else if (obj.isSingle == false) { + this.mailType = GM_MAIL_TYPE.SERVER; + } + this.receivers = obj.receivers; + this.reason = obj.reason; + } + + checkParams() { + if(!this.title || !this.content || !this.sendName || !this.reason) return false; + if(this.timeType == MAIL_TIME_TYPE.IMMEDIATE) { + if(!this.expire) return false; + } else if (this.timeType == MAIL_TIME_TYPE.DELAY) { + if(!this.expire || !this.startTime) return false; + } else if (this.timeType == MAIL_TIME_TYPE.CIRCLE) { + if(!this.expire || !this.circleStart || !this.circleEnd || this.circleDay == undefined || !this.circleHour) + return false; + } + if(!this.receivers || !isArray(this.receivers)) return false; + if(!this.mailType) return false; + for(let { serverId, roleId, roleName } of this.receivers) { + if(!serverId) return false; + if(this.mailType == GM_MAIL_TYPE.SINGLE||this.mailType == GM_MAIL_TYPE.GROUP) { + if(!roleId || !roleName) return false; + } + } + return true; + } +} \ No newline at end of file diff --git a/shared/domain/backEndField/search.ts b/shared/domain/backEndField/search.ts index 8eeff68cb..2cc308724 100644 --- a/shared/domain/backEndField/search.ts +++ b/shared/domain/backEndField/search.ts @@ -1,4 +1,4 @@ -import { GM_MAIL_STATUS, GM_MAIL_TYPE } from "@consts"; +import { GM_MAIL_STATUS, GM_MAIL_TYPE } from "../../consts"; export interface SearchUserParam { uid?: number; diff --git a/shared/domain/roleField/mail.ts b/shared/domain/roleField/mail.ts index 971494123..7975e9360 100644 --- a/shared/domain/roleField/mail.ts +++ b/shared/domain/roleField/mail.ts @@ -76,7 +76,8 @@ export class MailParam { } setContent(mail: MailType|GroupMailType|ServerMailType) { - let { contentId = 0, params, goods, sendName } = mail; + let { contentId = 0, goods, sendName } = mail; + let params = [] let dicMail = gameData.mail.get(contentId); if(!dicMail) dicMail = gameData.mail.get(0); From fe372de419e9acf3fb71c3c47086ec3c66ab0c69 Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 1 Dec 2021 14:45:06 +0800 Subject: [PATCH 09/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E9=82=AE?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/gm/handler/gmMailHandler.ts | 1 - gm-server/app/controller/mail.ts | 44 +++++-------------- gm-server/app/router.ts | 21 +++++---- gm-server/app/service/Mail.ts | 10 ++--- shared/db/Api.ts | 2 +- shared/db/GMGroup.ts | 2 +- shared/db/GMMail.ts | 18 ++++---- shared/db/GMRecord.ts | 2 +- shared/db/GMUser.ts | 2 +- shared/db/GMUserGroup.ts | 2 +- 10 files changed, 41 insertions(+), 63 deletions(-) diff --git a/game-server/app/servers/gm/handler/gmMailHandler.ts b/game-server/app/servers/gm/handler/gmMailHandler.ts index 7bf866b98..994629cea 100644 --- a/game-server/app/servers/gm/handler/gmMailHandler.ts +++ b/game-server/app/servers/gm/handler/gmMailHandler.ts @@ -9,7 +9,6 @@ import { delGuildActivityRank, getRoleOnlineInfo } from '../../../services/redis import { SendMailFun } from '../../../services/mailService'; import { GM_MAIL_TYPE } from '../../../consts'; import { RewardInter } from '../../../pubUtils/interface'; -import { CreateMailParams } from '../../../domain/backEndField/params'; export default function (app: Application) { return new GmMailHandler(app); diff --git a/gm-server/app/controller/mail.ts b/gm-server/app/controller/mail.ts index ca3d70611..7a1533fd3 100644 --- a/gm-server/app/controller/mail.ts +++ b/gm-server/app/controller/mail.ts @@ -1,52 +1,28 @@ import { Controller } from 'egg'; -import { GM_MAIL_STATUS, GM_MAIL_TYPE, STATUS } from '@consts'; +import { GM_MAIL_TYPE, STATUS } from '@consts'; import { UpdateMailParams } from '@domain/backEndField/params'; export default class MailController extends Controller { - public async getCreateSingleMail() { - const { ctx } = this; - const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; - ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SINGLE, status: GM_MAIL_STATUS.CREATE, hasGoods: true }); - return - } - public async getCreateSingleMailTxt() { - const { ctx } = this; - const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; - ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SINGLE, status: GM_MAIL_STATUS.CREATE, hasGoods: false }); - return - } - public async getCreateServerMail() { - const { ctx } = this; - const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; - ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SERVER, status: GM_MAIL_STATUS.CREATE, hasGoods: true }); - return - } - public async getCreateServerMailTxt() { - const { ctx } = this; - const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; - ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SERVER, status: GM_MAIL_STATUS.CREATE, hasGoods: false }); - return - } - public async getViewSingleMail() { + public async getSingleMail() { const { ctx } = this; const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SINGLE, hasGoods: true }); return } - public async getViewSingleMailTxt() { + public async getSingleMailTxt() { const { ctx } = this; const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SINGLE, hasGoods: false }); return } - public async getViewServerMail() { + public async getServerMail() { const { ctx } = this; const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SERVER, hasGoods: true }); return } - public async getViewServerMailTxt() { + public async getServerMailTxt() { const { ctx } = this; const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; ctx.body = await ctx.service.mail.getGMMailList(page, pageSize, sortField, sortOrder, {...form, mailType: GM_MAIL_TYPE.SERVER, hasGoods: false }); @@ -71,11 +47,15 @@ export default class MailController extends Controller { public async updateGMMail() { const { ctx } = this; const msg = ctx.request.body; + let params = new UpdateMailParams(msg); + let check = params.checkParams(); + if(!check) return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); if(msg._id == 'new') { - let params = new UpdateMailParams(msg); - let check = params.checkParams(); - if(!check) return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); ctx.body = await ctx.service.mail.createGmMail(params); + } else if(msg._id) { + ctx.body = await ctx.service.mail.updateGMMail(msg._id, params); + } else { + return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); } return diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index fffa2fbd9..64a7e1586 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -95,15 +95,18 @@ export default (app: Application) => { router.post('/api/activity/updateactivitytaskpoint', controller.activity.updateActivityTaskPoint); router.post('/api/activity/delactivitytaskpoint', controller.activity.delActivityTaskPoint); - router.post('/api/mail/getcreatesinglemail', controller.mail.getCreateSingleMail); - router.post('/api/mail/getcreatesinglemailtxt', controller.mail.getCreateSingleMailTxt); - router.post('/api/mail/getcreateservermail', controller.mail.getCreateServerMail); - router.post('/api/mail/getcreateservermailtxt', controller.mail.getCreateServerMailTxt); - router.post('/api/mail/getviewsinglemail', controller.mail.getViewSingleMail); - router.post('/api/mail/getviewsinglemailtxt', controller.mail.getViewSingleMailTxt); - router.post('/api/mail/getviewservermail', controller.mail.getViewServerMail); - router.post('/api/mail/getviewservermailtxt', controller.mail.getViewServerMailTxt); + router.post('/api/mail/getcreatesinglemail', controller.mail.getSingleMail); + router.post('/api/mail/getcreatesinglemailtxt', controller.mail.getSingleMailTxt); + router.post('/api/mail/getcreateservermail', controller.mail.getServerMail); + router.post('/api/mail/getcreateservermailtxt', controller.mail.getServerMailTxt); + router.post('/api/mail/getviewsinglemail', controller.mail.getSingleMail); + router.post('/api/mail/getviewsinglemailtxt', controller.mail.getSingleMailTxt); + router.post('/api/mail/getviewservermail', controller.mail.getServerMail); + router.post('/api/mail/getviewservermailtxt', controller.mail.getServerMailTxt); router.post('/api/mail/findrolebyidorname', controller.mail.findRoleByIdOrName); - router.post('/api/mail/updategmmail', controller.mail.updateGMMail); + router.post('/api/mail/updatesinglemail', controller.mail.updateGMMail); + router.post('/api/mail/updatesinglemailtxt', controller.mail.updateGMMail); + router.post('/api/mail/updateservermail', controller.mail.updateGMMail); + router.post('/api/mail/updateservermailtxt', controller.mail.updateGMMail); router.post('/api/mail/getgmmailrecords', controller.mail.getGMMailRecords); }; diff --git a/gm-server/app/service/Mail.ts b/gm-server/app/service/Mail.ts index 6e4dd5614..baa216eaf 100644 --- a/gm-server/app/service/Mail.ts +++ b/gm-server/app/service/Mail.ts @@ -33,18 +33,14 @@ export default class Mail extends Service { public async createGmMail(params: UpdateMailParams) { const { ctx } = this; - await GMMailModel.addMail(params); + await GMMailModel.addMail(params, ctx.user?.uid); return ctx.service.utils.resResult(STATUS.SUCCESS); } - public async updateGMMail(isCreate: boolean, params: UpdateMailParams) { + public async updateGMMail(_id: string, params: UpdateMailParams) { const { ctx } = this; - if(isCreate) { - await GMMailModel.addMail(params); - } else { - // await GMMailModel.updateMailById(params._id, params); - } + await GMMailModel.updateMailById(_id, params, ctx.user?.uid); return ctx.service.utils.resResult(STATUS.SUCCESS); } diff --git a/shared/db/Api.ts b/shared/db/Api.ts index 4e1918507..ea2e6b35a 100644 --- a/shared/db/Api.ts +++ b/shared/db/Api.ts @@ -38,7 +38,7 @@ export default class Api extends BaseModel { } -export let ApiModel: ReturnModelType = getModelForClass(Api); +export let ApiModel: ReturnModelType; export function loadApiModel(connect: mongoose.Connection) { ApiModel = getModelForClass(Api, { existingConnection: connect diff --git a/shared/db/GMGroup.ts b/shared/db/GMGroup.ts index 623175914..5fd24c9db 100644 --- a/shared/db/GMGroup.ts +++ b/shared/db/GMGroup.ts @@ -74,7 +74,7 @@ export default class GMGroup extends BaseModel { } -export let GMGroupModel: ReturnModelType = getModelForClass(GMGroup); +export let GMGroupModel: ReturnModelType; export function loadGMGroupModel(connect: mongoose.Connection) { GMGroupModel = getModelForClass(GMGroup, { existingConnection: connect diff --git a/shared/db/GMMail.ts b/shared/db/GMMail.ts index efd334cc5..8d04866c3 100644 --- a/shared/db/GMMail.ts +++ b/shared/db/GMMail.ts @@ -2,11 +2,10 @@ * 邮件的模板,在GM后台能看到的邮件列表 */ import BaseModel from './BaseModel'; -import { getModelForClass, prop, DocumentType, mongoose } from '@typegoose/typegoose'; +import { getModelForClass, prop, DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose'; import { nowSeconds } from '../pubUtils/timeUtil'; import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE } from '../consts'; import { SearchMailParam } from '../domain/backEndField/search'; -import { UpdateMailParams } from '../domain/backEndField/params'; class Reward { @prop({ required: true }) @@ -53,7 +52,7 @@ export default class GMMail extends BaseModel { circleDay: number; // 循环时间,每周几,0表示每天 @prop({ required: true }) - circleHour: number; // 几点发送 + circleHour: string; // 几点发送 @prop({ required: true }) title: string; @@ -73,14 +72,14 @@ export default class GMMail extends BaseModel { @prop({ required: true }) reason: string; // 原因 - @prop({ required: true }) + @prop({ required: true, default: false }) isSp: boolean; // 特殊邮件 - @prop({ required: true }) + @prop({ required: true, default: 0 }) status: GM_MAIL_STATUS; // 邮件状态 - public static async addMail(params: UpdateMailParams, uid = 1) { + public static async addMail(params: GMMailTypeParam, uid = 1) { const doc = new GMMailModel(); let mail = Object.assign(doc.toJSON(), params); let result: GMMailType = await GMMailModel.findOneAndUpdate({ _id: mail._id }, { $set: {...mail, updatedBy: uid}, $setOnInsert: { createdBy: uid } }, {upsert: true, new: true}).lean(); @@ -110,8 +109,9 @@ export default class GMMail extends BaseModel { private static getSearchObj(form: SearchMailParam) { let searchObj = {}; - if(form.createTimeStart) searchObj['createdAt'] = { $gt: new Date(form.createTimeStart) }; - if(form.createTimeEnd) searchObj['createdAt'] = { $lt: new Date(form.createTimeEnd) }; + console.log('******', form) + if(form.createTimeStart) searchObj['createdAt'] = { $gt: new Date(form.createTimeStart * 1000) }; + if(form.createTimeEnd) searchObj['createdAt'] = { $lt: new Date(form.createTimeEnd * 1000) }; if(form.serverId) searchObj['receivers.serverId'] = form.serverId; if(form.roleId) searchObj['receivers.roleId'] = form.roleId; if(form.roleName) searchObj['receivers.roleName'] = { $regex: new RegExp(form.roleName.toString(), 'i') } @@ -148,7 +148,7 @@ export default class GMMail extends BaseModel { } -export let GMMailModel = getModelForClass(GMMail); +export let GMMailModel: ReturnModelType; export function loadGMMailModel(connect: mongoose.Connection) { GMMailModel = getModelForClass(GMMail, { existingConnection: connect diff --git a/shared/db/GMRecord.ts b/shared/db/GMRecord.ts index ae940f36a..39e0cd9d6 100644 --- a/shared/db/GMRecord.ts +++ b/shared/db/GMRecord.ts @@ -28,7 +28,7 @@ export default class GMRecord extends BaseModel { } -export let GMRecordModel: ReturnModelType = getModelForClass(GMRecord); +export let GMRecordModel: ReturnModelType; export function loadGMRecordModel(connect: mongoose.Connection) { GMRecordModel = getModelForClass(GMRecord, { existingConnection: connect diff --git a/shared/db/GMUser.ts b/shared/db/GMUser.ts index 91d2a42da..d521f130a 100644 --- a/shared/db/GMUser.ts +++ b/shared/db/GMUser.ts @@ -85,7 +85,7 @@ export default class GMUser extends BaseModel { } } -export let GMUserModel: ReturnModelType = getModelForClass(GMUser); +export let GMUserModel: ReturnModelType; export function loadGMUserModel(connect: mongoose.Connection) { GMUserModel = getModelForClass(GMUser, { existingConnection: connect diff --git a/shared/db/GMUserGroup.ts b/shared/db/GMUserGroup.ts index e7e0f2be1..a84a74999 100644 --- a/shared/db/GMUserGroup.ts +++ b/shared/db/GMUserGroup.ts @@ -32,7 +32,7 @@ export default class GMUserGroup extends BaseModel { } } -export let GMUserGroupModel: ReturnModelType = getModelForClass(GMUserGroup); +export let GMUserGroupModel: ReturnModelType; export function loadGMUserGroupModel(connect: mongoose.Connection) { GMUserGroupModel = getModelForClass(GMUserGroup, { existingConnection: connect From eafc0600934397ab8e35ae54713e99331166fc9f Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 1 Dec 2021 17:42:36 +0800 Subject: [PATCH 10/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E5=AE=A1=E6=A0=B8=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../servers/connector/handler/entryHandler.ts | 1 + .../app/servers/gm/handler/gmHandler.ts | 41 ++++++++++- .../app/servers/gm/handler/gmMailHandler.ts | 47 ------------ game-server/app/servers/gm/remote/gmRemote.ts | 69 ------------------ game-server/app/services/gmService.ts | 2 +- game-server/app/services/mailService.ts | 68 ++++++++++-------- shared/consts/constModules/mailConst.ts | 3 +- shared/consts/statusCode.ts | 2 + shared/db/GMMail.ts | 23 +++--- shared/db/MailTemp.ts | 3 + shared/domain/roleField/mail.ts | 15 +--- shared/pubUtils/dictionary/DicMail.ts | 4 ++ shared/pubUtils/gmData/gmDataUtil.ts | 71 ------------------- shared/pubUtils/gmData/gmMail.ts | 61 ---------------- 14 files changed, 103 insertions(+), 307 deletions(-) delete mode 100644 game-server/app/servers/gm/handler/gmMailHandler.ts delete mode 100644 shared/pubUtils/gmData/gmDataUtil.ts delete mode 100644 shared/pubUtils/gmData/gmMail.ts diff --git a/game-server/app/servers/connector/handler/entryHandler.ts b/game-server/app/servers/connector/handler/entryHandler.ts index cbfc1e63f..b6617a3a0 100644 --- a/game-server/app/servers/connector/handler/entryHandler.ts +++ b/game-server/app/servers/connector/handler/entryHandler.ts @@ -240,6 +240,7 @@ export class EntryHandler { session.set('roleName', user.name); session.set('eventStatus', 0); session.set('sid', self.app.get('serverId')); + session.push('uid', () => { }); session.push('sid', () => { }); session.push('roleId', () => { }); session.push('roleName', () => { }); diff --git a/game-server/app/servers/gm/handler/gmHandler.ts b/game-server/app/servers/gm/handler/gmHandler.ts index cc68e3081..b5655dc3c 100644 --- a/game-server/app/servers/gm/handler/gmHandler.ts +++ b/game-server/app/servers/gm/handler/gmHandler.ts @@ -7,7 +7,7 @@ import { STATUS } from '../../../consts/statusCode'; import { GMMailModel } from '../../../db/GMMail'; import { delGuildActivityRank, getRoleOnlineInfo } from '../../../services/redisService'; import { SendMailFun } from '../../../services/mailService'; -import { GM_MAIL_TYPE } from '../../../consts'; +import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE } from '../../../consts'; import { RewardInter } from '../../../pubUtils/interface'; import { MarqueeModel } from '../../../db/Marquee'; import { ServerlistModel } from '../../../db/Serverlist'; @@ -22,6 +22,7 @@ import { GuildActivityCityModel } from '../../../db/GuildActivityCity'; import { GuildActivityRecordModel } from '../../../db/GuildActivityRec'; import { getTimeFunM } from '../../../pubUtils/timeUtil'; import { sendUngotDividend } from '../../../services/auctionService'; +import moment = require('moment'); let timer: NodeJS.Timer; export default function (app: Application) { return new GmHandler(app); @@ -31,6 +32,44 @@ export class GmHandler { constructor(private app: Application) { } + + //对接gm后台,下发邮件 + async sendMail(msg: { id: string, isPass: boolean }, session: BackendSession) { + const uid: number = session.get('uid') + let { id, isPass } = msg; + let gmmail = await GMMailModel.getGmMailById(id); + if(!gmmail) return resResult(STATUS.GM_MAIL_NOT_FOUND); + let { receivers, mailType, status, timeType, startTime, circleHour, circleDay } = gmmail; + if(status != GM_MAIL_STATUS.CREATE) { + return resResult(STATUS.GM_MAIL_HAS_SENT); + } + if(isPass) { + let f = new SendMailFun(); + await f.setWithGmMail(gmmail); + + if (mailType == GM_MAIL_TYPE.SINGLE || mailType == GM_MAIL_TYPE.GROUP) { + let roleIds = receivers.map(cur => cur.roleId); + await f.sendToUsers(mailType, roleIds); + } else { + let serverIds = receivers.map(cur => cur.serverId); + await f.sendToServer(serverIds); + } + // await f.saveRecord(uid); + } + let sendTime = ''; + if(isPass) { + if(timeType == MAIL_TIME_TYPE.IMMEDIATE) { + sendTime = moment().format('YYYY-MM-DD HH:mm:ss'); + } else if (timeType == MAIL_TIME_TYPE.DELAY) { + sendTime = moment(startTime * 1000).format('YYYY-MM-DD HH:mm:ss'); + } else if (timeType == MAIL_TIME_TYPE.CIRCLE) { + sendTime = (circleDay == 0?'每天': '每周'+circleDay) + ' ' + circleHour; + } + } + await GMMailModel.updateMailById(id, { status: isPass?GM_MAIL_STATUS.PASS: GM_MAIL_STATUS.NOT_PASS, viewAt: new Date(), viewBy: uid, sendTime }, uid); + return resResult(STATUS.SUCCESS); + } + async reloadResource(msg: {}, session: BackendSession) { try { let activityServers = this.app.getServersByType('activity'); diff --git a/game-server/app/servers/gm/handler/gmMailHandler.ts b/game-server/app/servers/gm/handler/gmMailHandler.ts deleted file mode 100644 index 994629cea..000000000 --- a/game-server/app/servers/gm/handler/gmMailHandler.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { Application, BackendSession, pinus } from 'pinus'; -import { RoleModel } from '../../../db/Role'; -import { EventRecordModel } from '../../../db/EventRecord'; -import { getEvent } from '../../../services/eventSercive'; -import { getRandSingleEelm, resResult } from '../../../pubUtils/util'; -import { STATUS } from '../../../consts/statusCode'; -import { GMMailModel } from '../../../db/GMMail'; -import { delGuildActivityRank, getRoleOnlineInfo } from '../../../services/redisService'; -import { SendMailFun } from '../../../services/mailService'; -import { GM_MAIL_TYPE } from '../../../consts'; -import { RewardInter } from '../../../pubUtils/interface'; - -export default function (app: Application) { - return new GmMailHandler(app); -} - -export class GmMailHandler { - constructor(private app: Application) { - } - - //对接gm后台,下发邮件 - async sendMail(msg: { id: string, mailType: number, roleIds?: string[], serverIds?: number[] }, session: BackendSession) { - const uid: number = session.get('uid') - let { id, mailType, roleIds, serverIds } = msg; - let f = new SendMailFun(); - await f.setWithGmMail(id); - if (mailType == GM_MAIL_TYPE.SINGLE || mailType == GM_MAIL_TYPE.GROUP) { - await f.sendToUsers(mailType, roleIds); - } else { - await f.sendToServer(serverIds); - } - await f.saveRecord(uid); - return resResult(STATUS.SUCCESS); - } - - async sendWithContent(msg: { contentId: number, mailType: number, params: { params?: string[], sendName?: string, goods?: RewardInter[], endTime?: number }, roleIds?: string[], serverIds?: number[] }, session: BackendSession) { - let { contentId, mailType, roleIds, serverIds, params } = msg; - let f = new SendMailFun(); - f.setWithContentId(contentId, params); - if (mailType == GM_MAIL_TYPE.SINGLE || mailType == GM_MAIL_TYPE.GROUP) { - await f.sendToUsers(mailType, roleIds); - } else { - await f.sendToServer(serverIds); - } - return resResult(STATUS.SUCCESS); - } -} \ No newline at end of file diff --git a/game-server/app/servers/gm/remote/gmRemote.ts b/game-server/app/servers/gm/remote/gmRemote.ts index 4d5e52268..a91f894fc 100644 --- a/game-server/app/servers/gm/remote/gmRemote.ts +++ b/game-server/app/servers/gm/remote/gmRemote.ts @@ -1,7 +1,6 @@ import { Application, ChannelService, HandlerService, } from 'pinus'; import { resResult } from '../../../pubUtils/util'; import { STATUS } from '../../../consts'; -import { setGmMails, getGmMailById, getGmMails, getGmUseMails } from '../../../pubUtils/gmData/gmDataUtil'; import { mongoose } from '@typegoose/typegoose'; const { ObjectId } = mongoose.Types; export default function (app: Application) { @@ -94,72 +93,4 @@ export class GMRemote { }; channel.pushMessage('onLeave', resResult(STATUS.SUCCESS, param)); } - - public refreshGmMails(mails: [any]) { - setGmMails(mails); - } - - /** - * 获得据上次刷新后,可以加入的邮件 - * @param updatedMailAt - * @param serverId - */ - public getMailsByTime(updatedMailAt: number, serverId: number) { - let gmMails = getGmMails(updatedMailAt, serverId); - return gmMails; - } - // /** - // * 获得可以领取的邮件奖 - // * @param serverId - // * @param groupMailRewards - // * @param mailRewards - // */ - // public getUseMails(serverId: number, groupMailRewards: GroupMailType[], mailRewards: MailType[]) { - // let nowTime = nowSeconds(); - // let mailGoods = []; - // let mails = []; - // let mailIds = []; - // let groupMailIds = []; - // groupMailRewards.map(({_id, goods, mailId, mailTemType})=>{ - // if (mailTemType == MAIL_TEM_TYPE.GMTYPE) {//gm邮件检查是否有奖励以及是否可以领取 - // let gmMail = getGmMailById(mailId, serverId, nowTime); - // if (!gmMail || !gmMail.goods.length|| gmMail.endTime < nowSeconds()) { - // return; - // } - // mailGoods.push(...gmMail.goods); - // } else { - // if (!goods.length)//系统邮件,检查是否有奖励 - // return; - // mailGoods.push(...goods); - // } - // mails.push({id: _id, status: MAIL_STATUS.RECEIVED, mailType: MAIL_TYPE.GROUPMAIL}); - // groupMailIds.push(_id); - // }); - // mailRewards.map(({_id, goods, mailId, mailTemType})=>{ - // if (mailTemType == MAIL_TEM_TYPE.GMTYPE) {//gm邮件检查是否有奖励以及是否可以领取 - // let gmMail = getGmMailById(mailId, serverId, nowTime); - // if (!gmMail || !gmMail.goods.length|| gmMail.endTime < nowSeconds()) { - // return; - // } - // mailGoods.push(...gmMail.goods); - // } else { - // if (!goods.length)//系统邮件,检查是否有奖励 - // return; - // mailGoods.push(...goods); - // } - // mails.push({id: _id, status: MAIL_STATUS.RECEIVED, mailType: MAIL_TYPE.SINGLEMAIL}); - // mailIds.push(_id); - // }); - // return {mailIds, groupMailIds, mails, mailGoods}; - // } - /** - * 通过模板mailId获得gm邮件 - * @param mailId - * @param serverId - * @param nowTime - */ - public getUseGmMailById(mailId: string, serverId: number, nowTime: number) { - let gmMail = getGmMailById(mailId, serverId, nowTime); - return gmMail; - } } \ No newline at end of file diff --git a/game-server/app/services/gmService.ts b/game-server/app/services/gmService.ts index 415274367..7b1d62bc0 100644 --- a/game-server/app/services/gmService.ts +++ b/game-server/app/services/gmService.ts @@ -166,6 +166,6 @@ export async function stopMaintenance(maintenance: MaintenanceType, uid: number) let f = new SendMailFun(); await f.setWithGmMail((mail)._id); await f.sendToServer(serverIds); - await f.saveRecord(uid); + // await f.saveRecord(uid); } } \ No newline at end of file diff --git a/game-server/app/services/mailService.ts b/game-server/app/services/mailService.ts index e4c12aee4..0ceb88d3d 100644 --- a/game-server/app/services/mailService.ts +++ b/game-server/app/services/mailService.ts @@ -8,13 +8,14 @@ import { gameData } from "../pubUtils/data"; import { nowSeconds } from '../pubUtils/timeUtil'; import { STATUS } from '../consts/statusCode'; import { resResult } from '../pubUtils/util'; -import { GM_MAIL_TYPE, ITID, MAIL_STATUS, MAIL_TYPE, SEND_NAME } from "../consts"; +import { GM_MAIL_TYPE, ITID, MAIL_STATUS, MAIL_TIME_TYPE, MAIL_TYPE, SEND_NAME, SEND_TITLE } from "../consts"; import { MailParam } from '../domain/roleField/mail'; import { GMMailType, GMMailModel } from "../db/GMMail"; import { getGuildChannelSid, getWorldChannelSid } from "./chatChannelService"; import { GMMailRecordModel } from "../db/GMMailRecord"; import { BAG } from "../pubUtils/dicParam"; import { GuildModel, GuildType } from "../db/Guild"; +import moment = require("moment"); /** * 获取邮件信息 @@ -73,8 +74,9 @@ export async function sendMailToGuildByContent(contentId: MAIL_TYPE, guildCode: export class SendMailFun { private mailType: GM_MAIL_TYPE = GM_MAIL_TYPE.SINGLE; // 邮件类型 1-单人 2-多人 3-全服 private contentId: MAIL_TYPE = MAIL_TYPE.SEND_MAIL; // 0-读GmMail,1以上读dicMail - private params: string[] = []; private sendName: string = SEND_NAME; + private title: string = SEND_TITLE; + private content: string = ''; private gmmail: GMMailType; private hasGoods: boolean = false; // 是否内含奖励 private goods: RewardInter[] = []; // 发送的奖励 @@ -86,41 +88,44 @@ export class SendMailFun { private serverMails: ServerMailType[] = []; // 从dicMail读取数据 - public setWithContentId(contentId: MAIL_TYPE, params: { sendName?: string, endTime?: number, params?: string[], goods?: RewardInter[] }) { + public setWithContentId(contentId: MAIL_TYPE, params: { sendName?: string, params?: string[], goods?: RewardInter[] }) { let dicMail = gameData.mail.get(contentId); this.contentId = contentId; this.sendTime = nowSeconds(); this.endTime = this.sendTime + dicMail?.time||0; - this.setParam({ ...params }); + this.content = this.getContent(dicMail.content, params.params); + if(dicMail.title) this.title = dicMail.title; + if(dicMail.sendName) this.sendName = dicMail.sendName; + this.hasGoods = params.goods.length > 0; + this.goods = params.goods; + } + + getContent(content: string, params: string[]) { + if(!content) content = '%d'; + for(let p of params) { + content = content.replace(/%d/, p); + } + return content } // 从GMMail表读取数据 - public async setWithGmMail(gmmailId: string) { - // let gmmail = await GMMailModel.getGmMailById(gmmailId); - // if(gmmail) { - // this.gmmail = gmmail; - // if(gmmail.useTempTime) { - // this.sendTime = gmmail.sendTime; - // this.endTime = gmmail.endTime; - // } else { - // this.sendTime = nowSeconds(); - // this.endTime = this.sendTime + (gmmail.continueHour||0) * 60 * 60; - // } - // this.setParam({ ...gmmail }); - // } - } - - private setParam(params: { sendName?: string, endTime?: number, params?: string[], goods?: RewardInter[], content?: string }) { - if(params.sendName) this.sendName = params.sendName; - if(params.endTime) this.endTime = params.endTime; - if(params.content) { - this.params.push(params.content); - } - if(params.params) this.params = params.params; - if(params.goods) { - this.hasGoods = params.goods.length > 0; - this.goods = params.goods; + public async setWithGmMail(gmmail: GMMailType) { + this.gmmail = gmmail; + this.contentId = 0; + if(gmmail.timeType == MAIL_TIME_TYPE.IMMEDIATE) { + this.sendTime = nowSeconds(); + } else if (gmmail.timeType == MAIL_TIME_TYPE.DELAY) { + this.sendTime = gmmail.startTime; + } else if (gmmail.timeType == MAIL_TIME_TYPE.CIRCLE) { + this.sendTime = moment(moment().format('YYYY-MM-DD ' + gmmail.circleHour)).unix(); } + this.endTime = this.sendTime + gmmail.expire * 60 * 60; + this.sendName = gmmail.sendName; + this.title = gmmail.title; + this.content = gmmail.content; + this.hasGoods = gmmail.hasGoods; + this.goods = gmmail.goods; + return gmmail; } private getCreateMailParams() { @@ -129,9 +134,10 @@ export class SendMailFun { mail: this.gmmail?._id, sendTime: this.sendTime, endTime: this.endTime, - params: this.params, - goods: this.goods, + goods: this.goods, + title: this.title, sendName: this.sendName, + content: this.content, hasGoods: this.hasGoods } } diff --git a/shared/consts/constModules/mailConst.ts b/shared/consts/constModules/mailConst.ts index 99960798e..abffe162e 100644 --- a/shared/consts/constModules/mailConst.ts +++ b/shared/consts/constModules/mailConst.ts @@ -51,4 +51,5 @@ export enum MAIL_TYPE { TREAT_GUILD_INFO = 22, // 月卡奖品 }; -export const SEND_NAME = '系统'; \ No newline at end of file +export const SEND_NAME = '系统'; +export const SEND_TITLE = '系统邮件'; \ No newline at end of file diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index 0095f28e0..b7d8cc406 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -439,6 +439,8 @@ export const STATUS = { GM_ACTIVITY_NOT_FIT_GROUP_TYPE: { code: 60021, simStr: '该活动不满足该活动组类型' }, GM_MARQUEE_ERR: { code: 60022, simStr: '跑马灯定时设置错误' }, GM_MARQUEE_CANCEL_ERR: { code: 60023, simStr: '取消失败' }, + GM_MAIL_NOT_FOUND: { code: 60024, simStr: '未找到该邮件' }, + GM_MAIL_HAS_SENT: { code: 60025, simStr: '邮件已经审批过了' }, // 支付相关状态 70000 - 79999 NO_PRODUCT_ID: { code: 70001, simStr: '无效商品' }, NO_PAY_TYPE: { code: 70002, simStr: '无效支付类型' }, diff --git a/shared/db/GMMail.ts b/shared/db/GMMail.ts index 8d04866c3..9baf2d987 100644 --- a/shared/db/GMMail.ts +++ b/shared/db/GMMail.ts @@ -3,7 +3,6 @@ */ import BaseModel from './BaseModel'; import { getModelForClass, prop, DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose'; -import { nowSeconds } from '../pubUtils/timeUtil'; import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE } from '../consts'; import { SearchMailParam } from '../domain/backEndField/search'; @@ -23,6 +22,8 @@ export class Receiver { roleId?: string; @prop({ required: true }) roleName?: string; + @prop({ required: true }) + hasSend?: boolean; } export default class GMMail extends BaseModel { @@ -78,6 +79,14 @@ export default class GMMail extends BaseModel { @prop({ required: true, default: 0 }) status: GM_MAIL_STATUS; // 邮件状态 + @prop({ required: true }) + viewBy: number; // 审核人 + + @prop({ required: true }) + viewAt: Date; // 审核时间 + + @prop({ required: true }) + sendTime: string; // 发送时间 public static async addMail(params: GMMailTypeParam, uid = 1) { const doc = new GMMailModel(); @@ -96,20 +105,8 @@ export default class GMMail extends BaseModel { return result; } - public static async getMail(updatedMailAt: number, lean = true) { - const result: GMMailType[] = await GMMailModel.find({ $or: [{updatedAt: { $gte: new Date(updatedMailAt) }}, {sendTime: { $lte: nowSeconds() }}], endTime: { $gte: nowSeconds()} }).lean(lean); - return result; - } - - public static async getMails( lean = true) { - const result: GMMailType[] = await GMMailModel.find({ endTime: { $gte: nowSeconds() }}).lean(lean); - return result; - } - - private static getSearchObj(form: SearchMailParam) { let searchObj = {}; - console.log('******', form) if(form.createTimeStart) searchObj['createdAt'] = { $gt: new Date(form.createTimeStart * 1000) }; if(form.createTimeEnd) searchObj['createdAt'] = { $lt: new Date(form.createTimeEnd * 1000) }; if(form.serverId) searchObj['receivers.serverId'] = form.serverId; diff --git a/shared/db/MailTemp.ts b/shared/db/MailTemp.ts index cf5c0ae40..42ceb1be7 100644 --- a/shared/db/MailTemp.ts +++ b/shared/db/MailTemp.ts @@ -10,6 +10,9 @@ class Reward { export default class MailTemp extends BaseModel { + @prop({ required: true }) + gmmailId: string; + @prop({ required: true }) contentId: number; // dic_email_content.json中的id diff --git a/shared/domain/roleField/mail.ts b/shared/domain/roleField/mail.ts index 7975e9360..0c654d6b6 100644 --- a/shared/domain/roleField/mail.ts +++ b/shared/domain/roleField/mail.ts @@ -76,21 +76,12 @@ export class MailParam { } setContent(mail: MailType|GroupMailType|ServerMailType) { - let { contentId = 0, goods, sendName } = mail; - let params = [] + let { contentId = 0, goods, sendName, content, title } = mail; let dicMail = gameData.mail.get(contentId); if(!dicMail) dicMail = gameData.mail.get(0); - - this.content = this.getContent(dicMail.content, params); + this.title = title; + this.content = content; this.sendName = sendName||SEND_NAME; this.goods = goods; } - - getContent(content: string, params: string[]) { - if(!content) content = '%d'; - for(let p of params) { - content = content.replace(/%d/, p); - } - return content - } } \ No newline at end of file diff --git a/shared/pubUtils/dictionary/DicMail.ts b/shared/pubUtils/dictionary/DicMail.ts index 0dd0fe344..ec10e8af3 100644 --- a/shared/pubUtils/dictionary/DicMail.ts +++ b/shared/pubUtils/dictionary/DicMail.ts @@ -7,6 +7,8 @@ export interface DicMail { readonly id: number; // 内容 %d 替换 readonly content: string; + readonly title: string; + readonly sendName: string; readonly time: number; } @@ -16,6 +18,8 @@ export function loadMail() { let arr = readFileAndParse(FILENAME.DIC_MAIL); arr.forEach(o => { + if(o.title == '&') o.title = ''; + if(o.sendName == '&') o.sendName = ''; o.time = o.time * 60 * 60; dicMail.set(o.id, o); }); diff --git a/shared/pubUtils/gmData/gmDataUtil.ts b/shared/pubUtils/gmData/gmDataUtil.ts deleted file mode 100644 index b8a14cbba..000000000 --- a/shared/pubUtils/gmData/gmDataUtil.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { mailInit, setMails, GMMail } from '../gmData/gmMail'; -import { nowSeconds } from '../timeUtil'; -const ALL_SERVER = 0; -export let gmData:any = {}; -export async function init() { - gmData.mails = await mailInit(); -} - -export function getGmMails(updatedMailAt: number, serverId: number) { - let list = []; - let nowTime = nowSeconds(); - let serverIds = [serverId, ALL_SERVER]; - for (let serverId of serverIds) { - let gmServerData = gmData.mails.get(serverId); - if (!gmServerData) - continue; - gmServerData.forEach((gmMail)=>{ - if (gmMail.updatedAt >= updatedMailAt || gmMail.sendTime > updatedMailAt || gmMail.endTime > nowTime ) - list.push(gmMail); - }); - } - return list; -} - -export function getUseGmMails(serverId: number) { - let list = new Map(); - let serverIds = [serverId, ALL_SERVER]; - let nowTime = nowSeconds(); - for (let serverId of serverIds) { - let gmServerData = gmData.mails.get(serverId); - if (!gmServerData) - continue; - gmServerData.forEach((gmMail)=>{ - if (gmMail.endTime > nowTime) - list.set(gmMail.id, gmMail); - }); - } - return list; -} - -export function getGmMailById(id: string, serverId: number, nowTime: number) { - let gmMail; - if (!!gmData.mails.get(serverId)) { - gmMail = gmData.mails.get(serverId).get(id); - } - if (!gmMail) { - if (!!gmData.mails.get(ALL_SERVER)) { - gmMail = gmData.mails.get(ALL_SERVER).get(id); - } - } - if (!gmMail || gmMail.endTime < nowTime) - return null; - return gmMail; -} - -export function setGmMails(mails: GMMail[]) { - setMails(mails, gmData.mails); -} - - -export function getGmUseMails(serverId: number) { - let list = new Map(); - if (!!gmData.mails.get(serverId)) { - list = gmData.mails.get(serverId); - } - let serverMail = gmData.mails.get(ALL_SERVER); - if (!!serverMail) { - list = Object.assign(list, serverMail); - } - return list; -} \ No newline at end of file diff --git a/shared/pubUtils/gmData/gmMail.ts b/shared/pubUtils/gmData/gmMail.ts deleted file mode 100644 index 71f1f2209..000000000 --- a/shared/pubUtils/gmData/gmMail.ts +++ /dev/null @@ -1,61 +0,0 @@ - -type KeysEnum = { [P in keyof Required]: true }; -import { RewardInter } from '../interface'; -import { GMMailModel } from '../../db/GMMail'; -const _ = require('lodash'); - -export interface GMMail { - readonly id: string; - readonly sendRoles?: Array<{roleId: string, status: number}>; - readonly goods: Array; - readonly sendTime: number; - readonly endTime: number; - readonly content: string; - readonly gmMailType: number; - readonly updatedAt: number; - readonly serverId: number; - readonly sendName: string; -} - -const GMMailKeys: KeysEnum = { - id: true, - sendRoles: true, - goods: true, - sendTime: true, - endTime: true, - content: true, - gmMailType: true, - updatedAt: true, - serverId: true, - sendName: true -}; - -export async function mailInit() { - let gmMail = new Map(); - let mails = await GMMailModel.getMails(); - mails.map((o:any)=>{ - o.id = o._id.toString(); - o.updatedAt = Math.floor(o.updatedAt.getTime()/1000); - let mail = gmMail.get(o.serverId); - if (!mail) - mail = new Map(); - o.sendName = o.sendName||'系统'; - mail.set(o.id, _.pick(o, Object.keys(GMMailKeys))); - gmMail.set(o.serverId, mail); - }); - return gmMail; -} - - -export function setMails(mails:GMMail[], gmMail) { - mails.map((o:any)=>{ - o.id = o._id.toString(); - o.updatedAt = Math.floor(o.updatedAt.getTime()/1000); - o.sendName = o.sendName||'系统'; - let mail = gmMail.get(o.serverId); - if (!mail) - mail = new Map(); - mail.set(o.id, _.pick(o, Object.keys(GMMailKeys))); - gmMail.set(o.serverId, mail); - }); -} From 11bba498ce00e654dcf5a6f86bb32d9dfdfb0a0d Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 1 Dec 2021 18:12:04 +0800 Subject: [PATCH 11/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E9=82=AE=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/gm/handler/gmHandler.ts | 20 +++++++++++--- game-server/app/services/timeTaskService.ts | 26 +++++++++++++++++-- shared/db/GMMail.ts | 10 +++++++ 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/game-server/app/servers/gm/handler/gmHandler.ts b/game-server/app/servers/gm/handler/gmHandler.ts index b5655dc3c..b28d6147e 100644 --- a/game-server/app/servers/gm/handler/gmHandler.ts +++ b/game-server/app/servers/gm/handler/gmHandler.ts @@ -20,7 +20,7 @@ import { ActivityGroupModel } from '../../../db/ActivityGroup'; import { ActivityGroupTypeModel } from '../../../db/ActivityGroupType'; import { GuildActivityCityModel } from '../../../db/GuildActivityCity'; import { GuildActivityRecordModel } from '../../../db/GuildActivityRec'; -import { getTimeFunM } from '../../../pubUtils/timeUtil'; +import { getTimeFunM, nowSeconds } from '../../../pubUtils/timeUtil'; import { sendUngotDividend } from '../../../services/auctionService'; import moment = require('moment'); let timer: NodeJS.Timer; @@ -43,15 +43,29 @@ export class GmHandler { if(status != GM_MAIL_STATUS.CREATE) { return resResult(STATUS.GM_MAIL_HAS_SENT); } + let needSend = false; if(isPass) { + if(timeType == MAIL_TIME_TYPE.CIRCLE) { + let refTime = moment(moment().format('YYYY-MM-DD 03:00:00')).unix(); + let sendTime = moment(moment().format('YYYY-MM-DD '+circleHour)).unix(); + if(sendTime < refTime) sendTime += 86400; + let now = nowSeconds(); + if(refTime < now && sendTime > now) { + needSend = true; + } + } else { + needSend = true; + } + } + if(needSend) { let f = new SendMailFun(); await f.setWithGmMail(gmmail); if (mailType == GM_MAIL_TYPE.SINGLE || mailType == GM_MAIL_TYPE.GROUP) { - let roleIds = receivers.map(cur => cur.roleId); + let roleIds = receivers.filter(cur => cur.env == this.app.get('env')).map(cur => cur.roleId); await f.sendToUsers(mailType, roleIds); } else { - let serverIds = receivers.map(cur => cur.serverId); + let serverIds = receivers.filter(cur => cur.env == this.app.get('env')).map(cur => cur.serverId); await f.sendToServer(serverIds); } // await f.saveRecord(uid); diff --git a/game-server/app/services/timeTaskService.ts b/game-server/app/services/timeTaskService.ts index 2d6110c0e..dd575a0ab 100644 --- a/game-server/app/services/timeTaskService.ts +++ b/game-server/app/services/timeTaskService.ts @@ -5,13 +5,13 @@ import { nowSeconds, getTimeFun, getSeconds } from '../pubUtils/timeUtil'; import { getTodayGuildActivity, gameData } from '../pubUtils/data'; import { pvpSeasonEnd } from './pvpService'; import { getAllOnlineRoles, getAllServers, delGuildActivityRank } from './redisService'; -import { GUILD_ACTIVITY_TYPE, REFRESH_TIME, SEND_NAME, SERVER_OPEN_TIME, COUNTER, AUCTION_TIME } from '../consts'; +import { GUILD_ACTIVITY_TYPE, REFRESH_TIME, SEND_NAME, SERVER_OPEN_TIME, COUNTER, AUCTION_TIME, GM_MAIL_TYPE } from '../consts'; import { RoleModel } from '../db/Role'; import { pinus } from 'pinus'; import { indexOf } from 'underscore'; import { PvpSeasonResultModel } from '../db/PvpSeasonResult'; import { settleGuildWeekly } from './guildService'; -import { sendMailByContent } from './mailService'; +import { sendMailByContent, SendMailFun } from './mailService'; import { getGuildActivityByDic, sendEndMsgToAll, autoDeclare, sendGuildActivityStatus } from './guildActivityService'; import { sendUngotDividendJob, startGuildAuction, startWorldAuction, stopAuction } from './auctionService'; import { DicGuildActivity } from '../pubUtils/dictionary/DicGuildActivity'; @@ -25,6 +25,7 @@ import { CounterModel } from '../db/Counter'; import { reportOneOnline } from './authenticateService'; import { PVP } from '../pubUtils/dicParam'; import { fetch37Words } from './sdkService'; +import { GMMailModel } from '../db/GMMail'; const PER_SECOND = 1 * 1000; const PER_DAY = 24 * 60 * 60; @@ -59,6 +60,9 @@ export async function init() { // 每天拉取37词库 scheduleJob('fetchWord', '0 0 4 * * ?', fetch37Words); + // 每天邮件 + scheduleJob('circleMail', '0 0 3 * * ?', sendCircleMail); + // 军团活动排行榜 guildActivitySchedule(); @@ -374,4 +378,22 @@ function clearAuctionSchedule() { sendUngotDividendJobId.cancel(); sendUngotDividendJobId = undefined; } +} + + +async function sendCircleMail() { + let gmmails = await GMMailModel.findCircleMails(pinus.app.get('env')); + for(let gmmail of gmmails) { + let { receivers, mailType } = gmmail; + let f = new SendMailFun(); + await f.setWithGmMail(gmmail); + + if (mailType == GM_MAIL_TYPE.SINGLE || mailType == GM_MAIL_TYPE.GROUP) { + let roleIds = receivers.map(cur => cur.roleId); + await f.sendToUsers(mailType, roleIds); + } else { + let serverIds = receivers.map(cur => cur.serverId); + await f.sendToServer(serverIds); + } + } } \ No newline at end of file diff --git a/shared/db/GMMail.ts b/shared/db/GMMail.ts index 9baf2d987..65d394359 100644 --- a/shared/db/GMMail.ts +++ b/shared/db/GMMail.ts @@ -5,6 +5,7 @@ import BaseModel from './BaseModel'; import { getModelForClass, prop, DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose'; import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE } from '../consts'; import { SearchMailParam } from '../domain/backEndField/search'; +import { getCurDay, nowSeconds } from '../pubUtils/timeUtil'; class Reward { @prop({ required: true }) @@ -142,6 +143,15 @@ export default class GMMail extends BaseModel { return result; } + public static async findCircleMails(env: string) { + const result: GMMailType[] = await GMMailModel.find({ + timeType: MAIL_TIME_TYPE.CIRCLE, + circleStart: { $lt: nowSeconds() }, circleEnd: { $gte: nowSeconds() }, + circleDay: { $in: [0, getCurDay(true)] }, 'receivers.env': env, + status: GM_MAIL_STATUS.PASS + }); + return result; + } } From b8fff7cc839b34b2bd1b43c00ce91b61d5dc338a Mon Sep 17 00:00:00 2001 From: luying Date: Fri, 3 Dec 2021 20:35:13 +0800 Subject: [PATCH 12/32] =?UTF-8?q?=E6=8A=BD=E5=8D=A1=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E5=BC=95=E5=AF=BC=E6=8A=BD=E5=8D=A1=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/servers/activity/handler/gachaHandler.ts | 7 ++++--- shared/db/UserGacha.ts | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/game-server/app/servers/activity/handler/gachaHandler.ts b/game-server/app/servers/activity/handler/gachaHandler.ts index 04510db53..61b8c3e4e 100644 --- a/game-server/app/servers/activity/handler/gachaHandler.ts +++ b/game-server/app/servers/activity/handler/gachaHandler.ts @@ -403,15 +403,16 @@ export class GachaHandler { const gachaId = GACHA_ID.NORMAL; let userGacha = await UserGachaModel.findByRole(roleId, GACHA_ID.NORMAL); - let { guideResultList, candidates = [] } = userGacha; + let { guideResultList, candidates = [], guideCount } = userGacha; let index = candidates.findIndex(cur => cur.id == id); if(index == -1) { candidates.push({ - id, list: guideResultList + id, guideCount, list: guideResultList }); - } else { + } else { candidates[index].list = guideResultList; + candidates[index].guideCount = guideCount; } userGacha = await UserGachaModel.updateInfo(roleId, gachaId, 0, { candidates }) diff --git a/shared/db/UserGacha.ts b/shared/db/UserGacha.ts index 79eaf4573..536349365 100644 --- a/shared/db/UserGacha.ts +++ b/shared/db/UserGacha.ts @@ -50,6 +50,8 @@ class SimpleResult { class Candidate { @prop({ required: true }) id: number; // 列表id + @prop({ required: true }) + guideCount: number; // 引导次数 @prop({ required: true, type: SimpleResult, _id: false }) list: SimpleResult[]; // 是否得到 } From 9e157730554ff4d02f5ee9ecb7db78a3f24f1ee3 Mon Sep 17 00:00:00 2001 From: luying Date: Sat, 4 Dec 2021 18:47:01 +0800 Subject: [PATCH 13/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E5=A4=A7?= =?UTF-8?q?=E5=8C=BA=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/gm/handler/gmHandler.ts | 2 +- .../app/servers/gm/handler/gmServerHandler.ts | 28 +++ gm-server/app/controller/game.ts | 103 +++++----- gm-server/app/router.ts | 13 +- gm-server/app/service/Game.ts | 182 +++++++++--------- shared/consts/constModules/sysConst.ts | 7 + shared/db/ActivityGroup.ts | 6 + shared/db/Region.ts | 24 ++- shared/db/ServerStategy.ts | 99 ++-------- shared/db/Serverlist.ts | 4 +- shared/domain/backEndField/params.ts | 41 +++- 11 files changed, 282 insertions(+), 227 deletions(-) create mode 100644 game-server/app/servers/gm/handler/gmServerHandler.ts diff --git a/game-server/app/servers/gm/handler/gmHandler.ts b/game-server/app/servers/gm/handler/gmHandler.ts index b28d6147e..2e13cc7d0 100644 --- a/game-server/app/servers/gm/handler/gmHandler.ts +++ b/game-server/app/servers/gm/handler/gmHandler.ts @@ -80,7 +80,7 @@ export class GmHandler { sendTime = (circleDay == 0?'每天': '每周'+circleDay) + ' ' + circleHour; } } - await GMMailModel.updateMailById(id, { status: isPass?GM_MAIL_STATUS.PASS: GM_MAIL_STATUS.NOT_PASS, viewAt: new Date(), viewBy: uid, sendTime }, uid); + await GMMailModel.updateMailById(id, { status: isPass? GM_MAIL_STATUS.PASS: GM_MAIL_STATUS.NOT_PASS, viewAt: new Date(), viewBy: uid, sendTime }, uid); return resResult(STATUS.SUCCESS); } diff --git a/game-server/app/servers/gm/handler/gmServerHandler.ts b/game-server/app/servers/gm/handler/gmServerHandler.ts new file mode 100644 index 000000000..8cb234665 --- /dev/null +++ b/game-server/app/servers/gm/handler/gmServerHandler.ts @@ -0,0 +1,28 @@ +import { Application, BackendSession, pinus } from 'pinus'; +import { getRandSingleEelm, resResult } from '../../../pubUtils/util'; +import { STATUS } from '../../../consts/statusCode'; +import moment = require('moment'); +import { UpdateRegionParams } from '../../../domain/backEndField/params'; +import { RegionModel } from '../../../db/Region'; +let timer: NodeJS.Timer; +export default function (app: Application) { + return new GmHandler(app); +} + +export class GmHandler { + constructor(private app: Application) { + } + + async saveRegionConf(msg: UpdateRegionParams, session: BackendSession) { + let params = new UpdateRegionParams(msg); + let uid = session.get('uid'); + if(!params.checkParams()) return resResult(STATUS.WRONG_PARMS); + let update = params.getUpdateParam(); + if(params.id == 'new') { + await RegionModel.createNewRegion(update, uid); + } else { + await RegionModel.updateRegion(params.id, update, uid); + } + return resResult(STATUS.SUCCESS); + } +} \ No newline at end of file diff --git a/gm-server/app/controller/game.ts b/gm-server/app/controller/game.ts index f972bc393..011c56def 100644 --- a/gm-server/app/controller/game.ts +++ b/gm-server/app/controller/game.ts @@ -1,5 +1,4 @@ import { Controller } from 'egg'; -import { STATUS } from '@consts'; export default class GameController extends Controller { @@ -24,6 +23,14 @@ export default class GameController extends Controller { return } + public async getRegionStategy() { + const { ctx } = this; + const { id } = ctx.request.body; + + ctx.body = await ctx.service.game.getRegionStategy(id); + return + } + public async getServers() { const { ctx } = this; @@ -31,63 +38,63 @@ export default class GameController extends Controller { return } - public async getMaintenanceList() { - const { ctx } = this; - const {page, pageSize, sortField, sortOrder, form} = ctx.request.body; + // public async getMaintenanceList() { + // const { ctx } = this; + // const {page, pageSize, sortField, sortOrder, form} = ctx.request.body; - ctx.body = await ctx.service.game.getMaintenanceList(page, pageSize, sortField, sortOrder, form); - return - } + // ctx.body = await ctx.service.game.getMaintenanceList(page, pageSize, sortField, sortOrder, form); + // return + // } - public async updateMaintenance() { - const { ctx } = this; - const {values, marquee, notice, mail} = ctx.request.body; + // public async updateMaintenance() { + // const { ctx } = this; + // const {values, marquee, notice, mail} = ctx.request.body; - let goods = []; - try{ - goods = JSON.parse(mail.goods); - } catch(e) { - ctx.body = ctx.service.utils.resResult(STATUS.GM_JSON_FORMAT_ERR); - return - } + // let goods = []; + // try{ + // goods = JSON.parse(mail.goods); + // } catch(e) { + // ctx.body = ctx.service.utils.resResult(STATUS.GM_JSON_FORMAT_ERR); + // return + // } - ctx.body = await ctx.service.game.updateMaintenance( - {...values, startTime: new Date(values.startTime)}, - {...marquee, startTime: new Date(marquee.startTime), endTime: new Date(marquee.endTime)}, - {...notice, showStartTime: new Date(notice.showStartTime), showEndTime: new Date(notice.showEndTime), startTime: new Date(notice.startTime), endTime: new Date(notice.endTime)}, - {...mail, goods}); - return - } + // ctx.body = await ctx.service.game.updateMaintenance( + // {...values, startTime: new Date(values.startTime)}, + // {...marquee, startTime: new Date(marquee.startTime), endTime: new Date(marquee.endTime)}, + // {...notice, showStartTime: new Date(notice.showStartTime), showEndTime: new Date(notice.showEndTime), startTime: new Date(notice.startTime), endTime: new Date(notice.endTime)}, + // {...mail, goods}); + // return + // } - public async getServerStategyList() { - const { ctx } = this; - const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + // public async getServerStategyList() { + // const { ctx } = this; + // const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; - ctx.body = await ctx.service.game.getServerStategyList(page, pageSize, sortField, sortOrder, form); - return - } + // ctx.body = await ctx.service.game.getServerStategyList(page, pageSize, sortField, sortOrder, form); + // return + // } - public async updateServerStategy() { - const { ctx } = this; - const { values } = ctx.request.body; + // public async updateServerStategy() { + // const { ctx } = this; + // const { values } = ctx.request.body; - ctx.body = await ctx.service.game.updateServerStategy(values); - return - } + // ctx.body = await ctx.service.game.updateServerStategy(values); + // return + // } - public async createNewServer() { - const { ctx } = this; - const { name, openTime, serverType, stategyId } = ctx.request.body; - ctx.body = await ctx.service.game.createNewServer(name, openTime, serverType, stategyId); - return - } + // public async createNewServer() { + // const { ctx } = this; + // const { name, openTime, serverType, stategyId } = ctx.request.body; + // ctx.body = await ctx.service.game.createNewServer(name, openTime, serverType, stategyId); + // return + // } - public async updateServer() { - const { ctx } = this; - const { id, name, groupName, serverStatus, } = ctx.request.body; - ctx.body = await ctx.service.game.updateServer(id, name, groupName, serverStatus); - return - } + // public async updateServer() { + // const { ctx } = this; + // const { id, name, groupName, serverStatus, } = ctx.request.body; + // ctx.body = await ctx.service.game.updateServer(id, name, groupName, serverStatus); + // return + // } public async getNoticeList() { const { ctx } = this; diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index 64a7e1586..6f1a49a65 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -54,9 +54,10 @@ export default (app: Application) => { router.post('/api/game/getserverlist', controller.game.getServerList); router.post('/api/game/getregions', controller.game.getRegions); router.post('/api/game/getservers', controller.game.getServers); + router.post('/api/game/getregionstategy', controller.game.getRegionStategy); - router.post('/api/game/getmaintenancelist', controller.game.getMaintenanceList); - router.post('/api/game/updatemaintenance', controller.game.updateMaintenance); + // router.post('/api/game/getmaintenancelist', controller.game.getMaintenanceList); + // router.post('/api/game/updatemaintenance', controller.game.updateMaintenance); router.post('/api/game/getdicgoods', tokenParser, controller.game.getDicGoods); router.post('/api/game/getdichero', tokenParser, controller.game.getDicHero); @@ -64,10 +65,10 @@ export default (app: Application) => { router.post('/api/game/getdicactivitytype', tokenParser, controller.game.getDicActivityType); router.post('/api/game/getdictasktype', tokenParser, controller.game.getDicTaskType); - router.post('/api/game/getserverstategylist', controller.game.getServerStategyList); - router.post('/api/game/updateserverstategy', controller.game.updateServerStategy); - router.post('/api/game/createnewserver', controller.game.createNewServer); - router.post('/api/game/updateserver', controller.game.updateServer); + // router.post('/api/game/getserverstategylist', controller.game.getServerStategyList); + // router.post('/api/game/updateserverstategy', controller.game.updateServerStategy); + // router.post('/api/game/createnewserver', controller.game.createNewServer); + // router.post('/api/game/updateserver', controller.game.updateServer); router.post('/api/game/getnoticelist', controller.game.getNoticeList); router.post('/api/game/updatenotice', controller.game.updateNotice); router.post('/api/game/delnotice', controller.game.delNotice); diff --git a/gm-server/app/service/Game.ts b/gm-server/app/service/Game.ts index 2e8dd8de0..a0538928b 100644 --- a/gm-server/app/service/Game.ts +++ b/gm-server/app/service/Game.ts @@ -1,19 +1,17 @@ import { Service } from 'egg'; -import { STATUS, MARQUEE_TYPE } from '@consts'; +import { STATUS } from '@consts'; import { GameModel } from '@db/Game'; -import { ServerlistModel, ServerlistUpdate } from '@db/Serverlist'; +import { ServerlistModel } from '@db/Serverlist'; import { gameData } from '@pubUtils/data'; import { DicHero } from '@pubUtils/dictionary/DicHero'; import { DicRMB } from '@pubUtils/dictionary/DicRMB'; import { DicActivityType } from '@pubUtils/dictionary/DicActivityType'; import { DicTaskType } from '@pubUtils/dictionary/DicTaskType'; -import { ServerStategyModel, ServerStategyTypeParam } from '@db/ServerStategy'; -import { NoticeModel, NoticeTypeParam, NoticeType } from '@db/Notice'; -import { MarqueeModel, MarqueeParam, MarqueeType } from '@db/Marquee'; -import { MaintenanceModel, MaintenanceTypeParam } from '@db/Maintenance'; -import { GMMailTypeParam, GMMailModel, GMMailType } from '@db/GMMail'; +import { NoticeModel, NoticeTypeParam } from '@db/Notice'; +import { MarqueeModel, MarqueeParam } from '@db/Marquee'; import { AccuseRecModel } from '@db/AccuseRec'; import { RegionModel } from '@db/Region'; +import { ActivityGroupModel } from '@db/ActivityGroup'; /** * Test Service @@ -64,106 +62,118 @@ export default class Game extends Service { }); } - public async getMaintenanceList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { isOpen?: boolean } = {}) { + public async getRegionStategy(id: number) { const { ctx } = this; + let region = await RegionModel.findRegionById(id); + if(!region) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); + + let activityGroups = await ActivityGroupModel.findAllActivityGroup(); - const list = await MaintenanceModel.findByCondition(page, pageSize, sortField, sortOrder, form); - const total = await MaintenanceModel.countByCondition( form ) return ctx.service.utils.resResult(STATUS.SUCCESS, { - list: list.map(cur => { - let marquee = cur.marquee; - let notice = cur.notice; - return { - ...cur, startTime: cur.startTime.getTime(), - marquee: marquee?{...marquee, startTime: marquee.startTime.getTime(), endTime: marquee.endTime.getTime()}:null, - notice: notice?{...notice, showStartTime: notice.showStartTime.getTime(), showEndTime: notice.showEndTime.getTime()}:null - } - }), total + region, activityGroups }); } - public async updateMaintenance(values: MaintenanceTypeParam, marquee: MarqueeParam, notice: NoticeTypeParam, mail: GMMailTypeParam) { - const { ctx } = this; - if(values.code == 'new') { - let serverEnv = await GameModel.getServerEnvList(); - let curEnv = serverEnv.find(cur => cur.env == this.app.config.env); + // public async getMaintenanceList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { isOpen?: boolean } = {}) { + // const { ctx } = this; + + // const list = await MaintenanceModel.findByCondition(page, pageSize, sortField, sortOrder, form); + // const total = await MaintenanceModel.countByCondition( form ) + // return ctx.service.utils.resResult(STATUS.SUCCESS, { + // list: list.map(cur => { + // let marquee = cur.marquee; + // let notice = cur.notice; + // return { + // ...cur, startTime: cur.startTime.getTime(), + // marquee: marquee?{...marquee, startTime: marquee.startTime.getTime(), endTime: marquee.endTime.getTime()}:null, + // notice: notice?{...notice, showStartTime: notice.showStartTime.getTime(), showEndTime: notice.showEndTime.getTime()}:null + // } + // }), total + // }); + // } + + // public async updateMaintenance(values: MaintenanceTypeParam, marquee: MarqueeParam, notice: NoticeTypeParam, mail: GMMailTypeParam) { + // const { ctx } = this; + // if(values.code == 'new') { + // let serverEnv = await GameModel.getServerEnvList(); + // 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: false }, ctx.user?.uid); - // let mailResult = await GMMailModel.addMail(mail, ctx.user?.uid); - await MaintenanceModel.createData(values, marqueeResult, noticeResult, null); - } else { - let maintenanceResult = await MaintenanceModel.updateData(values.code, values, ctx.user?.uid); - if(!maintenanceResult) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); - let marqueeResult = maintenanceResult.marquee; - let noticeResult = maintenanceResult.notice; - let mailResult = maintenanceResult.mail; - if(marqueeResult) await MarqueeModel.updateData(marqueeResult.code, marquee, ctx.user?.uid); - if(noticeResult) await NoticeModel.updateNotice(noticeResult.id, notice, ctx.user?.uid); - if(mailResult) await GMMailModel.updateMailById(mailResult._id, mail, ctx.user?.uid); - } - return ctx.service.utils.resResult(STATUS.SUCCESS); - } + // 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: false }, ctx.user?.uid); + // // let mailResult = await GMMailModel.addMail(mail, ctx.user?.uid); + // await MaintenanceModel.createData(values, marqueeResult, noticeResult, null); + // } else { + // let maintenanceResult = await MaintenanceModel.updateData(values.code, values, ctx.user?.uid); + // if(!maintenanceResult) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); + // let marqueeResult = maintenanceResult.marquee; + // let noticeResult = maintenanceResult.notice; + // let mailResult = maintenanceResult.mail; + // if(marqueeResult) await MarqueeModel.updateData(marqueeResult.code, marquee, ctx.user?.uid); + // if(noticeResult) await NoticeModel.updateNotice(noticeResult.id, notice, ctx.user?.uid); + // if(mailResult) await GMMailModel.updateMailById(mailResult._id, mail, ctx.user?.uid); + // } + // return ctx.service.utils.resResult(STATUS.SUCCESS); + // } - public async getServerStategyList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { id?: number, name?: string }) { - const { ctx } = this; + // public async getServerStategyList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { id?: number, name?: string }) { + // const { ctx } = this; - const list = await ServerStategyModel.findByCondition(page, pageSize, sortField, sortOrder, form); - const total = await ServerStategyModel.countByCondition( form ) - return ctx.service.utils.resResult(STATUS.SUCCESS, { - list, total - }); - } + // const list = await ServerStategyModel.findByCondition(page, pageSize, sortField, sortOrder, form); + // const total = await ServerStategyModel.countByCondition( form ) + // return ctx.service.utils.resResult(STATUS.SUCCESS, { + // list, total + // }); + // } - public async updateServerStategy(values: ServerStategyTypeParam & {id: string|number}) { - const { ctx } = this; + // public async updateServerStategy(values: ServerStategyTypeParam & {id: string|number}) { + // const { ctx } = this; - try { - await ServerStategyModel.updateServerStategy(values, ctx.user?.uid); + // try { + // await ServerStategyModel.updateServerStategy(values, ctx.user?.uid); - } catch(e) { - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (e).stack); - } - return ctx.service.utils.resResult(STATUS.SUCCESS); - } + // } catch(e) { + // return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (e).stack); + // } + // return ctx.service.utils.resResult(STATUS.SUCCESS); + // } - public async createNewServer(name: string, openTime: number, serverType: string, stategyId: number ) { - const { ctx } = this; + // public async createNewServer(name: string, openTime: number, serverType: string, stategyId: number ) { + // const { ctx } = this; - try { - let stategy = await ServerStategyModel.findBySId(stategyId); - if(!stategy) return ctx.service.utils.resResult(STATUS.GM_STATEGY_NOT_FOUND); + // try { + // let stategy = await ServerStategyModel.findBySId(stategyId); + // if(!stategy) return ctx.service.utils.resResult(STATUS.GM_STATEGY_NOT_FOUND); - await ServerlistModel.newServer({ name, openTime: new Date(openTime), serverType }, stategy, ctx.user?.uid); + // await ServerlistModel.newServer({ name, openTime: new Date(openTime), serverType }, stategy, ctx.user?.uid); - } catch(e) { - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (e).stack); - } - return ctx.service.utils.resResult(STATUS.SUCCESS); - } + // } catch(e) { + // return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (e).stack); + // } + // return ctx.service.utils.resResult(STATUS.SUCCESS); + // } - public async updateServer(id: number, name: string, groupName: string, serverStatus: number ) { - const { ctx } = this; + // public async updateServer(id: number, name: string, groupName: string, serverStatus: number ) { + // const { ctx } = this; - try { - let server = await ServerlistModel.findByServerId(id); - if(!server) return ctx.service.utils.resResult(STATUS.GM_SERVER_NOT_FOUND); + // try { + // let server = await ServerlistModel.findByServerId(id); + // if(!server) return ctx.service.utils.resResult(STATUS.GM_SERVER_NOT_FOUND); - if(server.groupName != groupName) { - await ServerlistModel.updateGroupName(server.groupId, groupName); - } - let update: ServerlistUpdate = {}; - if(name) update['name'] = name; - if(groupName) update['groupName'] = groupName; - if(serverStatus) update['serverStatus'] = serverStatus; + // if(server.groupName != groupName) { + // await ServerlistModel.updateGroupName(server.groupId, groupName); + // } + // let update: ServerlistUpdate = {}; + // if(name) update['name'] = name; + // if(groupName) update['groupName'] = groupName; + // if(serverStatus) update['serverStatus'] = serverStatus; - await ServerlistModel.updateByServerId(id, update); + // await ServerlistModel.updateByServerId(id, update); - } catch(e) { - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (e).stack); - } - return ctx.service.utils.resResult(STATUS.SUCCESS); - } + // } catch(e) { + // return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (e).stack); + // } + // return ctx.service.utils.resResult(STATUS.SUCCESS); + // } public async getDicHero() { let list: DicHero[] = []; diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index 774b01ac3..277f2c891 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -754,4 +754,11 @@ export enum BLOCK_TYPE { NOT = 0, BAN = 1, BLOCK = 2, +} + +export enum SERVER_TIMER { + FIVE_HALF = 1, // 5:30 + TEN_HALF = 2, // 10:30 + FIFTEEN_HALF = 3, // 15:30 + SEVENTEEN_HALF = 4, // 19:30 } \ No newline at end of file diff --git a/shared/db/ActivityGroup.ts b/shared/db/ActivityGroup.ts index 074aece13..29a72bc67 100644 --- a/shared/db/ActivityGroup.ts +++ b/shared/db/ActivityGroup.ts @@ -107,6 +107,12 @@ export default class Activity_Group extends BaseModel { return result; } + //获取所有活动组 + public static async findAllActivityGroup() { + let result: ActivityGroupModelType[] = await ActivityGroupModel.find({}).lean(); + return result; + } + //删除组 public static async deleteGroup(groupId: number) { let result = await ActivityGroupModel.deleteMany({ groupId }); diff --git a/shared/db/Region.ts b/shared/db/Region.ts index 401e4762d..864139d57 100644 --- a/shared/db/Region.ts +++ b/shared/db/Region.ts @@ -2,6 +2,7 @@ import { COUNTER } from './../consts'; import { CounterModel } from './Counter'; import BaseModel from './BaseModel'; import { index, getModelForClass, prop, DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose'; +import ServerStategy from './ServerStategy'; /** @@ -31,15 +32,32 @@ export default class Region extends BaseModel { @prop({ required: true }) gamePort: number; // 长链接地址 - public static async createNewRegion(params: RegionUpdate) { + @prop({ required: true }) + latestServer: number; // 最新服 + + @prop({ required: true }) + serverCount: number; // 总数 + + @prop({ required: true }) + remark: string; // 备注 + + @prop({ required: true, type: () => ServerStategy, _id: false }) + stategy: ServerStategy; // 策略配置 + + public static async createNewRegion(params: RegionUpdate, uid = 1) { let id = await CounterModel.getNewCounter(COUNTER.REGION); - const rec: RegionType = await RegionModel.findOneAndUpdate({ id }, { $setOnInsert: params }, { new: true, upsert: true }).lean(); + const rec: RegionType = await RegionModel.findOneAndUpdate({ id }, { $setOnInsert: { ...params, createdBy: uid}, $set: { updatedBy: uid } }, { new: true, upsert: true }).lean(); + return rec; + } + + public static async updateRegion(id: number, params: RegionUpdate, uid = 1) { + const rec: RegionType = await RegionModel.findOneAndUpdate({ id }, { $set: { ...params, updatedBy: uid } }, { new: true }).lean(); return rec; } public static async getAllRegion() { - const rec: RegionType[] = await RegionModel.find().select('-_id').lean(); + const rec: RegionType[] = await RegionModel.find().select('-_id -stategty').lean(); return rec; } diff --git a/shared/db/ServerStategy.ts b/shared/db/ServerStategy.ts index ef723a557..c2b272f2a 100644 --- a/shared/db/ServerStategy.ts +++ b/shared/db/ServerStategy.ts @@ -1,91 +1,32 @@ -import BaseModel from './BaseModel'; -import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose'; -import { CounterModel } from './Counter'; -import { COUNTER } from '../consts'; +import { prop, DocumentType, } from '@typegoose/typegoose'; +import GMMail from './GMMail'; -/** - * 开服策略 -*/ -@index({ id: 1 }) +export default class ServerStategy { -export default class ServerStategy extends BaseModel { - @prop({ required: true }) - id: number; // 策略唯一id - @prop({ required: true }) - name: string; // 策略名 - - @prop({ required: true, default: false }) - isDefault: boolean; // 是否是自动开服默认使用的策略 @prop({ required: true, default: 0 }) maxPlayerCnt: number; // 人数上限 + @prop({ required: true, default: 0, type: Number }) + timers: number[]; // 开服时间点 + @prop({ required: true, type: Number }) activityGroupId: number[]; // 选择活动组 - @prop({ required: true, type: Number }) - mails: number[]; // 选择邮件模板 - @prop({ required: true, type: Number }) - marquees: number[]; // 选择跑马灯 - @prop({ required: true, type: Number }) - notices: number[]; // 选择公告 - public static async findBySId(id: number) { - const result: ServerStategyType = await ServerStategyModel.findOne({ id }, { _id: 0 }).lean({ getters: true, virtuals: true }); - return result; + @prop({ required: true, type: GMMail, _id: false }) + openMail: GMMail; - } + @prop({ required: true, type: GMMail, _id: false }) + circleMail: GMMail; + + @prop({ required: true, default: 0 }) + stopRegisterTime: number; // 关闭注册时间 - private static getSearchObj(form: { id?: number, name?: string, isDefault?: boolean }) { - let searchObj = {}; - if (form.id != undefined) searchObj['id'] = form.id; - if (form.name != undefined) searchObj['name'] = { $regex: new RegExp(form.name.toString(), 'i') }; - if (form.isDefault != undefined) searchObj['isDefault'] = form.isDefault; - return searchObj - } - - public static async findByCondition(page: number, pageSize: number, sortField: string, sortOrder: string, form: { id?: number, name?: string, isDefault?: boolean } = {}) { - - let searchObj = this.getSearchObj(form); - let sort = {}; - if (sortField && sortOrder) { - if (sortOrder == 'ascend') { - sort[sortField] = 1; - } else if (sortOrder == 'descend') { - sort[sortField] = -1; - } - } - const result: ServerStategyType[] = await ServerStategyModel.find(searchObj, { _id: 0 }).limit(pageSize).skip((page - 1) * pageSize).sort(sort).lean({ getters: true, virtuals: true }); - return result; - - } - - public static async countByCondition(form: { id?: number, name?: string, isDefault?: boolean } = {}) { - - let searchObj = this.getSearchObj(form); - const result = await ServerStategyModel.count(searchObj); - return result; - } - - private static async unsetDefault() { - const rec = await ServerStategyModel.updateMany({ isDefault: true }, { $set: { isDefault: false } }); - return rec; - } - - public static async updateServerStategy(values: ServerStategyTypeParam & {id: string|number}, uid = 1) { - let id = values.id; - if(id == 'new') { - id = await CounterModel.getNewCounter(COUNTER.SERVER_STATEGY); - } - if(values.isDefault) { - await this.unsetDefault(); - } - delete values.id; - let rec: ServerStategyType = await ServerStategyModel.findOneAndUpdate({ id }, { $set: {...values, updatedBy: uid}, $setOnInsert: { createdBy: uid } }, - { new: true, upsert: true }).lean(true); - return rec; + constructor(stategy: ServerStategyUpdate) { + this.maxPlayerCnt = stategy.maxPlayerCnt; + this.timers = stategy.timers; + this.activityGroupId = stategy.activityGroupId; + this.stopRegisterTime = stategy.stopRegisterTime; } } - -export const ServerStategyModel = getModelForClass(ServerStategy); - -export interface ServerStategyType extends Pick, keyof ServerStategy> { } -export type ServerStategyTypeParam = Partial; // 将所有字段变成可选项 \ No newline at end of file +export interface ServerStategyType extends Pick, keyof ServerStategy> { }; +export type ServerStategyUpdate = Partial; // 将所有字段变成可选项 diff --git a/shared/db/Serverlist.ts b/shared/db/Serverlist.ts index f0ec201df..59cec17b7 100644 --- a/shared/db/Serverlist.ts +++ b/shared/db/Serverlist.ts @@ -3,7 +3,6 @@ import { index, getModelForClass, prop, DocumentType, modelOptions, ReturnModelT import { GameModel } from './Game'; import { CounterModel } from './Counter'; import { COUNTER, SERVER_STATUS } from '../consts'; -import { ServerStategyTypeParam } from './ServerStategy'; import { getServerName, getServerGroupName } from '../pubUtils/data'; /** @@ -74,7 +73,6 @@ export default class Serverlist extends BaseModel { let id = await CounterModel.getCounter(COUNTER.SERVER); let result: ServerlistType[] = []; let n = Math.ceil(id/1000); - console.log('****', id, n) for(let i = 0; i < n; i++) { let servers: ServerlistType[] = await ServerlistModel.find().limit(1000).skip(i * 1000).lean({ getters: true, virtuals: true }); result.push(...servers); @@ -107,7 +105,7 @@ export default class Serverlist extends BaseModel { return server; } - public static async newServer(params: { serverType: string, openTime: Date, name?: string }, stategy: ServerStategyTypeParam, uid = 1 ) { + public static async newServer(params: { serverType: string, openTime: Date, name?: string }, stategy: any, uid = 1 ) { let { serverType, name } = params; let serverEnvs = await GameModel.getServerEnvList(); diff --git a/shared/domain/backEndField/params.ts b/shared/domain/backEndField/params.ts index e0ab86ad1..2ffa9895c 100644 --- a/shared/domain/backEndField/params.ts +++ b/shared/domain/backEndField/params.ts @@ -1,5 +1,7 @@ -import { GM_MAIL_TYPE, MAIL_TIME_TYPE } from "../../consts"; +import { GM_MAIL_TYPE, MAIL_TIME_TYPE, SERVER_TIMER } from "../../consts"; import { isArray } from 'underscore'; +import GMMail from "../../db/GMMail"; +import ServerStategy from "../../db/ServerStategy"; export class UpdateMailParams { hasGoods: boolean = false; // 是否有道具 @@ -62,4 +64,41 @@ export class UpdateMailParams { } return true; } +} + +export class UpdateRegionParams { + id: number|'new' = 0; // 大区id + name: string = ''; // 大区名 + prefix: string = ''; // 区名前缀 + remark: string = ''; + + maxPlayerCnt: number = 0; + timers: SERVER_TIMER[] = []; + activityGroupId: number[] = []; + openMail?: GMMail; + circleMail?: GMMail; + stopRegisterTime: number = 0; + + constructor(obj: UpdateRegionParams) { + for(let key in obj) { + this[key] = obj[key]; + } + } + + checkParams() { + if(!this.id || !this.name || !this.prefix || !this.maxPlayerCnt || !isArray(this.timers) || this.timers.length <= 0 || !isArray(this.activityGroupId) || this.activityGroupId.length <= 0 ) { + return false + } + return true; + } + + getUpdateParam() { + let stategy = new ServerStategy(this); + return { + name: this.name, + prefix: this.prefix, + remark: this.remark, + stategy + } + } } \ No newline at end of file From 103314a8bf02f718c2949d6567441d71fb978cb6 Mon Sep 17 00:00:00 2001 From: luying Date: Tue, 7 Dec 2021 10:34:52 +0800 Subject: [PATCH 14/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=BC=80=E6=9C=8D=E9=82=AE=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/gm/handler/gmHandler.ts | 5 +- .../app/servers/gm/handler/gmServerHandler.ts | 47 +- .../app/services/guildActivityService.ts | 18 +- game-server/app/services/mailService.ts | 6 +- shared/consts/constModules/sysConst.ts | 1 + shared/db/Counter.ts | 2 +- shared/db/CounterAll.ts | 40 + shared/db/Notice.ts | 9 +- shared/db/Region.ts | 11 +- shared/db/ServerStategy.ts | 4 +- shared/db/Serverlist.ts | 60 +- shared/db/index.ts | 2 + shared/domain/backEndField/params.ts | 50 +- shared/domain/gameField/serverlist.ts | 8 +- shared/pubUtils/data.ts | 19 +- shared/pubUtils/dictionary/DicServerName.ts | 35 +- shared/resource/jsons/dic_zyz_serverName.json | 5800 ++++++++++++++++- web-server/app/controller/game.ts | 3 +- 18 files changed, 5902 insertions(+), 218 deletions(-) create mode 100644 shared/db/CounterAll.ts diff --git a/game-server/app/servers/gm/handler/gmHandler.ts b/game-server/app/servers/gm/handler/gmHandler.ts index 2e13cc7d0..679db47ca 100644 --- a/game-server/app/servers/gm/handler/gmHandler.ts +++ b/game-server/app/servers/gm/handler/gmHandler.ts @@ -7,7 +7,7 @@ import { STATUS } from '../../../consts/statusCode'; import { GMMailModel } from '../../../db/GMMail'; import { delGuildActivityRank, getRoleOnlineInfo } from '../../../services/redisService'; import { SendMailFun } from '../../../services/mailService'; -import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE } from '../../../consts'; +import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE, REF_CIRCLE_MAIL_TIME } from '../../../consts'; import { RewardInter } from '../../../pubUtils/interface'; import { MarqueeModel } from '../../../db/Marquee'; import { ServerlistModel } from '../../../db/Serverlist'; @@ -21,7 +21,6 @@ import { ActivityGroupTypeModel } from '../../../db/ActivityGroupType'; import { GuildActivityCityModel } from '../../../db/GuildActivityCity'; import { GuildActivityRecordModel } from '../../../db/GuildActivityRec'; import { getTimeFunM, nowSeconds } from '../../../pubUtils/timeUtil'; -import { sendUngotDividend } from '../../../services/auctionService'; import moment = require('moment'); let timer: NodeJS.Timer; export default function (app: Application) { @@ -46,7 +45,7 @@ export class GmHandler { let needSend = false; if(isPass) { if(timeType == MAIL_TIME_TYPE.CIRCLE) { - let refTime = moment(moment().format('YYYY-MM-DD 03:00:00')).unix(); + let refTime = moment(moment().format(`YYYY-MM-DD ${REF_CIRCLE_MAIL_TIME}:00:00`)).unix(); let sendTime = moment(moment().format('YYYY-MM-DD '+circleHour)).unix(); if(sendTime < refTime) sendTime += 86400; let now = nowSeconds(); diff --git a/game-server/app/servers/gm/handler/gmServerHandler.ts b/game-server/app/servers/gm/handler/gmServerHandler.ts index 8cb234665..7e8b5d51a 100644 --- a/game-server/app/servers/gm/handler/gmServerHandler.ts +++ b/game-server/app/servers/gm/handler/gmServerHandler.ts @@ -2,8 +2,13 @@ import { Application, BackendSession, pinus } from 'pinus'; import { getRandSingleEelm, resResult } from '../../../pubUtils/util'; import { STATUS } from '../../../consts/statusCode'; import moment = require('moment'); -import { UpdateRegionParams } from '../../../domain/backEndField/params'; +import { CreateServerParam, UpdateRegionParams } from '../../../domain/backEndField/params'; import { RegionModel } from '../../../db/Region'; +import { gameData } from '../../../pubUtils/data'; +import { ServerlistModel } from '../../../db/Serverlist'; +import { nowSeconds } from '../../../pubUtils/timeUtil'; +import { GM_MAIL_TYPE, MAIL_TIME_TYPE, REF_CIRCLE_MAIL_TIME } from '../../../consts'; +import { SendMailFun } from '../../../services/mailService'; let timer: NodeJS.Timer; export default function (app: Application) { return new GmHandler(app); @@ -17,12 +22,50 @@ export class GmHandler { let params = new UpdateRegionParams(msg); let uid = session.get('uid'); if(!params.checkParams()) return resResult(STATUS.WRONG_PARMS); - let update = params.getUpdateParam(); if(params.id == 'new') { + let update = params.getUpdateParam(); await RegionModel.createNewRegion(update, uid); } else { + let oldRegion = await RegionModel.findRegionById(params.id); + if(!oldRegion) return resResult(STATUS.WRONG_PARMS); + let update = params.getUpdateParam(oldRegion); await RegionModel.updateRegion(params.id, update, uid); } return resResult(STATUS.SUCCESS); } + + async createNewServer(msg: CreateServerParam, session: BackendSession) { + let params = new CreateServerParam(msg); + let uid = session.get('uid'); + if(!params.checkParams()) return resResult(STATUS.WRONG_PARMS); + let curRegion = await RegionModel.findRegionByEnv(params.env); + if(!curRegion) return resResult(STATUS.WRONG_PARMS); + + let { latestServer = 0 } = curRegion; + let dicServerName = gameData.serverNames.get(latestServer + 1); + if(!dicServerName) return resResult(STATUS.DIC_DATA_NOT_FOUND); + + let newServer = await ServerlistModel.newServer(params, curRegion, dicServerName, uid); + let mails = [ params.openMail, params.circleMail ]; + for(let mail of mails) { + let needSend = false; + if(mail.timeType == MAIL_TIME_TYPE.CIRCLE) { + let refTime = moment(moment().format(`YYYY-MM-DD ${REF_CIRCLE_MAIL_TIME}:00:00`)).unix(); + let sendTime = moment(moment().format('YYYY-MM-DD '+ mail.circleHour)).unix(); + if(sendTime < refTime) sendTime += 86400; + let now = nowSeconds(); + if(refTime < now && sendTime > now) { + needSend = true; + } + } else { + needSend = true; + } + if(needSend) { + let f = new SendMailFun(); + await f.setWithGmMail(mail); + await f.sendToServer([newServer.id]); + } + } + return resResult(STATUS.SUCCESS); + } } \ No newline at end of file diff --git a/game-server/app/services/guildActivityService.ts b/game-server/app/services/guildActivityService.ts index e3e97d4de..b623aa263 100644 --- a/game-server/app/services/guildActivityService.ts +++ b/game-server/app/services/guildActivityService.ts @@ -57,16 +57,14 @@ export async function setMedianCe() { let servers = await ServerlistModel.getAllServerList(); for (let server of servers) { - if (server.serverType == 'official') { - let medianRole = await RoleModel.getMedianRole(server.id); - if (!medianRole) { - await ServerlistModel.updateByServerId(server.id, { medianCe: GUILDACTIVITY.GATEACTIVITY_ENEMYCE }); - } else { - let { topLineup } = medianRole; - let topHero = topLineup.sort((a, b) => b.ce - a.ce); - let medianCe = reduceCe(topHero[0].ce); - await ServerlistModel.updateByServerId(server.id, { medianCe }); - } + let medianRole = await RoleModel.getMedianRole(server.id); + if (!medianRole) { + await ServerlistModel.updateByServerId(server.id, { medianCe: GUILDACTIVITY.GATEACTIVITY_ENEMYCE }); + } else { + let { topLineup } = medianRole; + let topHero = topLineup.sort((a, b) => b.ce - a.ce); + let medianCe = reduceCe(topHero[0].ce); + await ServerlistModel.updateByServerId(server.id, { medianCe }); } } return servers; diff --git a/game-server/app/services/mailService.ts b/game-server/app/services/mailService.ts index 0ceb88d3d..98be7adbc 100644 --- a/game-server/app/services/mailService.ts +++ b/game-server/app/services/mailService.ts @@ -10,7 +10,7 @@ import { STATUS } from '../consts/statusCode'; import { resResult } from '../pubUtils/util'; import { GM_MAIL_TYPE, ITID, MAIL_STATUS, MAIL_TIME_TYPE, MAIL_TYPE, SEND_NAME, SEND_TITLE } from "../consts"; import { MailParam } from '../domain/roleField/mail'; -import { GMMailType, GMMailModel } from "../db/GMMail"; +import { GMMailType, GMMailModel, GMMailTypeParam } from "../db/GMMail"; import { getGuildChannelSid, getWorldChannelSid } from "./chatChannelService"; import { GMMailRecordModel } from "../db/GMMailRecord"; import { BAG } from "../pubUtils/dicParam"; @@ -77,7 +77,7 @@ export class SendMailFun { private sendName: string = SEND_NAME; private title: string = SEND_TITLE; private content: string = ''; - private gmmail: GMMailType; + private gmmail: GMMailTypeParam; private hasGoods: boolean = false; // 是否内含奖励 private goods: RewardInter[] = []; // 发送的奖励 private sendTime: number; @@ -109,7 +109,7 @@ export class SendMailFun { } // 从GMMail表读取数据 - public async setWithGmMail(gmmail: GMMailType) { + public async setWithGmMail(gmmail: GMMailTypeParam) { this.gmmail = gmmail; this.contentId = 0; if(gmmail.timeType == MAIL_TIME_TYPE.IMMEDIATE) { diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index 277f2c891..128493ca0 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -21,6 +21,7 @@ export const TEEN_DAILY_MAX_TIME = 1.5 * 60 * 60; // 未成年人工作日每天 export const GUEST_DAY = 15; // 同一设备15天内不得重复体验游客模式 export const REFRESH_TIME = 5; // 统一一天刷新时间 +export const REF_CIRCLE_MAIL_TIME = 3; // 统一一天刷新定期邮件时间 export const PUSH_BATCH = 100; // 推送分批人数 export const PUSH_INTERVAL = 5 * 1000; // 分批时间,5秒一批 export enum TIME_OUTPUT_TYPE { diff --git a/shared/db/Counter.ts b/shared/db/Counter.ts index 6ac266312..68a181dca 100644 --- a/shared/db/Counter.ts +++ b/shared/db/Counter.ts @@ -1,5 +1,5 @@ import BaseModel from './BaseModel'; -import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose'; +import { index, getModelForClass, prop, DocumentType, ReturnModelType, mongoose } from '@typegoose/typegoose'; /** * 自增 ID diff --git a/shared/db/CounterAll.ts b/shared/db/CounterAll.ts new file mode 100644 index 000000000..f66149c40 --- /dev/null +++ b/shared/db/CounterAll.ts @@ -0,0 +1,40 @@ +import BaseModel from './BaseModel'; +import { index, getModelForClass, prop, DocumentType, ReturnModelType, mongoose } from '@typegoose/typegoose'; + +/** + * 自增 ID +*/ +@index({ name: 1 }) +export default class CounterAll extends BaseModel { + + @prop({ required: true }) + name: string; + + @prop({ required: true, default: 1 }) + seq: number; + + public static async getNewCounter(param:{name: string, def: number}, lean = true) { + let {name, def:defaultVal} = param; + let counter: CounterType = await CounterAllModal.findOneAndUpdate({ name }, { $inc: { seq: 1 } }, { new: true, upsert: true }).lean(lean); + if(!counter || (counter&&counter.seq == 1) && defaultVal != 1) { + counter = await CounterAllModal.findOneAndUpdate({ name }, { $set: { seq: defaultVal } }, { new: true, upsert: true }).lean(lean); + } + return counter?.seq; + } + + public static async getCounter(param:{name: string, def: number}, lean = true) { + let {name, def:defaultVal} = param; + let counter: CounterType = await CounterAllModal.findOne({ name }).lean(lean); + return counter?.seq||defaultVal; + } + +} + +export let CounterAllModal: ReturnModelType; +export function loadCounterModal(connect: mongoose.Connection) { + CounterAllModal = getModelForClass(CounterAll, { + existingConnection: connect + }); +} + +export interface CounterType extends Pick, keyof CounterAll>{}; \ No newline at end of file diff --git a/shared/db/Notice.ts b/shared/db/Notice.ts index 683e9643b..93965f2c7 100644 --- a/shared/db/Notice.ts +++ b/shared/db/Notice.ts @@ -31,15 +31,14 @@ export default class Notice extends BaseModel { showStartTime: Date; @prop({ required: true, select: false }) showEndTime: Date; - @prop({ required: true, select: false }) - serverType: string; // 服务器类型 + @prop({ required: true, select: false }) isEnable: boolean; - public static async getAllNotice(serverType: string) { + public static async getAllNotice() { let curTime = new Date(); - let notices: NoticeType[] = await NoticeModel.find({ showStartTime: { $lte: curTime }, showEndTime: { $gte: curTime }, isEnable: true, serverType }) + let notices: NoticeType[] = await NoticeModel.find({ showStartTime: { $lte: curTime }, showEndTime: { $gte: curTime }, isEnable: true }) .sort({ sort: -1, createTime: -1 }) .lean({ virtuals: true }); return notices; @@ -77,7 +76,7 @@ export default class Notice extends BaseModel { sort[sortField] = -1; } } - const result: NoticeType[] = await NoticeModel.find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort).select('+sort +showStartTime +showEndTime +serverType +isEnable').lean({ getters: true, virtuals: true }); + const result: NoticeType[] = await NoticeModel.find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort).select('+sort +showStartTime +showEndTime +isEnable').lean({ getters: true, virtuals: true }); return result; } diff --git a/shared/db/Region.ts b/shared/db/Region.ts index 864139d57..33ad11e70 100644 --- a/shared/db/Region.ts +++ b/shared/db/Region.ts @@ -30,7 +30,7 @@ export default class Region extends BaseModel { gameHost: string; // 长链接地址 @prop({ required: true }) - gamePort: number; // 长链接地址 + gmPort: number; // 长链接地址 @prop({ required: true }) latestServer: number; // 最新服 @@ -57,12 +57,17 @@ export default class Region extends BaseModel { } public static async getAllRegion() { - const rec: RegionType[] = await RegionModel.find().select('-_id -stategty').lean(); + const rec: RegionType[] = await RegionModel.find().select('-_id -stategy').lean(); return rec; } public static async findRegionById(id: number) { - const rec: RegionType = await RegionModel.findOne({ id }).lean(); + const rec: RegionType = await RegionModel.findOne({ id }).select('-_id').lean(); + return rec; + } + + public static async findRegionByEnv(env: string) { + const rec: RegionType = await RegionModel.findOne({ env }).select('-_id').lean(); return rec; } } diff --git a/shared/db/ServerStategy.ts b/shared/db/ServerStategy.ts index c2b272f2a..a37569da0 100644 --- a/shared/db/ServerStategy.ts +++ b/shared/db/ServerStategy.ts @@ -21,11 +21,13 @@ export default class ServerStategy { @prop({ required: true, default: 0 }) stopRegisterTime: number; // 关闭注册时间 - constructor(stategy: ServerStategyUpdate) { + constructor(stategy: ServerStategyUpdate & { hasOpenMail: boolean, hasCircleMail: boolean}) { this.maxPlayerCnt = stategy.maxPlayerCnt; this.timers = stategy.timers; this.activityGroupId = stategy.activityGroupId; this.stopRegisterTime = stategy.stopRegisterTime; + if(stategy.hasCircleMail) this.circleMail = stategy.circleMail; + if(stategy.hasOpenMail) this.openMail = stategy.openMail; } } export interface ServerStategyType extends Pick, keyof ServerStategy> { }; diff --git a/shared/db/Serverlist.ts b/shared/db/Serverlist.ts index 59cec17b7..53c5e55ae 100644 --- a/shared/db/Serverlist.ts +++ b/shared/db/Serverlist.ts @@ -1,9 +1,10 @@ import BaseModel from './BaseModel'; import { index, getModelForClass, prop, DocumentType, modelOptions, ReturnModelType, mongoose } from '@typegoose/typegoose'; -import { GameModel } from './Game'; -import { CounterModel } from './Counter'; +import { CounterAllModal } from './CounterAll'; import { COUNTER, SERVER_STATUS } from '../consts'; -import { getServerName, getServerGroupName } from '../pubUtils/data'; +import { CreateServerParam } from '../domain/backEndField/params'; +import { RegionType } from './Region'; +import { DicServerName } from '../pubUtils/dictionary/DicServerName'; /** * 游戏字段接口 @@ -12,9 +13,6 @@ import { getServerName, getServerGroupName } from '../pubUtils/data'; @modelOptions({ schemaOptions: { id: false } }) export default class Serverlist extends BaseModel { - @prop({ required: true, default: 1 }) - gameId: number; // 游戏id Game表的id - @prop({ required: true, default: 1 }) regionId: number; // 大区id @@ -22,7 +20,7 @@ export default class Serverlist extends BaseModel { env: string; // 环境变量 @prop({ required: true }) - serverType: string; + prefix: string; // 前缀 @prop({ required: true }) id: number; // 小区id 自增 @@ -39,12 +37,6 @@ export default class Serverlist extends BaseModel { @prop({ required: true }) groupName: string; // 战区区名 - @prop({ required: true }) - host: string; // pinus连接地址 - - @prop({ required: false, default: 3014 }) - port: number; // pinus端口 - @prop({ required: true, default: 1, enum: SERVER_STATUS }) serverStatus: number; // 服务器状态 @@ -63,14 +55,20 @@ export default class Serverlist extends BaseModel { @prop({ required: true }) openTime: Date; + @prop({ required: true }) + stopRegisterTime: Date; + + @prop({ required: true, default: true }) + canRegister: boolean; + @prop({ required: true, default: 0 }) - maxPlayerCnt: number; // 最大玩家人数 + playerCnt: number; // 当前玩家人数 @prop({ required: true, default: 0 }) medianCe: number; // 中位数武将战力、缩小10000倍后的结果 public static async getAllServerList() { - let id = await CounterModel.getCounter(COUNTER.SERVER); + let id = await CounterAllModal.getCounter(COUNTER.SERVER); let result: ServerlistType[] = []; let n = Math.ceil(id/1000); for(let i = 0; i < n; i++) { @@ -105,28 +103,22 @@ export default class Serverlist extends BaseModel { return server; } - public static async newServer(params: { serverType: string, openTime: Date, name?: string }, stategy: any, uid = 1 ) { - let { serverType, name } = params; - - let serverEnvs = await GameModel.getServerEnvList(); - let curEnv = serverEnvs.find(cur => cur.serverType == serverType); - if(!curEnv) return false; - let { gameHost: host } = curEnv; - + public static async newServer(params: CreateServerParam, region: RegionType, dicServerName: DicServerName, uid = 1 ) { + let { prefix, id: regionId, env } = region; // 分大区 - let groupId = await CounterModel.getCounter(COUNTER.SERVER_GROUP); - let groupServerCount = await ServerlistModel.countByCondition({ serverType, groupId }); - if(groupServerCount > 10) { - groupId = await CounterModel.getNewCounter(COUNTER.SERVER_GROUP); - } - let groupName = getServerGroupName(groupId)||""; - - let serverId = await CounterModel.getNewCounter({ name: `${COUNTER.SERVER_BY_TYPE.name}_${serverType}`, def: COUNTER.SERVER_BY_TYPE.def }); - let id = await CounterModel.getNewCounter(COUNTER.SERVER); - if(!name) name = getServerName(id)||""; + let id = await CounterAllModal.getNewCounter(COUNTER.SERVER); + let { openTime: openTimeNum, stopRegisterTime: hour, activityGroupId } = params; + let { id: serverId, sname: name, groupId, groupName } = dicServerName; + let openTime = new Date(openTimeNum * 1000); + let stopRegisterTime = new Date(openTimeNum + hour * 60 * 60); const doc = new ServerlistModel(); - const update = Object.assign(doc.toJSON(), params, { id, serverId, host, groupId, groupName, name, createdBy: uid, updatedBy: uid }, { activityGroupId: stategy.activityGroupId, maxPlayerCnt: stategy.maxPlayerCnt}); + const update = Object.assign(doc.toJSON(), { + id, regionId, env, prefix, + serverId, name, groupId, groupName, activityGroupId, + openTime, stopRegisterTime, + createdBy: uid, updatedBy: uid + }); let server: ServerlistType = await ServerlistModel.findOneAndUpdate({ id }, { $setOnInsert: update }, { new: true, upsert: true }).lean({ getters: true, virtuals: true }); return server; diff --git a/shared/db/index.ts b/shared/db/index.ts index ffacc8a31..64c559184 100644 --- a/shared/db/index.ts +++ b/shared/db/index.ts @@ -7,6 +7,7 @@ import { loadGMUserGroupModel } from "./GMUserGroup"; import { loadRegionModel } from "./Region"; import { loadServerlistModel } from "./Serverlist"; import { loadGMMailModel } from './GMMail'; +import { loadCounterModal } from "./CounterAll"; export function loadGmDb(connect: mongoose.Connection) { loadApiModel(connect); @@ -17,4 +18,5 @@ export function loadGmDb(connect: mongoose.Connection) { loadRegionModel(connect); loadServerlistModel(connect); loadGMMailModel(connect); + loadCounterModal(connect); } \ No newline at end of file diff --git a/shared/domain/backEndField/params.ts b/shared/domain/backEndField/params.ts index 2ffa9895c..2a59e16d5 100644 --- a/shared/domain/backEndField/params.ts +++ b/shared/domain/backEndField/params.ts @@ -2,6 +2,7 @@ import { GM_MAIL_TYPE, MAIL_TIME_TYPE, SERVER_TIMER } from "../../consts"; import { isArray } from 'underscore'; import GMMail from "../../db/GMMail"; import ServerStategy from "../../db/ServerStategy"; +import { RegionType } from "../../db/Region"; export class UpdateMailParams { hasGoods: boolean = false; // 是否有道具 @@ -79,6 +80,9 @@ export class UpdateRegionParams { circleMail?: GMMail; stopRegisterTime: number = 0; + hasOpenMail: boolean = false; + hasCircleMail: boolean = false; + constructor(obj: UpdateRegionParams) { for(let key in obj) { this[key] = obj[key]; @@ -92,13 +96,45 @@ export class UpdateRegionParams { return true; } - getUpdateParam() { - let stategy = new ServerStategy(this); - return { - name: this.name, - prefix: this.prefix, - remark: this.remark, - stategy + getUpdateParam(oldRegion?: RegionType) { + if(!oldRegion) { + let stategy = new ServerStategy(this); + return { + name: this.name, + prefix: this.prefix, + remark: this.remark, + stategy + } + } else { + let stategy = new ServerStategy(this); + return { + name: this.name||oldRegion.name, + prefix: this.prefix||oldRegion.prefix, + remark: this.remark||oldRegion.remark, + stategy: { ...(oldRegion.stategy||{}), ...stategy } + } } } +} + +export class CreateServerParam { + env: string = ''; + openTime: number = 0; + activityGroupId: number[] = []; + openMail?: GMMail; + circleMail?: GMMail; + stopRegisterTime: number = 0; + + constructor(obj: CreateServerParam) { + for(let key in obj) { + this[key] = obj[key]; + } + } + + checkParams() { + if(!this.env || !this.openTime || !this.stopRegisterTime || !isArray(this.activityGroupId) || this.activityGroupId.length <= 0 ) { + return false + } + return true; + } } \ No newline at end of file diff --git a/shared/domain/gameField/serverlist.ts b/shared/domain/gameField/serverlist.ts index 28e896b22..1c6cabe1d 100644 --- a/shared/domain/gameField/serverlist.ts +++ b/shared/domain/gameField/serverlist.ts @@ -7,22 +7,18 @@ export class ServerParam { serverId: number; // 显示的区号 serverStr: string; // 显示的区号 S1 name: string; // 区名 - host: string; // pinus地址 - port: number; // pinus端口 + host: string = ''; // pinus地址 + port: number = 0; // pinus端口 status: number; // 状态 openTime: number; // 开服时间 - serverType: string; // 分区类型 官服 测试服 开发服 constructor(server: ServerlistType) { this.id = server.id; this.serverId = server.serverId; this.serverStr = `S${server.serverId}`; this.name = server.name; - this.host = server.host; - this.port = server.port; this.status = server.status; this.openTime = getSeconds(server.openTime); - this.serverType = server.serverType; } } diff --git a/shared/pubUtils/data.ts b/shared/pubUtils/data.ts index 511caf90c..b2c86ba61 100644 --- a/shared/pubUtils/data.ts +++ b/shared/pubUtils/data.ts @@ -83,7 +83,7 @@ import { dicRecruit, loadRecruit } from './dictionary/DicRecruit'; import { loadRMB, dicRMB } from './dictionary/DicRMB'; import { dicActivityType, loadActivityType } from './dictionary/DicActivityType'; import { DicTaskType, dicTaskTypeDesc, loadTaskType } from './dictionary/DicTaskType'; -import { dicServerName, dicServerGroupName, loadServerName } from "./dictionary/DicServerName"; +import { dicServerName, loadServerName } from "./dictionary/DicServerName"; import { dicAp, loadAp, dicApMaxLevel } from './dictionary/DicAp'; import { dicApBuy, dicApMaxBuyTimes, loadApBuy } from "./dictionary/DicApBuy"; import { dicKingExpRatio, loadKingExpRatio } from './dictionary/DicKingExpRatio'; @@ -224,7 +224,6 @@ export const gameData = { activityType: dicActivityType, taskTypeDesc: dicTaskTypeDesc, serverNames: dicServerName, - serverGroupNames: dicServerGroupName, ap: dicAp, apMaxLevel: dicApMaxLevel, apBuy: dicApBuy, @@ -718,22 +717,6 @@ function getCeRatio() { }); } - -// 根据groupId获得当前大区名 -export function getServerGroupName(groupId: number) { - let name = gameData.serverGroupNames.get(groupId); - if(!name) { - let maxId = 0; - gameData.serverGroupNames.forEach((gname, id) => { - if(id > maxId) { - maxId = id; - name = gname; - } - }) - } - return name; -} - // 根据服务器id获得当前大区名 export function getServerName(id: number) { let name = gameData.serverNames.get(id); diff --git a/shared/pubUtils/dictionary/DicServerName.ts b/shared/pubUtils/dictionary/DicServerName.ts index 44cfbb1f9..d9895a863 100644 --- a/shared/pubUtils/dictionary/DicServerName.ts +++ b/shared/pubUtils/dictionary/DicServerName.ts @@ -1,4 +1,4 @@ -// 武将特技表 +// 服务器名 import { readFileAndParse } from '../util' import { FILENAME } from '../../consts' @@ -6,32 +6,21 @@ export interface DicServerName { // id readonly id: number; // 小区名 - readonly name: string; + readonly sname: string; + // 大区id + readonly groupId: number; + // 大区名 + readonly groupName: string; } -export const dicServerName = new Map(); -export const dicServerGroupName = new Map(); +export const dicServerName = new Map(); export function loadServerName() { dicServerName.clear(); - dicServerGroupName.clear(); - { - let arr = readFileAndParse(FILENAME.DIC_SERVER_NAME); - - arr.forEach(o => { - let { id, sname } = o; - dicServerName.set(id, sname); - }); - arr = undefined; - } + let arr = readFileAndParse(FILENAME.DIC_SERVER_NAME); - { - let arr = readFileAndParse(FILENAME.DIC_SERVER_GROUP_NAME); - - arr.forEach(o => { - let { id, groupName } = o; - dicServerGroupName.set(id, groupName); - }); - arr = undefined; - } + arr.forEach(o => { + dicServerName.set(o.id, o); + }); + arr = undefined; } \ No newline at end of file diff --git a/shared/resource/jsons/dic_zyz_serverName.json b/shared/resource/jsons/dic_zyz_serverName.json index 66124cef6..e2080a160 100644 --- a/shared/resource/jsons/dic_zyz_serverName.json +++ b/shared/resource/jsons/dic_zyz_serverName.json @@ -1,402 +1,6002 @@ [ { "id": 1, - "sname": "测试1服" + "sname": "初识轻衣", + "groupId": 1, + "groupName": "封龙山" }, { "id": 2, - "sname": "测试2服" + "sname": "两小无猜", + "groupId": 1, + "groupName": "封龙山" }, { "id": 3, - "sname": "测试3服" + "sname": "青梅竹马", + "groupId": 1, + "groupName": "封龙山" }, { "id": 4, - "sname": "测试4服" + "sname": "剑枪之争", + "groupId": 1, + "groupName": "封龙山" }, { "id": 5, - "sname": "测试5服" + "sname": "山中恶狼", + "groupId": 1, + "groupName": "封龙山" }, { "id": 6, - "sname": "测试6服" + "sname": "齐心协力", + "groupId": 1, + "groupName": "封龙山" }, { "id": 7, - "sname": "测试7服" + "sname": "游戏7服", + "groupId": 1, + "groupName": "封龙山" }, { "id": 8, - "sname": "测试8服" + "sname": "游戏8服", + "groupId": 1, + "groupName": "封龙山" }, { "id": 9, - "sname": "测试9服" + "sname": "游戏9服", + "groupId": 1, + "groupName": "封龙山" }, { "id": 10, - "sname": "测试10服" + "sname": "游戏10服", + "groupId": 1, + "groupName": "封龙山" }, { "id": 11, - "sname": "测试11服" + "sname": "游戏11服", + "groupId": 2, + "groupName": "真定城" }, { "id": 12, - "sname": "测试12服" + "sname": "游戏12服", + "groupId": 2, + "groupName": "真定城" }, { "id": 13, - "sname": "测试13服" + "sname": "游戏13服", + "groupId": 2, + "groupName": "真定城" }, { "id": 14, - "sname": "测试14服" + "sname": "游戏14服", + "groupId": 2, + "groupName": "真定城" }, { "id": 15, - "sname": "测试15服" + "sname": "游戏15服", + "groupId": 2, + "groupName": "真定城" }, { "id": 16, - "sname": "测试16服" + "sname": "游戏16服", + "groupId": 2, + "groupName": "真定城" }, { "id": 17, - "sname": "测试17服" + "sname": "游戏17服", + "groupId": 2, + "groupName": "真定城" }, { "id": 18, - "sname": "测试18服" + "sname": "游戏18服", + "groupId": 2, + "groupName": "真定城" }, { "id": 19, - "sname": "测试19服" + "sname": "游戏19服", + "groupId": 2, + "groupName": "真定城" }, { "id": 20, - "sname": "测试20服" + "sname": "游戏20服", + "groupId": 2, + "groupName": "真定城" }, { "id": 21, - "sname": "测试21服" + "sname": "游戏21服", + "groupId": 3, + "groupName": "真定城" }, { "id": 22, - "sname": "测试22服" + "sname": "游戏22服", + "groupId": 3, + "groupName": "真定城" }, { "id": 23, - "sname": "测试23服" + "sname": "游戏23服", + "groupId": 3, + "groupName": "真定城" }, { "id": 24, - "sname": "测试24服" + "sname": "游戏24服", + "groupId": 3, + "groupName": "真定城" }, { "id": 25, - "sname": "测试25服" + "sname": "游戏25服", + "groupId": 3, + "groupName": "真定城" }, { "id": 26, - "sname": "测试26服" + "sname": "游戏26服", + "groupId": 3, + "groupName": "真定城" }, { "id": 27, - "sname": "测试27服" + "sname": "游戏27服", + "groupId": 3, + "groupName": "真定城" }, { "id": 28, - "sname": "测试28服" + "sname": "游戏28服", + "groupId": 3, + "groupName": "真定城" }, { "id": 29, - "sname": "测试29服" + "sname": "游戏29服", + "groupId": 3, + "groupName": "真定城" }, { "id": 30, - "sname": "测试30服" + "sname": "游戏30服", + "groupId": 3, + "groupName": "真定城" }, { "id": 31, - "sname": "测试31服" + "sname": "游戏31服", + "groupId": 4, + "groupName": "真定城" }, { "id": 32, - "sname": "测试32服" + "sname": "游戏32服", + "groupId": 4, + "groupName": "真定城" }, { "id": 33, - "sname": "测试33服" + "sname": "游戏33服", + "groupId": 4, + "groupName": "真定城" }, { "id": 34, - "sname": "测试34服" + "sname": "游戏34服", + "groupId": 4, + "groupName": "真定城" }, { "id": 35, - "sname": "测试35服" + "sname": "游戏35服", + "groupId": 4, + "groupName": "真定城" }, { "id": 36, - "sname": "测试36服" + "sname": "游戏36服", + "groupId": 4, + "groupName": "真定城" }, { "id": 37, - "sname": "测试37服" + "sname": "游戏37服", + "groupId": 4, + "groupName": "真定城" }, { "id": 38, - "sname": "测试38服" + "sname": "游戏38服", + "groupId": 4, + "groupName": "真定城" }, { "id": 39, - "sname": "测试39服" + "sname": "游戏39服", + "groupId": 4, + "groupName": "真定城" }, { "id": 40, - "sname": "测试40服" + "sname": "游戏40服", + "groupId": 5, + "groupName": "真定城" }, { "id": 41, - "sname": "测试41服" + "sname": "游戏41服", + "groupId": 5, + "groupName": "真定城" }, { "id": 42, - "sname": "测试42服" + "sname": "游戏42服", + "groupId": 5, + "groupName": "真定城" }, { "id": 43, - "sname": "测试43服" + "sname": "游戏43服", + "groupId": 5, + "groupName": "真定城" }, { "id": 44, - "sname": "测试44服" + "sname": "游戏44服", + "groupId": 5, + "groupName": "真定城" }, { "id": 45, - "sname": "测试45服" + "sname": "游戏45服", + "groupId": 5, + "groupName": "真定城" }, { "id": 46, - "sname": "测试46服" + "sname": "游戏46服", + "groupId": 5, + "groupName": "真定城" }, { "id": 47, - "sname": "测试47服" + "sname": "游戏47服", + "groupId": 5, + "groupName": "真定城" }, { "id": 48, - "sname": "测试48服" + "sname": "游戏48服", + "groupId": 5, + "groupName": "真定城" }, { "id": 49, - "sname": "测试49服" + "sname": "游戏49服", + "groupId": 5, + "groupName": "真定城" }, { "id": 50, - "sname": "测试50服" + "sname": "游戏50服", + "groupId": 6, + "groupName": "真定城" }, { "id": 51, - "sname": "测试51服" + "sname": "游戏51服", + "groupId": 6, + "groupName": "真定城" }, { "id": 52, - "sname": "测试52服" + "sname": "游戏52服", + "groupId": 6, + "groupName": "真定城" }, { "id": 53, - "sname": "测试53服" + "sname": "游戏53服", + "groupId": 6, + "groupName": "真定城" }, { "id": 54, - "sname": "测试54服" + "sname": "游戏54服", + "groupId": 6, + "groupName": "真定城" }, { "id": 55, - "sname": "测试55服" + "sname": "游戏55服", + "groupId": 6, + "groupName": "真定城" }, { "id": 56, - "sname": "测试56服" + "sname": "游戏56服", + "groupId": 6, + "groupName": "真定城" }, { "id": 57, - "sname": "测试57服" + "sname": "游戏57服", + "groupId": 6, + "groupName": "真定城" }, { "id": 58, - "sname": "测试58服" + "sname": "游戏58服", + "groupId": 6, + "groupName": "真定城" }, { "id": 59, - "sname": "测试59服" + "sname": "游戏59服", + "groupId": 6, + "groupName": "真定城" }, { "id": 60, - "sname": "测试60服" + "sname": "游戏60服", + "groupId": 7, + "groupName": "真定城" }, { "id": 61, - "sname": "测试61服" + "sname": "游戏61服", + "groupId": 7, + "groupName": "真定城" }, { "id": 62, - "sname": "测试62服" + "sname": "游戏62服", + "groupId": 7, + "groupName": "真定城" }, { "id": 63, - "sname": "测试63服" + "sname": "游戏63服", + "groupId": 7, + "groupName": "真定城" }, { "id": 64, - "sname": "测试64服" + "sname": "游戏64服", + "groupId": 7, + "groupName": "真定城" }, { "id": 65, - "sname": "测试65服" + "sname": "游戏65服", + "groupId": 7, + "groupName": "真定城" }, { "id": 66, - "sname": "测试66服" + "sname": "游戏66服", + "groupId": 7, + "groupName": "真定城" }, { "id": 67, - "sname": "测试67服" + "sname": "游戏67服", + "groupId": 7, + "groupName": "真定城" }, { "id": 68, - "sname": "测试68服" + "sname": "游戏68服", + "groupId": 7, + "groupName": "真定城" }, { "id": 69, - "sname": "测试69服" + "sname": "游戏69服", + "groupId": 7, + "groupName": "真定城" }, { "id": 70, - "sname": "测试70服" + "sname": "游戏70服", + "groupId": 8, + "groupName": "真定城" }, { "id": 71, - "sname": "测试71服" + "sname": "游戏71服", + "groupId": 8, + "groupName": "真定城" }, { "id": 72, - "sname": "测试72服" + "sname": "游戏72服", + "groupId": 8, + "groupName": "真定城" }, { "id": 73, - "sname": "测试73服" + "sname": "游戏73服", + "groupId": 8, + "groupName": "真定城" }, { "id": 74, - "sname": "测试74服" + "sname": "游戏74服", + "groupId": 8, + "groupName": "真定城" }, { "id": 75, - "sname": "测试75服" + "sname": "游戏75服", + "groupId": 8, + "groupName": "真定城" }, { "id": 76, - "sname": "测试76服" + "sname": "游戏76服", + "groupId": 8, + "groupName": "真定城" }, { "id": 77, - "sname": "测试77服" + "sname": "游戏77服", + "groupId": 8, + "groupName": "真定城" }, { "id": 78, - "sname": "测试78服" + "sname": "游戏78服", + "groupId": 8, + "groupName": "真定城" }, { "id": 79, - "sname": "测试79服" + "sname": "游戏79服", + "groupId": 8, + "groupName": "真定城" }, { "id": 80, - "sname": "测试80服" + "sname": "游戏80服", + "groupId": 9, + "groupName": "真定城" }, { "id": 81, - "sname": "测试81服" + "sname": "游戏81服", + "groupId": 9, + "groupName": "真定城" }, { "id": 82, - "sname": "测试82服" + "sname": "游戏82服", + "groupId": 9, + "groupName": "真定城" }, { "id": 83, - "sname": "测试83服" + "sname": "游戏83服", + "groupId": 9, + "groupName": "真定城" }, { "id": 84, - "sname": "测试84服" + "sname": "游戏84服", + "groupId": 9, + "groupName": "真定城" }, { "id": 85, - "sname": "测试85服" + "sname": "游戏85服", + "groupId": 9, + "groupName": "真定城" }, { "id": 86, - "sname": "测试86服" + "sname": "游戏86服", + "groupId": 9, + "groupName": "真定城" }, { "id": 87, - "sname": "测试87服" + "sname": "游戏87服", + "groupId": 9, + "groupName": "真定城" }, { "id": 88, - "sname": "测试88服" + "sname": "游戏88服", + "groupId": 9, + "groupName": "真定城" }, { "id": 89, - "sname": "测试89服" + "sname": "游戏89服", + "groupId": 9, + "groupName": "真定城" }, { "id": 90, - "sname": "测试90服" + "sname": "游戏90服", + "groupId": 10, + "groupName": "真定城" }, { "id": 91, - "sname": "测试91服" + "sname": "游戏91服", + "groupId": 10, + "groupName": "真定城" }, { "id": 92, - "sname": "测试92服" + "sname": "游戏92服", + "groupId": 10, + "groupName": "真定城" }, { "id": 93, - "sname": "测试93服" + "sname": "游戏93服", + "groupId": 10, + "groupName": "真定城" }, { "id": 94, - "sname": "测试94服" + "sname": "游戏94服", + "groupId": 10, + "groupName": "真定城" }, { "id": 95, - "sname": "测试95服" + "sname": "游戏95服", + "groupId": 10, + "groupName": "真定城" }, { "id": 96, - "sname": "测试96服" + "sname": "游戏96服", + "groupId": 10, + "groupName": "真定城" }, { "id": 97, - "sname": "测试97服" + "sname": "游戏97服", + "groupId": 10, + "groupName": "真定城" }, { "id": 98, - "sname": "测试98服" + "sname": "游戏98服", + "groupId": 10, + "groupName": "真定城" }, { "id": 99, - "sname": "测试99服" + "sname": "游戏99服", + "groupId": 10, + "groupName": "真定城" }, { "id": 100, - "sname": "测试100服" + "sname": "游戏100服", + "groupId": 11, + "groupName": "真定城" + }, + { + "id": 101, + "sname": "游戏101服", + "groupId": 11, + "groupName": "真定城" + }, + { + "id": 102, + "sname": "游戏102服", + "groupId": 11, + "groupName": "真定城" + }, + { + "id": 103, + "sname": "游戏103服", + "groupId": 11, + "groupName": "真定城" + }, + { + "id": 104, + "sname": "游戏104服", + "groupId": 11, + "groupName": "真定城" + }, + { + "id": 105, + "sname": "游戏105服", + "groupId": 11, + "groupName": "真定城" + }, + { + "id": 106, + "sname": "游戏106服", + "groupId": 11, + "groupName": "真定城" + }, + { + "id": 107, + "sname": "游戏107服", + "groupId": 11, + "groupName": "真定城" + }, + { + "id": 108, + "sname": "游戏108服", + "groupId": 11, + "groupName": "真定城" + }, + { + "id": 109, + "sname": "游戏109服", + "groupId": 11, + "groupName": "真定城" + }, + { + "id": 110, + "sname": "游戏110服", + "groupId": 12, + "groupName": "真定城" + }, + { + "id": 111, + "sname": "游戏111服", + "groupId": 12, + "groupName": "真定城" + }, + { + "id": 112, + "sname": "游戏112服", + "groupId": 12, + "groupName": "真定城" + }, + { + "id": 113, + "sname": "游戏113服", + "groupId": 12, + "groupName": "真定城" + }, + { + "id": 114, + "sname": "游戏114服", + "groupId": 12, + "groupName": "真定城" + }, + { + "id": 115, + "sname": "游戏115服", + "groupId": 12, + "groupName": "真定城" + }, + { + "id": 116, + "sname": "游戏116服", + "groupId": 12, + "groupName": "真定城" + }, + { + "id": 117, + "sname": "游戏117服", + "groupId": 12, + "groupName": "真定城" + }, + { + "id": 118, + "sname": "游戏118服", + "groupId": 12, + "groupName": "真定城" + }, + { + "id": 119, + "sname": "游戏119服", + "groupId": 12, + "groupName": "真定城" + }, + { + "id": 120, + "sname": "游戏120服", + "groupId": 13, + "groupName": "真定城" + }, + { + "id": 121, + "sname": "游戏121服", + "groupId": 13, + "groupName": "真定城" + }, + { + "id": 122, + "sname": "游戏122服", + "groupId": 13, + "groupName": "真定城" + }, + { + "id": 123, + "sname": "游戏123服", + "groupId": 13, + "groupName": "真定城" + }, + { + "id": 124, + "sname": "游戏124服", + "groupId": 13, + "groupName": "真定城" + }, + { + "id": 125, + "sname": "游戏125服", + "groupId": 13, + "groupName": "真定城" + }, + { + "id": 126, + "sname": "游戏126服", + "groupId": 13, + "groupName": "真定城" + }, + { + "id": 127, + "sname": "游戏127服", + "groupId": 13, + "groupName": "真定城" + }, + { + "id": 128, + "sname": "游戏128服", + "groupId": 13, + "groupName": "真定城" + }, + { + "id": 129, + "sname": "游戏129服", + "groupId": 13, + "groupName": "真定城" + }, + { + "id": 130, + "sname": "游戏130服", + "groupId": 14, + "groupName": "真定城" + }, + { + "id": 131, + "sname": "游戏131服", + "groupId": 14, + "groupName": "真定城" + }, + { + "id": 132, + "sname": "游戏132服", + "groupId": 14, + "groupName": "真定城" + }, + { + "id": 133, + "sname": "游戏133服", + "groupId": 14, + "groupName": "真定城" + }, + { + "id": 134, + "sname": "游戏134服", + "groupId": 14, + "groupName": "真定城" + }, + { + "id": 135, + "sname": "游戏135服", + "groupId": 14, + "groupName": "真定城" + }, + { + "id": 136, + "sname": "游戏136服", + "groupId": 14, + "groupName": "真定城" + }, + { + "id": 137, + "sname": "游戏137服", + "groupId": 14, + "groupName": "真定城" + }, + { + "id": 138, + "sname": "游戏138服", + "groupId": 14, + "groupName": "真定城" + }, + { + "id": 139, + "sname": "游戏139服", + "groupId": 14, + "groupName": "真定城" + }, + { + "id": 140, + "sname": "游戏140服", + "groupId": 15, + "groupName": "真定城" + }, + { + "id": 141, + "sname": "游戏141服", + "groupId": 15, + "groupName": "真定城" + }, + { + "id": 142, + "sname": "游戏142服", + "groupId": 15, + "groupName": "真定城" + }, + { + "id": 143, + "sname": "游戏143服", + "groupId": 15, + "groupName": "真定城" + }, + { + "id": 144, + "sname": "游戏144服", + "groupId": 15, + "groupName": "真定城" + }, + { + "id": 145, + "sname": "游戏145服", + "groupId": 15, + "groupName": "真定城" + }, + { + "id": 146, + "sname": "游戏146服", + "groupId": 15, + "groupName": "真定城" + }, + { + "id": 147, + "sname": "游戏147服", + "groupId": 15, + "groupName": "真定城" + }, + { + "id": 148, + "sname": "游戏148服", + "groupId": 15, + "groupName": "真定城" + }, + { + "id": 149, + "sname": "游戏149服", + "groupId": 15, + "groupName": "真定城" + }, + { + "id": 150, + "sname": "游戏150服", + "groupId": 16, + "groupName": "真定城" + }, + { + "id": 151, + "sname": "游戏151服", + "groupId": 16, + "groupName": "真定城" + }, + { + "id": 152, + "sname": "游戏152服", + "groupId": 16, + "groupName": "真定城" + }, + { + "id": 153, + "sname": "游戏153服", + "groupId": 16, + "groupName": "真定城" + }, + { + "id": 154, + "sname": "游戏154服", + "groupId": 16, + "groupName": "真定城" + }, + { + "id": 155, + "sname": "游戏155服", + "groupId": 16, + "groupName": "真定城" + }, + { + "id": 156, + "sname": "游戏156服", + "groupId": 16, + "groupName": "真定城" + }, + { + "id": 157, + "sname": "游戏157服", + "groupId": 16, + "groupName": "真定城" + }, + { + "id": 158, + "sname": "游戏158服", + "groupId": 16, + "groupName": "真定城" + }, + { + "id": 159, + "sname": "游戏159服", + "groupId": 16, + "groupName": "真定城" + }, + { + "id": 160, + "sname": "游戏160服", + "groupId": 17, + "groupName": "真定城" + }, + { + "id": 161, + "sname": "游戏161服", + "groupId": 17, + "groupName": "真定城" + }, + { + "id": 162, + "sname": "游戏162服", + "groupId": 17, + "groupName": "真定城" + }, + { + "id": 163, + "sname": "游戏163服", + "groupId": 17, + "groupName": "真定城" + }, + { + "id": 164, + "sname": "游戏164服", + "groupId": 17, + "groupName": "真定城" + }, + { + "id": 165, + "sname": "游戏165服", + "groupId": 17, + "groupName": "真定城" + }, + { + "id": 166, + "sname": "游戏166服", + "groupId": 17, + "groupName": "真定城" + }, + { + "id": 167, + "sname": "游戏167服", + "groupId": 17, + "groupName": "真定城" + }, + { + "id": 168, + "sname": "游戏168服", + "groupId": 17, + "groupName": "真定城" + }, + { + "id": 169, + "sname": "游戏169服", + "groupId": 17, + "groupName": "真定城" + }, + { + "id": 170, + "sname": "游戏170服", + "groupId": 18, + "groupName": "真定城" + }, + { + "id": 171, + "sname": "游戏171服", + "groupId": 18, + "groupName": "真定城" + }, + { + "id": 172, + "sname": "游戏172服", + "groupId": 18, + "groupName": "真定城" + }, + { + "id": 173, + "sname": "游戏173服", + "groupId": 18, + "groupName": "真定城" + }, + { + "id": 174, + "sname": "游戏174服", + "groupId": 18, + "groupName": "真定城" + }, + { + "id": 175, + "sname": "游戏175服", + "groupId": 18, + "groupName": "真定城" + }, + { + "id": 176, + "sname": "游戏176服", + "groupId": 18, + "groupName": "真定城" + }, + { + "id": 177, + "sname": "游戏177服", + "groupId": 18, + "groupName": "真定城" + }, + { + "id": 178, + "sname": "游戏178服", + "groupId": 18, + "groupName": "真定城" + }, + { + "id": 179, + "sname": "游戏179服", + "groupId": 18, + "groupName": "真定城" + }, + { + "id": 180, + "sname": "游戏180服", + "groupId": 19, + "groupName": "真定城" + }, + { + "id": 181, + "sname": "游戏181服", + "groupId": 19, + "groupName": "真定城" + }, + { + "id": 182, + "sname": "游戏182服", + "groupId": 19, + "groupName": "真定城" + }, + { + "id": 183, + "sname": "游戏183服", + "groupId": 19, + "groupName": "真定城" + }, + { + "id": 184, + "sname": "游戏184服", + "groupId": 19, + "groupName": "真定城" + }, + { + "id": 185, + "sname": "游戏185服", + "groupId": 19, + "groupName": "真定城" + }, + { + "id": 186, + "sname": "游戏186服", + "groupId": 19, + "groupName": "真定城" + }, + { + "id": 187, + "sname": "游戏187服", + "groupId": 19, + "groupName": "真定城" + }, + { + "id": 188, + "sname": "游戏188服", + "groupId": 19, + "groupName": "真定城" + }, + { + "id": 189, + "sname": "游戏189服", + "groupId": 19, + "groupName": "真定城" + }, + { + "id": 190, + "sname": "游戏190服", + "groupId": 20, + "groupName": "真定城" + }, + { + "id": 191, + "sname": "游戏191服", + "groupId": 20, + "groupName": "真定城" + }, + { + "id": 192, + "sname": "游戏192服", + "groupId": 20, + "groupName": "真定城" + }, + { + "id": 193, + "sname": "游戏193服", + "groupId": 20, + "groupName": "真定城" + }, + { + "id": 194, + "sname": "游戏194服", + "groupId": 20, + "groupName": "真定城" + }, + { + "id": 195, + "sname": "游戏195服", + "groupId": 20, + "groupName": "真定城" + }, + { + "id": 196, + "sname": "游戏196服", + "groupId": 20, + "groupName": "真定城" + }, + { + "id": 197, + "sname": "游戏197服", + "groupId": 20, + "groupName": "真定城" + }, + { + "id": 198, + "sname": "游戏198服", + "groupId": 20, + "groupName": "真定城" + }, + { + "id": 199, + "sname": "游戏199服", + "groupId": 20, + "groupName": "真定城" + }, + { + "id": 200, + "sname": "游戏200服", + "groupId": 21, + "groupName": "真定城" + }, + { + "id": 201, + "sname": "游戏201服", + "groupId": 21, + "groupName": "真定城" + }, + { + "id": 202, + "sname": "游戏202服", + "groupId": 21, + "groupName": "真定城" + }, + { + "id": 203, + "sname": "游戏203服", + "groupId": 21, + "groupName": "真定城" + }, + { + "id": 204, + "sname": "游戏204服", + "groupId": 21, + "groupName": "真定城" + }, + { + "id": 205, + "sname": "游戏205服", + "groupId": 21, + "groupName": "真定城" + }, + { + "id": 206, + "sname": "游戏206服", + "groupId": 21, + "groupName": "真定城" + }, + { + "id": 207, + "sname": "游戏207服", + "groupId": 21, + "groupName": "真定城" + }, + { + "id": 208, + "sname": "游戏208服", + "groupId": 21, + "groupName": "真定城" + }, + { + "id": 209, + "sname": "游戏209服", + "groupId": 21, + "groupName": "真定城" + }, + { + "id": 210, + "sname": "游戏210服", + "groupId": 22, + "groupName": "真定城" + }, + { + "id": 211, + "sname": "游戏211服", + "groupId": 22, + "groupName": "真定城" + }, + { + "id": 212, + "sname": "游戏212服", + "groupId": 22, + "groupName": "真定城" + }, + { + "id": 213, + "sname": "游戏213服", + "groupId": 22, + "groupName": "真定城" + }, + { + "id": 214, + "sname": "游戏214服", + "groupId": 22, + "groupName": "真定城" + }, + { + "id": 215, + "sname": "游戏215服", + "groupId": 22, + "groupName": "真定城" + }, + { + "id": 216, + "sname": "游戏216服", + "groupId": 22, + "groupName": "真定城" + }, + { + "id": 217, + "sname": "游戏217服", + "groupId": 22, + "groupName": "真定城" + }, + { + "id": 218, + "sname": "游戏218服", + "groupId": 22, + "groupName": "真定城" + }, + { + "id": 219, + "sname": "游戏219服", + "groupId": 22, + "groupName": "真定城" + }, + { + "id": 220, + "sname": "游戏220服", + "groupId": 23, + "groupName": "真定城" + }, + { + "id": 221, + "sname": "游戏221服", + "groupId": 23, + "groupName": "真定城" + }, + { + "id": 222, + "sname": "游戏222服", + "groupId": 23, + "groupName": "真定城" + }, + { + "id": 223, + "sname": "游戏223服", + "groupId": 23, + "groupName": "真定城" + }, + { + "id": 224, + "sname": "游戏224服", + "groupId": 23, + "groupName": "真定城" + }, + { + "id": 225, + "sname": "游戏225服", + "groupId": 23, + "groupName": "真定城" + }, + { + "id": 226, + "sname": "游戏226服", + "groupId": 23, + "groupName": "真定城" + }, + { + "id": 227, + "sname": "游戏227服", + "groupId": 23, + "groupName": "真定城" + }, + { + "id": 228, + "sname": "游戏228服", + "groupId": 23, + "groupName": "真定城" + }, + { + "id": 229, + "sname": "游戏229服", + "groupId": 23, + "groupName": "真定城" + }, + { + "id": 230, + "sname": "游戏230服", + "groupId": 24, + "groupName": "真定城" + }, + { + "id": 231, + "sname": "游戏231服", + "groupId": 24, + "groupName": "真定城" + }, + { + "id": 232, + "sname": "游戏232服", + "groupId": 24, + "groupName": "真定城" + }, + { + "id": 233, + "sname": "游戏233服", + "groupId": 24, + "groupName": "真定城" + }, + { + "id": 234, + "sname": "游戏234服", + "groupId": 24, + "groupName": "真定城" + }, + { + "id": 235, + "sname": "游戏235服", + "groupId": 24, + "groupName": "真定城" + }, + { + "id": 236, + "sname": "游戏236服", + "groupId": 24, + "groupName": "真定城" + }, + { + "id": 237, + "sname": "游戏237服", + "groupId": 24, + "groupName": "真定城" + }, + { + "id": 238, + "sname": "游戏238服", + "groupId": 24, + "groupName": "真定城" + }, + { + "id": 239, + "sname": "游戏239服", + "groupId": 24, + "groupName": "真定城" + }, + { + "id": 240, + "sname": "游戏240服", + "groupId": 25, + "groupName": "真定城" + }, + { + "id": 241, + "sname": "游戏241服", + "groupId": 25, + "groupName": "真定城" + }, + { + "id": 242, + "sname": "游戏242服", + "groupId": 25, + "groupName": "真定城" + }, + { + "id": 243, + "sname": "游戏243服", + "groupId": 25, + "groupName": "真定城" + }, + { + "id": 244, + "sname": "游戏244服", + "groupId": 25, + "groupName": "真定城" + }, + { + "id": 245, + "sname": "游戏245服", + "groupId": 25, + "groupName": "真定城" + }, + { + "id": 246, + "sname": "游戏246服", + "groupId": 25, + "groupName": "真定城" + }, + { + "id": 247, + "sname": "游戏247服", + "groupId": 25, + "groupName": "真定城" + }, + { + "id": 248, + "sname": "游戏248服", + "groupId": 25, + "groupName": "真定城" + }, + { + "id": 249, + "sname": "游戏249服", + "groupId": 25, + "groupName": "真定城" + }, + { + "id": 250, + "sname": "游戏250服", + "groupId": 26, + "groupName": "真定城" + }, + { + "id": 251, + "sname": "游戏251服", + "groupId": 26, + "groupName": "真定城" + }, + { + "id": 252, + "sname": "游戏252服", + "groupId": 26, + "groupName": "真定城" + }, + { + "id": 253, + "sname": "游戏253服", + "groupId": 26, + "groupName": "真定城" + }, + { + "id": 254, + "sname": "游戏254服", + "groupId": 26, + "groupName": "真定城" + }, + { + "id": 255, + "sname": "游戏255服", + "groupId": 26, + "groupName": "真定城" + }, + { + "id": 256, + "sname": "游戏256服", + "groupId": 26, + "groupName": "真定城" + }, + { + "id": 257, + "sname": "游戏257服", + "groupId": 26, + "groupName": "真定城" + }, + { + "id": 258, + "sname": "游戏258服", + "groupId": 26, + "groupName": "真定城" + }, + { + "id": 259, + "sname": "游戏259服", + "groupId": 26, + "groupName": "真定城" + }, + { + "id": 260, + "sname": "游戏260服", + "groupId": 27, + "groupName": "真定城" + }, + { + "id": 261, + "sname": "游戏261服", + "groupId": 27, + "groupName": "真定城" + }, + { + "id": 262, + "sname": "游戏262服", + "groupId": 27, + "groupName": "真定城" + }, + { + "id": 263, + "sname": "游戏263服", + "groupId": 27, + "groupName": "真定城" + }, + { + "id": 264, + "sname": "游戏264服", + "groupId": 27, + "groupName": "真定城" + }, + { + "id": 265, + "sname": "游戏265服", + "groupId": 27, + "groupName": "真定城" + }, + { + "id": 266, + "sname": "游戏266服", + "groupId": 27, + "groupName": "真定城" + }, + { + "id": 267, + "sname": "游戏267服", + "groupId": 27, + "groupName": "真定城" + }, + { + "id": 268, + "sname": "游戏268服", + "groupId": 27, + "groupName": "真定城" + }, + { + "id": 269, + "sname": "游戏269服", + "groupId": 27, + "groupName": "真定城" + }, + { + "id": 270, + "sname": "游戏270服", + "groupId": 28, + "groupName": "真定城" + }, + { + "id": 271, + "sname": "游戏271服", + "groupId": 28, + "groupName": "真定城" + }, + { + "id": 272, + "sname": "游戏272服", + "groupId": 28, + "groupName": "真定城" + }, + { + "id": 273, + "sname": "游戏273服", + "groupId": 28, + "groupName": "真定城" + }, + { + "id": 274, + "sname": "游戏274服", + "groupId": 28, + "groupName": "真定城" + }, + { + "id": 275, + "sname": "游戏275服", + "groupId": 28, + "groupName": "真定城" + }, + { + "id": 276, + "sname": "游戏276服", + "groupId": 28, + "groupName": "真定城" + }, + { + "id": 277, + "sname": "游戏277服", + "groupId": 28, + "groupName": "真定城" + }, + { + "id": 278, + "sname": "游戏278服", + "groupId": 28, + "groupName": "真定城" + }, + { + "id": 279, + "sname": "游戏279服", + "groupId": 28, + "groupName": "真定城" + }, + { + "id": 280, + "sname": "游戏280服", + "groupId": 29, + "groupName": "真定城" + }, + { + "id": 281, + "sname": "游戏281服", + "groupId": 29, + "groupName": "真定城" + }, + { + "id": 282, + "sname": "游戏282服", + "groupId": 29, + "groupName": "真定城" + }, + { + "id": 283, + "sname": "游戏283服", + "groupId": 29, + "groupName": "真定城" + }, + { + "id": 284, + "sname": "游戏284服", + "groupId": 29, + "groupName": "真定城" + }, + { + "id": 285, + "sname": "游戏285服", + "groupId": 29, + "groupName": "真定城" + }, + { + "id": 286, + "sname": "游戏286服", + "groupId": 29, + "groupName": "真定城" + }, + { + "id": 287, + "sname": "游戏287服", + "groupId": 29, + "groupName": "真定城" + }, + { + "id": 288, + "sname": "游戏288服", + "groupId": 29, + "groupName": "真定城" + }, + { + "id": 289, + "sname": "游戏289服", + "groupId": 29, + "groupName": "真定城" + }, + { + "id": 290, + "sname": "游戏290服", + "groupId": 30, + "groupName": "真定城" + }, + { + "id": 291, + "sname": "游戏291服", + "groupId": 30, + "groupName": "真定城" + }, + { + "id": 292, + "sname": "游戏292服", + "groupId": 30, + "groupName": "真定城" + }, + { + "id": 293, + "sname": "游戏293服", + "groupId": 30, + "groupName": "真定城" + }, + { + "id": 294, + "sname": "游戏294服", + "groupId": 30, + "groupName": "真定城" + }, + { + "id": 295, + "sname": "游戏295服", + "groupId": 30, + "groupName": "真定城" + }, + { + "id": 296, + "sname": "游戏296服", + "groupId": 30, + "groupName": "真定城" + }, + { + "id": 297, + "sname": "游戏297服", + "groupId": 30, + "groupName": "真定城" + }, + { + "id": 298, + "sname": "游戏298服", + "groupId": 30, + "groupName": "真定城" + }, + { + "id": 299, + "sname": "游戏299服", + "groupId": 30, + "groupName": "真定城" + }, + { + "id": 300, + "sname": "游戏300服", + "groupId": 31, + "groupName": "真定城" + }, + { + "id": 301, + "sname": "游戏301服", + "groupId": 31, + "groupName": "真定城" + }, + { + "id": 302, + "sname": "游戏302服", + "groupId": 31, + "groupName": "真定城" + }, + { + "id": 303, + "sname": "游戏303服", + "groupId": 31, + "groupName": "真定城" + }, + { + "id": 304, + "sname": "游戏304服", + "groupId": 31, + "groupName": "真定城" + }, + { + "id": 305, + "sname": "游戏305服", + "groupId": 31, + "groupName": "真定城" + }, + { + "id": 306, + "sname": "游戏306服", + "groupId": 31, + "groupName": "真定城" + }, + { + "id": 307, + "sname": "游戏307服", + "groupId": 31, + "groupName": "真定城" + }, + { + "id": 308, + "sname": "游戏308服", + "groupId": 31, + "groupName": "真定城" + }, + { + "id": 309, + "sname": "游戏309服", + "groupId": 31, + "groupName": "真定城" + }, + { + "id": 310, + "sname": "游戏310服", + "groupId": 32, + "groupName": "真定城" + }, + { + "id": 311, + "sname": "游戏311服", + "groupId": 32, + "groupName": "真定城" + }, + { + "id": 312, + "sname": "游戏312服", + "groupId": 32, + "groupName": "真定城" + }, + { + "id": 313, + "sname": "游戏313服", + "groupId": 32, + "groupName": "真定城" + }, + { + "id": 314, + "sname": "游戏314服", + "groupId": 32, + "groupName": "真定城" + }, + { + "id": 315, + "sname": "游戏315服", + "groupId": 32, + "groupName": "真定城" + }, + { + "id": 316, + "sname": "游戏316服", + "groupId": 32, + "groupName": "真定城" + }, + { + "id": 317, + "sname": "游戏317服", + "groupId": 32, + "groupName": "真定城" + }, + { + "id": 318, + "sname": "游戏318服", + "groupId": 32, + "groupName": "真定城" + }, + { + "id": 319, + "sname": "游戏319服", + "groupId": 32, + "groupName": "真定城" + }, + { + "id": 320, + "sname": "游戏320服", + "groupId": 33, + "groupName": "真定城" + }, + { + "id": 321, + "sname": "游戏321服", + "groupId": 33, + "groupName": "真定城" + }, + { + "id": 322, + "sname": "游戏322服", + "groupId": 33, + "groupName": "真定城" + }, + { + "id": 323, + "sname": "游戏323服", + "groupId": 33, + "groupName": "真定城" + }, + { + "id": 324, + "sname": "游戏324服", + "groupId": 33, + "groupName": "真定城" + }, + { + "id": 325, + "sname": "游戏325服", + "groupId": 33, + "groupName": "真定城" + }, + { + "id": 326, + "sname": "游戏326服", + "groupId": 33, + "groupName": "真定城" + }, + { + "id": 327, + "sname": "游戏327服", + "groupId": 33, + "groupName": "真定城" + }, + { + "id": 328, + "sname": "游戏328服", + "groupId": 33, + "groupName": "真定城" + }, + { + "id": 329, + "sname": "游戏329服", + "groupId": 33, + "groupName": "真定城" + }, + { + "id": 330, + "sname": "游戏330服", + "groupId": 34, + "groupName": "真定城" + }, + { + "id": 331, + "sname": "游戏331服", + "groupId": 34, + "groupName": "真定城" + }, + { + "id": 332, + "sname": "游戏332服", + "groupId": 34, + "groupName": "真定城" + }, + { + "id": 333, + "sname": "游戏333服", + "groupId": 34, + "groupName": "真定城" + }, + { + "id": 334, + "sname": "游戏334服", + "groupId": 34, + "groupName": "真定城" + }, + { + "id": 335, + "sname": "游戏335服", + "groupId": 34, + "groupName": "真定城" + }, + { + "id": 336, + "sname": "游戏336服", + "groupId": 34, + "groupName": "真定城" + }, + { + "id": 337, + "sname": "游戏337服", + "groupId": 34, + "groupName": "真定城" + }, + { + "id": 338, + "sname": "游戏338服", + "groupId": 34, + "groupName": "真定城" + }, + { + "id": 339, + "sname": "游戏339服", + "groupId": 34, + "groupName": "真定城" + }, + { + "id": 340, + "sname": "游戏340服", + "groupId": 35, + "groupName": "真定城" + }, + { + "id": 341, + "sname": "游戏341服", + "groupId": 35, + "groupName": "真定城" + }, + { + "id": 342, + "sname": "游戏342服", + "groupId": 35, + "groupName": "真定城" + }, + { + "id": 343, + "sname": "游戏343服", + "groupId": 35, + "groupName": "真定城" + }, + { + "id": 344, + "sname": "游戏344服", + "groupId": 35, + "groupName": "真定城" + }, + { + "id": 345, + "sname": "游戏345服", + "groupId": 35, + "groupName": "真定城" + }, + { + "id": 346, + "sname": "游戏346服", + "groupId": 35, + "groupName": "真定城" + }, + { + "id": 347, + "sname": "游戏347服", + "groupId": 35, + "groupName": "真定城" + }, + { + "id": 348, + "sname": "游戏348服", + "groupId": 35, + "groupName": "真定城" + }, + { + "id": 349, + "sname": "游戏349服", + "groupId": 35, + "groupName": "真定城" + }, + { + "id": 350, + "sname": "游戏350服", + "groupId": 36, + "groupName": "真定城" + }, + { + "id": 351, + "sname": "游戏351服", + "groupId": 36, + "groupName": "真定城" + }, + { + "id": 352, + "sname": "游戏352服", + "groupId": 36, + "groupName": "真定城" + }, + { + "id": 353, + "sname": "游戏353服", + "groupId": 36, + "groupName": "真定城" + }, + { + "id": 354, + "sname": "游戏354服", + "groupId": 36, + "groupName": "真定城" + }, + { + "id": 355, + "sname": "游戏355服", + "groupId": 36, + "groupName": "真定城" + }, + { + "id": 356, + "sname": "游戏356服", + "groupId": 36, + "groupName": "真定城" + }, + { + "id": 357, + "sname": "游戏357服", + "groupId": 36, + "groupName": "真定城" + }, + { + "id": 358, + "sname": "游戏358服", + "groupId": 36, + "groupName": "真定城" + }, + { + "id": 359, + "sname": "游戏359服", + "groupId": 36, + "groupName": "真定城" + }, + { + "id": 360, + "sname": "游戏360服", + "groupId": 37, + "groupName": "真定城" + }, + { + "id": 361, + "sname": "游戏361服", + "groupId": 37, + "groupName": "真定城" + }, + { + "id": 362, + "sname": "游戏362服", + "groupId": 37, + "groupName": "真定城" + }, + { + "id": 363, + "sname": "游戏363服", + "groupId": 37, + "groupName": "真定城" + }, + { + "id": 364, + "sname": "游戏364服", + "groupId": 37, + "groupName": "真定城" + }, + { + "id": 365, + "sname": "游戏365服", + "groupId": 37, + "groupName": "真定城" + }, + { + "id": 366, + "sname": "游戏366服", + "groupId": 37, + "groupName": "真定城" + }, + { + "id": 367, + "sname": "游戏367服", + "groupId": 37, + "groupName": "真定城" + }, + { + "id": 368, + "sname": "游戏368服", + "groupId": 37, + "groupName": "真定城" + }, + { + "id": 369, + "sname": "游戏369服", + "groupId": 37, + "groupName": "真定城" + }, + { + "id": 370, + "sname": "游戏370服", + "groupId": 38, + "groupName": "真定城" + }, + { + "id": 371, + "sname": "游戏371服", + "groupId": 38, + "groupName": "真定城" + }, + { + "id": 372, + "sname": "游戏372服", + "groupId": 38, + "groupName": "真定城" + }, + { + "id": 373, + "sname": "游戏373服", + "groupId": 38, + "groupName": "真定城" + }, + { + "id": 374, + "sname": "游戏374服", + "groupId": 38, + "groupName": "真定城" + }, + { + "id": 375, + "sname": "游戏375服", + "groupId": 38, + "groupName": "真定城" + }, + { + "id": 376, + "sname": "游戏376服", + "groupId": 38, + "groupName": "真定城" + }, + { + "id": 377, + "sname": "游戏377服", + "groupId": 38, + "groupName": "真定城" + }, + { + "id": 378, + "sname": "游戏378服", + "groupId": 38, + "groupName": "真定城" + }, + { + "id": 379, + "sname": "游戏379服", + "groupId": 38, + "groupName": "真定城" + }, + { + "id": 380, + "sname": "游戏380服", + "groupId": 39, + "groupName": "真定城" + }, + { + "id": 381, + "sname": "游戏381服", + "groupId": 39, + "groupName": "真定城" + }, + { + "id": 382, + "sname": "游戏382服", + "groupId": 39, + "groupName": "真定城" + }, + { + "id": 383, + "sname": "游戏383服", + "groupId": 39, + "groupName": "真定城" + }, + { + "id": 384, + "sname": "游戏384服", + "groupId": 39, + "groupName": "真定城" + }, + { + "id": 385, + "sname": "游戏385服", + "groupId": 39, + "groupName": "真定城" + }, + { + "id": 386, + "sname": "游戏386服", + "groupId": 39, + "groupName": "真定城" + }, + { + "id": 387, + "sname": "游戏387服", + "groupId": 39, + "groupName": "真定城" + }, + { + "id": 388, + "sname": "游戏388服", + "groupId": 39, + "groupName": "真定城" + }, + { + "id": 389, + "sname": "游戏389服", + "groupId": 39, + "groupName": "真定城" + }, + { + "id": 390, + "sname": "游戏390服", + "groupId": 40, + "groupName": "真定城" + }, + { + "id": 391, + "sname": "游戏391服", + "groupId": 40, + "groupName": "真定城" + }, + { + "id": 392, + "sname": "游戏392服", + "groupId": 40, + "groupName": "真定城" + }, + { + "id": 393, + "sname": "游戏393服", + "groupId": 40, + "groupName": "真定城" + }, + { + "id": 394, + "sname": "游戏394服", + "groupId": 40, + "groupName": "真定城" + }, + { + "id": 395, + "sname": "游戏395服", + "groupId": 40, + "groupName": "真定城" + }, + { + "id": 396, + "sname": "游戏396服", + "groupId": 40, + "groupName": "真定城" + }, + { + "id": 397, + "sname": "游戏397服", + "groupId": 40, + "groupName": "真定城" + }, + { + "id": 398, + "sname": "游戏398服", + "groupId": 40, + "groupName": "真定城" + }, + { + "id": 399, + "sname": "游戏399服", + "groupId": 40, + "groupName": "真定城" + }, + { + "id": 400, + "sname": "游戏400服", + "groupId": 41, + "groupName": "真定城" + }, + { + "id": 401, + "sname": "游戏401服", + "groupId": 41, + "groupName": "真定城" + }, + { + "id": 402, + "sname": "游戏402服", + "groupId": 41, + "groupName": "真定城" + }, + { + "id": 403, + "sname": "游戏403服", + "groupId": 41, + "groupName": "真定城" + }, + { + "id": 404, + "sname": "游戏404服", + "groupId": 41, + "groupName": "真定城" + }, + { + "id": 405, + "sname": "游戏405服", + "groupId": 41, + "groupName": "真定城" + }, + { + "id": 406, + "sname": "游戏406服", + "groupId": 41, + "groupName": "真定城" + }, + { + "id": 407, + "sname": "游戏407服", + "groupId": 41, + "groupName": "真定城" + }, + { + "id": 408, + "sname": "游戏408服", + "groupId": 41, + "groupName": "真定城" + }, + { + "id": 409, + "sname": "游戏409服", + "groupId": 41, + "groupName": "真定城" + }, + { + "id": 410, + "sname": "游戏410服", + "groupId": 42, + "groupName": "真定城" + }, + { + "id": 411, + "sname": "游戏411服", + "groupId": 42, + "groupName": "真定城" + }, + { + "id": 412, + "sname": "游戏412服", + "groupId": 42, + "groupName": "真定城" + }, + { + "id": 413, + "sname": "游戏413服", + "groupId": 42, + "groupName": "真定城" + }, + { + "id": 414, + "sname": "游戏414服", + "groupId": 42, + "groupName": "真定城" + }, + { + "id": 415, + "sname": "游戏415服", + "groupId": 42, + "groupName": "真定城" + }, + { + "id": 416, + "sname": "游戏416服", + "groupId": 42, + "groupName": "真定城" + }, + { + "id": 417, + "sname": "游戏417服", + "groupId": 42, + "groupName": "真定城" + }, + { + "id": 418, + "sname": "游戏418服", + "groupId": 42, + "groupName": "真定城" + }, + { + "id": 419, + "sname": "游戏419服", + "groupId": 42, + "groupName": "真定城" + }, + { + "id": 420, + "sname": "游戏420服", + "groupId": 43, + "groupName": "真定城" + }, + { + "id": 421, + "sname": "游戏421服", + "groupId": 43, + "groupName": "真定城" + }, + { + "id": 422, + "sname": "游戏422服", + "groupId": 43, + "groupName": "真定城" + }, + { + "id": 423, + "sname": "游戏423服", + "groupId": 43, + "groupName": "真定城" + }, + { + "id": 424, + "sname": "游戏424服", + "groupId": 43, + "groupName": "真定城" + }, + { + "id": 425, + "sname": "游戏425服", + "groupId": 43, + "groupName": "真定城" + }, + { + "id": 426, + "sname": "游戏426服", + "groupId": 43, + "groupName": "真定城" + }, + { + "id": 427, + "sname": "游戏427服", + "groupId": 43, + "groupName": "真定城" + }, + { + "id": 428, + "sname": "游戏428服", + "groupId": 43, + "groupName": "真定城" + }, + { + "id": 429, + "sname": "游戏429服", + "groupId": 43, + "groupName": "真定城" + }, + { + "id": 430, + "sname": "游戏430服", + "groupId": 44, + "groupName": "真定城" + }, + { + "id": 431, + "sname": "游戏431服", + "groupId": 44, + "groupName": "真定城" + }, + { + "id": 432, + "sname": "游戏432服", + "groupId": 44, + "groupName": "真定城" + }, + { + "id": 433, + "sname": "游戏433服", + "groupId": 44, + "groupName": "真定城" + }, + { + "id": 434, + "sname": "游戏434服", + "groupId": 44, + "groupName": "真定城" + }, + { + "id": 435, + "sname": "游戏435服", + "groupId": 44, + "groupName": "真定城" + }, + { + "id": 436, + "sname": "游戏436服", + "groupId": 44, + "groupName": "真定城" + }, + { + "id": 437, + "sname": "游戏437服", + "groupId": 44, + "groupName": "真定城" + }, + { + "id": 438, + "sname": "游戏438服", + "groupId": 44, + "groupName": "真定城" + }, + { + "id": 439, + "sname": "游戏439服", + "groupId": 44, + "groupName": "真定城" + }, + { + "id": 440, + "sname": "游戏440服", + "groupId": 45, + "groupName": "真定城" + }, + { + "id": 441, + "sname": "游戏441服", + "groupId": 45, + "groupName": "真定城" + }, + { + "id": 442, + "sname": "游戏442服", + "groupId": 45, + "groupName": "真定城" + }, + { + "id": 443, + "sname": "游戏443服", + "groupId": 45, + "groupName": "真定城" + }, + { + "id": 444, + "sname": "游戏444服", + "groupId": 45, + "groupName": "真定城" + }, + { + "id": 445, + "sname": "游戏445服", + "groupId": 45, + "groupName": "真定城" + }, + { + "id": 446, + "sname": "游戏446服", + "groupId": 45, + "groupName": "真定城" + }, + { + "id": 447, + "sname": "游戏447服", + "groupId": 45, + "groupName": "真定城" + }, + { + "id": 448, + "sname": "游戏448服", + "groupId": 45, + "groupName": "真定城" + }, + { + "id": 449, + "sname": "游戏449服", + "groupId": 45, + "groupName": "真定城" + }, + { + "id": 450, + "sname": "游戏450服", + "groupId": 46, + "groupName": "真定城" + }, + { + "id": 451, + "sname": "游戏451服", + "groupId": 46, + "groupName": "真定城" + }, + { + "id": 452, + "sname": "游戏452服", + "groupId": 46, + "groupName": "真定城" + }, + { + "id": 453, + "sname": "游戏453服", + "groupId": 46, + "groupName": "真定城" + }, + { + "id": 454, + "sname": "游戏454服", + "groupId": 46, + "groupName": "真定城" + }, + { + "id": 455, + "sname": "游戏455服", + "groupId": 46, + "groupName": "真定城" + }, + { + "id": 456, + "sname": "游戏456服", + "groupId": 46, + "groupName": "真定城" + }, + { + "id": 457, + "sname": "游戏457服", + "groupId": 46, + "groupName": "真定城" + }, + { + "id": 458, + "sname": "游戏458服", + "groupId": 46, + "groupName": "真定城" + }, + { + "id": 459, + "sname": "游戏459服", + "groupId": 46, + "groupName": "真定城" + }, + { + "id": 460, + "sname": "游戏460服", + "groupId": 47, + "groupName": "真定城" + }, + { + "id": 461, + "sname": "游戏461服", + "groupId": 47, + "groupName": "真定城" + }, + { + "id": 462, + "sname": "游戏462服", + "groupId": 47, + "groupName": "真定城" + }, + { + "id": 463, + "sname": "游戏463服", + "groupId": 47, + "groupName": "真定城" + }, + { + "id": 464, + "sname": "游戏464服", + "groupId": 47, + "groupName": "真定城" + }, + { + "id": 465, + "sname": "游戏465服", + "groupId": 47, + "groupName": "真定城" + }, + { + "id": 466, + "sname": "游戏466服", + "groupId": 47, + "groupName": "真定城" + }, + { + "id": 467, + "sname": "游戏467服", + "groupId": 47, + "groupName": "真定城" + }, + { + "id": 468, + "sname": "游戏468服", + "groupId": 47, + "groupName": "真定城" + }, + { + "id": 469, + "sname": "游戏469服", + "groupId": 47, + "groupName": "真定城" + }, + { + "id": 470, + "sname": "游戏470服", + "groupId": 48, + "groupName": "真定城" + }, + { + "id": 471, + "sname": "游戏471服", + "groupId": 48, + "groupName": "真定城" + }, + { + "id": 472, + "sname": "游戏472服", + "groupId": 48, + "groupName": "真定城" + }, + { + "id": 473, + "sname": "游戏473服", + "groupId": 48, + "groupName": "真定城" + }, + { + "id": 474, + "sname": "游戏474服", + "groupId": 48, + "groupName": "真定城" + }, + { + "id": 475, + "sname": "游戏475服", + "groupId": 48, + "groupName": "真定城" + }, + { + "id": 476, + "sname": "游戏476服", + "groupId": 48, + "groupName": "真定城" + }, + { + "id": 477, + "sname": "游戏477服", + "groupId": 48, + "groupName": "真定城" + }, + { + "id": 478, + "sname": "游戏478服", + "groupId": 48, + "groupName": "真定城" + }, + { + "id": 479, + "sname": "游戏479服", + "groupId": 48, + "groupName": "真定城" + }, + { + "id": 480, + "sname": "游戏480服", + "groupId": 49, + "groupName": "真定城" + }, + { + "id": 481, + "sname": "游戏481服", + "groupId": 49, + "groupName": "真定城" + }, + { + "id": 482, + "sname": "游戏482服", + "groupId": 49, + "groupName": "真定城" + }, + { + "id": 483, + "sname": "游戏483服", + "groupId": 49, + "groupName": "真定城" + }, + { + "id": 484, + "sname": "游戏484服", + "groupId": 49, + "groupName": "真定城" + }, + { + "id": 485, + "sname": "游戏485服", + "groupId": 49, + "groupName": "真定城" + }, + { + "id": 486, + "sname": "游戏486服", + "groupId": 49, + "groupName": "真定城" + }, + { + "id": 487, + "sname": "游戏487服", + "groupId": 49, + "groupName": "真定城" + }, + { + "id": 488, + "sname": "游戏488服", + "groupId": 49, + "groupName": "真定城" + }, + { + "id": 489, + "sname": "游戏489服", + "groupId": 49, + "groupName": "真定城" + }, + { + "id": 490, + "sname": "游戏490服", + "groupId": 50, + "groupName": "真定城" + }, + { + "id": 491, + "sname": "游戏491服", + "groupId": 50, + "groupName": "真定城" + }, + { + "id": 492, + "sname": "游戏492服", + "groupId": 50, + "groupName": "真定城" + }, + { + "id": 493, + "sname": "游戏493服", + "groupId": 50, + "groupName": "真定城" + }, + { + "id": 494, + "sname": "游戏494服", + "groupId": 50, + "groupName": "真定城" + }, + { + "id": 495, + "sname": "游戏495服", + "groupId": 50, + "groupName": "真定城" + }, + { + "id": 496, + "sname": "游戏496服", + "groupId": 50, + "groupName": "真定城" + }, + { + "id": 497, + "sname": "游戏497服", + "groupId": 50, + "groupName": "真定城" + }, + { + "id": 498, + "sname": "游戏498服", + "groupId": 50, + "groupName": "真定城" + }, + { + "id": 499, + "sname": "游戏499服", + "groupId": 50, + "groupName": "真定城" + }, + { + "id": 500, + "sname": "游戏500服", + "groupId": 51, + "groupName": "真定城" + }, + { + "id": 501, + "sname": "游戏501服", + "groupId": 51, + "groupName": "真定城" + }, + { + "id": 502, + "sname": "游戏502服", + "groupId": 51, + "groupName": "真定城" + }, + { + "id": 503, + "sname": "游戏503服", + "groupId": 51, + "groupName": "真定城" + }, + { + "id": 504, + "sname": "游戏504服", + "groupId": 51, + "groupName": "真定城" + }, + { + "id": 505, + "sname": "游戏505服", + "groupId": 51, + "groupName": "真定城" + }, + { + "id": 506, + "sname": "游戏506服", + "groupId": 51, + "groupName": "真定城" + }, + { + "id": 507, + "sname": "游戏507服", + "groupId": 51, + "groupName": "真定城" + }, + { + "id": 508, + "sname": "游戏508服", + "groupId": 51, + "groupName": "真定城" + }, + { + "id": 509, + "sname": "游戏509服", + "groupId": 51, + "groupName": "真定城" + }, + { + "id": 510, + "sname": "游戏510服", + "groupId": 52, + "groupName": "真定城" + }, + { + "id": 511, + "sname": "游戏511服", + "groupId": 52, + "groupName": "真定城" + }, + { + "id": 512, + "sname": "游戏512服", + "groupId": 52, + "groupName": "真定城" + }, + { + "id": 513, + "sname": "游戏513服", + "groupId": 52, + "groupName": "真定城" + }, + { + "id": 514, + "sname": "游戏514服", + "groupId": 52, + "groupName": "真定城" + }, + { + "id": 515, + "sname": "游戏515服", + "groupId": 52, + "groupName": "真定城" + }, + { + "id": 516, + "sname": "游戏516服", + "groupId": 52, + "groupName": "真定城" + }, + { + "id": 517, + "sname": "游戏517服", + "groupId": 52, + "groupName": "真定城" + }, + { + "id": 518, + "sname": "游戏518服", + "groupId": 52, + "groupName": "真定城" + }, + { + "id": 519, + "sname": "游戏519服", + "groupId": 52, + "groupName": "真定城" + }, + { + "id": 520, + "sname": "游戏520服", + "groupId": 53, + "groupName": "真定城" + }, + { + "id": 521, + "sname": "游戏521服", + "groupId": 53, + "groupName": "真定城" + }, + { + "id": 522, + "sname": "游戏522服", + "groupId": 53, + "groupName": "真定城" + }, + { + "id": 523, + "sname": "游戏523服", + "groupId": 53, + "groupName": "真定城" + }, + { + "id": 524, + "sname": "游戏524服", + "groupId": 53, + "groupName": "真定城" + }, + { + "id": 525, + "sname": "游戏525服", + "groupId": 53, + "groupName": "真定城" + }, + { + "id": 526, + "sname": "游戏526服", + "groupId": 53, + "groupName": "真定城" + }, + { + "id": 527, + "sname": "游戏527服", + "groupId": 53, + "groupName": "真定城" + }, + { + "id": 528, + "sname": "游戏528服", + "groupId": 53, + "groupName": "真定城" + }, + { + "id": 529, + "sname": "游戏529服", + "groupId": 53, + "groupName": "真定城" + }, + { + "id": 530, + "sname": "游戏530服", + "groupId": 54, + "groupName": "真定城" + }, + { + "id": 531, + "sname": "游戏531服", + "groupId": 54, + "groupName": "真定城" + }, + { + "id": 532, + "sname": "游戏532服", + "groupId": 54, + "groupName": "真定城" + }, + { + "id": 533, + "sname": "游戏533服", + "groupId": 54, + "groupName": "真定城" + }, + { + "id": 534, + "sname": "游戏534服", + "groupId": 54, + "groupName": "真定城" + }, + { + "id": 535, + "sname": "游戏535服", + "groupId": 54, + "groupName": "真定城" + }, + { + "id": 536, + "sname": "游戏536服", + "groupId": 54, + "groupName": "真定城" + }, + { + "id": 537, + "sname": "游戏537服", + "groupId": 54, + "groupName": "真定城" + }, + { + "id": 538, + "sname": "游戏538服", + "groupId": 54, + "groupName": "真定城" + }, + { + "id": 539, + "sname": "游戏539服", + "groupId": 54, + "groupName": "真定城" + }, + { + "id": 540, + "sname": "游戏540服", + "groupId": 55, + "groupName": "真定城" + }, + { + "id": 541, + "sname": "游戏541服", + "groupId": 55, + "groupName": "真定城" + }, + { + "id": 542, + "sname": "游戏542服", + "groupId": 55, + "groupName": "真定城" + }, + { + "id": 543, + "sname": "游戏543服", + "groupId": 55, + "groupName": "真定城" + }, + { + "id": 544, + "sname": "游戏544服", + "groupId": 55, + "groupName": "真定城" + }, + { + "id": 545, + "sname": "游戏545服", + "groupId": 55, + "groupName": "真定城" + }, + { + "id": 546, + "sname": "游戏546服", + "groupId": 55, + "groupName": "真定城" + }, + { + "id": 547, + "sname": "游戏547服", + "groupId": 55, + "groupName": "真定城" + }, + { + "id": 548, + "sname": "游戏548服", + "groupId": 55, + "groupName": "真定城" + }, + { + "id": 549, + "sname": "游戏549服", + "groupId": 55, + "groupName": "真定城" + }, + { + "id": 550, + "sname": "游戏550服", + "groupId": 56, + "groupName": "真定城" + }, + { + "id": 551, + "sname": "游戏551服", + "groupId": 56, + "groupName": "真定城" + }, + { + "id": 552, + "sname": "游戏552服", + "groupId": 56, + "groupName": "真定城" + }, + { + "id": 553, + "sname": "游戏553服", + "groupId": 56, + "groupName": "真定城" + }, + { + "id": 554, + "sname": "游戏554服", + "groupId": 56, + "groupName": "真定城" + }, + { + "id": 555, + "sname": "游戏555服", + "groupId": 56, + "groupName": "真定城" + }, + { + "id": 556, + "sname": "游戏556服", + "groupId": 56, + "groupName": "真定城" + }, + { + "id": 557, + "sname": "游戏557服", + "groupId": 56, + "groupName": "真定城" + }, + { + "id": 558, + "sname": "游戏558服", + "groupId": 56, + "groupName": "真定城" + }, + { + "id": 559, + "sname": "游戏559服", + "groupId": 56, + "groupName": "真定城" + }, + { + "id": 560, + "sname": "游戏560服", + "groupId": 57, + "groupName": "真定城" + }, + { + "id": 561, + "sname": "游戏561服", + "groupId": 57, + "groupName": "真定城" + }, + { + "id": 562, + "sname": "游戏562服", + "groupId": 57, + "groupName": "真定城" + }, + { + "id": 563, + "sname": "游戏563服", + "groupId": 57, + "groupName": "真定城" + }, + { + "id": 564, + "sname": "游戏564服", + "groupId": 57, + "groupName": "真定城" + }, + { + "id": 565, + "sname": "游戏565服", + "groupId": 57, + "groupName": "真定城" + }, + { + "id": 566, + "sname": "游戏566服", + "groupId": 57, + "groupName": "真定城" + }, + { + "id": 567, + "sname": "游戏567服", + "groupId": 57, + "groupName": "真定城" + }, + { + "id": 568, + "sname": "游戏568服", + "groupId": 57, + "groupName": "真定城" + }, + { + "id": 569, + "sname": "游戏569服", + "groupId": 57, + "groupName": "真定城" + }, + { + "id": 570, + "sname": "游戏570服", + "groupId": 58, + "groupName": "真定城" + }, + { + "id": 571, + "sname": "游戏571服", + "groupId": 58, + "groupName": "真定城" + }, + { + "id": 572, + "sname": "游戏572服", + "groupId": 58, + "groupName": "真定城" + }, + { + "id": 573, + "sname": "游戏573服", + "groupId": 58, + "groupName": "真定城" + }, + { + "id": 574, + "sname": "游戏574服", + "groupId": 58, + "groupName": "真定城" + }, + { + "id": 575, + "sname": "游戏575服", + "groupId": 58, + "groupName": "真定城" + }, + { + "id": 576, + "sname": "游戏576服", + "groupId": 58, + "groupName": "真定城" + }, + { + "id": 577, + "sname": "游戏577服", + "groupId": 58, + "groupName": "真定城" + }, + { + "id": 578, + "sname": "游戏578服", + "groupId": 58, + "groupName": "真定城" + }, + { + "id": 579, + "sname": "游戏579服", + "groupId": 58, + "groupName": "真定城" + }, + { + "id": 580, + "sname": "游戏580服", + "groupId": 59, + "groupName": "真定城" + }, + { + "id": 581, + "sname": "游戏581服", + "groupId": 59, + "groupName": "真定城" + }, + { + "id": 582, + "sname": "游戏582服", + "groupId": 59, + "groupName": "真定城" + }, + { + "id": 583, + "sname": "游戏583服", + "groupId": 59, + "groupName": "真定城" + }, + { + "id": 584, + "sname": "游戏584服", + "groupId": 59, + "groupName": "真定城" + }, + { + "id": 585, + "sname": "游戏585服", + "groupId": 59, + "groupName": "真定城" + }, + { + "id": 586, + "sname": "游戏586服", + "groupId": 59, + "groupName": "真定城" + }, + { + "id": 587, + "sname": "游戏587服", + "groupId": 59, + "groupName": "真定城" + }, + { + "id": 588, + "sname": "游戏588服", + "groupId": 59, + "groupName": "真定城" + }, + { + "id": 589, + "sname": "游戏589服", + "groupId": 59, + "groupName": "真定城" + }, + { + "id": 590, + "sname": "游戏590服", + "groupId": 60, + "groupName": "真定城" + }, + { + "id": 591, + "sname": "游戏591服", + "groupId": 60, + "groupName": "真定城" + }, + { + "id": 592, + "sname": "游戏592服", + "groupId": 60, + "groupName": "真定城" + }, + { + "id": 593, + "sname": "游戏593服", + "groupId": 60, + "groupName": "真定城" + }, + { + "id": 594, + "sname": "游戏594服", + "groupId": 60, + "groupName": "真定城" + }, + { + "id": 595, + "sname": "游戏595服", + "groupId": 60, + "groupName": "真定城" + }, + { + "id": 596, + "sname": "游戏596服", + "groupId": 60, + "groupName": "真定城" + }, + { + "id": 597, + "sname": "游戏597服", + "groupId": 60, + "groupName": "真定城" + }, + { + "id": 598, + "sname": "游戏598服", + "groupId": 60, + "groupName": "真定城" + }, + { + "id": 599, + "sname": "游戏599服", + "groupId": 60, + "groupName": "真定城" + }, + { + "id": 600, + "sname": "游戏600服", + "groupId": 61, + "groupName": "真定城" + }, + { + "id": 601, + "sname": "游戏601服", + "groupId": 61, + "groupName": "真定城" + }, + { + "id": 602, + "sname": "游戏602服", + "groupId": 61, + "groupName": "真定城" + }, + { + "id": 603, + "sname": "游戏603服", + "groupId": 61, + "groupName": "真定城" + }, + { + "id": 604, + "sname": "游戏604服", + "groupId": 61, + "groupName": "真定城" + }, + { + "id": 605, + "sname": "游戏605服", + "groupId": 61, + "groupName": "真定城" + }, + { + "id": 606, + "sname": "游戏606服", + "groupId": 61, + "groupName": "真定城" + }, + { + "id": 607, + "sname": "游戏607服", + "groupId": 61, + "groupName": "真定城" + }, + { + "id": 608, + "sname": "游戏608服", + "groupId": 61, + "groupName": "真定城" + }, + { + "id": 609, + "sname": "游戏609服", + "groupId": 61, + "groupName": "真定城" + }, + { + "id": 610, + "sname": "游戏610服", + "groupId": 62, + "groupName": "真定城" + }, + { + "id": 611, + "sname": "游戏611服", + "groupId": 62, + "groupName": "真定城" + }, + { + "id": 612, + "sname": "游戏612服", + "groupId": 62, + "groupName": "真定城" + }, + { + "id": 613, + "sname": "游戏613服", + "groupId": 62, + "groupName": "真定城" + }, + { + "id": 614, + "sname": "游戏614服", + "groupId": 62, + "groupName": "真定城" + }, + { + "id": 615, + "sname": "游戏615服", + "groupId": 62, + "groupName": "真定城" + }, + { + "id": 616, + "sname": "游戏616服", + "groupId": 62, + "groupName": "真定城" + }, + { + "id": 617, + "sname": "游戏617服", + "groupId": 62, + "groupName": "真定城" + }, + { + "id": 618, + "sname": "游戏618服", + "groupId": 62, + "groupName": "真定城" + }, + { + "id": 619, + "sname": "游戏619服", + "groupId": 62, + "groupName": "真定城" + }, + { + "id": 620, + "sname": "游戏620服", + "groupId": 63, + "groupName": "真定城" + }, + { + "id": 621, + "sname": "游戏621服", + "groupId": 63, + "groupName": "真定城" + }, + { + "id": 622, + "sname": "游戏622服", + "groupId": 63, + "groupName": "真定城" + }, + { + "id": 623, + "sname": "游戏623服", + "groupId": 63, + "groupName": "真定城" + }, + { + "id": 624, + "sname": "游戏624服", + "groupId": 63, + "groupName": "真定城" + }, + { + "id": 625, + "sname": "游戏625服", + "groupId": 63, + "groupName": "真定城" + }, + { + "id": 626, + "sname": "游戏626服", + "groupId": 63, + "groupName": "真定城" + }, + { + "id": 627, + "sname": "游戏627服", + "groupId": 63, + "groupName": "真定城" + }, + { + "id": 628, + "sname": "游戏628服", + "groupId": 63, + "groupName": "真定城" + }, + { + "id": 629, + "sname": "游戏629服", + "groupId": 63, + "groupName": "真定城" + }, + { + "id": 630, + "sname": "游戏630服", + "groupId": 64, + "groupName": "真定城" + }, + { + "id": 631, + "sname": "游戏631服", + "groupId": 64, + "groupName": "真定城" + }, + { + "id": 632, + "sname": "游戏632服", + "groupId": 64, + "groupName": "真定城" + }, + { + "id": 633, + "sname": "游戏633服", + "groupId": 64, + "groupName": "真定城" + }, + { + "id": 634, + "sname": "游戏634服", + "groupId": 64, + "groupName": "真定城" + }, + { + "id": 635, + "sname": "游戏635服", + "groupId": 64, + "groupName": "真定城" + }, + { + "id": 636, + "sname": "游戏636服", + "groupId": 64, + "groupName": "真定城" + }, + { + "id": 637, + "sname": "游戏637服", + "groupId": 64, + "groupName": "真定城" + }, + { + "id": 638, + "sname": "游戏638服", + "groupId": 64, + "groupName": "真定城" + }, + { + "id": 639, + "sname": "游戏639服", + "groupId": 64, + "groupName": "真定城" + }, + { + "id": 640, + "sname": "游戏640服", + "groupId": 65, + "groupName": "真定城" + }, + { + "id": 641, + "sname": "游戏641服", + "groupId": 65, + "groupName": "真定城" + }, + { + "id": 642, + "sname": "游戏642服", + "groupId": 65, + "groupName": "真定城" + }, + { + "id": 643, + "sname": "游戏643服", + "groupId": 65, + "groupName": "真定城" + }, + { + "id": 644, + "sname": "游戏644服", + "groupId": 65, + "groupName": "真定城" + }, + { + "id": 645, + "sname": "游戏645服", + "groupId": 65, + "groupName": "真定城" + }, + { + "id": 646, + "sname": "游戏646服", + "groupId": 65, + "groupName": "真定城" + }, + { + "id": 647, + "sname": "游戏647服", + "groupId": 65, + "groupName": "真定城" + }, + { + "id": 648, + "sname": "游戏648服", + "groupId": 65, + "groupName": "真定城" + }, + { + "id": 649, + "sname": "游戏649服", + "groupId": 65, + "groupName": "真定城" + }, + { + "id": 650, + "sname": "游戏650服", + "groupId": 66, + "groupName": "真定城" + }, + { + "id": 651, + "sname": "游戏651服", + "groupId": 66, + "groupName": "真定城" + }, + { + "id": 652, + "sname": "游戏652服", + "groupId": 66, + "groupName": "真定城" + }, + { + "id": 653, + "sname": "游戏653服", + "groupId": 66, + "groupName": "真定城" + }, + { + "id": 654, + "sname": "游戏654服", + "groupId": 66, + "groupName": "真定城" + }, + { + "id": 655, + "sname": "游戏655服", + "groupId": 66, + "groupName": "真定城" + }, + { + "id": 656, + "sname": "游戏656服", + "groupId": 66, + "groupName": "真定城" + }, + { + "id": 657, + "sname": "游戏657服", + "groupId": 66, + "groupName": "真定城" + }, + { + "id": 658, + "sname": "游戏658服", + "groupId": 66, + "groupName": "真定城" + }, + { + "id": 659, + "sname": "游戏659服", + "groupId": 66, + "groupName": "真定城" + }, + { + "id": 660, + "sname": "游戏660服", + "groupId": 67, + "groupName": "真定城" + }, + { + "id": 661, + "sname": "游戏661服", + "groupId": 67, + "groupName": "真定城" + }, + { + "id": 662, + "sname": "游戏662服", + "groupId": 67, + "groupName": "真定城" + }, + { + "id": 663, + "sname": "游戏663服", + "groupId": 67, + "groupName": "真定城" + }, + { + "id": 664, + "sname": "游戏664服", + "groupId": 67, + "groupName": "真定城" + }, + { + "id": 665, + "sname": "游戏665服", + "groupId": 67, + "groupName": "真定城" + }, + { + "id": 666, + "sname": "游戏666服", + "groupId": 67, + "groupName": "真定城" + }, + { + "id": 667, + "sname": "游戏667服", + "groupId": 67, + "groupName": "真定城" + }, + { + "id": 668, + "sname": "游戏668服", + "groupId": 67, + "groupName": "真定城" + }, + { + "id": 669, + "sname": "游戏669服", + "groupId": 67, + "groupName": "真定城" + }, + { + "id": 670, + "sname": "游戏670服", + "groupId": 68, + "groupName": "真定城" + }, + { + "id": 671, + "sname": "游戏671服", + "groupId": 68, + "groupName": "真定城" + }, + { + "id": 672, + "sname": "游戏672服", + "groupId": 68, + "groupName": "真定城" + }, + { + "id": 673, + "sname": "游戏673服", + "groupId": 68, + "groupName": "真定城" + }, + { + "id": 674, + "sname": "游戏674服", + "groupId": 68, + "groupName": "真定城" + }, + { + "id": 675, + "sname": "游戏675服", + "groupId": 68, + "groupName": "真定城" + }, + { + "id": 676, + "sname": "游戏676服", + "groupId": 68, + "groupName": "真定城" + }, + { + "id": 677, + "sname": "游戏677服", + "groupId": 68, + "groupName": "真定城" + }, + { + "id": 678, + "sname": "游戏678服", + "groupId": 68, + "groupName": "真定城" + }, + { + "id": 679, + "sname": "游戏679服", + "groupId": 68, + "groupName": "真定城" + }, + { + "id": 680, + "sname": "游戏680服", + "groupId": 69, + "groupName": "真定城" + }, + { + "id": 681, + "sname": "游戏681服", + "groupId": 69, + "groupName": "真定城" + }, + { + "id": 682, + "sname": "游戏682服", + "groupId": 69, + "groupName": "真定城" + }, + { + "id": 683, + "sname": "游戏683服", + "groupId": 69, + "groupName": "真定城" + }, + { + "id": 684, + "sname": "游戏684服", + "groupId": 69, + "groupName": "真定城" + }, + { + "id": 685, + "sname": "游戏685服", + "groupId": 69, + "groupName": "真定城" + }, + { + "id": 686, + "sname": "游戏686服", + "groupId": 69, + "groupName": "真定城" + }, + { + "id": 687, + "sname": "游戏687服", + "groupId": 69, + "groupName": "真定城" + }, + { + "id": 688, + "sname": "游戏688服", + "groupId": 69, + "groupName": "真定城" + }, + { + "id": 689, + "sname": "游戏689服", + "groupId": 69, + "groupName": "真定城" + }, + { + "id": 690, + "sname": "游戏690服", + "groupId": 70, + "groupName": "真定城" + }, + { + "id": 691, + "sname": "游戏691服", + "groupId": 70, + "groupName": "真定城" + }, + { + "id": 692, + "sname": "游戏692服", + "groupId": 70, + "groupName": "真定城" + }, + { + "id": 693, + "sname": "游戏693服", + "groupId": 70, + "groupName": "真定城" + }, + { + "id": 694, + "sname": "游戏694服", + "groupId": 70, + "groupName": "真定城" + }, + { + "id": 695, + "sname": "游戏695服", + "groupId": 70, + "groupName": "真定城" + }, + { + "id": 696, + "sname": "游戏696服", + "groupId": 70, + "groupName": "真定城" + }, + { + "id": 697, + "sname": "游戏697服", + "groupId": 70, + "groupName": "真定城" + }, + { + "id": 698, + "sname": "游戏698服", + "groupId": 70, + "groupName": "真定城" + }, + { + "id": 699, + "sname": "游戏699服", + "groupId": 70, + "groupName": "真定城" + }, + { + "id": 700, + "sname": "游戏700服", + "groupId": 71, + "groupName": "真定城" + }, + { + "id": 701, + "sname": "游戏701服", + "groupId": 71, + "groupName": "真定城" + }, + { + "id": 702, + "sname": "游戏702服", + "groupId": 71, + "groupName": "真定城" + }, + { + "id": 703, + "sname": "游戏703服", + "groupId": 71, + "groupName": "真定城" + }, + { + "id": 704, + "sname": "游戏704服", + "groupId": 71, + "groupName": "真定城" + }, + { + "id": 705, + "sname": "游戏705服", + "groupId": 71, + "groupName": "真定城" + }, + { + "id": 706, + "sname": "游戏706服", + "groupId": 71, + "groupName": "真定城" + }, + { + "id": 707, + "sname": "游戏707服", + "groupId": 71, + "groupName": "真定城" + }, + { + "id": 708, + "sname": "游戏708服", + "groupId": 71, + "groupName": "真定城" + }, + { + "id": 709, + "sname": "游戏709服", + "groupId": 71, + "groupName": "真定城" + }, + { + "id": 710, + "sname": "游戏710服", + "groupId": 72, + "groupName": "真定城" + }, + { + "id": 711, + "sname": "游戏711服", + "groupId": 72, + "groupName": "真定城" + }, + { + "id": 712, + "sname": "游戏712服", + "groupId": 72, + "groupName": "真定城" + }, + { + "id": 713, + "sname": "游戏713服", + "groupId": 72, + "groupName": "真定城" + }, + { + "id": 714, + "sname": "游戏714服", + "groupId": 72, + "groupName": "真定城" + }, + { + "id": 715, + "sname": "游戏715服", + "groupId": 72, + "groupName": "真定城" + }, + { + "id": 716, + "sname": "游戏716服", + "groupId": 72, + "groupName": "真定城" + }, + { + "id": 717, + "sname": "游戏717服", + "groupId": 72, + "groupName": "真定城" + }, + { + "id": 718, + "sname": "游戏718服", + "groupId": 72, + "groupName": "真定城" + }, + { + "id": 719, + "sname": "游戏719服", + "groupId": 72, + "groupName": "真定城" + }, + { + "id": 720, + "sname": "游戏720服", + "groupId": 73, + "groupName": "真定城" + }, + { + "id": 721, + "sname": "游戏721服", + "groupId": 73, + "groupName": "真定城" + }, + { + "id": 722, + "sname": "游戏722服", + "groupId": 73, + "groupName": "真定城" + }, + { + "id": 723, + "sname": "游戏723服", + "groupId": 73, + "groupName": "真定城" + }, + { + "id": 724, + "sname": "游戏724服", + "groupId": 73, + "groupName": "真定城" + }, + { + "id": 725, + "sname": "游戏725服", + "groupId": 73, + "groupName": "真定城" + }, + { + "id": 726, + "sname": "游戏726服", + "groupId": 73, + "groupName": "真定城" + }, + { + "id": 727, + "sname": "游戏727服", + "groupId": 73, + "groupName": "真定城" + }, + { + "id": 728, + "sname": "游戏728服", + "groupId": 73, + "groupName": "真定城" + }, + { + "id": 729, + "sname": "游戏729服", + "groupId": 73, + "groupName": "真定城" + }, + { + "id": 730, + "sname": "游戏730服", + "groupId": 74, + "groupName": "真定城" + }, + { + "id": 731, + "sname": "游戏731服", + "groupId": 74, + "groupName": "真定城" + }, + { + "id": 732, + "sname": "游戏732服", + "groupId": 74, + "groupName": "真定城" + }, + { + "id": 733, + "sname": "游戏733服", + "groupId": 74, + "groupName": "真定城" + }, + { + "id": 734, + "sname": "游戏734服", + "groupId": 74, + "groupName": "真定城" + }, + { + "id": 735, + "sname": "游戏735服", + "groupId": 74, + "groupName": "真定城" + }, + { + "id": 736, + "sname": "游戏736服", + "groupId": 74, + "groupName": "真定城" + }, + { + "id": 737, + "sname": "游戏737服", + "groupId": 74, + "groupName": "真定城" + }, + { + "id": 738, + "sname": "游戏738服", + "groupId": 74, + "groupName": "真定城" + }, + { + "id": 739, + "sname": "游戏739服", + "groupId": 74, + "groupName": "真定城" + }, + { + "id": 740, + "sname": "游戏740服", + "groupId": 75, + "groupName": "真定城" + }, + { + "id": 741, + "sname": "游戏741服", + "groupId": 75, + "groupName": "真定城" + }, + { + "id": 742, + "sname": "游戏742服", + "groupId": 75, + "groupName": "真定城" + }, + { + "id": 743, + "sname": "游戏743服", + "groupId": 75, + "groupName": "真定城" + }, + { + "id": 744, + "sname": "游戏744服", + "groupId": 75, + "groupName": "真定城" + }, + { + "id": 745, + "sname": "游戏745服", + "groupId": 75, + "groupName": "真定城" + }, + { + "id": 746, + "sname": "游戏746服", + "groupId": 75, + "groupName": "真定城" + }, + { + "id": 747, + "sname": "游戏747服", + "groupId": 75, + "groupName": "真定城" + }, + { + "id": 748, + "sname": "游戏748服", + "groupId": 75, + "groupName": "真定城" + }, + { + "id": 749, + "sname": "游戏749服", + "groupId": 75, + "groupName": "真定城" + }, + { + "id": 750, + "sname": "游戏750服", + "groupId": 76, + "groupName": "真定城" + }, + { + "id": 751, + "sname": "游戏751服", + "groupId": 76, + "groupName": "真定城" + }, + { + "id": 752, + "sname": "游戏752服", + "groupId": 76, + "groupName": "真定城" + }, + { + "id": 753, + "sname": "游戏753服", + "groupId": 76, + "groupName": "真定城" + }, + { + "id": 754, + "sname": "游戏754服", + "groupId": 76, + "groupName": "真定城" + }, + { + "id": 755, + "sname": "游戏755服", + "groupId": 76, + "groupName": "真定城" + }, + { + "id": 756, + "sname": "游戏756服", + "groupId": 76, + "groupName": "真定城" + }, + { + "id": 757, + "sname": "游戏757服", + "groupId": 76, + "groupName": "真定城" + }, + { + "id": 758, + "sname": "游戏758服", + "groupId": 76, + "groupName": "真定城" + }, + { + "id": 759, + "sname": "游戏759服", + "groupId": 76, + "groupName": "真定城" + }, + { + "id": 760, + "sname": "游戏760服", + "groupId": 77, + "groupName": "真定城" + }, + { + "id": 761, + "sname": "游戏761服", + "groupId": 77, + "groupName": "真定城" + }, + { + "id": 762, + "sname": "游戏762服", + "groupId": 77, + "groupName": "真定城" + }, + { + "id": 763, + "sname": "游戏763服", + "groupId": 77, + "groupName": "真定城" + }, + { + "id": 764, + "sname": "游戏764服", + "groupId": 77, + "groupName": "真定城" + }, + { + "id": 765, + "sname": "游戏765服", + "groupId": 77, + "groupName": "真定城" + }, + { + "id": 766, + "sname": "游戏766服", + "groupId": 77, + "groupName": "真定城" + }, + { + "id": 767, + "sname": "游戏767服", + "groupId": 77, + "groupName": "真定城" + }, + { + "id": 768, + "sname": "游戏768服", + "groupId": 77, + "groupName": "真定城" + }, + { + "id": 769, + "sname": "游戏769服", + "groupId": 77, + "groupName": "真定城" + }, + { + "id": 770, + "sname": "游戏770服", + "groupId": 78, + "groupName": "真定城" + }, + { + "id": 771, + "sname": "游戏771服", + "groupId": 78, + "groupName": "真定城" + }, + { + "id": 772, + "sname": "游戏772服", + "groupId": 78, + "groupName": "真定城" + }, + { + "id": 773, + "sname": "游戏773服", + "groupId": 78, + "groupName": "真定城" + }, + { + "id": 774, + "sname": "游戏774服", + "groupId": 78, + "groupName": "真定城" + }, + { + "id": 775, + "sname": "游戏775服", + "groupId": 78, + "groupName": "真定城" + }, + { + "id": 776, + "sname": "游戏776服", + "groupId": 78, + "groupName": "真定城" + }, + { + "id": 777, + "sname": "游戏777服", + "groupId": 78, + "groupName": "真定城" + }, + { + "id": 778, + "sname": "游戏778服", + "groupId": 78, + "groupName": "真定城" + }, + { + "id": 779, + "sname": "游戏779服", + "groupId": 78, + "groupName": "真定城" + }, + { + "id": 780, + "sname": "游戏780服", + "groupId": 79, + "groupName": "真定城" + }, + { + "id": 781, + "sname": "游戏781服", + "groupId": 79, + "groupName": "真定城" + }, + { + "id": 782, + "sname": "游戏782服", + "groupId": 79, + "groupName": "真定城" + }, + { + "id": 783, + "sname": "游戏783服", + "groupId": 79, + "groupName": "真定城" + }, + { + "id": 784, + "sname": "游戏784服", + "groupId": 79, + "groupName": "真定城" + }, + { + "id": 785, + "sname": "游戏785服", + "groupId": 79, + "groupName": "真定城" + }, + { + "id": 786, + "sname": "游戏786服", + "groupId": 79, + "groupName": "真定城" + }, + { + "id": 787, + "sname": "游戏787服", + "groupId": 79, + "groupName": "真定城" + }, + { + "id": 788, + "sname": "游戏788服", + "groupId": 79, + "groupName": "真定城" + }, + { + "id": 789, + "sname": "游戏789服", + "groupId": 79, + "groupName": "真定城" + }, + { + "id": 790, + "sname": "游戏790服", + "groupId": 80, + "groupName": "真定城" + }, + { + "id": 791, + "sname": "游戏791服", + "groupId": 80, + "groupName": "真定城" + }, + { + "id": 792, + "sname": "游戏792服", + "groupId": 80, + "groupName": "真定城" + }, + { + "id": 793, + "sname": "游戏793服", + "groupId": 80, + "groupName": "真定城" + }, + { + "id": 794, + "sname": "游戏794服", + "groupId": 80, + "groupName": "真定城" + }, + { + "id": 795, + "sname": "游戏795服", + "groupId": 80, + "groupName": "真定城" + }, + { + "id": 796, + "sname": "游戏796服", + "groupId": 80, + "groupName": "真定城" + }, + { + "id": 797, + "sname": "游戏797服", + "groupId": 80, + "groupName": "真定城" + }, + { + "id": 798, + "sname": "游戏798服", + "groupId": 80, + "groupName": "真定城" + }, + { + "id": 799, + "sname": "游戏799服", + "groupId": 80, + "groupName": "真定城" + }, + { + "id": 800, + "sname": "游戏800服", + "groupId": 81, + "groupName": "真定城" + }, + { + "id": 801, + "sname": "游戏801服", + "groupId": 81, + "groupName": "真定城" + }, + { + "id": 802, + "sname": "游戏802服", + "groupId": 81, + "groupName": "真定城" + }, + { + "id": 803, + "sname": "游戏803服", + "groupId": 81, + "groupName": "真定城" + }, + { + "id": 804, + "sname": "游戏804服", + "groupId": 81, + "groupName": "真定城" + }, + { + "id": 805, + "sname": "游戏805服", + "groupId": 81, + "groupName": "真定城" + }, + { + "id": 806, + "sname": "游戏806服", + "groupId": 81, + "groupName": "真定城" + }, + { + "id": 807, + "sname": "游戏807服", + "groupId": 81, + "groupName": "真定城" + }, + { + "id": 808, + "sname": "游戏808服", + "groupId": 81, + "groupName": "真定城" + }, + { + "id": 809, + "sname": "游戏809服", + "groupId": 81, + "groupName": "真定城" + }, + { + "id": 810, + "sname": "游戏810服", + "groupId": 82, + "groupName": "真定城" + }, + { + "id": 811, + "sname": "游戏811服", + "groupId": 82, + "groupName": "真定城" + }, + { + "id": 812, + "sname": "游戏812服", + "groupId": 82, + "groupName": "真定城" + }, + { + "id": 813, + "sname": "游戏813服", + "groupId": 82, + "groupName": "真定城" + }, + { + "id": 814, + "sname": "游戏814服", + "groupId": 82, + "groupName": "真定城" + }, + { + "id": 815, + "sname": "游戏815服", + "groupId": 82, + "groupName": "真定城" + }, + { + "id": 816, + "sname": "游戏816服", + "groupId": 82, + "groupName": "真定城" + }, + { + "id": 817, + "sname": "游戏817服", + "groupId": 82, + "groupName": "真定城" + }, + { + "id": 818, + "sname": "游戏818服", + "groupId": 82, + "groupName": "真定城" + }, + { + "id": 819, + "sname": "游戏819服", + "groupId": 82, + "groupName": "真定城" + }, + { + "id": 820, + "sname": "游戏820服", + "groupId": 83, + "groupName": "真定城" + }, + { + "id": 821, + "sname": "游戏821服", + "groupId": 83, + "groupName": "真定城" + }, + { + "id": 822, + "sname": "游戏822服", + "groupId": 83, + "groupName": "真定城" + }, + { + "id": 823, + "sname": "游戏823服", + "groupId": 83, + "groupName": "真定城" + }, + { + "id": 824, + "sname": "游戏824服", + "groupId": 83, + "groupName": "真定城" + }, + { + "id": 825, + "sname": "游戏825服", + "groupId": 83, + "groupName": "真定城" + }, + { + "id": 826, + "sname": "游戏826服", + "groupId": 83, + "groupName": "真定城" + }, + { + "id": 827, + "sname": "游戏827服", + "groupId": 83, + "groupName": "真定城" + }, + { + "id": 828, + "sname": "游戏828服", + "groupId": 83, + "groupName": "真定城" + }, + { + "id": 829, + "sname": "游戏829服", + "groupId": 83, + "groupName": "真定城" + }, + { + "id": 830, + "sname": "游戏830服", + "groupId": 84, + "groupName": "真定城" + }, + { + "id": 831, + "sname": "游戏831服", + "groupId": 84, + "groupName": "真定城" + }, + { + "id": 832, + "sname": "游戏832服", + "groupId": 84, + "groupName": "真定城" + }, + { + "id": 833, + "sname": "游戏833服", + "groupId": 84, + "groupName": "真定城" + }, + { + "id": 834, + "sname": "游戏834服", + "groupId": 84, + "groupName": "真定城" + }, + { + "id": 835, + "sname": "游戏835服", + "groupId": 84, + "groupName": "真定城" + }, + { + "id": 836, + "sname": "游戏836服", + "groupId": 84, + "groupName": "真定城" + }, + { + "id": 837, + "sname": "游戏837服", + "groupId": 84, + "groupName": "真定城" + }, + { + "id": 838, + "sname": "游戏838服", + "groupId": 84, + "groupName": "真定城" + }, + { + "id": 839, + "sname": "游戏839服", + "groupId": 84, + "groupName": "真定城" + }, + { + "id": 840, + "sname": "游戏840服", + "groupId": 85, + "groupName": "真定城" + }, + { + "id": 841, + "sname": "游戏841服", + "groupId": 85, + "groupName": "真定城" + }, + { + "id": 842, + "sname": "游戏842服", + "groupId": 85, + "groupName": "真定城" + }, + { + "id": 843, + "sname": "游戏843服", + "groupId": 85, + "groupName": "真定城" + }, + { + "id": 844, + "sname": "游戏844服", + "groupId": 85, + "groupName": "真定城" + }, + { + "id": 845, + "sname": "游戏845服", + "groupId": 85, + "groupName": "真定城" + }, + { + "id": 846, + "sname": "游戏846服", + "groupId": 85, + "groupName": "真定城" + }, + { + "id": 847, + "sname": "游戏847服", + "groupId": 85, + "groupName": "真定城" + }, + { + "id": 848, + "sname": "游戏848服", + "groupId": 85, + "groupName": "真定城" + }, + { + "id": 849, + "sname": "游戏849服", + "groupId": 85, + "groupName": "真定城" + }, + { + "id": 850, + "sname": "游戏850服", + "groupId": 86, + "groupName": "真定城" + }, + { + "id": 851, + "sname": "游戏851服", + "groupId": 86, + "groupName": "真定城" + }, + { + "id": 852, + "sname": "游戏852服", + "groupId": 86, + "groupName": "真定城" + }, + { + "id": 853, + "sname": "游戏853服", + "groupId": 86, + "groupName": "真定城" + }, + { + "id": 854, + "sname": "游戏854服", + "groupId": 86, + "groupName": "真定城" + }, + { + "id": 855, + "sname": "游戏855服", + "groupId": 86, + "groupName": "真定城" + }, + { + "id": 856, + "sname": "游戏856服", + "groupId": 86, + "groupName": "真定城" + }, + { + "id": 857, + "sname": "游戏857服", + "groupId": 86, + "groupName": "真定城" + }, + { + "id": 858, + "sname": "游戏858服", + "groupId": 86, + "groupName": "真定城" + }, + { + "id": 859, + "sname": "游戏859服", + "groupId": 86, + "groupName": "真定城" + }, + { + "id": 860, + "sname": "游戏860服", + "groupId": 87, + "groupName": "真定城" + }, + { + "id": 861, + "sname": "游戏861服", + "groupId": 87, + "groupName": "真定城" + }, + { + "id": 862, + "sname": "游戏862服", + "groupId": 87, + "groupName": "真定城" + }, + { + "id": 863, + "sname": "游戏863服", + "groupId": 87, + "groupName": "真定城" + }, + { + "id": 864, + "sname": "游戏864服", + "groupId": 87, + "groupName": "真定城" + }, + { + "id": 865, + "sname": "游戏865服", + "groupId": 87, + "groupName": "真定城" + }, + { + "id": 866, + "sname": "游戏866服", + "groupId": 87, + "groupName": "真定城" + }, + { + "id": 867, + "sname": "游戏867服", + "groupId": 87, + "groupName": "真定城" + }, + { + "id": 868, + "sname": "游戏868服", + "groupId": 87, + "groupName": "真定城" + }, + { + "id": 869, + "sname": "游戏869服", + "groupId": 87, + "groupName": "真定城" + }, + { + "id": 870, + "sname": "游戏870服", + "groupId": 88, + "groupName": "真定城" + }, + { + "id": 871, + "sname": "游戏871服", + "groupId": 88, + "groupName": "真定城" + }, + { + "id": 872, + "sname": "游戏872服", + "groupId": 88, + "groupName": "真定城" + }, + { + "id": 873, + "sname": "游戏873服", + "groupId": 88, + "groupName": "真定城" + }, + { + "id": 874, + "sname": "游戏874服", + "groupId": 88, + "groupName": "真定城" + }, + { + "id": 875, + "sname": "游戏875服", + "groupId": 88, + "groupName": "真定城" + }, + { + "id": 876, + "sname": "游戏876服", + "groupId": 88, + "groupName": "真定城" + }, + { + "id": 877, + "sname": "游戏877服", + "groupId": 88, + "groupName": "真定城" + }, + { + "id": 878, + "sname": "游戏878服", + "groupId": 88, + "groupName": "真定城" + }, + { + "id": 879, + "sname": "游戏879服", + "groupId": 88, + "groupName": "真定城" + }, + { + "id": 880, + "sname": "游戏880服", + "groupId": 89, + "groupName": "真定城" + }, + { + "id": 881, + "sname": "游戏881服", + "groupId": 89, + "groupName": "真定城" + }, + { + "id": 882, + "sname": "游戏882服", + "groupId": 89, + "groupName": "真定城" + }, + { + "id": 883, + "sname": "游戏883服", + "groupId": 89, + "groupName": "真定城" + }, + { + "id": 884, + "sname": "游戏884服", + "groupId": 89, + "groupName": "真定城" + }, + { + "id": 885, + "sname": "游戏885服", + "groupId": 89, + "groupName": "真定城" + }, + { + "id": 886, + "sname": "游戏886服", + "groupId": 89, + "groupName": "真定城" + }, + { + "id": 887, + "sname": "游戏887服", + "groupId": 89, + "groupName": "真定城" + }, + { + "id": 888, + "sname": "游戏888服", + "groupId": 89, + "groupName": "真定城" + }, + { + "id": 889, + "sname": "游戏889服", + "groupId": 89, + "groupName": "真定城" + }, + { + "id": 890, + "sname": "游戏890服", + "groupId": 90, + "groupName": "真定城" + }, + { + "id": 891, + "sname": "游戏891服", + "groupId": 90, + "groupName": "真定城" + }, + { + "id": 892, + "sname": "游戏892服", + "groupId": 90, + "groupName": "真定城" + }, + { + "id": 893, + "sname": "游戏893服", + "groupId": 90, + "groupName": "真定城" + }, + { + "id": 894, + "sname": "游戏894服", + "groupId": 90, + "groupName": "真定城" + }, + { + "id": 895, + "sname": "游戏895服", + "groupId": 90, + "groupName": "真定城" + }, + { + "id": 896, + "sname": "游戏896服", + "groupId": 90, + "groupName": "真定城" + }, + { + "id": 897, + "sname": "游戏897服", + "groupId": 90, + "groupName": "真定城" + }, + { + "id": 898, + "sname": "游戏898服", + "groupId": 90, + "groupName": "真定城" + }, + { + "id": 899, + "sname": "游戏899服", + "groupId": 90, + "groupName": "真定城" + }, + { + "id": 900, + "sname": "游戏900服", + "groupId": 91, + "groupName": "真定城" + }, + { + "id": 901, + "sname": "游戏901服", + "groupId": 91, + "groupName": "真定城" + }, + { + "id": 902, + "sname": "游戏902服", + "groupId": 91, + "groupName": "真定城" + }, + { + "id": 903, + "sname": "游戏903服", + "groupId": 91, + "groupName": "真定城" + }, + { + "id": 904, + "sname": "游戏904服", + "groupId": 91, + "groupName": "真定城" + }, + { + "id": 905, + "sname": "游戏905服", + "groupId": 91, + "groupName": "真定城" + }, + { + "id": 906, + "sname": "游戏906服", + "groupId": 91, + "groupName": "真定城" + }, + { + "id": 907, + "sname": "游戏907服", + "groupId": 91, + "groupName": "真定城" + }, + { + "id": 908, + "sname": "游戏908服", + "groupId": 91, + "groupName": "真定城" + }, + { + "id": 909, + "sname": "游戏909服", + "groupId": 91, + "groupName": "真定城" + }, + { + "id": 910, + "sname": "游戏910服", + "groupId": 92, + "groupName": "真定城" + }, + { + "id": 911, + "sname": "游戏911服", + "groupId": 92, + "groupName": "真定城" + }, + { + "id": 912, + "sname": "游戏912服", + "groupId": 92, + "groupName": "真定城" + }, + { + "id": 913, + "sname": "游戏913服", + "groupId": 92, + "groupName": "真定城" + }, + { + "id": 914, + "sname": "游戏914服", + "groupId": 92, + "groupName": "真定城" + }, + { + "id": 915, + "sname": "游戏915服", + "groupId": 92, + "groupName": "真定城" + }, + { + "id": 916, + "sname": "游戏916服", + "groupId": 92, + "groupName": "真定城" + }, + { + "id": 917, + "sname": "游戏917服", + "groupId": 92, + "groupName": "真定城" + }, + { + "id": 918, + "sname": "游戏918服", + "groupId": 92, + "groupName": "真定城" + }, + { + "id": 919, + "sname": "游戏919服", + "groupId": 92, + "groupName": "真定城" + }, + { + "id": 920, + "sname": "游戏920服", + "groupId": 93, + "groupName": "真定城" + }, + { + "id": 921, + "sname": "游戏921服", + "groupId": 93, + "groupName": "真定城" + }, + { + "id": 922, + "sname": "游戏922服", + "groupId": 93, + "groupName": "真定城" + }, + { + "id": 923, + "sname": "游戏923服", + "groupId": 93, + "groupName": "真定城" + }, + { + "id": 924, + "sname": "游戏924服", + "groupId": 93, + "groupName": "真定城" + }, + { + "id": 925, + "sname": "游戏925服", + "groupId": 93, + "groupName": "真定城" + }, + { + "id": 926, + "sname": "游戏926服", + "groupId": 93, + "groupName": "真定城" + }, + { + "id": 927, + "sname": "游戏927服", + "groupId": 93, + "groupName": "真定城" + }, + { + "id": 928, + "sname": "游戏928服", + "groupId": 93, + "groupName": "真定城" + }, + { + "id": 929, + "sname": "游戏929服", + "groupId": 93, + "groupName": "真定城" + }, + { + "id": 930, + "sname": "游戏930服", + "groupId": 94, + "groupName": "真定城" + }, + { + "id": 931, + "sname": "游戏931服", + "groupId": 94, + "groupName": "真定城" + }, + { + "id": 932, + "sname": "游戏932服", + "groupId": 94, + "groupName": "真定城" + }, + { + "id": 933, + "sname": "游戏933服", + "groupId": 94, + "groupName": "真定城" + }, + { + "id": 934, + "sname": "游戏934服", + "groupId": 94, + "groupName": "真定城" + }, + { + "id": 935, + "sname": "游戏935服", + "groupId": 94, + "groupName": "真定城" + }, + { + "id": 936, + "sname": "游戏936服", + "groupId": 94, + "groupName": "真定城" + }, + { + "id": 937, + "sname": "游戏937服", + "groupId": 94, + "groupName": "真定城" + }, + { + "id": 938, + "sname": "游戏938服", + "groupId": 94, + "groupName": "真定城" + }, + { + "id": 939, + "sname": "游戏939服", + "groupId": 94, + "groupName": "真定城" + }, + { + "id": 940, + "sname": "游戏940服", + "groupId": 95, + "groupName": "真定城" + }, + { + "id": 941, + "sname": "游戏941服", + "groupId": 95, + "groupName": "真定城" + }, + { + "id": 942, + "sname": "游戏942服", + "groupId": 95, + "groupName": "真定城" + }, + { + "id": 943, + "sname": "游戏943服", + "groupId": 95, + "groupName": "真定城" + }, + { + "id": 944, + "sname": "游戏944服", + "groupId": 95, + "groupName": "真定城" + }, + { + "id": 945, + "sname": "游戏945服", + "groupId": 95, + "groupName": "真定城" + }, + { + "id": 946, + "sname": "游戏946服", + "groupId": 95, + "groupName": "真定城" + }, + { + "id": 947, + "sname": "游戏947服", + "groupId": 95, + "groupName": "真定城" + }, + { + "id": 948, + "sname": "游戏948服", + "groupId": 95, + "groupName": "真定城" + }, + { + "id": 949, + "sname": "游戏949服", + "groupId": 95, + "groupName": "真定城" + }, + { + "id": 950, + "sname": "游戏950服", + "groupId": 96, + "groupName": "真定城" + }, + { + "id": 951, + "sname": "游戏951服", + "groupId": 96, + "groupName": "真定城" + }, + { + "id": 952, + "sname": "游戏952服", + "groupId": 96, + "groupName": "真定城" + }, + { + "id": 953, + "sname": "游戏953服", + "groupId": 96, + "groupName": "真定城" + }, + { + "id": 954, + "sname": "游戏954服", + "groupId": 96, + "groupName": "真定城" + }, + { + "id": 955, + "sname": "游戏955服", + "groupId": 96, + "groupName": "真定城" + }, + { + "id": 956, + "sname": "游戏956服", + "groupId": 96, + "groupName": "真定城" + }, + { + "id": 957, + "sname": "游戏957服", + "groupId": 96, + "groupName": "真定城" + }, + { + "id": 958, + "sname": "游戏958服", + "groupId": 96, + "groupName": "真定城" + }, + { + "id": 959, + "sname": "游戏959服", + "groupId": 96, + "groupName": "真定城" + }, + { + "id": 960, + "sname": "游戏960服", + "groupId": 97, + "groupName": "真定城" + }, + { + "id": 961, + "sname": "游戏961服", + "groupId": 97, + "groupName": "真定城" + }, + { + "id": 962, + "sname": "游戏962服", + "groupId": 97, + "groupName": "真定城" + }, + { + "id": 963, + "sname": "游戏963服", + "groupId": 97, + "groupName": "真定城" + }, + { + "id": 964, + "sname": "游戏964服", + "groupId": 97, + "groupName": "真定城" + }, + { + "id": 965, + "sname": "游戏965服", + "groupId": 97, + "groupName": "真定城" + }, + { + "id": 966, + "sname": "游戏966服", + "groupId": 97, + "groupName": "真定城" + }, + { + "id": 967, + "sname": "游戏967服", + "groupId": 97, + "groupName": "真定城" + }, + { + "id": 968, + "sname": "游戏968服", + "groupId": 97, + "groupName": "真定城" + }, + { + "id": 969, + "sname": "游戏969服", + "groupId": 97, + "groupName": "真定城" + }, + { + "id": 970, + "sname": "游戏970服", + "groupId": 98, + "groupName": "真定城" + }, + { + "id": 971, + "sname": "游戏971服", + "groupId": 98, + "groupName": "真定城" + }, + { + "id": 972, + "sname": "游戏972服", + "groupId": 98, + "groupName": "真定城" + }, + { + "id": 973, + "sname": "游戏973服", + "groupId": 98, + "groupName": "真定城" + }, + { + "id": 974, + "sname": "游戏974服", + "groupId": 98, + "groupName": "真定城" + }, + { + "id": 975, + "sname": "游戏975服", + "groupId": 98, + "groupName": "真定城" + }, + { + "id": 976, + "sname": "游戏976服", + "groupId": 98, + "groupName": "真定城" + }, + { + "id": 977, + "sname": "游戏977服", + "groupId": 98, + "groupName": "真定城" + }, + { + "id": 978, + "sname": "游戏978服", + "groupId": 98, + "groupName": "真定城" + }, + { + "id": 979, + "sname": "游戏979服", + "groupId": 98, + "groupName": "真定城" + }, + { + "id": 980, + "sname": "游戏980服", + "groupId": 99, + "groupName": "真定城" + }, + { + "id": 981, + "sname": "游戏981服", + "groupId": 99, + "groupName": "真定城" + }, + { + "id": 982, + "sname": "游戏982服", + "groupId": 99, + "groupName": "真定城" + }, + { + "id": 983, + "sname": "游戏983服", + "groupId": 99, + "groupName": "真定城" + }, + { + "id": 984, + "sname": "游戏984服", + "groupId": 99, + "groupName": "真定城" + }, + { + "id": 985, + "sname": "游戏985服", + "groupId": 99, + "groupName": "真定城" + }, + { + "id": 986, + "sname": "游戏986服", + "groupId": 99, + "groupName": "真定城" + }, + { + "id": 987, + "sname": "游戏987服", + "groupId": 99, + "groupName": "真定城" + }, + { + "id": 988, + "sname": "游戏988服", + "groupId": 99, + "groupName": "真定城" + }, + { + "id": 989, + "sname": "游戏989服", + "groupId": 99, + "groupName": "真定城" + }, + { + "id": 990, + "sname": "游戏990服", + "groupId": 100, + "groupName": "真定城" + }, + { + "id": 991, + "sname": "游戏991服", + "groupId": 100, + "groupName": "真定城" + }, + { + "id": 992, + "sname": "游戏992服", + "groupId": 100, + "groupName": "真定城" + }, + { + "id": 993, + "sname": "游戏993服", + "groupId": 100, + "groupName": "真定城" + }, + { + "id": 994, + "sname": "游戏994服", + "groupId": 100, + "groupName": "真定城" + }, + { + "id": 995, + "sname": "游戏995服", + "groupId": 100, + "groupName": "真定城" + }, + { + "id": 996, + "sname": "游戏996服", + "groupId": 100, + "groupName": "真定城" + }, + { + "id": 997, + "sname": "游戏997服", + "groupId": 100, + "groupName": "真定城" + }, + { + "id": 998, + "sname": "游戏998服", + "groupId": 100, + "groupName": "真定城" + }, + { + "id": 999, + "sname": "游戏999服", + "groupId": 100, + "groupName": "真定城" + }, + { + "id": 1000, + "sname": "游戏1000服", + "groupId": 101, + "groupName": "真定城" } ] \ No newline at end of file diff --git a/web-server/app/controller/game.ts b/web-server/app/controller/game.ts index 027761739..2cdbb530b 100644 --- a/web-server/app/controller/game.ts +++ b/web-server/app/controller/game.ts @@ -80,9 +80,8 @@ export default class GameController extends Controller { public async getnotice() { const { ctx } = this; - let { serverType } = ctx.request.body; - let notice = await NoticeModel.getAllNotice(serverType); + let notice = await NoticeModel.getAllNotice(); let result = notice.map(cur => { let { id, title, tag, type, content, time } = cur; return { From 22f8d3c438ecccd5823962acc18d516f92898559 Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 8 Dec 2021 10:25:21 +0800 Subject: [PATCH 15/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8=E7=BB=B4=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../servers/activity/remote/activityRemote.ts | 17 +- .../app/servers/battle/remote/battleRemote.ts | 13 ++ .../app/servers/chat/remote/chatRemote.ts | 13 ++ .../app/servers/connector/filter/global.ts | 20 +- .../connector/remote/connectorRemote.ts | 15 +- .../app/servers/gm/handler/gmHandler.ts | 27 --- .../app/servers/gm/handler/gmServerHandler.ts | 60 +++--- .../app/servers/guild/remote/guildRemote.ts | 13 ++ .../app/servers/order/remote/orderRemote.ts | 13 ++ .../app/servers/role/remote/roleRemote.ts | 14 ++ .../servers/systimer/remote/systimerRemote.ts | 11 +- game-server/app/services/gmService.ts | 184 ++++++++++++------ game-server/app/services/mailService.ts | 2 +- game-server/app/services/redisService.ts | 2 +- game-server/app/services/timeTaskService.ts | 137 ++++++++++++- gm-server/app/controller/game.ts | 22 +-- gm-server/app/router.ts | 4 +- gm-server/app/service/Game.ts | 39 ++-- shared/consts/constModules/sysConst.ts | 1 + shared/db/Counter.ts | 2 +- shared/db/GMMail.ts | 2 - shared/db/Maintenance.ts | 107 ---------- shared/db/Region.ts | 11 ++ shared/db/Serverlist.ts | 88 ++++----- shared/db/index.ts | 1 + shared/domain/backEndField/params.ts | 4 + shared/domain/gameField/serverlist.ts | 13 +- web-server/app/controller/game.ts | 4 +- web-server/app/service/Game.ts | 16 +- 29 files changed, 512 insertions(+), 343 deletions(-) delete mode 100644 shared/db/Maintenance.ts diff --git a/game-server/app/servers/activity/remote/activityRemote.ts b/game-server/app/servers/activity/remote/activityRemote.ts index e17efc18c..1aadef38d 100644 --- a/game-server/app/servers/activity/remote/activityRemote.ts +++ b/game-server/app/servers/activity/remote/activityRemote.ts @@ -3,6 +3,7 @@ import { ActivityModel, ActivityModelType } from '../../../db/Activity'; import { ServerlistModel } from '../../../db/Serverlist'; import { reloadResources } from '../../../pubUtils/data'; import { _getActivitiesByType, _getActivityById, _getActivities } from '../../../services/activity/activityService'; +import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService'; export default function (app: Application) { new HandlerService(app, {}); @@ -30,8 +31,8 @@ export class ActivityRemote { } public async loadActivities() { - let servers = await ServerlistModel.getAllServerList(); - for(let { serverId, activityGroupId } of servers) { + let servers = await ServerlistModel.findByEnv(this.app.get('env')); + for(let { id: serverId, activityGroupId } of servers) { for(let groupId of activityGroupId) { if(!this.groupToServer.has(groupId)) { this.groupToServer.set(groupId, []); @@ -116,4 +117,16 @@ export class ActivityRemote { public getActivities() { return _getActivities(); } + + public setServerMainten(serverIds: number[], startTime: number, endTime: number) { + setServerMainten(serverIds, startTime, endTime); + } + + public stopServerMainten(serverIds: number[]) { + stopServerMainten(serverIds); + } + + public getServerMainten(serverId: number) { + return getServerMainten(serverId); + } } \ No newline at end of file diff --git a/game-server/app/servers/battle/remote/battleRemote.ts b/game-server/app/servers/battle/remote/battleRemote.ts index 9b9a2a74c..e72acdc67 100644 --- a/game-server/app/servers/battle/remote/battleRemote.ts +++ b/game-server/app/servers/battle/remote/battleRemote.ts @@ -1,6 +1,7 @@ import { Application, ChannelService, FrontendSession, RemoterClass, HandlerService, } from 'pinus'; import { PVPConfigType } from '../../../db/SystemConfig'; import { reloadResources } from '../../../pubUtils/data'; +import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService'; export default function (app: Application) { new HandlerService(app, {}); @@ -87,4 +88,16 @@ export class BattleRemote { this.app.set('pvpSeasonEndTime', pvpConfig.seasonEndTime); } } + + public setServerMainten(serverIds: number[], startTime: number, endTime: number) { + setServerMainten(serverIds, startTime, endTime); + } + + public stopServerMainten(serverIds: number[]) { + stopServerMainten(serverIds); + } + + public getServerMainten(serverId: number) { + return getServerMainten(serverId); + } } \ No newline at end of file diff --git a/game-server/app/servers/chat/remote/chatRemote.ts b/game-server/app/servers/chat/remote/chatRemote.ts index 3eb7a3d7e..c74d68f45 100644 --- a/game-server/app/servers/chat/remote/chatRemote.ts +++ b/game-server/app/servers/chat/remote/chatRemote.ts @@ -13,6 +13,7 @@ import { MailParam } from '../../../domain/roleField/mail'; import { RankFirstType } from '../../../db/RankFirst'; import { LotType } from '../../../db/Lot'; import { _checkFilterWords, getTire } from '../../../services/sdkService'; +import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService'; export default function (app: Application) { new HandlerService(app, {}); @@ -289,4 +290,16 @@ export class ChatRemote { public async checkFilterWords(word: string) { return await _checkFilterWords(word); } + + public setServerMainten(serverIds: number[], startTime: number, endTime: number) { + setServerMainten(serverIds, startTime, endTime); + } + + public stopServerMainten(serverIds: number[]) { + stopServerMainten(serverIds); + } + + public getServerMainten(serverId: number) { + return getServerMainten(serverId); + } } diff --git a/game-server/app/servers/connector/filter/global.ts b/game-server/app/servers/connector/filter/global.ts index 39bacedc4..b9de897d3 100644 --- a/game-server/app/servers/connector/filter/global.ts +++ b/game-server/app/servers/connector/filter/global.ts @@ -6,6 +6,8 @@ import { resResult, checkWhiteListWithUid, genCode } from "../../../pubUtils/uti import { BLOCK_TYPE, CHANNEL_PREFIX, MSG_TYPE, STATUS } from "../../../consts"; import { UserModel } from "../../../db/User"; import { SERVER_DEBUG_MODE } from "../../../pubUtils/dicParam"; +import { nowSeconds } from "../../../pubUtils/timeUtil"; +import { getServerMainten } from "../../../services/gmService"; export function globalFilter(app: Application) { return new Filter(app); } @@ -37,13 +39,17 @@ Filter.prototype.before = async function (routeRecord: RouteRecord, msg: any, se session.push('teamCode', () => {}); - const maintenServers = this.app.get('maintenServers'); - if(maintenServers && maintenServers.indexOf(serverId) != -1) { // 该服务器维护 - let isWhiteList = await checkWhiteListWithUid(uid); - if(isWhiteList) return next(null); - - pinus.app.get('channelService').pushMessageByUids('onServerMaintenance', resResult(STATUS.SERVER_MAINTENANCE), [{ uid: roleId, sid }]); - return next(new Error(), resResult(STATUS.SERVER_MAINTENANCE)); + if(sid) { + const mainten = getServerMainten(serverId); + console.log('***** maintenServers', mainten) + if(mainten) { // 该服务器维护 + if(mainten.startTime > nowSeconds() || mainten.endTime < nowSeconds()) return next(null) + let isWhiteList = await checkWhiteListWithUid(uid); + if(isWhiteList) return next(null); + + pinus.app.get('channelService').pushMessageByUids('onServerMaintenance', resResult(STATUS.SERVER_MAINTENANCE), [{ uid: roleId, sid }]); + return next(new Error(), resResult(STATUS.SERVER_MAINTENANCE)); + } } let hasBlockWords = false; diff --git a/game-server/app/servers/connector/remote/connectorRemote.ts b/game-server/app/servers/connector/remote/connectorRemote.ts index c5c1d943a..87da81832 100644 --- a/game-server/app/servers/connector/remote/connectorRemote.ts +++ b/game-server/app/servers/connector/remote/connectorRemote.ts @@ -6,6 +6,7 @@ import { UserGuildType } from '../../../db/UserGuild'; import { kickUser } from '../../../services/connectorService'; import { PVPConfigType } from '../../../db/SystemConfig'; import { setDicAuctionTime } from '../../../services/guildActivityService'; +import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService'; export default function (app: Application) { new HandlerService(app, {}); return new ConnectorRemote(app); @@ -16,7 +17,6 @@ export class ConnectorRemote { constructor(private app: Application) { this.app = app; } - private maintenServers: number[] = []; // 维护中的服务器 public async remoteLogin(uid: string, message?: any) { await kickUser(this.app, uid, message); @@ -69,13 +69,16 @@ export class ConnectorRemote { reloadResources(); } - public setServerMainten(maintenServers: number[]) { - this.app.set('maintenServers', maintenServers); - return this.maintenServers = maintenServers; + public setServerMainten(serverIds: number[], startTime: number, endTime: number) { + setServerMainten(serverIds, startTime, endTime); } - public getServerMainten() { - return this.maintenServers; + public stopServerMainten(serverIds: number[]) { + stopServerMainten(serverIds); + } + + public getServerMainten(serverId: number) { + return getServerMainten(serverId); } public setPvpSeasonNum(pvpConfig: PVPConfigType) { diff --git a/game-server/app/servers/gm/handler/gmHandler.ts b/game-server/app/servers/gm/handler/gmHandler.ts index 679db47ca..955548dcd 100644 --- a/game-server/app/servers/gm/handler/gmHandler.ts +++ b/game-server/app/servers/gm/handler/gmHandler.ts @@ -12,8 +12,6 @@ import { RewardInter } from '../../../pubUtils/interface'; import { MarqueeModel } from '../../../db/Marquee'; import { ServerlistModel } from '../../../db/Serverlist'; import { pushCurrentTime } from '../../../services/chatService'; -import { MaintenanceModel } from '../../../db/Maintenance'; -import { initMaintenance, stopMaintenance } from '../../../services/gmService'; import { checkActivityEditable, checkActivityGroupType } from '../../../services/activity/activityService'; import { ActivityModel } from '../../../db/Activity'; import { ActivityGroupModel } from '../../../db/ActivityGroup'; @@ -156,31 +154,6 @@ export class GmHandler { return resResult(STATUS.SUCCESS); } - async startMaintenance(msg: { code: string }, session: BackendSession) { - const { code } = msg; - const uid = session.get('uid'); - const maintenance = await MaintenanceModel.updateStatusByCode(code, true, uid); - if (!maintenance) return resResult(STATUS.WRONG_PARMS); - await initMaintenance(maintenance); - - return resResult(STATUS.SUCCESS,); - } - - async stopMaintenance(msg: { code: string }, session: BackendSession) { - const { code } = msg; - const uid = session.get('uid'); - const maintenance = await MaintenanceModel.updateStatusByCode(code, false, uid); - if (!maintenance) return resResult(STATUS.WRONG_PARMS); - await stopMaintenance(maintenance, uid); - - return resResult(STATUS.SUCCESS,); - } - - async setMaintenance() { - pinus.app.rpc.connector.connectorRemote.setServerMainten.broadcast([1]); - return resResult(STATUS.SUCCESS); - } - async updateActivity(msg: { activityId: number|string, groupId: number, beginTime: number, endTime: number, type: number, data: string }, session: BackendSession) { const { activityId, groupId, beginTime, endTime, type, data } = msg; const uid = session.get('uid'); diff --git a/game-server/app/servers/gm/handler/gmServerHandler.ts b/game-server/app/servers/gm/handler/gmServerHandler.ts index 7e8b5d51a..0b536995f 100644 --- a/game-server/app/servers/gm/handler/gmServerHandler.ts +++ b/game-server/app/servers/gm/handler/gmServerHandler.ts @@ -1,14 +1,17 @@ import { Application, BackendSession, pinus } from 'pinus'; -import { getRandSingleEelm, resResult } from '../../../pubUtils/util'; +import { genCode, getRandSingleEelm, resResult } from '../../../pubUtils/util'; import { STATUS } from '../../../consts/statusCode'; import moment = require('moment'); import { CreateServerParam, UpdateRegionParams } from '../../../domain/backEndField/params'; import { RegionModel } from '../../../db/Region'; import { gameData } from '../../../pubUtils/data'; -import { ServerlistModel } from '../../../db/Serverlist'; +import { Maintenance, ServerlistModel } from '../../../db/Serverlist'; import { nowSeconds } from '../../../pubUtils/timeUtil'; import { GM_MAIL_TYPE, MAIL_TIME_TYPE, REF_CIRCLE_MAIL_TIME } from '../../../consts'; import { SendMailFun } from '../../../services/mailService'; +import { sendOpenServerMail } from '../../../services/gmService'; +import { initMaintenance, stopMaintenance } from '../../../services/timeTaskService'; +import { isNumber } from 'util'; let timer: NodeJS.Timer; export default function (app: Application) { return new GmHandler(app); @@ -18,6 +21,7 @@ export class GmHandler { constructor(private app: Application) { } + // 保存大区配置 async saveRegionConf(msg: UpdateRegionParams, session: BackendSession) { let params = new UpdateRegionParams(msg); let uid = session.get('uid'); @@ -34,10 +38,13 @@ export class GmHandler { return resResult(STATUS.SUCCESS); } + // 手动开服 async createNewServer(msg: CreateServerParam, session: BackendSession) { let params = new CreateServerParam(msg); let uid = session.get('uid'); if(!params.checkParams()) return resResult(STATUS.WRONG_PARMS); + + console.log('*******', params); let curRegion = await RegionModel.findRegionByEnv(params.env); if(!curRegion) return resResult(STATUS.WRONG_PARMS); @@ -46,26 +53,35 @@ export class GmHandler { if(!dicServerName) return resResult(STATUS.DIC_DATA_NOT_FOUND); let newServer = await ServerlistModel.newServer(params, curRegion, dicServerName, uid); - let mails = [ params.openMail, params.circleMail ]; - for(let mail of mails) { - let needSend = false; - if(mail.timeType == MAIL_TIME_TYPE.CIRCLE) { - let refTime = moment(moment().format(`YYYY-MM-DD ${REF_CIRCLE_MAIL_TIME}:00:00`)).unix(); - let sendTime = moment(moment().format('YYYY-MM-DD '+ mail.circleHour)).unix(); - if(sendTime < refTime) sendTime += 86400; - let now = nowSeconds(); - if(refTime < now && sendTime > now) { - needSend = true; - } - } else { - needSend = true; - } - if(needSend) { - let f = new SendMailFun(); - await f.setWithGmMail(mail); - await f.sendToServer([newServer.id]); - } - } + if(params.openMail) await sendOpenServerMail('openMail', params.openMail, newServer, uid); + if(params.circleMail) await sendOpenServerMail('circleMail', params.circleMail, newServer, uid); + await RegionModel.newServer(curRegion.id, newServer) return resResult(STATUS.SUCCESS); } + + // 开始维护 + async startMaintenance(msg: { id: number, startTime: number, endTime: number, hasNotify: boolean }, session: BackendSession) { + const { id, startTime, endTime, hasNotify } = msg; + if(!id || !isNumber(startTime) || !isNumber(endTime)) return resResult(STATUS.WRONG_PARMS); + const uid = session.get('uid'); + let newMaintenance: Maintenance = { batchCode: genCode(10), startTime, endTime, hasNotify, isOpen: true } + let server = await ServerlistModel.updateByServerId(id, { maintenance: newMaintenance }); + await pinus.app.rpc.systimer.systimerRemote.initMaintenance.broadcast([server]); + + return resResult(STATUS.SUCCESS,); + } + + // 提前结束维护 + async stopMaintenance(msg: { id: number }, session: BackendSession) { + const { id } = msg; + const uid = session.get('uid'); + let server = await ServerlistModel.findByServerId(id); + let maintenance = server.maintenance; + if(maintenance) { + // console.log('&&&', server, server.id) + await pinus.app.rpc.systimer.systimerRemote.stopMaintenance.broadcast(maintenance.batchCode, [server.id]); + } + + return resResult(STATUS.SUCCESS,); + } } \ No newline at end of file diff --git a/game-server/app/servers/guild/remote/guildRemote.ts b/game-server/app/servers/guild/remote/guildRemote.ts index 3dc540ed5..9d59ed997 100644 --- a/game-server/app/servers/guild/remote/guildRemote.ts +++ b/game-server/app/servers/guild/remote/guildRemote.ts @@ -1,6 +1,7 @@ import { Application, ChannelService, HandlerService, } from 'pinus'; import { reloadResources } from '../../../pubUtils/data'; import { treatGuildName } from '../../../services/sdkService'; +import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService'; export default function (app: Application) { new HandlerService(app, {}); @@ -26,4 +27,16 @@ export class GuildRemote { public async treatGuildName(content: string) { await treatGuildName(content); } + + public setServerMainten(serverIds: number[], startTime: number, endTime: number) { + setServerMainten(serverIds, startTime, endTime); + } + + public stopServerMainten(serverIds: number[]) { + stopServerMainten(serverIds); + } + + public getServerMainten(serverId: number) { + return getServerMainten(serverId); + } } \ No newline at end of file diff --git a/game-server/app/servers/order/remote/orderRemote.ts b/game-server/app/servers/order/remote/orderRemote.ts index d804e1ca5..f243022e7 100644 --- a/game-server/app/servers/order/remote/orderRemote.ts +++ b/game-server/app/servers/order/remote/orderRemote.ts @@ -1,6 +1,7 @@ import { Application, ChannelService, HandlerService, } from 'pinus'; import { reloadResources } from '../../../pubUtils/data'; import { settleOrderFromRedisPub } from '../../../services/orderService'; +import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService'; export default function (app: Application) { new HandlerService(app, {}); @@ -26,4 +27,16 @@ export class OrderRemote { public async settleOrderFromRedisPub(message: string) { await settleOrderFromRedisPub(message); } + + public setServerMainten(serverIds: number[], startTime: number, endTime: number) { + setServerMainten(serverIds, startTime, endTime); + } + + public stopServerMainten(serverIds: number[]) { + stopServerMainten(serverIds); + } + + public getServerMainten(serverId: number) { + return getServerMainten(serverId); + } } \ No newline at end of file diff --git a/game-server/app/servers/role/remote/roleRemote.ts b/game-server/app/servers/role/remote/roleRemote.ts index 263bd233a..a4a376eb7 100644 --- a/game-server/app/servers/role/remote/roleRemote.ts +++ b/game-server/app/servers/role/remote/roleRemote.ts @@ -11,6 +11,8 @@ import { Figure } from '../../../domain/dbGeneral'; import { getDefaultRoleInfo } from '../../../services/roleService'; import { PVPConfigType } from '../../../db/SystemConfig'; import { treatRoleName } from '../../../services/sdkService'; +import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService'; + export default function (app: Application) { new HandlerService(app, {}); return new RoleRemote(app); @@ -121,4 +123,16 @@ export class RoleRemote { public async treatRoleName(roleId: string) { await treatRoleName(roleId); } + + public setServerMainten(serverIds: number[], startTime: number, endTime: number) { + setServerMainten(serverIds, startTime, endTime); + } + + public stopServerMainten(serverIds: number[]) { + stopServerMainten(serverIds); + } + + public getServerMainten(serverId: number) { + return getServerMainten(serverId); + } } diff --git a/game-server/app/servers/systimer/remote/systimerRemote.ts b/game-server/app/servers/systimer/remote/systimerRemote.ts index 854669712..9960f502b 100644 --- a/game-server/app/servers/systimer/remote/systimerRemote.ts +++ b/game-server/app/servers/systimer/remote/systimerRemote.ts @@ -1,11 +1,12 @@ import { Application, ChannelService } from 'pinus'; -import { resetPvpSeasonTime, guildActivityStart, gateActivityEnd, cityActivityEnd, raceActivityEnd, guildActivitySchedule, auctionSchedule } from '../../../services/timeTaskService'; +import { resetPvpSeasonTime, guildActivityStart, gateActivityEnd, cityActivityEnd, raceActivityEnd, guildActivitySchedule, auctionSchedule, initMaintenance, stopMaintenance } from '../../../services/timeTaskService'; import PvpDefenseType from '../../../db/PvpDefense'; import { DicGuildActivity } from '../../../pubUtils/dictionary/DicGuildActivity'; import { reloadResources } from '../../../pubUtils/data'; import { setMarquee, cancelMarquee } from '../../../services/gmService'; import { setDicAuctionTime, setDicGuildActivity } from '../../../services/guildActivityService'; import { setWeek } from '../../../pubUtils/timeUtil'; +import { ServerlistType } from '../../../db/Serverlist'; export default function (app: Application) { return new SystimerRemote(app); @@ -89,4 +90,12 @@ export class SystimerRemote { async setDay(week: number) { setWeek(week); } + + public async initMaintenance(servers?: ServerlistType[]) { + await initMaintenance(servers); + } + + public async stopMaintenance(batchCode: string, serverIds: number[]) { + await stopMaintenance(batchCode, serverIds); + } } diff --git a/game-server/app/services/gmService.ts b/game-server/app/services/gmService.ts index 7b1d62bc0..4faea1a24 100644 --- a/game-server/app/services/gmService.ts +++ b/game-server/app/services/gmService.ts @@ -1,15 +1,16 @@ import { MarqueeType, MarqueeModel } from "../db/Marquee"; -import { MARQUEE_TYPE, SERVER_STATUS } from "../consts"; +import { GM_MAIL_STATUS, MAIL_TIME_TYPE, MARQUEE_TYPE, REF_CIRCLE_MAIL_TIME, SERVER_STATUS } from "../consts"; import { scheduleJob, scheduledJobs, Job } from 'node-schedule'; import { createMarqueeMsg as sysCreateMarqueeMsg, pushMarqueeMsg as sysPushMarqueeMsg } from './sysChatService'; import { GroupMessageType } from "../db/GroupMessage"; -import { MaintenanceModel, MaintenanceType } from '../db/Maintenance'; import { pinus } from "pinus"; import { getWorldChannelSid } from "./chatChannelService"; -import { ServerlistModel } from "../db/Serverlist"; +import { ServerlistModel, ServerlistType } from "../db/Serverlist"; import { NoticeModel, NoticeType } from "../db/Notice"; import { SendMailFun } from "./mailService"; -import { GMMailType } from '../db/GMMail'; +import GMMail, { GMMailModel, GMMailType } from '../db/GMMail'; +import moment = require("moment"); +import { getSeconds, nowSeconds } from "../pubUtils/timeUtil"; // —————————————— 跑马灯 —————————————— // // 初始 @@ -103,69 +104,132 @@ export async function cancelMarquee(code: string) { // —————————————— 停服维护 —————————————— // // 维护信息 -export async function initMaintenance(maintenance?: MaintenanceType) { - if(!maintenance) - maintenance = await MaintenanceModel.findOpenMaintenance(); - if(maintenance) { - let { startTime, marquee } = maintenance; - if(marquee) { - let result = await generateMarqueeSchedule(marquee); - // console.log(result); - } - if(Date.now() > startTime.getTime()) { - await startMaintenance(maintenance); - } else { - let startJob = scheduleJob(`startMainten${maintenance.code}`, startTime.getTime(), async () => { - await startMaintenance(maintenance, startJob); - }); - } - } -} +// export async function initMaintenance() { +// let servers = await ServerlistModel.findByEnv(pinus.app.get('env')); +// for(let server of servers) +// // if(!maintenance) +// // maintenance = await MaintenanceModel.findOpenMaintenance(); +// // if(maintenance) { +// // let { startTime, marquee } = maintenance; +// // if(marquee) { +// // let result = await generateMarqueeSchedule(marquee); +// // // console.log(result); +// // } +// // if(Date.now() > startTime.getTime()) { +// // await startMaintenance(maintenance); +// // } else { +// // let startJob = scheduleJob(`startMainten${maintenance.code}`, startTime.getTime(), async () => { +// // await startMaintenance(maintenance, startJob); +// // }); +// // } +// } +// } -// 开启维护 -async function startMaintenance(maintenance: MaintenanceType, startJob?: Job) { - // 向全服发送 - let { serverIds, notice } = maintenance; - for(let serverId of serverIds) { - let chatSid = await getWorldChannelSid(serverId); - await pinus.app.rpc.chat.chatRemote.sendServerMaintenance.toServer(chatSid, serverId); - } +// // 开启维护 +// async function startMaintenance(maintenance: MaintenanceType, startJob?: Job) { +// // 向全服发送 +// let { serverIds, notice } = maintenance; +// for(let serverId of serverIds) { +// let chatSid = await getWorldChannelSid(serverId); +// await pinus.app.rpc.chat.chatRemote.sendServerMaintenance.toServer(chatSid, serverId); +// } - // 更新serverlist上的status - await ServerlistModel.updateByServerIds(serverIds, { serverStatus: SERVER_STATUS.MAINTENANCE }); - // 更新notice的isEnable - if(notice) { - await NoticeModel.updateNotice((notice).id, { isEnable: true }); - } +// // 更新serverlist上的status +// await ServerlistModel.updateByServerIds(serverIds, { serverStatus: SERVER_STATUS.MAINTENANCE }); +// // 更新notice的isEnable +// if(notice) { +// await NoticeModel.updateNotice((notice).id, { isEnable: true }); +// } - // 更新connectorRemote里面的维护服务器 - await pinus.app.rpc.connector.connectorRemote.setServerMainten.broadcast(serverIds); +// // 更新connectorRemote里面的维护服务器 +// await pinus.app.rpc.connector.connectorRemote.setServerMainten.broadcast(serverIds); +// } + +// // 停止维护 +// 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 +// if(notice) { +// await NoticeModel.updateNotice((notice).id, { isEnable: false }); +// } + +// // 更新connectorRemote里面的维护服务器 +// let connectorServers = pinus.app.getServersByType('connector'); +// for(let { id } of connectorServers) { +// await pinus.app.rpc.connector.connectorRemote.setServerMainten.toServer(id, []); +// } + +// if(marquee) { +// await cancelMarquee((marquee).code); +// } +// console.log('*****', JSON.stringify(mail)); +// if(mail) { +// let f = new SendMailFun(); +// await f.setWithGmMail((mail)._id); +// await f.sendToServer(serverIds); +// // await f.saveRecord(uid); +// } +// } + +export async function sendOpenServerMail(type: 'openMail'|'circleMail', mail: GMMail, newServer: ServerlistType, uid: number) { + let receivers = [{ + env: newServer.env, + serverId: newServer.id + }]; + let addParam = {...mail, receivers, status: GM_MAIL_STATUS.PASS }; + if(type == 'openMail') { + addParam.timeType = MAIL_TIME_TYPE.DELAY; + addParam.startTime = newServer.openTime; + } + let gmmail = await GMMailModel.addMail(addParam, uid); + let needSend = false; + if(mail.timeType == MAIL_TIME_TYPE.CIRCLE) { + let refTime = moment(moment().format(`YYYY-MM-DD ${REF_CIRCLE_MAIL_TIME}:00:00`)).unix(); + let sendTime = moment(moment().format('YYYY-MM-DD '+ mail.circleHour)).unix(); + if(sendTime < refTime) sendTime += 86400; + let now = nowSeconds(); + if(refTime < now && sendTime > now) { + needSend = true; + } + } else { + needSend = true; + } + if(needSend) { + let f = new SendMailFun(); + await f.setWithGmMail(gmmail); + await f.sendToServer([newServer.id]); + } + return true; } -// 停止维护 -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 - if(notice) { - await NoticeModel.updateNotice((notice).id, { isEnable: false }); - } - // 更新connectorRemote里面的维护服务器 - let connectorServers = pinus.app.getServersByType('connector'); - for(let { id } of connectorServers) { - await pinus.app.rpc.connector.connectorRemote.setServerMainten.toServer(id, []); - } - if(marquee) { - await cancelMarquee((marquee).code); +export function setServerMainten(serverIds: number[], startTime: number, endTime: number) { + let maintenServers = pinus.app.get('maintenServers')||new Map(); + for(let id of serverIds) { + if(!maintenServers.has(id)) { + maintenServers.set(id, { startTime, endTime }); + } else { + maintenServers.get(id).startTime = startTime; + maintenServers.get(id).endTime = endTime; + } } - console.log('*****', JSON.stringify(mail)); - if(mail) { - let f = new SendMailFun(); - await f.setWithGmMail((mail)._id); - await f.sendToServer(serverIds); - // await f.saveRecord(uid); + pinus.app.set('maintenServers', maintenServers); +} + +export function stopServerMainten(serverIds: number[]) { + let maintenServers = pinus.app.get('maintenServers')||new Map(); + for(let id of serverIds) { + if(maintenServers.has(id)) { + maintenServers.delete(id); + } } + pinus.app.set('maintenServers', maintenServers); +} + +export function getServerMainten(serverId: number) { + let maintenServers = pinus.app.get('maintenServers')||new Map(); + return maintenServers.get(serverId); } \ No newline at end of file diff --git a/game-server/app/services/mailService.ts b/game-server/app/services/mailService.ts index 98be7adbc..bb8cd5cd3 100644 --- a/game-server/app/services/mailService.ts +++ b/game-server/app/services/mailService.ts @@ -109,7 +109,7 @@ export class SendMailFun { } // 从GMMail表读取数据 - public async setWithGmMail(gmmail: GMMailTypeParam) { + public async setWithGmMail(gmmail: GMMailType) { this.gmmail = gmmail; this.contentId = 0; if(gmmail.timeType == MAIL_TIME_TYPE.IMMEDIATE) { diff --git a/game-server/app/services/redisService.ts b/game-server/app/services/redisService.ts index 308c94aef..5c896d69a 100644 --- a/game-server/app/services/redisService.ts +++ b/game-server/app/services/redisService.ts @@ -17,7 +17,7 @@ import { getRandSingleEelm } from '../pubUtils/util'; */ export async function initAllRank() { console.log('******* initAllRank ******') - const serverList = await ServerlistModel.getAllServerList(); + const serverList = await ServerlistModel?.findByEnv(pinus.app.get('env'))||[]; await delKeys(REDIS_KEY.ONLINE_USERS); await delKeys(REDIS_KEY.USER_INFO); await delKeys(REDIS_KEY.GUILD_INFO); diff --git a/game-server/app/services/timeTaskService.ts b/game-server/app/services/timeTaskService.ts index dd575a0ab..d74eec711 100644 --- a/game-server/app/services/timeTaskService.ts +++ b/game-server/app/services/timeTaskService.ts @@ -1,11 +1,11 @@ -import { scheduleJob, Job, } from 'node-schedule'; +import { scheduleJob, Job, scheduledJobs, } from 'node-schedule'; import { PVPConfigModel, PVPConfigType } from '../db/SystemConfig'; import { nowSeconds, getTimeFun, getSeconds } from '../pubUtils/timeUtil'; import { getTodayGuildActivity, gameData } from '../pubUtils/data'; import { pvpSeasonEnd } from './pvpService'; import { getAllOnlineRoles, getAllServers, delGuildActivityRank } from './redisService'; -import { GUILD_ACTIVITY_TYPE, REFRESH_TIME, SEND_NAME, SERVER_OPEN_TIME, COUNTER, AUCTION_TIME, GM_MAIL_TYPE } from '../consts'; +import { GUILD_ACTIVITY_TYPE, REFRESH_TIME, SEND_NAME, SERVER_OPEN_TIME, COUNTER, AUCTION_TIME, GM_MAIL_TYPE, SERVER_STATUS } from '../consts'; import { RoleModel } from '../db/Role'; import { pinus } from 'pinus'; import { indexOf } from 'underscore'; @@ -19,13 +19,16 @@ import { dispatch } from '../pubUtils/dispatcher'; import { Rank } from './rankService'; import { checkTask } from './taskService'; import { everydayRefresh } from './connectorService'; -import { initMarquee, initMaintenance } from './gmService'; +import { initMarquee } from './gmService'; import moment = require('moment'); import { CounterModel } from '../db/Counter'; import { reportOneOnline } from './authenticateService'; import { PVP } from '../pubUtils/dicParam'; import { fetch37Words } from './sdkService'; import { GMMailModel } from '../db/GMMail'; +import { Maintenance, ServerlistModel, ServerlistType, ServerlistUpdate } from '../db/Serverlist'; +import { getWorldChannelSid } from './chatService'; +import { createMarqueeMsg, pushMarqueeMsg } from './sysChatService'; const PER_SECOND = 1 * 1000; const PER_DAY = 24 * 60 * 60; @@ -396,4 +399,132 @@ async function sendCircleMail() { await f.sendToServer(serverIds); } } +} + + +/*** 维护 */ + +let maintenInfos = new Map(); // batchCode => {servers, maintenance} +export async function initMaintenance(servers?: ServerlistType[]) { + if(!servers) servers = await ServerlistModel.findByEnv(pinus.app.get('env')); + + console.log('#### initMaintenance', servers) + + for(let server of servers) { + let { maintenance } = server; + if(maintenance && maintenance.isOpen) { + if(!maintenInfos.has(maintenance.batchCode)) { + maintenInfos.set(maintenance.batchCode, { servers: [], maintenance }); + } + maintenInfos.get(maintenance.batchCode).servers.push(server); + } + } + for(let [batchCode] of maintenInfos) { + await setMaintenance(batchCode); + } +} + +// 设置维护 +async function setMaintenance(batchCode: string) { + let { maintenance } = maintenInfos.get(batchCode); + let now = nowSeconds(); + // 发送消息 + if(maintenance.hasNotify && now < maintenance.startTime) { + if(now > maintenance.startTime - 5 * 60) { + maintenanceNotifySchedule(batchCode); + } else { + scheduleJob(`maintenNotify${batchCode}`, maintenance.startTime - 5 * 60, () => { + maintenanceNotifySchedule(batchCode); + }) + } + } else { + if(scheduledJobs[`maintenNotify${batchCode}`]) scheduledJobs[`maintenNotify${batchCode}`].cancel(); + } + // 开始维护 + console.log('******* setMaintenance', now, now < maintenance.endTime, now > maintenance.startTime) + if(now < maintenance.endTime) { + if(now > maintenance.startTime) { + console.log('*******') + await startMaintenanceSchedule(batchCode); + } else { + scheduleJob(`startMainten${batchCode}`, maintenance.startTime * 1000, async () => { + await startMaintenanceSchedule(batchCode); + }); + } + } else { + if(scheduledJobs[`startMainten${batchCode}`]) scheduledJobs[`startMainten${batchCode}`].cancel(); + } + +} + +// 维护前通知 +async function maintenanceNotifySchedule(batchCode: string) { + let { servers, maintenance } = maintenInfos.get(batchCode); + if(scheduledJobs[`maintenNotify${batchCode}`]) scheduledJobs[`maintenNotify${batchCode}`].cancel(); + if(scheduledJobs[`maintenSec${batchCode}`]) scheduledJobs[`maintenSec${batchCode}`].cancel(); + + scheduleJob(`maintenSec${batchCode}`, `0 */1 * * * *`, async () => { + for(let { id: serverId } of servers) { + let msgData = await createMarqueeMsg('', '系统', serverId, '服务器即将维护,请玩家提前退出游戏'); + await pushMarqueeMsg(msgData); + } + }) +} + +// 开始维护 +async function startMaintenanceSchedule(batchCode: string) { + let { servers, maintenance } = maintenInfos.get(batchCode); + let serverIds = servers.map(cur => cur.id); + if(scheduledJobs[`maintenNotify${batchCode}`]) scheduledJobs[`maintenNotify${batchCode}`].cancel(); + if(scheduledJobs[`maintenSec${batchCode}`]) scheduledJobs[`maintenSec${batchCode}`].cancel(); + if(scheduledJobs[`startMainten${batchCode}`]) scheduledJobs[`startMainten${batchCode}`].cancel(); + + // 向全服发送 + for(let { id: serverId } of servers) { + let chatSid = await getWorldChannelSid(serverId); + if(chatSid) { + await pinus.app.rpc.chat.chatRemote.sendServerMaintenance.toServer(chatSid, serverId); + } + } + + // 更新serverlist上的status + await ServerlistModel.updateByServerIds(serverIds, { serverStatus: SERVER_STATUS.MAINTENANCE }); + + // 更新connectorRemote里面的维护服务器 + console.log('******** startMaintenanceSchedule', batchCode, serverIds, maintenance.startTime, maintenance.endTime) + pinus.app.rpc.connector.connectorRemote.setServerMainten.broadcast(serverIds, maintenance.startTime, maintenance.endTime); + pinus.app.rpc.activity.activityRemote.setServerMainten.broadcast(serverIds, maintenance.startTime, maintenance.endTime); + pinus.app.rpc.battle.battleRemote.setServerMainten.broadcast(serverIds, maintenance.startTime, maintenance.endTime); + pinus.app.rpc.chat.chatRemote.setServerMainten.broadcast(serverIds, maintenance.startTime, maintenance.endTime); + pinus.app.rpc.guild.guildRemote.setServerMainten.broadcast(serverIds, maintenance.startTime, maintenance.endTime); + pinus.app.rpc.order.orderRemote.setServerMainten.broadcast(serverIds, maintenance.startTime, maintenance.endTime); + pinus.app.rpc.role.roleRemote.setServerMainten.broadcast(serverIds, maintenance.startTime, maintenance.endTime); +} + +// 提前结束维护 +export async function stopMaintenance(batchCode: string, serverIds: number[]) { + // console.log('***********', serverIds) + let { servers = [], maintenance = {} as Maintenance } = maintenInfos.get(batchCode)||{}; + for(let id of serverIds) { + let index = servers.findIndex(cur => cur.id == id); + if(index != -1) servers.splice(index); + } + if(servers.length == 0) { + if(scheduledJobs[`maintenNotify${batchCode}`]) scheduledJobs[`maintenNotify${batchCode}`].cancel(); + if(scheduledJobs[`maintenSec${batchCode}`]) scheduledJobs[`maintenSec${batchCode}`].cancel(); + if(scheduledJobs[`startMainten${batchCode}`]) scheduledJobs[`startMainten${batchCode}`].cancel(); + maintenInfos.delete(batchCode); + } + + // 更新serverlist上的status + await ServerlistModel.updateByServerIds(serverIds, { serverStatus: SERVER_STATUS.HOT, 'maintenance.isOpen': false } as ServerlistUpdate); + + // 更新connectorRemote里面的维护服务器 + pinus.app.rpc.connector.connectorRemote.stopServerMainten.broadcast(serverIds); + pinus.app.rpc.activity.activityRemote.stopServerMainten.broadcast(serverIds); + pinus.app.rpc.battle.battleRemote.stopServerMainten.broadcast(serverIds); + pinus.app.rpc.chat.chatRemote.stopServerMainten.broadcast(serverIds); + pinus.app.rpc.guild.guildRemote.stopServerMainten.broadcast(serverIds); + pinus.app.rpc.order.orderRemote.stopServerMainten.broadcast(serverIds); + pinus.app.rpc.role.roleRemote.stopServerMainten.broadcast(serverIds); } \ No newline at end of file diff --git a/gm-server/app/controller/game.ts b/gm-server/app/controller/game.ts index 011c56def..ab7ffd912 100644 --- a/gm-server/app/controller/game.ts +++ b/gm-server/app/controller/game.ts @@ -2,19 +2,19 @@ import { Controller } from 'egg'; export default class GameController extends Controller { - public async getServerListByEnv() { - const { ctx } = this; - ctx.body = await ctx.service.game.getServerListByEnv(); - return - } + // public async getServerListByEnv() { + // const { ctx } = this; + // ctx.body = await ctx.service.game.getServerListByEnv(); + // return + // } - public async getServerList() { - const { ctx } = this; - const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + // public async getServerList() { + // const { ctx } = this; + // const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; - ctx.body = await ctx.service.game.getServerList(page, pageSize, sortField, sortOrder, form); - return - } + // ctx.body = await ctx.service.game.getServerList(page, pageSize, sortField, sortOrder, form); + // return + // } public async getRegions() { const { ctx } = this; diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index 6f1a49a65..ace939d7c 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -50,8 +50,8 @@ export default (app: Application) => { // router.post('/api/users/delgiftCode', controller.users.delGiftCode); router.get('/api/users/getgiftcodedetails/:id/:filename', controller.users.getGiftCodeDetails); - router.post('/api/game/getserverlistbyenv', tokenParser, controller.game.getServerListByEnv); - router.post('/api/game/getserverlist', controller.game.getServerList); + // router.post('/api/game/getserverlistbyenv', tokenParser, controller.game.getServerListByEnv); + // router.post('/api/game/getserverlist', controller.game.getServerList); router.post('/api/game/getregions', controller.game.getRegions); router.post('/api/game/getservers', controller.game.getServers); router.post('/api/game/getregionstategy', controller.game.getRegionStategy); diff --git a/gm-server/app/service/Game.ts b/gm-server/app/service/Game.ts index a0538928b..a75627ced 100644 --- a/gm-server/app/service/Game.ts +++ b/gm-server/app/service/Game.ts @@ -1,6 +1,6 @@ import { Service } from 'egg'; import { STATUS } from '@consts'; -import { GameModel } from '@db/Game'; +// import { GameModel } from '@db/Game'; import { ServerlistModel } from '@db/Serverlist'; import { gameData } from '@pubUtils/data'; import { DicHero } from '@pubUtils/dictionary/DicHero'; @@ -21,27 +21,27 @@ export default class Game extends Service { /** * 获取正式服,测试服,开发服等环境 */ - public async getServerListByEnv() { - const { ctx, app } = this; - let env = app.config.env - let serverEnv = await GameModel.getServerEnvList(); - let curEnv = serverEnv.find(cur => cur.env == env); - const list = await ServerlistModel.findByServerType(curEnv?.serverType); + // public async getServerListByEnv() { + // const { ctx, app } = this; + // let env = app.config.env + // let serverEnv = await GameModel.getServerEnvList(); + // let curEnv = serverEnv.find(cur => cur.env == env); + // const list = await ServerlistModel.findByServerType(curEnv?.serverType); - return ctx.service.utils.resResult(STATUS.SUCCESS, { - list - }); - } + // return ctx.service.utils.resResult(STATUS.SUCCESS, { + // list + // }); + // } - public async getServerList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { id?: number, serverId?: string|number, name?: string, groupName?: string, groupId?: number, serverType?: string } = {}) { - const { ctx } = this; + // public async getServerList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { id?: number, serverId?: string|number, name?: string, groupName?: string, groupId?: number, serverType?: string } = {}) { + // const { ctx } = this; - const list = await ServerlistModel.findByCondition(page, pageSize, sortField, sortOrder, form); - const total = await ServerlistModel.countByCondition( form ) - return ctx.service.utils.resResult(STATUS.SUCCESS, { - list, total - }); - } + // const list = await ServerlistModel.findByCondition(page, pageSize, sortField, sortOrder, form); + // const total = await ServerlistModel.countByCondition( form ) + // return ctx.service.utils.resResult(STATUS.SUCCESS, { + // list, total + // }); + // } public async getRegions() { @@ -57,6 +57,7 @@ export default class Game extends Service { const { ctx } = this; const list = await ServerlistModel.getAllServerList(); + console.log('******', list) return ctx.service.utils.resResult(STATUS.SUCCESS, { list }); diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index 128493ca0..d1745c53d 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -707,6 +707,7 @@ export enum SERVER_STATUS { HOT = 2, // 火爆 WILL_OPEN = 3, // 即将开启 MAINTENANCE = 4, // 维护中 + HIDE = 0, // 隐藏 } export enum WHITE_LIST_TYPE { diff --git a/shared/db/Counter.ts b/shared/db/Counter.ts index 68a181dca..6ac266312 100644 --- a/shared/db/Counter.ts +++ b/shared/db/Counter.ts @@ -1,5 +1,5 @@ import BaseModel from './BaseModel'; -import { index, getModelForClass, prop, DocumentType, ReturnModelType, mongoose } from '@typegoose/typegoose'; +import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose'; /** * 自增 ID diff --git a/shared/db/GMMail.ts b/shared/db/GMMail.ts index 65d394359..a341f2cd0 100644 --- a/shared/db/GMMail.ts +++ b/shared/db/GMMail.ts @@ -23,8 +23,6 @@ export class Receiver { roleId?: string; @prop({ required: true }) roleName?: string; - @prop({ required: true }) - hasSend?: boolean; } export default class GMMail extends BaseModel { diff --git a/shared/db/Maintenance.ts b/shared/db/Maintenance.ts deleted file mode 100644 index 99a8393f9..000000000 --- a/shared/db/Maintenance.ts +++ /dev/null @@ -1,107 +0,0 @@ -import BaseModel from './BaseModel'; -import { index, getModelForClass, prop, DocumentType, mongoose, Ref } from '@typegoose/typegoose'; -import Marquee, { MarqueeType } from './Marquee'; -import Notice, { NoticeType } from './Notice'; -import GMMail from './GMMail'; -import { genCode } from '../pubUtils/util'; -import { GMMailType } from './GMMail'; - -/** - * 开服策略 -*/ -@index({ id: 1 }) - -export default class Maintenance extends BaseModel { - - @prop({ required: true }) - code: string; // 策略唯一标志 - - @prop({ required: true, type: Number }) - serverIds: number[]; // 服务器类型 - - @prop({ required: true }) - isOpen: boolean; // 维护是否使用 - - @prop({ required: true }) - startTime: Date; // 维护开始时间 - - @prop({ ref: () => Marquee, type: mongoose.Schema.Types.ObjectId }) - marquee: Ref; // 跑马灯,连接到marquee表 - - @prop({ ref: () => Notice, type: mongoose.Schema.Types.ObjectId }) - notice: Ref; // 维护公告 - - @prop({ ref: () => GMMail, type: mongoose.Schema.Types.ObjectId }) - mail: Ref; // 维护结束邮件 - - - public static async createData(values: MaintenanceTypeParam, marquee: MarqueeType, notice: NoticeType, mail: GMMailType, uid = 1) { - const code = genCode(8); - const rec: MaintenanceType = await MaintenanceModel.findOneAndUpdate({ code }, { - $setOnInsert: {...values, code, isOpen: false, marquee: marquee._id, notice: notice._id, mail: mail._id, createdBy: uid}, $set: { updatedBy: uid } - }, { new: true, upsert: true }).lean(); - return rec; - } - - public static async updateData(code: string, values: MaintenanceTypeParam, uid = 1) { - const rec: MaintenanceType = await MaintenanceModel.findOneAndUpdate({ code }, { $set: { ...values, updatedBy: uid } }, { new: true, upsert: true }) - .populate('marquee', 'code') - .populate('notice') - .populate('mail') - .lean(); - return rec; - } - - public static async findOpenMaintenance() { - const rec: MaintenanceType = await MaintenanceModel.findOne({ isOpen: true }, { _id: 0 }).populate('marquee').populate('notice').populate('mail').lean(); - return rec; - } - - public static async findByCode(code: string) { - const rec: MaintenanceType = await MaintenanceModel.findOne({ code }).populate('marquee').populate('notice').populate('mail').lean(); - return rec; - } - - public static async updateStatusByCode(code: string, isOpen: boolean, uid = 1) { - const rec: MaintenanceType = await MaintenanceModel.findOneAndUpdate({ code }, { $set: { isOpen, updatedBy: uid } }).populate('marquee').populate('notice').populate('mail').lean(); - return rec; - } - - private static getSearchObj(form: { isOpen?: boolean }) { - let searchObj = {}; - if (form.isOpen) searchObj['isOpen'] = form.isOpen; - return searchObj - } - - public static async findByCondition(page: number, pageSize: number, sortField: string, sortOrder: string, form: { isOpen?: boolean } = {}) { - - let searchObj = this.getSearchObj(form); - let sort = {}; - if (sortField && sortOrder) { - if (sortOrder == 'ascend') { - sort[sortField] = 1; - } else if (sortOrder == 'descend') { - sort[sortField] = -1; - } - } - const result: MaintenanceType[] = await MaintenanceModel.find(searchObj, { _id: 0 }) - .populate('marquee').populate('notice', '+showStartTime +showEndTime').populate('mail') - .limit(pageSize).skip((page - 1) * pageSize).sort(sort).lean({ getters: true, virtuals: true }); - return result; - - } - - public static async countByCondition(form: { isOpen?: boolean } = {}) { - - let searchObj = this.getSearchObj(form); - const result = await MaintenanceModel.count(searchObj); - return result; - } - - -} - -export const MaintenanceModel = getModelForClass(Maintenance); - -export interface MaintenanceType extends Pick, keyof Maintenance> { } -export type MaintenanceTypeParam = Partial; // 将所有字段变成可选项 \ No newline at end of file diff --git a/shared/db/Region.ts b/shared/db/Region.ts index 33ad11e70..a5da14952 100644 --- a/shared/db/Region.ts +++ b/shared/db/Region.ts @@ -3,6 +3,7 @@ import { CounterModel } from './Counter'; import BaseModel from './BaseModel'; import { index, getModelForClass, prop, DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose'; import ServerStategy from './ServerStategy'; +import { ServerlistType } from './Serverlist'; /** @@ -35,6 +36,9 @@ export default class Region extends BaseModel { @prop({ required: true }) latestServer: number; // 最新服 + @prop({ required: true }) + latestServerUniqId: number; // 最新服唯一id + @prop({ required: true }) serverCount: number; // 总数 @@ -56,6 +60,13 @@ export default class Region extends BaseModel { return rec; } + public static async newServer(id: number, newServer: ServerlistType, uid = 1) { + const rec: RegionType = await RegionModel.findOneAndUpdate({ id }, { + $set: { latestServer: newServer.serverId, latestServerUniqId: newServer.id, updatedBy: uid }, + $inc: { serverCount: 1 } + }, { new: true }).lean(); + return rec; + } public static async getAllRegion() { const rec: RegionType[] = await RegionModel.find().select('-_id -stategy').lean(); return rec; diff --git a/shared/db/Serverlist.ts b/shared/db/Serverlist.ts index 53c5e55ae..68ac8e72f 100644 --- a/shared/db/Serverlist.ts +++ b/shared/db/Serverlist.ts @@ -5,11 +5,31 @@ import { COUNTER, SERVER_STATUS } from '../consts'; import { CreateServerParam } from '../domain/backEndField/params'; import { RegionType } from './Region'; import { DicServerName } from '../pubUtils/dictionary/DicServerName'; +import { nowSeconds } from '../pubUtils/timeUtil'; +export class Maintenance { + + @prop({ required: true }) + batchCode: string; // 批次,如果是从大区列表维护就是一批的,小区列表上就是一服一个 + + @prop({ required: true }) + isOpen: boolean; // 维护是否使用 + + @prop({ required: true }) + startTime: number; // 维护开始时间 + + @prop({ required: true }) + endTime: number; // 维护结束时间 + + @prop({ required: true }) + hasNotify: boolean; // 是否有维护通知 + +} /** * 游戏字段接口 */ @index({ id: 1 }) +@index({ env: 1 }) @modelOptions({ schemaOptions: { id: false } }) export default class Serverlist extends BaseModel { @@ -23,7 +43,7 @@ export default class Serverlist extends BaseModel { prefix: string; // 前缀 @prop({ required: true }) - id: number; // 小区id 自增 + id: number; // 小区id 自增,全大区共用自增counter,玩家role表中存的就是这个serverId @prop({ required: true }) serverId: number; // 相同serverType下的id,不同serverType下id一定不同,但是serverId可能相同 @@ -44,8 +64,7 @@ export default class Serverlist extends BaseModel { activityGroupId: number[]; // 活动组 public get status() { - let now = new Date(); - if (now > this.openTime) { + if (nowSeconds() > this.openTime) { return this.serverStatus; } else { return SERVER_STATUS.WILL_OPEN; // 未开服 @@ -53,10 +72,10 @@ export default class Serverlist extends BaseModel { } @prop({ required: true }) - openTime: Date; + openTime: number; @prop({ required: true }) - stopRegisterTime: Date; + stopRegisterTime: number; @prop({ required: true, default: true }) canRegister: boolean; @@ -67,6 +86,9 @@ export default class Serverlist extends BaseModel { @prop({ required: true, default: 0 }) medianCe: number; // 中位数武将战力、缩小10000倍后的结果 + @prop({ required: true, type: Maintenance, _id: false }) + maintenance: Maintenance + public static async getAllServerList() { let id = await CounterAllModal.getCounter(COUNTER.SERVER); let result: ServerlistType[] = []; @@ -79,7 +101,7 @@ export default class Serverlist extends BaseModel { } public static async findByServerId(serverId: number) { - let server: ServerlistType = await ServerlistModel.findOne({ id: serverId }).select('medianCe activityGroupId').lean({ getters: true, virtuals: true }); + let server: ServerlistType = await ServerlistModel.findOne({ id: serverId }).lean({ getters: true, virtuals: true }); return server; } @@ -89,7 +111,7 @@ export default class Serverlist extends BaseModel { } public static async updateByServerId(serverId: number, update: ServerlistUpdate) { - let server: ServerlistType = await ServerlistModel.findOneAndUpdate({ id: serverId }, { $set: update }).lean({ getters: true, virtuals: true }); + let server: ServerlistType = await ServerlistModel.findOneAndUpdate({ id: serverId }, { $set: update }, {new: true}).lean({ getters: true, virtuals: true }); return server; } @@ -98,19 +120,13 @@ export default class Serverlist extends BaseModel { return result; } - public static async updateGroupName(groupId: number, groupName: string) { - let server = await ServerlistModel.updateMany({ groupId }, { $set: { groupName } }); - return server; - } - public static async newServer(params: CreateServerParam, region: RegionType, dicServerName: DicServerName, uid = 1 ) { let { prefix, id: regionId, env } = region; // 分大区 let id = await CounterAllModal.getNewCounter(COUNTER.SERVER); - let { openTime: openTimeNum, stopRegisterTime: hour, activityGroupId } = params; + let { openTime, stopRegisterTime: hour, activityGroupId } = params; let { id: serverId, sname: name, groupId, groupName } = dicServerName; - let openTime = new Date(openTimeNum * 1000); - let stopRegisterTime = new Date(openTimeNum + hour * 60 * 60); + let stopRegisterTime = openTime + hour * 60 * 60; const doc = new ServerlistModel(); const update = Object.assign(doc.toJSON(), { @@ -124,49 +140,11 @@ export default class Serverlist extends BaseModel { return server; } - public static async findByServerType(serverType?: string) { - let condition = {}; - if(serverType) { - condition['serverType'] = serverType; - } - let server: ServerlistType[] = await ServerlistModel.find(condition).sort({ id: -1 }).lean({ getters: true, virtuals: true }); + public static async findByEnv(env?: string) { + let server: ServerlistType[] = await ServerlistModel.find({ env, serverStatus: { $gt: 0 } }).sort({ id: -1 }).lean({ getters: true, virtuals: true }); return server; } - private static getSearchObj(form: { id?: number, serverId?: string|number, name?: string, groupName?: string, groupId?: number, serverType?: string }) { - let searchObj = {}; - if (form.id != undefined) searchObj['id'] = form.id; - if (form.serverId != undefined) searchObj['serverId'] = form.serverId; - if (form.groupId != undefined) searchObj['groupId'] = form.groupId; - if (form.name != undefined) searchObj['name'] = { $regex: new RegExp(form.name.toString(), 'i') }; - if (form.groupName != undefined) searchObj['groupName'] = { $regex: new RegExp(form.groupName.toString(), 'i') }; - if (form.serverType != undefined) searchObj['serverType'] = form.serverType; - return searchObj - } - - public static async findByCondition(page: number, pageSize: number, sortField: string, sortOrder: string, form: { id?: number, serverId?: string|number, name?: string, groupName?: string, groupId?: number, serverType?: string } = {}) { - - let searchObj = this.getSearchObj(form); - let sort = {}; - if(sortField && sortOrder) { - if(sortOrder == 'ascend') { - sort[sortField] = 1; - } else if (sortOrder == 'descend') { - sort[sortField] = -1; - } - } - const result: ServerlistType[] = await ServerlistModel.find(searchObj, { _id: 0 }).limit(pageSize).skip((page - 1) * pageSize).sort(sort).lean({ getters: true, virtuals: true }); - return result; - - } - - public static async countByCondition(form: { id?: number, serverId?: string|number, name?: string, groupName?: string, groupId?: number, serverType?: string } = {}) { - - let searchObj = this.getSearchObj(form); - const result = await ServerlistModel.count(searchObj); - return result; - } - //根据多个活动id查询活动数据 public static async findServerByIds(ids: number[]) { let result: ServerlistType[] = await ServerlistModel.find({ id: { $in: ids } }).lean(); diff --git a/shared/db/index.ts b/shared/db/index.ts index 64c559184..42adb0b1e 100644 --- a/shared/db/index.ts +++ b/shared/db/index.ts @@ -10,6 +10,7 @@ import { loadGMMailModel } from './GMMail'; import { loadCounterModal } from "./CounterAll"; export function loadGmDb(connect: mongoose.Connection) { + // console.log('************') loadApiModel(connect); loadGMGroupModel(connect); loadGMUserModel(connect); diff --git a/shared/domain/backEndField/params.ts b/shared/domain/backEndField/params.ts index 2a59e16d5..34b57cc6c 100644 --- a/shared/domain/backEndField/params.ts +++ b/shared/domain/backEndField/params.ts @@ -121,7 +121,9 @@ export class CreateServerParam { env: string = ''; openTime: number = 0; activityGroupId: number[] = []; + hasOpenMail: boolean = false; openMail?: GMMail; + hasCircleMail: boolean = false; circleMail?: GMMail; stopRegisterTime: number = 0; @@ -135,6 +137,8 @@ export class CreateServerParam { if(!this.env || !this.openTime || !this.stopRegisterTime || !isArray(this.activityGroupId) || this.activityGroupId.length <= 0 ) { return false } + if(this.hasOpenMail && !this.openMail) return false; + if(this.hasCircleMail && !this.circleMail) return false; return true; } } \ No newline at end of file diff --git a/shared/domain/gameField/serverlist.ts b/shared/domain/gameField/serverlist.ts index 1c6cabe1d..0aa331234 100644 --- a/shared/domain/gameField/serverlist.ts +++ b/shared/domain/gameField/serverlist.ts @@ -1,5 +1,4 @@ import { RoleType } from '../../db/Role'; -import { getSeconds } from '../../pubUtils/timeUtil'; import { ServerlistType } from '../../db/Serverlist'; export class ServerParam { @@ -15,10 +14,10 @@ export class ServerParam { constructor(server: ServerlistType) { this.id = server.id; this.serverId = server.serverId; - this.serverStr = `S${server.serverId}`; + this.serverStr = `${server.prefix}${server.serverId}`; this.name = server.name; this.status = server.status; - this.openTime = getSeconds(server.openTime); + this.openTime = server.openTime; } } @@ -31,15 +30,17 @@ export class GroupParam { constructor(server: ServerlistType) { this.groupId = server.groupId; this.groupName = server.groupName; - this.groupStr = `S${server.serverId}-S${server.serverId + 9}`; + this.groupStr = `${server.prefix}${server.serverId}`; this.servers = new Array(); } public pushServer(server: ServerlistType) { let srv = new ServerParam(server); this.servers.push(srv); - let min = this.servers.reduce((pre, cur) => pre < cur? pre: cur); - this.groupStr = `${min.serverId}-${min.serverId + 9}` + this.servers.sort((a, b) => b.serverId - a.serverId); + let min = this.servers[this.servers.length - 1]; + let max = this.servers[0]; + this.groupStr = `${min.serverStr}-${max.serverStr}` } } diff --git a/web-server/app/controller/game.ts b/web-server/app/controller/game.ts index 2cdbb530b..574299750 100644 --- a/web-server/app/controller/game.ts +++ b/web-server/app/controller/game.ts @@ -26,12 +26,12 @@ export default class GameController extends Controller { public async getServerList() { const { ctx } = this; - let { serverType, auth, uid, clientVersion } = ctx; + let { uid, clientVersion } = ctx; console.log('clientVersion', clientVersion); let serverList = new Array(); let loginServerList = new Array(); - let allServers = await ServerlistModel.findByServerType(auth == 1 ? null : serverType); + let allServers = await ServerlistModel.findByEnv(ctx.app.config.realEnv); let roles = await RoleModel.findAllByUid(uid, true, true); for (let server of allServers) { let curGroup = serverList.find(cur => cur.groupId == server.groupId); diff --git a/web-server/app/service/Game.ts b/web-server/app/service/Game.ts index faf39ab1b..8f93cedde 100644 --- a/web-server/app/service/Game.ts +++ b/web-server/app/service/Game.ts @@ -1,6 +1,5 @@ import { Service } from 'egg'; -import { MaintenanceModel } from '@db/Maintenance'; /** * Test Service @@ -12,14 +11,15 @@ export default class Game extends Service { // } public async getServerMainten() { - // return this.app['maintenServers']||[]; + // // return this.app['maintenServers']||[]; - const maintenance = await MaintenanceModel.findOpenMaintenance(); - if(maintenance) { - return maintenance.serverIds; - } else { - return []; - } + // const maintenance = await MaintenanceModel.findOpenMaintenance(); + // if(maintenance) { + // return maintenance.serverIds; + // } else { + // return []; + // } + return [] } // public async readDbMaintenance() { From b51a2839da197b29804ad1ecb6b1e129c1486e2e Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 8 Dec 2021 11:58:56 +0800 Subject: [PATCH 16/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=9C=8D=E5=8A=A1=E5=99=A8=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/gm/handler/gmServerHandler.ts | 5 ++++- game-server/app/services/timeTaskService.ts | 6 ------ gm-server/app/controller/game.ts | 16 ++++++++++++++++ gm-server/app/router.ts | 2 ++ gm-server/app/service/Game.ts | 15 +++++++++++++++ shared/db/Serverlist.ts | 9 ++++++--- web-server/app.ts | 4 ++++ web-server/app/controller/game.ts | 3 ++- web-server/app/service/Auth.ts | 6 +++--- 9 files changed, 52 insertions(+), 14 deletions(-) diff --git a/game-server/app/servers/gm/handler/gmServerHandler.ts b/game-server/app/servers/gm/handler/gmServerHandler.ts index 0b536995f..3f74b63ca 100644 --- a/game-server/app/servers/gm/handler/gmServerHandler.ts +++ b/game-server/app/servers/gm/handler/gmServerHandler.ts @@ -5,7 +5,7 @@ import moment = require('moment'); import { CreateServerParam, UpdateRegionParams } from '../../../domain/backEndField/params'; import { RegionModel } from '../../../db/Region'; import { gameData } from '../../../pubUtils/data'; -import { Maintenance, ServerlistModel } from '../../../db/Serverlist'; +import { Maintenance, ServerlistModel, ServerlistUpdate } from '../../../db/Serverlist'; import { nowSeconds } from '../../../pubUtils/timeUtil'; import { GM_MAIL_TYPE, MAIL_TIME_TYPE, REF_CIRCLE_MAIL_TIME } from '../../../consts'; import { SendMailFun } from '../../../services/mailService'; @@ -78,6 +78,9 @@ export class GmHandler { let server = await ServerlistModel.findByServerId(id); let maintenance = server.maintenance; if(maintenance) { + // 更新serverlist上的status + await ServerlistModel.updateByServerId(server.id, { 'maintenance.isOpen': false } as ServerlistUpdate); + // console.log('&&&', server, server.id) await pinus.app.rpc.systimer.systimerRemote.stopMaintenance.broadcast(maintenance.batchCode, [server.id]); } diff --git a/game-server/app/services/timeTaskService.ts b/game-server/app/services/timeTaskService.ts index d74eec711..a8295d528 100644 --- a/game-server/app/services/timeTaskService.ts +++ b/game-server/app/services/timeTaskService.ts @@ -486,9 +486,6 @@ async function startMaintenanceSchedule(batchCode: string) { await pinus.app.rpc.chat.chatRemote.sendServerMaintenance.toServer(chatSid, serverId); } } - - // 更新serverlist上的status - await ServerlistModel.updateByServerIds(serverIds, { serverStatus: SERVER_STATUS.MAINTENANCE }); // 更新connectorRemote里面的维护服务器 console.log('******** startMaintenanceSchedule', batchCode, serverIds, maintenance.startTime, maintenance.endTime) @@ -516,9 +513,6 @@ export async function stopMaintenance(batchCode: string, serverIds: number[]) { maintenInfos.delete(batchCode); } - // 更新serverlist上的status - await ServerlistModel.updateByServerIds(serverIds, { serverStatus: SERVER_STATUS.HOT, 'maintenance.isOpen': false } as ServerlistUpdate); - // 更新connectorRemote里面的维护服务器 pinus.app.rpc.connector.connectorRemote.stopServerMainten.broadcast(serverIds); pinus.app.rpc.activity.activityRemote.stopServerMainten.broadcast(serverIds); diff --git a/gm-server/app/controller/game.ts b/gm-server/app/controller/game.ts index ab7ffd912..c0256a531 100644 --- a/gm-server/app/controller/game.ts +++ b/gm-server/app/controller/game.ts @@ -38,6 +38,22 @@ export default class GameController extends Controller { return } + public async stopServerRegister() { + const { ctx } = this; + const { id } = ctx.request.body; + + ctx.body = await ctx.service.game.stopServerRegister(id); + return + } + + public async switchServerStatus() { + const { ctx } = this; + const { id, status } = ctx.request.body; + + ctx.body = await ctx.service.game.switchServerStatus(id, status); + return + } + // public async getMaintenanceList() { // const { ctx } = this; // const {page, pageSize, sortField, sortOrder, form} = ctx.request.body; diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index ace939d7c..b7d528755 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -55,6 +55,8 @@ export default (app: Application) => { router.post('/api/game/getregions', controller.game.getRegions); router.post('/api/game/getservers', controller.game.getServers); router.post('/api/game/getregionstategy', controller.game.getRegionStategy); + router.post('/api/game/stopserverregister', controller.game.stopServerRegister); + router.post('/api/game/swicthserverstatus', controller.game.switchServerStatus); // router.post('/api/game/getmaintenancelist', controller.game.getMaintenanceList); // router.post('/api/game/updatemaintenance', controller.game.updateMaintenance); diff --git a/gm-server/app/service/Game.ts b/gm-server/app/service/Game.ts index a75627ced..8ea7e3cd0 100644 --- a/gm-server/app/service/Game.ts +++ b/gm-server/app/service/Game.ts @@ -12,6 +12,7 @@ import { MarqueeModel, MarqueeParam } from '@db/Marquee'; import { AccuseRecModel } from '@db/AccuseRec'; import { RegionModel } from '@db/Region'; import { ActivityGroupModel } from '@db/ActivityGroup'; +import { nowSeconds } from '@pubUtils/timeUtil'; /** * Test Service @@ -63,6 +64,20 @@ export default class Game extends Service { }); } + public async stopServerRegister(id: number) { + const { ctx } = this; + const server = await ServerlistModel.updateByServerId(id, { stopRegisterTime: nowSeconds() - 1 }); + if(!server) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); + return ctx.service.utils.resResult(STATUS.SUCCESS); + } + + public async switchServerStatus(id: number, status: number) { + const { ctx } = this; + const server = await ServerlistModel.updateByServerId(id, { serverStatus: status }); + if(!server) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); + return ctx.service.utils.resResult(STATUS.SUCCESS); + } + public async getRegionStategy(id: number) { const { ctx } = this; let region = await RegionModel.findRegionById(id); diff --git a/shared/db/Serverlist.ts b/shared/db/Serverlist.ts index 68ac8e72f..1d1ac3bbf 100644 --- a/shared/db/Serverlist.ts +++ b/shared/db/Serverlist.ts @@ -64,10 +64,13 @@ export default class Serverlist extends BaseModel { activityGroupId: number[]; // 活动组 public get status() { - if (nowSeconds() > this.openTime) { - return this.serverStatus; + let now = nowSeconds(); + if (now < this.openTime) { + return SERVER_STATUS.WILL_OPEN; + } else if (this.maintenance && this.maintenance.isOpen && this.maintenance.startTime < now && this.maintenance.endTime > now) { + return SERVER_STATUS.MAINTENANCE; } else { - return SERVER_STATUS.WILL_OPEN; // 未开服 + return this.serverStatus; // 未开服 } } diff --git a/web-server/app.ts b/web-server/app.ts index 98722b94e..514dc7ba6 100644 --- a/web-server/app.ts +++ b/web-server/app.ts @@ -19,6 +19,10 @@ export default class FooBoot implements IBoot { await this.connectGMDB(this.app); await this.connectRedis(this.app); + this.app.config.realEnv = this.app.config.env; + if(this.app.config.env == 'local') { + this.app.config.realEnv = 'development'; + } } configDidLoad() { diff --git a/web-server/app/controller/game.ts b/web-server/app/controller/game.ts index 574299750..ea6fdb30d 100644 --- a/web-server/app/controller/game.ts +++ b/web-server/app/controller/game.ts @@ -31,6 +31,7 @@ export default class GameController extends Controller { let serverList = new Array(); let loginServerList = new Array(); + console.log('****', ctx.app.config.realEnv) let allServers = await ServerlistModel.findByEnv(ctx.app.config.realEnv); let roles = await RoleModel.findAllByUid(uid, true, true); for (let server of allServers) { @@ -50,7 +51,7 @@ export default class GameController extends Controller { loginServerList.sort((a, b) => { return b.updatedAt.getTime() - a.updatedAt.getTime() }); - if (serverList && serverList.length > 0) { + if (serverList) { ctx.body = ctx.service.utils.resResult(STATUS.SUCCESS, { serverList, loginServerList }); } else { ctx.body = ctx.service.utils.resResult(STATUS.SERVER_NOT_FOUND); diff --git a/web-server/app/service/Auth.ts b/web-server/app/service/Auth.ts index 5b0b5d332..c79d9f5a0 100644 --- a/web-server/app/service/Auth.ts +++ b/web-server/app/service/Auth.ts @@ -291,10 +291,10 @@ export default class Auth extends Service { const ctx = this.ctx; const { uid } = ctx; const role = await RoleModel.findByUid(uid, serverId); - if(role.blockType == BLOCK_TYPE.BLOCK) { - return ctx.service.utils.resResult(STATUS.BLOCKED); - } if (role) { + if(role.blockType == BLOCK_TYPE.BLOCK) { + return ctx.service.utils.resResult(STATUS.BLOCKED); + } return ctx.service.utils.resResult(STATUS.SUCCESS, { roleId: role.roleId }); } return ctx.service.utils.resResult(STATUS.ROLE_NOT_FOUND); From 02c2096704a98dce817fd230abad3b800262c289 Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 8 Dec 2021 14:59:01 +0800 Subject: [PATCH 17/32] =?UTF-8?q?=E9=85=8D=E7=BD=AE=EF=BC=9A=E5=8E=BB?= =?UTF-8?q?=E9=99=A4stable=E6=9C=8Denv=E7=9A=84=E7=89=B9=E6=AE=8A=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config.js | 3 -- .../app/servers/gm/handler/gmServerHandler.ts | 14 ++++++++ .../app/services/activity/activityService.ts | 21 ++++++------ game-server/app/services/timeTaskService.ts | 28 ++++++++++++---- game-server/config.js | 3 -- game-server/config/database.ts | 2 +- game-server/config/master.ts | 5 +++ game-server/config/serverName.ts | 4 +-- game-server/config/servers.ts | 2 +- gm-server/app/service/Activity.ts | 17 +++++----- web-server/app/controller/game.ts | 1 - web-server/app/middleware/checkMainten.ts | 6 ++-- web-server/app/service/Game.ts | 33 ------------------- web-server/typings/app/service/index.d.ts | 2 -- 14 files changed, 66 insertions(+), 75 deletions(-) delete mode 100644 web-server/app/service/Game.ts diff --git a/config.js b/config.js index a0f15c076..59b624a33 100644 --- a/config.js +++ b/config.js @@ -5,9 +5,6 @@ function main (){ return console.log('参数请填写环境变量'); } let env = args[0]; - if(args[0] == 'stable') { - env = 'production'; - } let configObject = { env: env diff --git a/game-server/app/servers/gm/handler/gmServerHandler.ts b/game-server/app/servers/gm/handler/gmServerHandler.ts index 3f74b63ca..3f6aae810 100644 --- a/game-server/app/servers/gm/handler/gmServerHandler.ts +++ b/game-server/app/servers/gm/handler/gmServerHandler.ts @@ -71,6 +71,20 @@ export class GmHandler { return resResult(STATUS.SUCCESS,); } + // 大区一起维护 + async startRegionMaintenance(msg: { startTime: number, endTime: number, hasNotify: boolean }, session: BackendSession) { + const { startTime, endTime, hasNotify } = msg; + if(!isNumber(startTime) || !isNumber(endTime)) return resResult(STATUS.WRONG_PARMS); + const uid = session.get('uid'); + let newMaintenance: Maintenance = { batchCode: genCode(10), startTime, endTime, hasNotify, isOpen: true } + let servers = await ServerlistModel.findByEnv(this.app.get('env')); + console.log('*********servers', servers) + await ServerlistModel.updateByServerIds(servers.map(server => server.id), { maintenance: newMaintenance }); + await pinus.app.rpc.systimer.systimerRemote.initMaintenance.broadcast(servers); + + return resResult(STATUS.SUCCESS,); + } + // 提前结束维护 async stopMaintenance(msg: { id: number }, session: BackendSession) { const { id } = msg; diff --git a/game-server/app/services/activity/activityService.ts b/game-server/app/services/activity/activityService.ts index 9216ab75e..745b82eff 100644 --- a/game-server/app/services/activity/activityService.ts +++ b/game-server/app/services/activity/activityService.ts @@ -261,22 +261,21 @@ export function _getActivities() { export async function checkActivityEditable(activities: ActivityModelType[]) { let now = new Date(); - if(pinus.app.get('env') == 'production') { - for(let activity of activities) { - if(!activity || (activity.beginTime < now && activity.endTime > now)) { - - if(activity.type == ACTIVITY_TYPE.SIGN_IN || activity.type == ACTIVITY_TYPE.SIGN_IN_VIP) { - // 签到活动的不显示期内也可以编辑 - let signInObj = new SignInData(activity, 0); - if(signInObj.beginTime < now.getTime() && signInObj.endTime > now.getTime() ) { - return false; - } - } else { + for(let activity of activities) { + if(!activity || (activity.beginTime < now && activity.endTime > now)) { + + if(activity.type == ACTIVITY_TYPE.SIGN_IN || activity.type == ACTIVITY_TYPE.SIGN_IN_VIP) { + // 签到活动的不显示期内也可以编辑 + let signInObj = new SignInData(activity, 0); + if(signInObj.beginTime < now.getTime() && signInObj.endTime > now.getTime() ) { return false; } + } else { + return false; } } } + return true; } diff --git a/game-server/app/services/timeTaskService.ts b/game-server/app/services/timeTaskService.ts index a8295d528..974a677a2 100644 --- a/game-server/app/services/timeTaskService.ts +++ b/game-server/app/services/timeTaskService.ts @@ -29,23 +29,21 @@ import { GMMailModel } from '../db/GMMail'; import { Maintenance, ServerlistModel, ServerlistType, ServerlistUpdate } from '../db/Serverlist'; import { getWorldChannelSid } from './chatService'; import { createMarqueeMsg, pushMarqueeMsg } from './sysChatService'; +import { RegionModel, RegionType } from '../db/Region'; const PER_SECOND = 1 * 1000; const PER_DAY = 24 * 60 * 60; const PER_HOUR = 1 * 60 * 60; const PER_MINUTE = 1 * 60; var seasonMakeRewardTimJobId: Job; -var warJobId: Job; var seasonRefreshTimeJobId: Job; let guildWeeklyJobId: Job; let guildActStartJobId: Job; // 军团活动开启后每10(or 1)秒循环的定时任务,到结束活动清除 let guildActSecondsJobId: Job; // 军团活动开启后每10(or 1)秒循环的定时任务,到结束活动清除 let guildActEndJobId: Job; // 军团活动开启后每10(or 1)秒循环的定时任务,到结束活动清除 -let pvpMakeRewardInterval = null; -let pvpRefreshInterval = null; /** - * 服务器启动即开启定时任务,结算时常是23-24点,实际结算的时间点是23:31分钟 + * 初始定时器 */ export async function init() { @@ -83,6 +81,7 @@ export async function init() { await initMaintenance(); } +// —————————————— PVP 及赛季相关 —————————————— // function getSeasonContinueDay(seasonNum: number) { const pvpSeasonDuring = PVP.PVP_SEASON_DAYS.split('|').map(cur => { let arr = cur.split('&'); @@ -197,7 +196,9 @@ export async function reportOnlineSchedule() { } } +// —————————————— PVP 及赛季相关 end —————————————— // +// —————————————— 军团活动 —————————————— // /** * 军团活动,每晚8点开启 */ @@ -343,6 +344,10 @@ export async function raceActivitySeconds() { } } +// —————————————— 军团活动 end —————————————— // + +// —————————————— 拍卖行 —————————————— // + let startGuildAuctionJobId: Job; let startWorldAuctionJobId: Job; let stopAuctionJobId: Job; @@ -383,7 +388,9 @@ function clearAuctionSchedule() { } } +// —————————————— 拍卖行 end —————————————— // +// —————————————— 邮件 —————————————— // async function sendCircleMail() { let gmmails = await GMMailModel.findCircleMails(pinus.app.get('env')); for(let gmmail of gmmails) { @@ -401,9 +408,9 @@ async function sendCircleMail() { } } +// —————————————— 邮件 end —————————————— // -/*** 维护 */ - +// —————————————— 维护 —————————————— // let maintenInfos = new Map(); // batchCode => {servers, maintenance} export async function initMaintenance(servers?: ServerlistType[]) { if(!servers) servers = await ServerlistModel.findByEnv(pinus.app.get('env')); @@ -521,4 +528,11 @@ export async function stopMaintenance(batchCode: string, serverIds: number[]) { pinus.app.rpc.guild.guildRemote.stopServerMainten.broadcast(serverIds); pinus.app.rpc.order.orderRemote.stopServerMainten.broadcast(serverIds); pinus.app.rpc.role.roleRemote.stopServerMainten.broadcast(serverIds); -} \ No newline at end of file +} + +// —————————————— 维护 end —————————————— // +// —————————————— 自动开服 —————————————— // +async function initAutoCreateServer(region?: RegionType) { + if(!region) region = await RegionModel.findRegionByEnv(pinus.app.get('env')); +} +// —————————————— 自动开服 end —————————————— // \ No newline at end of file diff --git a/game-server/config.js b/game-server/config.js index 94c26d348..499ce9914 100644 --- a/game-server/config.js +++ b/game-server/config.js @@ -5,9 +5,6 @@ function main (){ return console.log('参数请填写环境变量'); } let env = args[0]; - if(args[0] == 'stable') { - env = 'production'; - } let configObject = { env: env diff --git a/game-server/config/database.ts b/game-server/config/database.ts index 432ddce4e..844a90380 100644 --- a/game-server/config/database.ts +++ b/game-server/config/database.ts @@ -6,7 +6,7 @@ module.exports = { 'redispw': 'zyz_2020' }, - 'production': { + 'stable': { 'mongo': 'mongodb://dbop:zyzdbopbantu@dds-8vbdb47c6fb58a541.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vbdb47c6fb58a542.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-500808098', 'gmmongo': 'mongodb://dbop:zyzGm2021@dds-8vb9964bb4cc7f241.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb9964bb4cc7f242.mongodb.zhangbei.rds.aliyuncs.com:3717/zyzgm?replicaSet=mgset-507933150', 'redis': 'r-8vb4i2kgl91886fkxd.redis.zhangbei.rds.aliyuncs.com', diff --git a/game-server/config/master.ts b/game-server/config/master.ts index 98ce0b1ff..d4ae37c90 100644 --- a/game-server/config/master.ts +++ b/game-server/config/master.ts @@ -9,6 +9,11 @@ module.exports = { 'host': '127.0.0.1', 'port': 3005 }, + 'stable': { + 'id': 'master-server-1', + 'host': '127.0.0.1', + 'port': 3005 + }, 'alpha': { 'id': 'master-server-1', 'host': '172.26.145.159', diff --git a/game-server/config/serverName.ts b/game-server/config/serverName.ts index ae9e62a9a..ff71680ee 100644 --- a/game-server/config/serverName.ts +++ b/game-server/config/serverName.ts @@ -3,8 +3,8 @@ module.exports = { 'type': 'development', 'name': '本地服' }, - 'production': { - 'type': 'production', + 'stable': { + 'type': 'stable', 'name': '正式服' }, 'alpha': { diff --git a/game-server/config/servers.ts b/game-server/config/servers.ts index e71cd1324..4b4c48892 100644 --- a/game-server/config/servers.ts +++ b/game-server/config/servers.ts @@ -50,7 +50,7 @@ module.exports = { { 'id': 'order-server-1', 'host': '127.0.0.1', 'port': 6060, "args": " --inspect=9242" }, ] }, - 'production': { + 'stable': { 'connector': [ { 'id': 'connector-server-1', 'port': 4050, 'clientHost': 'zyz_web.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3050, 'frontend': true }, { 'id': 'connector-server-2', 'port': 4051, 'clientHost': 'zyz_web.trgame.cn', 'host': '127.0.0.1', 'clientPort': 3051, 'frontend': true }, diff --git a/gm-server/app/service/Activity.ts b/gm-server/app/service/Activity.ts index 952b83c0a..7f8700cf8 100644 --- a/gm-server/app/service/Activity.ts +++ b/gm-server/app/service/Activity.ts @@ -35,20 +35,19 @@ export default class Activity extends Service { let now = new Date(); let activity = await ActivityModel.findActivity(activityId); - if(this.app.config.env == 'production') { - if(!activity || (activity.beginTime < now && activity.endTime > now)) { + if(!activity || (activity.beginTime < now && activity.endTime > now)) { - if(activity.type == ACTIVITY_TYPE.SIGN_IN || activity.type == ACTIVITY_TYPE.SIGN_IN_VIP) { - // 签到活动的不显示期内也可以编辑 - let signInObj = new SignInData(activity, 0); - if(signInObj.beginTime < now.getTime() && signInObj.endTime > now.getTime() ) { - return this.ctx.service.utils.resResult(STATUS.GM_CAN_NOT_EDIT_ACT); - } - } else { + if(activity.type == ACTIVITY_TYPE.SIGN_IN || activity.type == ACTIVITY_TYPE.SIGN_IN_VIP) { + // 签到活动的不显示期内也可以编辑 + let signInObj = new SignInData(activity, 0); + if(signInObj.beginTime < now.getTime() && signInObj.endTime > now.getTime() ) { return this.ctx.service.utils.resResult(STATUS.GM_CAN_NOT_EDIT_ACT); } + } else { + return this.ctx.service.utils.resResult(STATUS.GM_CAN_NOT_EDIT_ACT); } } + return 0 } diff --git a/web-server/app/controller/game.ts b/web-server/app/controller/game.ts index ea6fdb30d..776b3491b 100644 --- a/web-server/app/controller/game.ts +++ b/web-server/app/controller/game.ts @@ -31,7 +31,6 @@ export default class GameController extends Controller { let serverList = new Array(); let loginServerList = new Array(); - console.log('****', ctx.app.config.realEnv) let allServers = await ServerlistModel.findByEnv(ctx.app.config.realEnv); let roles = await RoleModel.findAllByUid(uid, true, true); for (let server of allServers) { diff --git a/web-server/app/middleware/checkMainten.ts b/web-server/app/middleware/checkMainten.ts index 03a95f6c6..debf1f4d6 100644 --- a/web-server/app/middleware/checkMainten.ts +++ b/web-server/app/middleware/checkMainten.ts @@ -1,12 +1,14 @@ import { STATUS } from '@consts'; +import { ServerlistModel } from '@db/Serverlist'; +import { nowSeconds } from 'app/pubUtils/timeUtil'; import { checkWhiteList } from 'app/pubUtils/util'; module.exports = () => { return async function checkMainten(ctx, next) { const { serverId } = ctx.request.body; if (serverId) { - let maintenServers = await ctx.service.game.getServerMainten(); - if (maintenServers.indexOf(serverId) != -1) { + let server = await ServerlistModel.findByServerId(serverId); + if (server && server.maintenance && server.maintenance.isOpen && server.maintenance.startTime < nowSeconds() && server.maintenance.endTime > nowSeconds()) { let isWhiteList = await checkWhiteList(ctx.tel, ctx.request.ip); if (isWhiteList) { await next(); diff --git a/web-server/app/service/Game.ts b/web-server/app/service/Game.ts deleted file mode 100644 index 8f93cedde..000000000 --- a/web-server/app/service/Game.ts +++ /dev/null @@ -1,33 +0,0 @@ - -import { Service } from 'egg'; - -/** - * Test Service - */ -export default class Game extends Service { - - // public setServerMainten(maintenServers: number[]) { - // return this.app['maintenServers'] = maintenServers; - // } - - public async getServerMainten() { - // // return this.app['maintenServers']||[]; - - // const maintenance = await MaintenanceModel.findOpenMaintenance(); - // if(maintenance) { - // return maintenance.serverIds; - // } else { - // return []; - // } - return [] - } - - // public async readDbMaintenance() { - // const maintenance = await MaintenanceModel.findOpenMaintenance(); - // if(maintenance) { - // this.setServerMainten(maintenance.serverIds); - // } - // } - - -} diff --git a/web-server/typings/app/service/index.d.ts b/web-server/typings/app/service/index.d.ts index 74e610693..c555ba577 100644 --- a/web-server/typings/app/service/index.d.ts +++ b/web-server/typings/app/service/index.d.ts @@ -7,7 +7,6 @@ type AnyFunc = (...args: any[]) => T; type CanExportFunc = AnyFunc> | AnyFunc>; type AutoInstanceType : T> = U extends AnyClass ? InstanceType : U; import ExportAuth from '../../../app/service/Auth'; -import ExportGame from '../../../app/service/Game'; import ExportSdk from '../../../app/service/Sdk'; import ExportTest from '../../../app/service/Test'; import ExportTurboCore from '../../../app/service/TurboCore'; @@ -17,7 +16,6 @@ import ExportUtils from '../../../app/service/Utils'; declare module 'egg' { interface IService { auth: AutoInstanceType; - game: AutoInstanceType; sdk: AutoInstanceType; test: AutoInstanceType; turboCore: AutoInstanceType; From fc38485f94df764a31c098ccf068fd1e5fa9d382 Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 8 Dec 2021 16:23:00 +0800 Subject: [PATCH 18/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E5=BC=80=E6=9C=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/gm/handler/gmServerHandler.ts | 18 ++-- game-server/app/services/gmService.ts | 85 +++---------------- game-server/app/services/timeTaskService.ts | 47 ++++++++-- shared/consts/constModules/sysConst.ts | 2 +- shared/consts/statusCode.ts | 1 + shared/db/Serverlist.ts | 15 +++- shared/domain/backEndField/params.ts | 23 ++++- web-server/app/service/Auth.ts | 8 +- 8 files changed, 102 insertions(+), 97 deletions(-) diff --git a/game-server/app/servers/gm/handler/gmServerHandler.ts b/game-server/app/servers/gm/handler/gmServerHandler.ts index 3f6aae810..e595abe36 100644 --- a/game-server/app/servers/gm/handler/gmServerHandler.ts +++ b/game-server/app/servers/gm/handler/gmServerHandler.ts @@ -3,14 +3,14 @@ import { genCode, getRandSingleEelm, resResult } from '../../../pubUtils/util'; import { STATUS } from '../../../consts/statusCode'; import moment = require('moment'); import { CreateServerParam, UpdateRegionParams } from '../../../domain/backEndField/params'; -import { RegionModel } from '../../../db/Region'; +import { RegionModel, RegionType } from '../../../db/Region'; import { gameData } from '../../../pubUtils/data'; import { Maintenance, ServerlistModel, ServerlistUpdate } from '../../../db/Serverlist'; import { nowSeconds } from '../../../pubUtils/timeUtil'; import { GM_MAIL_TYPE, MAIL_TIME_TYPE, REF_CIRCLE_MAIL_TIME } from '../../../consts'; import { SendMailFun } from '../../../services/mailService'; -import { sendOpenServerMail } from '../../../services/gmService'; -import { initMaintenance, stopMaintenance } from '../../../services/timeTaskService'; +import { createNewServer, sendOpenServerMail } from '../../../services/gmService'; +import { initAutoCreateServer, initMaintenance, stopMaintenance } from '../../../services/timeTaskService'; import { isNumber } from 'util'; let timer: NodeJS.Timer; export default function (app: Application) { @@ -26,15 +26,18 @@ export class GmHandler { let params = new UpdateRegionParams(msg); let uid = session.get('uid'); if(!params.checkParams()) return resResult(STATUS.WRONG_PARMS); + let region: RegionType; if(params.id == 'new') { let update = params.getUpdateParam(); - await RegionModel.createNewRegion(update, uid); + region = await RegionModel.createNewRegion(update, uid); } else { let oldRegion = await RegionModel.findRegionById(params.id); if(!oldRegion) return resResult(STATUS.WRONG_PARMS); let update = params.getUpdateParam(oldRegion); - await RegionModel.updateRegion(params.id, update, uid); + region = await RegionModel.updateRegion(params.id, update, uid); } + await initAutoCreateServer(region); + return resResult(STATUS.SUCCESS); } @@ -52,10 +55,7 @@ export class GmHandler { let dicServerName = gameData.serverNames.get(latestServer + 1); if(!dicServerName) return resResult(STATUS.DIC_DATA_NOT_FOUND); - let newServer = await ServerlistModel.newServer(params, curRegion, dicServerName, uid); - if(params.openMail) await sendOpenServerMail('openMail', params.openMail, newServer, uid); - if(params.circleMail) await sendOpenServerMail('circleMail', params.circleMail, newServer, uid); - await RegionModel.newServer(curRegion.id, newServer) + await createNewServer(curRegion, latestServer + 1, params, uid); return resResult(STATUS.SUCCESS); } diff --git a/game-server/app/services/gmService.ts b/game-server/app/services/gmService.ts index 4faea1a24..63eebd310 100644 --- a/game-server/app/services/gmService.ts +++ b/game-server/app/services/gmService.ts @@ -11,6 +11,8 @@ import { SendMailFun } from "./mailService"; import GMMail, { GMMailModel, GMMailType } from '../db/GMMail'; import moment = require("moment"); import { getSeconds, nowSeconds } from "../pubUtils/timeUtil"; +import { CreateServerParam } from "../domain/backEndField/params"; +import { RegionModel, RegionType } from "../db/Region"; // —————————————— 跑马灯 —————————————— // // 初始 @@ -102,77 +104,6 @@ export async function cancelMarquee(code: string) { return true } -// —————————————— 停服维护 —————————————— // -// 维护信息 -// export async function initMaintenance() { -// let servers = await ServerlistModel.findByEnv(pinus.app.get('env')); -// for(let server of servers) -// // if(!maintenance) -// // maintenance = await MaintenanceModel.findOpenMaintenance(); -// // if(maintenance) { -// // let { startTime, marquee } = maintenance; -// // if(marquee) { -// // let result = await generateMarqueeSchedule(marquee); -// // // console.log(result); -// // } -// // if(Date.now() > startTime.getTime()) { -// // await startMaintenance(maintenance); -// // } else { -// // let startJob = scheduleJob(`startMainten${maintenance.code}`, startTime.getTime(), async () => { -// // await startMaintenance(maintenance, startJob); -// // }); -// // } -// } -// } - -// // 开启维护 -// async function startMaintenance(maintenance: MaintenanceType, startJob?: Job) { -// // 向全服发送 -// let { serverIds, notice } = maintenance; -// for(let serverId of serverIds) { -// let chatSid = await getWorldChannelSid(serverId); -// await pinus.app.rpc.chat.chatRemote.sendServerMaintenance.toServer(chatSid, serverId); -// } - -// // 更新serverlist上的status -// await ServerlistModel.updateByServerIds(serverIds, { serverStatus: SERVER_STATUS.MAINTENANCE }); -// // 更新notice的isEnable -// if(notice) { -// await NoticeModel.updateNotice((notice).id, { isEnable: true }); -// } - -// // 更新connectorRemote里面的维护服务器 -// await pinus.app.rpc.connector.connectorRemote.setServerMainten.broadcast(serverIds); -// } - -// // 停止维护 -// 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 -// if(notice) { -// await NoticeModel.updateNotice((notice).id, { isEnable: false }); -// } - -// // 更新connectorRemote里面的维护服务器 -// let connectorServers = pinus.app.getServersByType('connector'); -// for(let { id } of connectorServers) { -// await pinus.app.rpc.connector.connectorRemote.setServerMainten.toServer(id, []); -// } - -// if(marquee) { -// await cancelMarquee((marquee).code); -// } -// console.log('*****', JSON.stringify(mail)); -// if(mail) { -// let f = new SendMailFun(); -// await f.setWithGmMail((mail)._id); -// await f.sendToServer(serverIds); -// // await f.saveRecord(uid); -// } -// } - export async function sendOpenServerMail(type: 'openMail'|'circleMail', mail: GMMail, newServer: ServerlistType, uid: number) { let receivers = [{ env: newServer.env, @@ -186,7 +117,8 @@ export async function sendOpenServerMail(type: 'openMail'|'circleMail', mail: GM let gmmail = await GMMailModel.addMail(addParam, uid); let needSend = false; if(mail.timeType == MAIL_TIME_TYPE.CIRCLE) { - let refTime = moment(moment().format(`YYYY-MM-DD ${REF_CIRCLE_MAIL_TIME}:00:00`)).unix(); + let refTimeStr = REF_CIRCLE_MAIL_TIME >= 10? `${REF_CIRCLE_MAIL_TIME}`: `0${REF_CIRCLE_MAIL_TIME}`; + let refTime = moment(moment().format(`YYYY-MM-DD ${refTimeStr}:00:00`)).unix(); let sendTime = moment(moment().format('YYYY-MM-DD '+ mail.circleHour)).unix(); if(sendTime < refTime) sendTime += 86400; let now = nowSeconds(); @@ -204,8 +136,6 @@ export async function sendOpenServerMail(type: 'openMail'|'circleMail', mail: GM return true; } - - export function setServerMainten(serverIds: number[], startTime: number, endTime: number) { let maintenServers = pinus.app.get('maintenServers')||new Map(); for(let id of serverIds) { @@ -232,4 +162,11 @@ export function stopServerMainten(serverIds: number[]) { export function getServerMainten(serverId: number) { let maintenServers = pinus.app.get('maintenServers')||new Map(); return maintenServers.get(serverId); +} + +export async function createNewServer(region: RegionType ,serverId: number, params: CreateServerParam, uid?: number) { + let newServer = await ServerlistModel.newServer(params, region, serverId, uid); + if(params.openMail) await sendOpenServerMail('openMail', params.openMail, newServer, uid); + if(params.circleMail) await sendOpenServerMail('circleMail', params.circleMail, newServer, uid); + await RegionModel.newServer(region.id, newServer); } \ No newline at end of file diff --git a/game-server/app/services/timeTaskService.ts b/game-server/app/services/timeTaskService.ts index 974a677a2..a6a32eecd 100644 --- a/game-server/app/services/timeTaskService.ts +++ b/game-server/app/services/timeTaskService.ts @@ -5,7 +5,7 @@ import { nowSeconds, getTimeFun, getSeconds } from '../pubUtils/timeUtil'; import { getTodayGuildActivity, gameData } from '../pubUtils/data'; import { pvpSeasonEnd } from './pvpService'; import { getAllOnlineRoles, getAllServers, delGuildActivityRank } from './redisService'; -import { GUILD_ACTIVITY_TYPE, REFRESH_TIME, SEND_NAME, SERVER_OPEN_TIME, COUNTER, AUCTION_TIME, GM_MAIL_TYPE, SERVER_STATUS } from '../consts'; +import { GUILD_ACTIVITY_TYPE, REFRESH_TIME, SEND_NAME, SERVER_OPEN_TIME, COUNTER, AUCTION_TIME, GM_MAIL_TYPE, SERVER_STATUS, SERVER_TIMER } from '../consts'; import { RoleModel } from '../db/Role'; import { pinus } from 'pinus'; import { indexOf } from 'underscore'; @@ -19,7 +19,7 @@ import { dispatch } from '../pubUtils/dispatcher'; import { Rank } from './rankService'; import { checkTask } from './taskService'; import { everydayRefresh } from './connectorService'; -import { initMarquee } from './gmService'; +import { createNewServer, initMarquee } from './gmService'; import moment = require('moment'); import { CounterModel } from '../db/Counter'; import { reportOneOnline } from './authenticateService'; @@ -30,6 +30,7 @@ import { Maintenance, ServerlistModel, ServerlistType, ServerlistUpdate } from ' import { getWorldChannelSid } from './chatService'; import { createMarqueeMsg, pushMarqueeMsg } from './sysChatService'; import { RegionModel, RegionType } from '../db/Region'; +import { CreateServerParam } from '../domain/backEndField/params'; const PER_SECOND = 1 * 1000; const PER_DAY = 24 * 60 * 60; @@ -79,6 +80,9 @@ export async function init() { // 维护信息 await initMaintenance(); + + // 自动开服 + await initAutoCreateServer(); } // —————————————— PVP 及赛季相关 —————————————— // @@ -415,8 +419,6 @@ let maintenInfos = new Map { + autoCreateServerSchedule(region); + }) + } +} + +async function autoCreateServerSchedule(region: RegionType) { + console.log('******* createNewServer *******') + let latestServer = await ServerlistModel.findByServerId(region.latestServerUniqId); + if(!latestServer || latestServer.playerCnt >= region.stategy.maxPlayerCnt) { + let params = new CreateServerParam(); + params.setByRegionStategy(region, nowSeconds()) + await createNewServer(region, (latestServer?.serverId||0) + 1, params); + } } // —————————————— 自动开服 end —————————————— // \ No newline at end of file diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index d1745c53d..b5d9fcd94 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -762,5 +762,5 @@ export enum SERVER_TIMER { FIVE_HALF = 1, // 5:30 TEN_HALF = 2, // 10:30 FIFTEEN_HALF = 3, // 15:30 - SEVENTEEN_HALF = 4, // 19:30 + NINETEEN_HALF = 4, // 19:30 } \ No newline at end of file diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index b7d8cc406..c47e9a03c 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -37,6 +37,7 @@ export const STATUS = { ROLE_EXIST: { code: 10017, simStr: '账号已存在' }, CHANNEL_ERR: { code: 10018, simStr: '无此渠道' }, VALIDATE_ERR: { code: 10019, simStr: '渠道校验错误' }, + SERVER_STOP_REGISTER: { code: 10020, simStr: '服务器已停止注册' }, // 战斗相关状态 20000 - 29999 // 战斗通用 20000 - 20099 BATTLE_MISS_INFO: { code: 20001, simStr: '缺少关卡信息' }, diff --git a/shared/db/Serverlist.ts b/shared/db/Serverlist.ts index 1d1ac3bbf..145c18a07 100644 --- a/shared/db/Serverlist.ts +++ b/shared/db/Serverlist.ts @@ -4,8 +4,8 @@ import { CounterAllModal } from './CounterAll'; import { COUNTER, SERVER_STATUS } from '../consts'; import { CreateServerParam } from '../domain/backEndField/params'; import { RegionType } from './Region'; -import { DicServerName } from '../pubUtils/dictionary/DicServerName'; import { nowSeconds } from '../pubUtils/timeUtil'; +import { gameData } from '../pubUtils/data'; export class Maintenance { @@ -123,12 +123,13 @@ export default class Serverlist extends BaseModel { return result; } - public static async newServer(params: CreateServerParam, region: RegionType, dicServerName: DicServerName, uid = 1 ) { + public static async newServer(params: CreateServerParam, region: RegionType, serverId: number, uid = 1 ) { + let dicServerName = gameData.serverNames.get(serverId); let { prefix, id: regionId, env } = region; // 分大区 let id = await CounterAllModal.getNewCounter(COUNTER.SERVER); let { openTime, stopRegisterTime: hour, activityGroupId } = params; - let { id: serverId, sname: name, groupId, groupName } = dicServerName; + let { sname: name, groupId, groupName } = dicServerName; let stopRegisterTime = openTime + hour * 60 * 60; const doc = new ServerlistModel(); @@ -138,7 +139,8 @@ export default class Serverlist extends BaseModel { openTime, stopRegisterTime, createdBy: uid, updatedBy: uid }); - + // 旧服修改状态 + await ServerlistModel.updateMany({ env, serverStatus: SERVER_STATUS.NEW }, { $set: { serverStatus: SERVER_STATUS.HOT } }) let server: ServerlistType = await ServerlistModel.findOneAndUpdate({ id }, { $setOnInsert: update }, { new: true, upsert: true }).lean({ getters: true, virtuals: true }); return server; } @@ -168,6 +170,11 @@ export default class Serverlist extends BaseModel { return result; } + public static async incRoleCnt(serverId: number) { + let server: ServerlistType = await ServerlistModel.findOneAndUpdate({ serverId }, { $inc: { playerCnt: 1 } }); + return server; + } + } export let ServerlistModel: ReturnModelType; diff --git a/shared/domain/backEndField/params.ts b/shared/domain/backEndField/params.ts index 34b57cc6c..028491e44 100644 --- a/shared/domain/backEndField/params.ts +++ b/shared/domain/backEndField/params.ts @@ -3,6 +3,7 @@ import { isArray } from 'underscore'; import GMMail from "../../db/GMMail"; import ServerStategy from "../../db/ServerStategy"; import { RegionType } from "../../db/Region"; +import { nowSeconds } from "../../pubUtils/timeUtil"; export class UpdateMailParams { hasGoods: boolean = false; // 是否有道具 @@ -127,12 +128,28 @@ export class CreateServerParam { circleMail?: GMMail; stopRegisterTime: number = 0; - constructor(obj: CreateServerParam) { - for(let key in obj) { - this[key] = obj[key]; + constructor(obj?: any) { + if(obj) { + for(let key in obj) { + this[key] = obj[key]; + } } } + setByRegionStategy(region: RegionType, openTime: number) { + this.env = region.env; + this.openTime = openTime; + if(region.stategy) { + this.activityGroupId = region.stategy.activityGroupId; + this.hasOpenMail = !!region.stategy.openMail; + this.openMail = region.stategy.openMail; + this.hasCircleMail = !!region.stategy.circleMail; + this.circleMail = region.stategy.circleMail; + this.stopRegisterTime = region.stategy.stopRegisterTime; + } + + } + checkParams() { if(!this.env || !this.openTime || !this.stopRegisterTime || !isArray(this.activityGroupId) || this.activityGroupId.length <= 0 ) { return false diff --git a/web-server/app/service/Auth.ts b/web-server/app/service/Auth.ts index c79d9f5a0..1c7f3e857 100644 --- a/web-server/app/service/Auth.ts +++ b/web-server/app/service/Auth.ts @@ -8,13 +8,14 @@ import { Service } from 'egg'; import Counter from '@db/Counter'; import { getExpByLv } from '../pubUtils/data'; import { isString } from 'underscore'; -import { getAge } from '../pubUtils/timeUtil'; +import { getAge, nowSeconds } from '../pubUtils/timeUtil'; import { resResult } from '../pubUtils/util'; import { checkTeeanAgerTime } from '../pubUtils/authenticateUtil'; // import { authenticate } from '../pubUtils/httpUtil'; import { checkTask } from 'app/pubUtils/taskUtil'; import { getChannelId, loginValidata } from '../pubUtils/sdkUtil'; import { LoginValidateData37 } from 'app/domain/sdk'; +import { ServerlistModel } from '@db/Serverlist'; /** * Test Service @@ -308,12 +309,17 @@ export default class Auth extends Service { if (exist === true) { return ctx.service.utils.resResult(STATUS.ROLE_EXIST); } + const server = await ServerlistModel.findByServerId(serverId); + if(!server) return ctx.service.utils.resResult(STATUS.SERVER_NOT_FOUND); + if(nowSeconds() > server.stopRegisterTime) return ctx.service.utils.resResult(STATUS.SERVER_STOP_REGISTER); + const roleId = ctx.service.utils.genCode(10); const code = ctx.service.utils.genCode(6); const seqId = await Counter.getNewCounter(COUNTER.ROLE) || -1; const role = await RoleModel.createRole(uid, serverId, { roleId, code, roleName: "", seqId, lv: DEFAULT_LV, exp: (getExpByLv(DEFAULT_LV - 1) || { sum: 0 }).sum || 0 }); if (role) { + await ServerlistModel.incRoleCnt(serverId); // 任务 await checkTask(roleId, TASK_TYPE.ROLE_LV, role.lv, false, {}); From 46108f90f225250e061cc4923f3852fb008a7271 Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 8 Dec 2021 17:35:23 +0800 Subject: [PATCH 19/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=99=BD=E5=90=8D=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/connector/filter/global.ts | 11 +++++---- .../servers/connector/handler/entryHandler.ts | 4 ++++ shared/db/WhiteList.ts | 24 ++++++++++++------- shared/domain/backEndField/params.ts | 1 - shared/pubUtils/util.ts | 18 ++++---------- web-server/app/middleware/checkMainten.ts | 2 +- web-server/app/middleware/getIp.ts | 12 ++++++++++ web-server/app/middleware/tokenParser.ts | 1 + web-server/app/router.ts | 1 + web-server/app/service/Auth.ts | 11 ++++----- web-server/app/service/Sdk.ts | 7 +----- web-server/config/config.default.ts | 2 +- web-server/package.json | 3 ++- web-server/typings/app/middleware/index.d.ts | 2 ++ 14 files changed, 56 insertions(+), 43 deletions(-) create mode 100644 web-server/app/middleware/getIp.ts diff --git a/game-server/app/servers/connector/filter/global.ts b/game-server/app/servers/connector/filter/global.ts index b9de897d3..b0c832adb 100644 --- a/game-server/app/servers/connector/filter/global.ts +++ b/game-server/app/servers/connector/filter/global.ts @@ -1,8 +1,8 @@ -import {Application, RouteRecord, FrontendOrBackendSession, HandlerCallback, pinus} from "pinus"; +import {Application, RouteRecord, FrontendOrBackendSession, HandlerCallback, pinus, FrontendSession} from "pinus"; // import { checkEvent } from '../../../services/eventSercive'; import { refresh } from '../../../services/refreshService'; import { checkPrivateChat, checkGuildChat, checkOtherChat, checkRoleName, checkGuildName } from "../../../services/sdkService"; -import { resResult, checkWhiteListWithUid, genCode } from "../../../pubUtils/util"; +import { resResult, checkWhiteList, genCode } from "../../../pubUtils/util"; import { BLOCK_TYPE, CHANNEL_PREFIX, MSG_TYPE, STATUS } from "../../../consts"; import { UserModel } from "../../../db/User"; import { SERVER_DEBUG_MODE } from "../../../pubUtils/dicParam"; @@ -21,6 +21,8 @@ Filter.prototype.before = async function (routeRecord: RouteRecord, msg: any, se const sid: string = session.get('sid'); const roleId: string = session.get('roleId'); const uid: number = session.get('userid'); + const ip: string = session.get('ip'); + console.log('*********** global before ip', ip) let guildCode = session.get('guildCode'); let blockType = session.get('blockType'); if(blockType == BLOCK_TYPE.BLOCK) return next(new Error(), resResult(STATUS.BLOCKED)); @@ -36,15 +38,14 @@ Filter.prototype.before = async function (routeRecord: RouteRecord, msg: any, se } } - session.push('teamCode', () => {}); if(sid) { const mainten = getServerMainten(serverId); - console.log('***** maintenServers', mainten) if(mainten) { // 该服务器维护 if(mainten.startTime > nowSeconds() || mainten.endTime < nowSeconds()) return next(null) - let isWhiteList = await checkWhiteListWithUid(uid); + + let isWhiteList = await checkWhiteList(this.app.get('env'), ip, uid, serverId); if(isWhiteList) return next(null); pinus.app.get('channelService').pushMessageByUids('onServerMaintenance', resResult(STATUS.SERVER_MAINTENANCE), [{ uid: roleId, sid }]); diff --git a/game-server/app/servers/connector/handler/entryHandler.ts b/game-server/app/servers/connector/handler/entryHandler.ts index b6617a3a0..21cc3eec2 100644 --- a/game-server/app/servers/connector/handler/entryHandler.ts +++ b/game-server/app/servers/connector/handler/entryHandler.ts @@ -120,6 +120,8 @@ export class EntryHandler { async addSession(role: RoleType, session: FrontendSession) { const self = this; + let ip = session.remoteAddress.ip.replace('::ffff:', ''); + await session.abind(role.roleId); session.set('userid', role.userInfo.uid); session.set('uid', role.roleId); @@ -132,6 +134,7 @@ export class EntryHandler { session.set('sid', self.app.get('serverId')); session.set('serverId', role.serverId); session.set('guildCode', role.guildCode); + session.set('ip', ip); session.push('userid', () => { }); session.push('sid', () => { }); session.push('roleId', () => { }); @@ -141,6 +144,7 @@ export class EntryHandler { session.push('updatedMailAt', () => { }); session.push('guildCode', () => { }); session.push('blockType', () => { }); + session.push('ip', () => { }); // console.log(role.guildCode) // session.push('rid', function (err) { // if (err) { diff --git a/shared/db/WhiteList.ts b/shared/db/WhiteList.ts index a91c3cc97..ed1e4c012 100644 --- a/shared/db/WhiteList.ts +++ b/shared/db/WhiteList.ts @@ -1,22 +1,30 @@ import BaseModel from './BaseModel'; import { prop, DocumentType, getModelForClass } from '@typegoose/typegoose'; -import { WHITE_LIST_TYPE } from '../consts'; export default class WhiteList extends BaseModel { - @prop({ required: true, enum: WHITE_LIST_TYPE }) - type: WHITE_LIST_TYPE; // 区号 + @prop({ required: true }) + regionId: number; // 大区区号 @prop({ required: true }) - str: string; // ip或手机号 + env: string; // 环境变量 - public static async checkIp(ip: string) { - const rec: WhiteListModelType = await WhiteListModel.findOne({ type: WHITE_LIST_TYPE.IP, str: ip }).lean(); + @prop({ required: true }) + ip: string; // ip + + @prop({ required: true }) + serverId: number; // 小区id + + @prop({ required: true }) + uid: number; // 玩家uid + + public static async checkIp(env: string, ip: string) { + const rec = await WhiteListModel.exists({ env, ip }); return rec; } - public static async checkTel(tel: string) { - const rec: WhiteListModelType = await WhiteListModel.findOne({ type: WHITE_LIST_TYPE.TEL, str: tel }).lean(); + public static async checkUid(env: string, serverId: number, uid: number) { + const rec = await WhiteListModel.exists({ env, serverId, uid }); return rec; } } diff --git a/shared/domain/backEndField/params.ts b/shared/domain/backEndField/params.ts index 028491e44..b78f92049 100644 --- a/shared/domain/backEndField/params.ts +++ b/shared/domain/backEndField/params.ts @@ -3,7 +3,6 @@ import { isArray } from 'underscore'; import GMMail from "../../db/GMMail"; import ServerStategy from "../../db/ServerStategy"; import { RegionType } from "../../db/Region"; -import { nowSeconds } from "../../pubUtils/timeUtil"; export class UpdateMailParams { hasGoods: boolean = false; // 是否有道具 diff --git a/shared/pubUtils/util.ts b/shared/pubUtils/util.ts index 191b8a1af..54ebd39f9 100644 --- a/shared/pubUtils/util.ts +++ b/shared/pubUtils/util.ts @@ -11,7 +11,6 @@ import { findIndex } from 'underscore'; import { getTimeFunM } from './timeUtil'; import { Floor } from '../domain/activityField/gachaField'; import { WhiteListModel } from '../db/WhiteList'; -import { UserModel } from '../db/User'; const randomName = require("chinese-random-name"); const moment = require('moment'); const crypto = require('crypto'); @@ -659,20 +658,13 @@ export function getFloorStatus(gachaId: number, floor: Floor[]) { }); } -export async function checkWhiteListWithUid(uid: number) { - let user = await UserModel.findUserByUid(uid); - if(!user) return false; - let { tel, ip } = user; - return await checkWhiteList(tel, ip); -} - -export async function checkWhiteList(tel: string, ip: string) { - if(tel) { - let result = await WhiteListModel.checkTel(tel); +export async function checkWhiteList(env: string, ip: string, uid: number, serverId: number) { + if(ip) { + let result = await WhiteListModel.checkIp(env, ip); if(!!result) return true; } - if(ip) { - let result = await WhiteListModel.checkIp(ip); + if(uid && serverId) { + let result = await WhiteListModel.checkUid(env, serverId, uid); if(!!result) return true; } return false diff --git a/web-server/app/middleware/checkMainten.ts b/web-server/app/middleware/checkMainten.ts index debf1f4d6..ab60d479d 100644 --- a/web-server/app/middleware/checkMainten.ts +++ b/web-server/app/middleware/checkMainten.ts @@ -9,7 +9,7 @@ module.exports = () => { if (serverId) { let server = await ServerlistModel.findByServerId(serverId); if (server && server.maintenance && server.maintenance.isOpen && server.maintenance.startTime < nowSeconds() && server.maintenance.endTime > nowSeconds()) { - let isWhiteList = await checkWhiteList(ctx.tel, ctx.request.ip); + let isWhiteList = await checkWhiteList(ctx.app.config.realEnv, ctx.clientIp, ctx.uid, serverId); if (isWhiteList) { await next(); } else { diff --git a/web-server/app/middleware/getIp.ts b/web-server/app/middleware/getIp.ts new file mode 100644 index 000000000..657ef2856 --- /dev/null +++ b/web-server/app/middleware/getIp.ts @@ -0,0 +1,12 @@ +import { Context } from 'egg'; + +module.exports = () => { + return async function parmsDecode(ctx: Context, next) { + + let xRealIp = typeof ctx.header['x-real-ip'] == 'string'? ctx.header['x-real-ip']: ctx.header['x-real-ip'][0]; + ctx.clientIp = xRealIp||ctx.request.ip; + console.log('*****', ctx.clientIp); + await next(); + }; +}; + diff --git a/web-server/app/middleware/tokenParser.ts b/web-server/app/middleware/tokenParser.ts index 3b0aa1120..2eb4a915e 100644 --- a/web-server/app/middleware/tokenParser.ts +++ b/web-server/app/middleware/tokenParser.ts @@ -3,6 +3,7 @@ import { UserModel } from '@db/User'; module.exports = () => { return async function tokenParser(ctx, next) { + if (!ctx.request.body || !ctx.request.body.token) { console.error('token not found'); ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); diff --git a/web-server/app/router.ts b/web-server/app/router.ts index c4a677f17..5594b7d2e 100644 --- a/web-server/app/router.ts +++ b/web-server/app/router.ts @@ -2,6 +2,7 @@ import { Application } from 'egg'; export default (app: Application) => { const { controller, router } = app; + const tokenParser = app.middleware.tokenParser(); const checkMainten = app.middleware.checkMainten(); router.get('/dev', controller.home.dev); diff --git a/web-server/app/service/Auth.ts b/web-server/app/service/Auth.ts index 1c7f3e857..5191f2e4b 100644 --- a/web-server/app/service/Auth.ts +++ b/web-server/app/service/Auth.ts @@ -29,7 +29,6 @@ export default class Auth extends Service { public async deviceLogin(isGuest: boolean, token: string, deviceId: string, platform: string, pkgName: string, serverType: string, getuiCID: string) { const ctx = this.ctx; - const ip = ctx.request.ip; let user = await UserModel.findUserByToken(token); @@ -46,7 +45,7 @@ export default class Auth extends Service { }); } else { - user = await UserModel.createUser(isGuest, tel, token, platform, pkgName, serverType, deviceId, 0, ip); + user = await UserModel.createUser(isGuest, tel, token, platform, pkgName, serverType, deviceId, 0, ctx.clientIp); if (getuiCID) {//更新个推cid await UserModel.updateGetuiCID(tel, getuiCID); } @@ -66,7 +65,7 @@ export default class Auth extends Service { } } else { const token = ctx.service.utils.generateStr(256); - user = await UserModel.updateToken(user.tel, token, deviceId, ip); + user = await UserModel.updateToken(user.tel, token, deviceId, ctx.clientIp); if (getuiCID) {//更新个推cid await UserModel.updateGetuiCID(user.tel, getuiCID); } @@ -188,7 +187,6 @@ export default class Auth extends Service { */ public async smsLogin(tel: string, deviceId: string, code: string, platform: string, pkgName: string, serverType: string, getuiCID: string) { const ctx = this.ctx; - const ip = ctx.request.ip; // 参数检查 const telVerify = this.checkTelNo(tel); if (telVerify.status !== 0) { @@ -218,7 +216,7 @@ export default class Auth extends Service { // 用户注册登录 const token = ctx.service.utils.generateStr(256); - const user = await UserModel.createOrUpdate(false, tel, token, platform, pkgName, serverType, deviceId, ip); + const user = await UserModel.createOrUpdate(false, tel, token, platform, pkgName, serverType, deviceId, ctx.clientIp); if (getuiCID) {//更新个推cid await UserModel.updateGetuiCID(tel, getuiCID); } @@ -403,7 +401,6 @@ export default class Auth extends Service { const { channelType, pst, clientId, deviceId, platform, platformAppid, childGameId, pkgName, serverType, getuiCID } = params; const ctx = this.ctx; - const ip = ctx.request.ip; let requestResult = await loginValidata(channelType, { clientId, pst, platformAppid, childGameId }); if(!requestResult) return this.ctx.service.utils.resResult(STATUS.CHANNEL_ERR); @@ -416,7 +413,7 @@ export default class Auth extends Service { const token = ctx.service.utils.generateStr(256); let user = await UserModel.createOrUpdateChannelUser(channelId, channelType, { ...requestResult.data, childGameId, platformAppid - }, token, platform, pkgName, serverType, deviceId, ip); + }, token, platform, pkgName, serverType, deviceId, ctx.clientIp); if (getuiCID) {//更新个推cid await UserModel.updateGetuiCIDByChannel(channelId, getuiCID); } diff --git a/web-server/app/service/Sdk.ts b/web-server/app/service/Sdk.ts index a831db5ab..1f4c4b69f 100644 --- a/web-server/app/service/Sdk.ts +++ b/web-server/app/service/Sdk.ts @@ -29,14 +29,12 @@ export default class Sdk extends Service { public async pay37Callback(params: PayCallback37Data) { const { ctx } = this; const { app } = ctx; - let ip = typeof ctx.header['x-real-ip'] == 'string'? ctx.header['x-real-ip']: ctx.header['x-real-ip'][0]; - console.log('*****pay37Callback', ip) let checkResult = this.check37Sign(params); if(!checkResult) return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.MD5_ERR, ''); console.log('*****pay37Callback check sign ok') - if(gameData.whiteip.indexOf(ip) == -1) { + if(gameData.whiteip.indexOf(ctx.clientIp) == -1) { return ctx.service.utils.resResult(PAY_37_CALLBACK_CODE.IP_LIMIT, ''); } @@ -95,9 +93,6 @@ export default class Sdk extends Service { } public treatRoleOrGuildNameValidate(params: RoleNameCallBackParam|GuildNameCallBackParam|GetGuildInfoByUserParam) { - const { ctx } = this; - let ip = ctx.header['x-real-ip']; - console.log('*****', ip) if(!params.checkParams()) return SDK_37_TREAT_CODE.WRONG_PARAMS; diff --git a/web-server/config/config.default.ts b/web-server/config/config.default.ts index 2ff815dcb..f8964e79f 100644 --- a/web-server/config/config.default.ts +++ b/web-server/config/config.default.ts @@ -18,7 +18,7 @@ export default (appInfo: EggAppInfo) => { allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH', }; // add your egg config in here - config.middleware = [ 'parmsDecode' ]; + config.middleware = [ 'parmsDecode', 'getIp' ]; config.mongoose = { url: 'mongodb://dbop:zyzdbopbantu@dds-8vbdb47c6fb58a541.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vbdb47c6fb58a542.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-500808098', // 内网 diff --git a/web-server/package.json b/web-server/package.json index 59afd8fcd..b32eae575 100644 --- a/web-server/package.json +++ b/web-server/package.json @@ -26,7 +26,8 @@ "distribute": "cross-env EGG_SERVER_ENV=distribute npm run dev", "lylocal": "cross-env EGG_SERVER_ENV=lylocal npm run dev", "alpha": "cross-env EGG_SERVER_ENV=alpha npm run dev", - "stable": "cross-env EGG_SERVER_ENV=stable npm run dev" + "stable": "cross-env EGG_SERVER_ENV=stable npm run dev", + "deve": "cross-env EGG_SERVER_ENV=dev npm run dev" }, "dependencies": { "@types/underscore": "^1.11.3", diff --git a/web-server/typings/app/middleware/index.d.ts b/web-server/typings/app/middleware/index.d.ts index f795f5782..557b17ea3 100644 --- a/web-server/typings/app/middleware/index.d.ts +++ b/web-server/typings/app/middleware/index.d.ts @@ -3,6 +3,7 @@ import 'egg'; import ExportCheckMainten from '../../../app/middleware/checkMainten'; +import ExportGetIp from '../../../app/middleware/getIp'; import ExportGmTokenParser from '../../../app/middleware/gmTokenParser'; import ExportParmsDecode from '../../../app/middleware/parmsDecode'; import ExportTokenParser from '../../../app/middleware/tokenParser'; @@ -10,6 +11,7 @@ import ExportTokenParser from '../../../app/middleware/tokenParser'; declare module 'egg' { interface IMiddleware { checkMainten: typeof ExportCheckMainten; + getIp: typeof ExportGetIp; gmTokenParser: typeof ExportGmTokenParser; parmsDecode: typeof ExportParmsDecode; tokenParser: typeof ExportTokenParser; From 24a9295ff3dc21402421d88611cd0a9eb732ed70 Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 8 Dec 2021 20:45:06 +0800 Subject: [PATCH 20/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E7=99=BD?= =?UTF-8?q?=E5=90=8D=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gm-server/app/controller/game.ts | 24 ++++++++++ gm-server/app/router.ts | 3 ++ gm-server/app/service/Game.ts | 38 ++++++++++++++++ shared/consts/constModules/sysConst.ts | 2 +- shared/db/RegionWhiteList.ts | 63 ++++++++++++++++++++++++++ shared/db/WhiteList.ts | 35 -------------- shared/pubUtils/util.ts | 2 +- 7 files changed, 130 insertions(+), 37 deletions(-) create mode 100644 shared/db/RegionWhiteList.ts delete mode 100644 shared/db/WhiteList.ts diff --git a/gm-server/app/controller/game.ts b/gm-server/app/controller/game.ts index c0256a531..07080532f 100644 --- a/gm-server/app/controller/game.ts +++ b/gm-server/app/controller/game.ts @@ -31,6 +31,30 @@ export default class GameController extends Controller { return } + public async getWhiteList() { + const { ctx } = this; + const { id } = ctx.request.body; + + ctx.body = await ctx.service.game.getWhiteList(id); + return + } + + public async updateWhiteList() { + const { ctx } = this; + const { id, code, type, content } = ctx.request.body; + + ctx.body = await ctx.service.game.updateWhiteList(id, code, type, content); + return + } + + public async deleteWhiteList() { + const { ctx } = this; + const { id, code } = ctx.request.body; + + ctx.body = await ctx.service.game.deleteWhiteList(id, code); + return + } + public async getServers() { const { ctx } = this; diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index b7d528755..8b29f8cc6 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -55,6 +55,9 @@ export default (app: Application) => { router.post('/api/game/getregions', controller.game.getRegions); router.post('/api/game/getservers', controller.game.getServers); router.post('/api/game/getregionstategy', controller.game.getRegionStategy); + router.post('/api/game/getwhitelist', controller.game.getWhiteList); + router.post('/api/game/updatewhitelist', controller.game.updateWhiteList); + router.post('/api/game/deletewhitelist', controller.game.deleteWhiteList); router.post('/api/game/stopserverregister', controller.game.stopServerRegister); router.post('/api/game/swicthserverstatus', controller.game.switchServerStatus); diff --git a/gm-server/app/service/Game.ts b/gm-server/app/service/Game.ts index 8ea7e3cd0..4ee6662db 100644 --- a/gm-server/app/service/Game.ts +++ b/gm-server/app/service/Game.ts @@ -13,6 +13,8 @@ import { AccuseRecModel } from '@db/AccuseRec'; import { RegionModel } from '@db/Region'; import { ActivityGroupModel } from '@db/ActivityGroup'; import { nowSeconds } from '@pubUtils/timeUtil'; +import { WhiteListModel } from '@db/RegionWhiteList'; +import { RoleModel } from '@db/Role'; /** * Test Service @@ -90,6 +92,42 @@ export default class Game extends Service { }); } + public async getWhiteList(id: number) { + const { ctx } = this; + let region = await RegionModel.findRegionById(id); + if(!region) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); + + let whitelist = await WhiteListModel.findByRegionId(id); + + return ctx.service.utils.resResult(STATUS.SUCCESS, { + whitelist + }); + } + + public async updateWhiteList(id: number, code: string, type: number, content: string) { + const { ctx } = this; + let region = await RegionModel.findRegionById(id); + if(!region) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); + if(type == 1) { + let whitelist = await WhiteListModel.updateWhiteList(code, { type, regionId: region.id, env: region.env, ip: content }); + return ctx.service.utils.resResult(STATUS.SUCCESS, { whitelist }); + } else if(type == 2) { + let role = await RoleModel.findByRoleId(content, 'roleId userInfo serverId roleName'); + let whitelist = await WhiteListModel.updateWhiteList(code, { type, regionId: region.id, env: region.env, uid: role.userInfo.uid, serverId: role.serverId, roleId: role.roleId, roleName: role.roleName }); + return ctx.service.utils.resResult(STATUS.SUCCESS, { whitelist }); + } else { + return ctx.service.utils.resResult(STATUS.WRONG_PARMS); + } + } + + public async deleteWhiteList(id: number, code: string) { + const { ctx } = this; + let region = await RegionModel.findRegionById(id); + if(!region) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); + let whitelist = await WhiteListModel.deleteWhiteList(code); + return ctx.service.utils.resResult(STATUS.SUCCESS, { whitelist }); + } + // public async getMaintenanceList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { isOpen?: boolean } = {}) { // const { ctx } = this; diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index b5d9fcd94..7eb6753a3 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -712,7 +712,7 @@ export enum SERVER_STATUS { export enum WHITE_LIST_TYPE { IP = 1, // ip地址 - TEL = 2, // 玩家手机号 + UID = 2, // 玩家账号 } // 获取道具类型 diff --git a/shared/db/RegionWhiteList.ts b/shared/db/RegionWhiteList.ts new file mode 100644 index 000000000..8ebe94fd8 --- /dev/null +++ b/shared/db/RegionWhiteList.ts @@ -0,0 +1,63 @@ +import BaseModel from './BaseModel'; +import { prop, DocumentType, getModelForClass } from '@typegoose/typegoose'; +import { WHITE_LIST_TYPE } from '../consts'; + +export default class RegionWhiteList extends BaseModel { + + @prop({ required: true }) + code: string; // 编码 + + @prop({ required: true }) + regionId: number; // 大区区号 + + @prop({ required: true }) + env: string; // 环境变量 + + @prop({ required: true, enum: WHITE_LIST_TYPE }) + type: WHITE_LIST_TYPE; // 环境变量 + + @prop({ required: true }) + ip: string; // ip + + @prop({ required: true }) + serverId: number; // 小区id + + @prop({ required: true }) + uid: number; // 玩家uid + + @prop({ required: true }) + roleId: string; // 玩家角色id + + @prop({ required: true }) + roleName: string; // 玩家角色名 + + public static async checkIp(env: string, ip: string) { + const rec = await WhiteListModel.exists({ env, ip }); + return rec; + } + + public static async checkUid(env: string, serverId: number, uid: number) { + const rec = await WhiteListModel.exists({ env, serverId, uid }); + return rec; + } + + public static async findByRegionId(regionId: number) { + const rec: WhiteListModelType[] = await WhiteListModel.find({ regionId }); + return rec; + } + + public static async updateWhiteList(code: string, params: WhiteListModelTypeParam) { + const rec: WhiteListModelType = await WhiteListModel.findOneAndUpdate({ code }, params, { new: true, upsert: true }).lean(); + return rec; + } + + public static async deleteWhiteList(code: string) { + const rec: WhiteListModelType = await WhiteListModel.findOneAndDelete({ code }).lean(); + return rec; + } +} + +export let WhiteListModel = getModelForClass(RegionWhiteList) + +export interface WhiteListModelType extends Pick, keyof RegionWhiteList> { } +export type WhiteListModelTypeParam = Partial; // 将所有字段变成可选项 \ No newline at end of file diff --git a/shared/db/WhiteList.ts b/shared/db/WhiteList.ts deleted file mode 100644 index ed1e4c012..000000000 --- a/shared/db/WhiteList.ts +++ /dev/null @@ -1,35 +0,0 @@ -import BaseModel from './BaseModel'; -import { prop, DocumentType, getModelForClass } from '@typegoose/typegoose'; - -export default class WhiteList extends BaseModel { - - @prop({ required: true }) - regionId: number; // 大区区号 - - @prop({ required: true }) - env: string; // 环境变量 - - @prop({ required: true }) - ip: string; // ip - - @prop({ required: true }) - serverId: number; // 小区id - - @prop({ required: true }) - uid: number; // 玩家uid - - public static async checkIp(env: string, ip: string) { - const rec = await WhiteListModel.exists({ env, ip }); - return rec; - } - - public static async checkUid(env: string, serverId: number, uid: number) { - const rec = await WhiteListModel.exists({ env, serverId, uid }); - return rec; - } -} - -export const WhiteListModel = getModelForClass(WhiteList); - -export interface WhiteListModelType extends Pick, keyof WhiteList> { } -export type WhiteListModelTypeParam = Partial; // 将所有字段变成可选项 \ No newline at end of file diff --git a/shared/pubUtils/util.ts b/shared/pubUtils/util.ts index 54ebd39f9..967989f8f 100644 --- a/shared/pubUtils/util.ts +++ b/shared/pubUtils/util.ts @@ -10,7 +10,7 @@ import { HERO_CE_RATIO, ABI_STAGE, GACHA_TO_FLOOR, REFRESH_TIME, ROBOT_SYS_TYPE, import { findIndex } from 'underscore'; import { getTimeFunM } from './timeUtil'; import { Floor } from '../domain/activityField/gachaField'; -import { WhiteListModel } from '../db/WhiteList'; +import { WhiteListModel } from '../db/RegionWhiteList'; const randomName = require("chinese-random-name"); const moment = require('moment'); const crypto = require('crypto'); From 3db2735d6e7780956f1b81f3a73d60499283b94b Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 9 Dec 2021 11:25:26 +0800 Subject: [PATCH 21/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E9=82=AE?= =?UTF-8?q?=E4=BB=B6=E8=AE=BE=E7=BD=AE=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/services/gmService.ts | 16 +++------ shared/db/GMMail.ts | 36 +++++++++++++++++++ shared/db/ServerStategy.ts | 52 ++++++++++++++++++++++++++- shared/domain/backEndField/params.ts | 3 +- 4 files changed, 93 insertions(+), 14 deletions(-) diff --git a/game-server/app/services/gmService.ts b/game-server/app/services/gmService.ts index 63eebd310..9d5defc00 100644 --- a/game-server/app/services/gmService.ts +++ b/game-server/app/services/gmService.ts @@ -1,5 +1,5 @@ import { MarqueeType, MarqueeModel } from "../db/Marquee"; -import { GM_MAIL_STATUS, MAIL_TIME_TYPE, MARQUEE_TYPE, REF_CIRCLE_MAIL_TIME, SERVER_STATUS } from "../consts"; +import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE, MARQUEE_TYPE, REF_CIRCLE_MAIL_TIME, SERVER_STATUS } from "../consts"; import { scheduleJob, scheduledJobs, Job } from 'node-schedule'; import { createMarqueeMsg as sysCreateMarqueeMsg, pushMarqueeMsg as sysPushMarqueeMsg } from './sysChatService'; import { GroupMessageType } from "../db/GroupMessage"; @@ -13,6 +13,7 @@ import moment = require("moment"); import { getSeconds, nowSeconds } from "../pubUtils/timeUtil"; import { CreateServerParam } from "../domain/backEndField/params"; import { RegionModel, RegionType } from "../db/Region"; +import { GMMail as StategyMail } from "../db/ServerStategy"; // —————————————— 跑马灯 —————————————— // // 初始 @@ -104,16 +105,9 @@ export async function cancelMarquee(code: string) { return true } -export async function sendOpenServerMail(type: 'openMail'|'circleMail', mail: GMMail, newServer: ServerlistType, uid: number) { - let receivers = [{ - env: newServer.env, - serverId: newServer.id - }]; - let addParam = {...mail, receivers, status: GM_MAIL_STATUS.PASS }; - if(type == 'openMail') { - addParam.timeType = MAIL_TIME_TYPE.DELAY; - addParam.startTime = newServer.openTime; - } +export async function sendOpenServerMail(type: 'openMail'|'circleMail', mail: StategyMail, newServer: ServerlistType, uid: number) { + let addParam = new GMMail(); + addParam.setByRegionStategy(type, mail, newServer, uid); let gmmail = await GMMailModel.addMail(addParam, uid); let needSend = false; if(mail.timeType == MAIL_TIME_TYPE.CIRCLE) { diff --git a/shared/db/GMMail.ts b/shared/db/GMMail.ts index a341f2cd0..98b11f98d 100644 --- a/shared/db/GMMail.ts +++ b/shared/db/GMMail.ts @@ -6,6 +6,9 @@ import { getModelForClass, prop, DocumentType, mongoose, ReturnModelType } from import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE } from '../consts'; import { SearchMailParam } from '../domain/backEndField/search'; import { getCurDay, nowSeconds } from '../pubUtils/timeUtil'; +import { GMMail as StategyMail } from './ServerStategy'; +import { ServerlistType } from './Serverlist'; +import moment = require('moment'); class Reward { @prop({ required: true }) @@ -87,6 +90,39 @@ export default class GMMail extends BaseModel { @prop({ required: true }) sendTime: string; // 发送时间 + public setByRegionStategy(type: 'openMail'|'circleMail', gmmail: StategyMail, newServer: ServerlistType, uid) { + this.hasGoods = !!gmmail.goods?.length; + this.goods = gmmail.goods; + this.timeType = type == 'openMail'? MAIL_TIME_TYPE.DELAY: MAIL_TIME_TYPE.CIRCLE; + this.expire = gmmail.expire; + if(type == 'openMail') { + this.startTime = nowSeconds(); + } else { + this.circleStart = nowSeconds(); + this.circleEnd = nowSeconds() + gmmail.circleContinueDay * 24 * 60 * 60; + this.circleDay = gmmail.circleDay; + this.circleHour = gmmail.circleHour; + } + this.title = gmmail.title; + this.content = gmmail.content; + this.sendName = gmmail.sendName; + this.mailType = GM_MAIL_TYPE.SERVER; + this.receivers = [{ + env: newServer.env, + serverId: newServer.id + }]; + this.reason = gmmail.reason; + this.isSp = gmmail.isSp; + this.status = GM_MAIL_STATUS.PASS; + this.viewBy = uid; + this.viewAt = new Date(); + if (type == 'openMail') { + this.sendTime = moment(this.startTime * 1000).format('YYYY-MM-DD HH:mm:ss'); + } else { + this.sendTime = (this.circleDay == 0?'每天': '每周'+this.circleDay) + ' ' + this.circleHour; + } + } + public static async addMail(params: GMMailTypeParam, uid = 1) { const doc = new GMMailModel(); let mail = Object.assign(doc.toJSON(), params); diff --git a/shared/db/ServerStategy.ts b/shared/db/ServerStategy.ts index a37569da0..92a58fc35 100644 --- a/shared/db/ServerStategy.ts +++ b/shared/db/ServerStategy.ts @@ -1,5 +1,55 @@ import { prop, DocumentType, } from '@typegoose/typegoose'; -import GMMail from './GMMail'; +import { GM_MAIL_TYPE, MAIL_TIME_TYPE } from '../consts'; + +class Reward { + @prop({ required: true }) + id: number; + @prop({ required: true }) + count: number; +} + +export class GMMail { + + @prop({ required: false}) + hasGoods: boolean; // 有效时间,单位小时 + + @prop({ required: true, type: Reward, default: [], _id: false }) + goods: Reward[]; + + @prop({ required: true, default: true }) + timeType: MAIL_TIME_TYPE; // 邮件时间类型 + + @prop({ required: false}) + expire: number; // 有效时间,单位小时 + + @prop({ required: true }) + circleContinueDay: number; // 循环邮件持续天数 + + @prop({ required: true }) + circleDay: number; // 循环时间,每周几,0表示每天 + + @prop({ required: true }) + circleHour: string; // 几点发送 + + @prop({ required: true }) + title: string; + + @prop({ required: true }) + content: string; + + @prop({ required: true }) + sendName: string; + + @prop({ required: true }) + mailType: GM_MAIL_TYPE; // 收件人类型 + + @prop({ required: true }) + reason: string; // 原因 + + @prop({ required: true, default: false }) + isSp: boolean; // 特殊邮件 +} + export default class ServerStategy { diff --git a/shared/domain/backEndField/params.ts b/shared/domain/backEndField/params.ts index b78f92049..43567aee3 100644 --- a/shared/domain/backEndField/params.ts +++ b/shared/domain/backEndField/params.ts @@ -1,7 +1,6 @@ import { GM_MAIL_TYPE, MAIL_TIME_TYPE, SERVER_TIMER } from "../../consts"; import { isArray } from 'underscore'; -import GMMail from "../../db/GMMail"; -import ServerStategy from "../../db/ServerStategy"; +import ServerStategy, { GMMail } from "../../db/ServerStategy"; import { RegionType } from "../../db/Region"; export class UpdateMailParams { From ecca95b40b36a779380ef6508abf89d746e99474 Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 9 Dec 2021 20:38:23 +0800 Subject: [PATCH 22/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E8=B7=91?= =?UTF-8?q?=E9=A9=AC=E7=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/gm/handler/gmHandler.ts | 24 +--- .../app/servers/gm/handler/gmServerHandler.ts | 20 ++++ .../servers/systimer/remote/systimerRemote.ts | 5 +- game-server/app/services/gmService.ts | 82 ++++++++------ game-server/app/services/timeTaskService.ts | 2 +- gm-server/app/service/Game.ts | 18 +-- shared/consts/constModules/sysConst.ts | 9 +- shared/consts/statusCode.ts | 1 + shared/db/Marquee.ts | 107 +++++++++++++----- shared/db/index.ts | 2 + shared/domain/backEndField/search.ts | 9 ++ web-server/app/middleware/getIp.ts | 2 +- 12 files changed, 187 insertions(+), 94 deletions(-) diff --git a/game-server/app/servers/gm/handler/gmHandler.ts b/game-server/app/servers/gm/handler/gmHandler.ts index 955548dcd..6571e041a 100644 --- a/game-server/app/servers/gm/handler/gmHandler.ts +++ b/game-server/app/servers/gm/handler/gmHandler.ts @@ -126,34 +126,14 @@ export class GmHandler { } } - async createMarquee(msg: { startTime: string, endTime: string, interval: number, content: string }, session: BackendSession) { + async createMarquee(msg: { startTime: number, endTime: number, interval: number, content: string }, session: BackendSession) { const { startTime, endTime, interval, content } = msg; - let marquee = await MarqueeModel.createData({ serverIds: [1], type: 2, startTime: new Date(startTime), endTime: new Date(endTime), interval, content }); + let marquee = await MarqueeModel.createData({ timeType: 2, startTime, endTime, interval, content }); return resResult(STATUS.SUCCESS, { code: marquee.code }); } - async sendMarquee(msg: { code: string }, session: BackendSession) { - const { code } = msg; - let systimerServers = this.app.getServersByType('systimer'); - for (let { id } of systimerServers) { - let result = await this.app.rpc.systimer.systimerRemote.setMarquee.toServer(id, code); - if (!result) return resResult(STATUS.GM_MARQUEE_ERR); - } - return resResult(STATUS.SUCCESS); - } - - async cancelMarquee(msg: { code: string }, session: BackendSession) { - const { code } = msg; - let systimerServers = this.app.getServersByType('systimer'); - for (let { id } of systimerServers) { - let result = await this.app.rpc.systimer.systimerRemote.cancelMarquee.toServer(id, code); - if (!result) return resResult(STATUS.GM_MARQUEE_CANCEL_ERR); - } - return resResult(STATUS.SUCCESS); - } - async updateActivity(msg: { activityId: number|string, groupId: number, beginTime: number, endTime: number, type: number, data: string }, session: BackendSession) { const { activityId, groupId, beginTime, endTime, type, data } = msg; const uid = session.get('uid'); diff --git a/game-server/app/servers/gm/handler/gmServerHandler.ts b/game-server/app/servers/gm/handler/gmServerHandler.ts index e595abe36..4cdfda50b 100644 --- a/game-server/app/servers/gm/handler/gmServerHandler.ts +++ b/game-server/app/servers/gm/handler/gmServerHandler.ts @@ -12,6 +12,7 @@ import { SendMailFun } from '../../../services/mailService'; import { createNewServer, sendOpenServerMail } from '../../../services/gmService'; import { initAutoCreateServer, initMaintenance, stopMaintenance } from '../../../services/timeTaskService'; import { isNumber } from 'util'; +import { MarqueeModel } from '../../../db/Marquee'; let timer: NodeJS.Timer; export default function (app: Application) { return new GmHandler(app); @@ -101,4 +102,23 @@ export class GmHandler { return resResult(STATUS.SUCCESS,); } + + async sendMarquee(msg: { code: string }, session: BackendSession) { + const { code } = msg; + let marquee = await MarqueeModel.findByCode(code); + if(!marquee) return resResult(STATUS.DB_DATA_NOT_FOUND); + + await MarqueeModel.updateData(code, { isEnable: true }); + let result = await this.app.rpc.systimer.systimerRemote.setMarquee.broadcast(marquee); + if (!result) return resResult(STATUS.GM_MARQUEE_ERR); + return resResult(STATUS.SUCCESS); + } + + async cancelMarquee(msg: { code: string }, session: BackendSession) { + const { code } = msg; + await MarqueeModel.updateData(code, { isEnable: false }); + let result = await this.app.rpc.systimer.systimerRemote.cancelMarquee.broadcast(code); + if (!result) return resResult(STATUS.GM_MARQUEE_CANCEL_ERR); + return resResult(STATUS.SUCCESS); + } } \ No newline at end of file diff --git a/game-server/app/servers/systimer/remote/systimerRemote.ts b/game-server/app/servers/systimer/remote/systimerRemote.ts index 9960f502b..05bef4807 100644 --- a/game-server/app/servers/systimer/remote/systimerRemote.ts +++ b/game-server/app/servers/systimer/remote/systimerRemote.ts @@ -7,6 +7,7 @@ import { setMarquee, cancelMarquee } from '../../../services/gmService'; import { setDicAuctionTime, setDicGuildActivity } from '../../../services/guildActivityService'; import { setWeek } from '../../../pubUtils/timeUtil'; import { ServerlistType } from '../../../db/Serverlist'; +import { MarqueeType } from '../../../db/Marquee'; export default function (app: Application) { return new SystimerRemote(app); @@ -51,8 +52,8 @@ export class SystimerRemote { * @description 设置跑马灯配置 * @param code 跑马灯唯一code */ - public async setMarquee(code: string) { - return await setMarquee(code); + public async setMarquee(marquee: MarqueeType) { + return await setMarquee(marquee); } public async cancelMarquee(code: string) { diff --git a/game-server/app/services/gmService.ts b/game-server/app/services/gmService.ts index 9d5defc00..5906d45f3 100644 --- a/game-server/app/services/gmService.ts +++ b/game-server/app/services/gmService.ts @@ -1,5 +1,5 @@ -import { MarqueeType, MarqueeModel } from "../db/Marquee"; -import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE, MARQUEE_TYPE, REF_CIRCLE_MAIL_TIME, SERVER_STATUS } from "../consts"; +import Marquee, { MarqueeType, MarqueeModel } from "../db/Marquee"; +import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE, MARQUEE_SHOW_TYPE, MARQUEE_TIME_TYPE, REF_CIRCLE_MAIL_TIME, SERVER_STATUS } from "../consts"; import { scheduleJob, scheduledJobs, Job } from 'node-schedule'; import { createMarqueeMsg as sysCreateMarqueeMsg, pushMarqueeMsg as sysPushMarqueeMsg } from './sysChatService'; import { GroupMessageType } from "../db/GroupMessage"; @@ -14,21 +14,21 @@ import { getSeconds, nowSeconds } from "../pubUtils/timeUtil"; import { CreateServerParam } from "../domain/backEndField/params"; import { RegionModel, RegionType } from "../db/Region"; import { GMMail as StategyMail } from "../db/ServerStategy"; +import { uniq } from "underscore"; // —————————————— 跑马灯 —————————————— // // 初始 export async function initMarquee() { - const marquees = await MarqueeModel.findEffectiveMarque(); + const marquees = await MarqueeModel.findEffectiveMarque(pinus.app.get('env')); for(let marquee of marquees) { await generateMarqueeSchedule(marquee); } } -export async function setMarquee(code: string) { - let marquee = await MarqueeModel.findByCode(code); - if(marquee.type == MARQUEE_TYPE.INSTANT) { - let msgDatas = await createMarqueeMsg(marquee); - await pushMarqueeMsg(msgDatas); +export async function setMarquee(marquee: MarqueeType) { + console.log('******', marquee.timeType, marquee) + if(marquee.timeType == MARQUEE_TIME_TYPE.INSTANT) { + await startMarquee(marquee); return true; } else { return await generateMarqueeSchedule(marquee); @@ -36,14 +36,14 @@ export async function setMarquee(code: string) { } async function generateMarqueeSchedule(marquee: MarqueeType) { + // 定时发送 let setSecondsMarquee = scheduledJobs[`setSeconds${marquee.code}`]; if(setSecondsMarquee) return false; // 已经在运行中了 - if(marquee.type != MARQUEE_TYPE.SCHEDULE) return false; - if(marquee.startTime.getTime() >= marquee.endTime.getTime()) return false; - if(marquee.endTime.getTime() < Date.now()) return false; - if(marquee.startTime.getTime() > Date.now()) { - let startJob = scheduleJob(`start${marquee.code}`, marquee.startTime.getTime(), async () => { + if(marquee.timeType != MARQUEE_TIME_TYPE.SCHEDULE) return false; + if(marquee.endTime && marquee.endTime < nowSeconds()) return false; + if(marquee.startTime > nowSeconds()) { + let startJob = scheduleJob(`start${marquee.code}`, marquee.startTime * 1000, async () => { await startMarquee(marquee, startJob) }); } else { @@ -54,37 +54,56 @@ async function generateMarqueeSchedule(marquee: MarqueeType) { async function startMarquee(marquee: MarqueeType, startJob?: Job) { console.log('************', `跑马灯定时器 ${marquee.code}开始`, '************'); - await MarqueeModel.updateData(marquee.code, { isRunning: true }); let msgDatas = await createMarqueeMsg(marquee); - await pushMarqueeMsg(msgDatas); - let secondsJob = scheduleJob(`setSeconds${marquee.code}`, `*/${marquee.interval} * * * * *`, async () => { - console.log(`*****setSeconds${marquee.code}****`) + if(marquee.showType == MARQUEE_SHOW_TYPE.ONCE) { // 一次性发送 await pushMarqueeMsg(msgDatas); - }); - let endJob = scheduleJob(`end${marquee.code}`, marquee.endTime.getTime(), async () => { if(startJob) { startJob.cancel(); startJob = undefined; } - if(secondsJob) { - secondsJob.cancel(); - secondsJob = undefined; - } - if(endJob) { - endJob.cancel(); - endJob = undefined; - } - await MarqueeModel.updateData(marquee.code, { isRunning: false }); - }); + } else { + await pushMarqueeMsg(msgDatas); + console.log('***', marquee.interval) + let secondsJob = scheduleJob(`setSeconds${marquee.code}`, `*/${marquee.interval} * * * * *`, async () => { + console.log(`*****setSeconds${marquee.code}****`) + await pushMarqueeMsg(msgDatas); + }); + let endJob = scheduleJob(`end${marquee.code}`, marquee.endTime * 1000, async () => { + if(startJob) { + startJob.cancel(); + startJob = undefined; + } + if(secondsJob) { + secondsJob.cancel(); + secondsJob = undefined; + } + if(endJob) { + endJob.cancel(); + endJob = undefined; + } + }); + } } async function createMarqueeMsg(marquee: MarqueeType) { - let { serverIds, content } = marquee; + let { receivers, content } = marquee; let msgDatas: GroupMessageType[] = []; - for(let serverId of serverIds) { + let serverIds: number[] = []; + for(let { env, serverId } of receivers) { + if(serverId == 0) { + let servers = await ServerlistModel.findByEnv(env); + for(let { serverId } of servers) { + serverIds.push(serverId); + } + } else { + serverIds.push(serverId); + } + } + for(let serverId of uniq(serverIds)) { let msgData = await sysCreateMarqueeMsg('', '系统', serverId, content); msgDatas.push(msgData); } + return msgDatas; } @@ -101,7 +120,6 @@ export async function cancelMarquee(code: string) { if(startMarquee) startMarquee.cancel(); if(setSecondsMarquee) setSecondsMarquee.cancel(); if(endMarquee) endMarquee.cancel(); - await MarqueeModel.updateData(code, { isRunning: false }); return true } diff --git a/game-server/app/services/timeTaskService.ts b/game-server/app/services/timeTaskService.ts index a6a32eecd..63a7a5cdd 100644 --- a/game-server/app/services/timeTaskService.ts +++ b/game-server/app/services/timeTaskService.ts @@ -552,7 +552,7 @@ function setStategyTimer(timerId: number, region: RegionType) { case SERVER_TIMER.TEN_HALF: cron = '0 30 10 * * *'; break; case SERVER_TIMER.FIFTEEN_HALF: - cron = '0 19 16 * * *'; break; + cron = '0 30 15 * * *'; break; case SERVER_TIMER.NINETEEN_HALF: cron = '0 30 19 * * *'; break; } diff --git a/gm-server/app/service/Game.ts b/gm-server/app/service/Game.ts index 4ee6662db..b0b0e0b54 100644 --- a/gm-server/app/service/Game.ts +++ b/gm-server/app/service/Game.ts @@ -8,13 +8,14 @@ import { DicRMB } from '@pubUtils/dictionary/DicRMB'; import { DicActivityType } from '@pubUtils/dictionary/DicActivityType'; import { DicTaskType } from '@pubUtils/dictionary/DicTaskType'; import { NoticeModel, NoticeTypeParam } from '@db/Notice'; -import { MarqueeModel, MarqueeParam } from '@db/Marquee'; +import Marquee, { MarqueeModel } from '@db/Marquee'; import { AccuseRecModel } from '@db/AccuseRec'; import { RegionModel } from '@db/Region'; import { ActivityGroupModel } from '@db/ActivityGroup'; import { nowSeconds } from '@pubUtils/timeUtil'; import { WhiteListModel } from '@db/RegionWhiteList'; import { RoleModel } from '@db/Role'; +import { SearchMarqueeParam } from '@domain/backEndField/search'; /** * Test Service @@ -305,21 +306,20 @@ export default class Game extends Service { } - public async getMarqueeList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { type?: number, current?: boolean, content?: string }) { + public async getMarqueeList(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchMarqueeParam) { const { ctx } = this; const list = await MarqueeModel.findByCondition(page, pageSize, sortField, sortOrder, form); const total = await MarqueeModel.countByCondition( form ) return ctx.service.utils.resResult(STATUS.SUCCESS, { - list: list.map(cur => { - return { ...cur, startTime: cur.startTime?.getTime()||0, endTime: cur.endTime?.getTime()||0 } - }), total + list, total }); } - public async updateMarquee(code: string, params: MarqueeParam) { + public async updateMarquee(code: string, values: any) { const { ctx } = this; - if(params.startTime) params.startTime = new Date(params.startTime); - if(params.endTime) params.endTime = new Date(params.endTime); + let params = new Marquee(); + params.setByForm(values); + let result; if(code == 'new') { result = await MarqueeModel.createData(params); @@ -327,7 +327,7 @@ export default class Game extends Service { result = await MarqueeModel.updateData(code, params); } if(!result) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); - return ctx.service.utils.resResult(STATUS.SUCCESS); + return ctx.service.utils.resResult(STATUS.SUCCESS, { code: result.code }); } public async getAccuse(page: number, pageSize: number, sortField: string, sortOrder: string, form: {}) { diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index 7eb6753a3..e7958ef35 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -697,7 +697,14 @@ export enum GACHA_CONTENT_TYPE { export const GACHA_OCCUPY_HID = 9999; // 抽卡里占位的武将 -export enum MARQUEE_TYPE { +// 跑马灯显示类型 +export enum MARQUEE_SHOW_TYPE { + ONCE = 1, // 一次性 + CIRCLE = 2, // 循环 +} + +// 推送时间类型 +export enum MARQUEE_TIME_TYPE { INSTANT = 1, // 发送后立刻推送 SCHEDULE = 2, // 定时器 } diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index c47e9a03c..580cf4682 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -244,6 +244,7 @@ export const STATUS = { ROLE_IS_NOT_INIT: { code: 30006, simStr: '玩家未初始化' }, AP_BUY_TIMES_LACK: { code: 30007, simStr: '购买次数不足' }, CONSUME_TYPE_ERR: { code: 30008, simStr: '道具类型错误' }, + DB_DATA_NOT_FOUND: { code: 30009, simStr: '数据库数据未找到' }, // 武将养成通用 30100 - 30199 diff --git a/shared/db/Marquee.ts b/shared/db/Marquee.ts index 97c5c33fd..0d545b152 100644 --- a/shared/db/Marquee.ts +++ b/shared/db/Marquee.ts @@ -1,36 +1,74 @@ import BaseModel from './BaseModel'; -import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose'; -import { MARQUEE_TYPE } from '../consts'; +import { index, getModelForClass, prop, DocumentType, modelOptions, ReturnModelType, mongoose } from '@typegoose/typegoose'; +import { MARQUEE_SHOW_TYPE, MARQUEE_TIME_TYPE } from '../consts'; import { genCode } from '../pubUtils/util'; +import { SearchMarqueeParam } from '../domain/backEndField/search'; +import { nowSeconds } from '../pubUtils/timeUtil'; + /** * 跑马灯 **/ +class Receiver { + @prop({ required: true }) + regionId: number; + + @prop({ required: true }) + env: string; + + @prop({ required: true }) + serverId: number; +} + @modelOptions({ schemaOptions: { id: false } }) @index({ code: 1 }) export default class Marquee extends BaseModel { @prop({ required: true }) code: string; // 跑马灯唯一标识 - @prop({ required: true, type: Number }) - serverIds: number[]; // 推送服务器 - - @prop({ required: true, enum: MARQUEE_TYPE }) - type: MARQUEE_TYPE; // 推送类型 - @prop({ required: true }) - startTime: Date; // 活动开始时间 + receiverType: number; // 推送目标 - @prop({ required: true }) - endTime: Date; // 活动结束时间 + @prop({ required: true, type: Receiver, _id: false }) + receivers: Receiver[]; // 推送服务器 - @prop({ required: true }) - interval: number; // 活动结束时间 + @prop({ required: true, enum: MARQUEE_TIME_TYPE }) + timeType: MARQUEE_TIME_TYPE; // 推送时间类型,立刻/定时 + + @prop({ required: true, enum: MARQUEE_SHOW_TYPE }) + showType: MARQUEE_SHOW_TYPE; // 推送显示类型,一次性/循环 + + @prop({ required: true, default: 0 }) + startTime: number; // 循环开始时间/定时开始时间 + + @prop({ required: true, default: 0 }) + endTime: number; // 循环结束时间 + + @prop({ required: true, default: 0 }) + interval: number; // 推送间隔 @prop({ required: true }) content: string; // 广播内容 - @prop({ required: true }) - isRunning: boolean; // 当前正在发布 + @prop({ required: true, default: true }) + isEnable: boolean; // 当前正在发布 + + setByForm(obj: any) { + this.code = obj.code; + this.receiverType = obj.receiverType; + this.receivers = obj.receivers; + this.timeType = obj.timeType; + this.showType = obj.showType; + if(this.timeType == MARQUEE_TIME_TYPE.INSTANT) { + this.startTime = nowSeconds(); + } else { + this.startTime = obj.startTime; + } + if(this.showType == MARQUEE_SHOW_TYPE.CIRCLE) { + this.endTime = this.startTime + obj.continueMinute * 60; + this.interval = obj.interval; + } + this.content = obj.content; + } /** * 创建跑马灯 @@ -38,7 +76,7 @@ export default class Marquee extends BaseModel { * @param uid 后台操作人 */ public static async createData(params: MarqueeParam, uid = 1) { - const code = genCode(10); + const code = genCode(6); const doc = new MarqueeModel(); const update = Object.assign(doc.toJSON(), params, { code, createdBy: uid, updatedBy: uid }); const result: MarqueeType = await MarqueeModel.findOneAndUpdate({ code }, { $setOnInsert: update }, { new: true, upsert: true }).lean(); @@ -69,21 +107,33 @@ export default class Marquee extends BaseModel { /** * 查询所有生效中的跑马灯 */ - public static async findEffectiveMarque() { - const result: MarqueeType[] = await MarqueeModel.find({ type: MARQUEE_TYPE.SCHEDULE, startTime: { $lte: new Date() }, endTime: { $gte: new Date() } }).lean(); + public static async findEffectiveMarque(env: string) { + const result: MarqueeType[] = await MarqueeModel.find({ + $or: [ + { showType: MARQUEE_SHOW_TYPE.CIRCLE, startTime: { $lte: nowSeconds() }, endTime: { $gte: nowSeconds() }}, + { showType: MARQUEE_SHOW_TYPE.ONCE, startTime: { $lte: nowSeconds() }} + ], + isEnable: true, + 'receivers.env': env + }).lean(); return result; } - private static getSearchObj(form: { type?: number, current?: boolean, content?: string }) { + private static getSearchObj(form: SearchMarqueeParam) { let searchObj = {}; - if(form['type']) searchObj['type'] = form.type; - if(form['current']) searchObj['isRunning'] = form.current - if(form['content']) searchObj['content'] = { $regex: new RegExp(form.content.toString(), 'i') }; + if(form.code) searchObj['code'] = form.code; + if(form.createdBy) searchObj['createdBy'] = form.createdBy + if(form.createTimeStart && form.createTimeEnd) { + searchObj['createdAt'] = { $gt: new Date(form.createTimeStart * 1000), $lt: new Date(form.createTimeEnd * 1000) }; + } + if(form.sendTimeStart && form.sendTimeEnd) { + searchObj['startTime'] = { $gt: form.sendTimeStart, $lt: form.sendTimeEnd } + } return searchObj } - public static async findByCondition(page: number, pageSize: number, sortField: string = 'updatedAt', sortOrder: string = 'descend', form: { type?: number, current?: boolean, content?: string } = {}) { + public static async findByCondition(page: number, pageSize: number, sortField: string = 'updatedAt', sortOrder: string = 'descend', form: SearchMarqueeParam = {}) { let searchObj = this.getSearchObj(form); let sort = {}; @@ -94,12 +144,12 @@ export default class Marquee extends BaseModel { sort[sortField] = -1; } } - const result: MarqueeType[] = await MarqueeModel.find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort).select('+sort +showStartTime +showEndTime +serverType +isEnable').lean({ getters: true, virtuals: true }); + const result: MarqueeType[] = await MarqueeModel.find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort).lean({ getters: true, virtuals: true }); return result; } - public static async countByCondition(form: { type?: number, current?: boolean, content?: string } = {}) { + public static async countByCondition(form: SearchMarqueeParam = {}) { let searchObj = this.getSearchObj(form); const result = await MarqueeModel.count(searchObj); @@ -108,7 +158,12 @@ export default class Marquee extends BaseModel { } -export const MarqueeModel = getModelForClass(Marquee); +export let MarqueeModel: ReturnModelType; +export function loadMarqueeModel(connect: mongoose.Connection) { + MarqueeModel = getModelForClass(Marquee, { + existingConnection: connect + }); +} export interface MarqueeType extends Pick, keyof Marquee> {}; export type MarqueeParam = Partial; diff --git a/shared/db/index.ts b/shared/db/index.ts index 42adb0b1e..0cfaef575 100644 --- a/shared/db/index.ts +++ b/shared/db/index.ts @@ -8,6 +8,7 @@ import { loadRegionModel } from "./Region"; import { loadServerlistModel } from "./Serverlist"; import { loadGMMailModel } from './GMMail'; import { loadCounterModal } from "./CounterAll"; +import { loadMarqueeModel } from "./Marquee"; export function loadGmDb(connect: mongoose.Connection) { // console.log('************') @@ -20,4 +21,5 @@ export function loadGmDb(connect: mongoose.Connection) { loadServerlistModel(connect); loadGMMailModel(connect); loadCounterModal(connect); + loadMarqueeModel(connect); } \ No newline at end of file diff --git a/shared/domain/backEndField/search.ts b/shared/domain/backEndField/search.ts index 2cc308724..9308474de 100644 --- a/shared/domain/backEndField/search.ts +++ b/shared/domain/backEndField/search.ts @@ -34,4 +34,13 @@ export interface SearchMailParam { status?: GM_MAIL_STATUS; mailType?: GM_MAIL_TYPE; hasGoods?: boolean; +} + +export interface SearchMarqueeParam { + code?: string; + createdBy?: number; + createTimeStart?: number; + createTimeEnd?: number; + sendTimeStart?: number; + sendTimeEnd?: number; } \ No newline at end of file diff --git a/web-server/app/middleware/getIp.ts b/web-server/app/middleware/getIp.ts index 657ef2856..0c764ab73 100644 --- a/web-server/app/middleware/getIp.ts +++ b/web-server/app/middleware/getIp.ts @@ -3,7 +3,7 @@ import { Context } from 'egg'; module.exports = () => { return async function parmsDecode(ctx: Context, next) { - let xRealIp = typeof ctx.header['x-real-ip'] == 'string'? ctx.header['x-real-ip']: ctx.header['x-real-ip'][0]; + let xRealIp = ctx.header['x-real-ip'] && (typeof ctx.header['x-real-ip'] == 'string'? ctx.header['x-real-ip']: ctx.header['x-real-ip'][0]); ctx.clientIp = xRealIp||ctx.request.ip; console.log('*****', ctx.clientIp); await next(); From cb999cec10753c4f9b40dd49aeb94c882514d6bf Mon Sep 17 00:00:00 2001 From: luying Date: Fri, 10 Dec 2021 17:36:01 +0800 Subject: [PATCH 23/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E7=A4=BC?= =?UTF-8?q?=E5=8C=85=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/role/handler/itemHandler.ts | 23 +++--- gm-server/app/controller/users.ts | 39 +++++---- gm-server/app/router.ts | 5 +- gm-server/app/service/users.ts | 81 +++++++++---------- shared/consts/constModules/sysConst.ts | 5 ++ shared/db/GiftCode.ts | 79 +++++++++--------- shared/db/GiftCodeDetail.ts | 71 +++++++++++----- shared/db/UserGiftCode.ts | 36 --------- shared/domain/backEndField/params.ts | 73 ++++++++++++++++- shared/domain/backEndField/search.ts | 8 ++ shared/pubUtils/roleUtil.ts | 2 - shared/pubUtils/util.ts | 7 ++ 12 files changed, 255 insertions(+), 174 deletions(-) delete mode 100644 shared/db/UserGiftCode.ts diff --git a/game-server/app/servers/role/handler/itemHandler.ts b/game-server/app/servers/role/handler/itemHandler.ts index 2084a1e2d..8b6b12302 100644 --- a/game-server/app/servers/role/handler/itemHandler.ts +++ b/game-server/app/servers/role/handler/itemHandler.ts @@ -1,5 +1,5 @@ import { Application, BackendSession, HandlerService, } from "pinus"; -import { STATUS, CONSUME_TYPE, DEBUG_MAGIC_WORD } from "../../../consts"; +import { STATUS, CONSUME_TYPE, DEBUG_MAGIC_WORD, GIFT_GENERATE_TYPE } from "../../../consts"; import { RewardInter } from "../../../pubUtils/interface"; import { resResult } from "../../../pubUtils/util"; @@ -12,7 +12,7 @@ import { getAp, setAp, setApBuyTimes } from "../../../services/actionPointServic import { ActionPointModel } from "../../../db/ActionPoint"; import { GiftCodeDetailModel } from "../../../db/GiftCodeDetail"; import { GiftCodeType, GiftCodeModel } from "../../../db/GiftCode"; -import UserGiftCode, { UserGiftCodeModel } from "../../../db/UserGiftCode"; +import { nowSeconds } from "../../../pubUtils/timeUtil"; export default function (app: Application) { new HandlerService(app, {}); @@ -140,6 +140,7 @@ export class ItemHandler { public async useGiftCode(msg: { code: string }, session: BackendSession) { const roleId: string = session.get('roleId'); const roleName: string = session.get('roleName'); + const serverId: number = session.get('serverId'); const sid: string = session.get('sid'); const { code } = msg; @@ -147,24 +148,20 @@ export class ItemHandler { if(!giftCodeDetail) { return resResult(STATUS.GIFT_CODE_NOT_FOUND); } - let giftCode = giftCodeDetail.giftCode; + let giftCode = await GiftCodeModel.findByGiftId(giftCodeDetail.giftId); if(!giftCode) { return resResult(STATUS.GIFT_CODE_NOT_FOUND); } + + if(!giftCode.isEnable) return resResult(STATUS.GIFT_CODE_HAS_EXPIRED); + if (giftCode.beginTime > nowSeconds()) return resResult(STATUS.GIFT_CODE_NOT_START); + if (giftCode.endTime < nowSeconds()) return resResult(STATUS.GIFT_CODE_HAS_EXPIRED); - if (giftCode.isLimit && giftCodeDetail.usedNum >= giftCode.count) { - return resResult(STATUS.GIFT_CODE_USED_NUM_MAX); - } - if (giftCode.beginTime > new Date()) return resResult(STATUS.GIFT_CODE_NOT_START); - if (giftCode.endTime < new Date()) return resResult(STATUS.GIFT_CODE_HAS_EXPIRED); - - let userGiftCode = await UserGiftCodeModel.findByCode(roleId, code); - if (userGiftCode) { + if (giftCodeDetail.roleIds.indexOf(roleId) != -1) { return resResult(STATUS.YOU_HAVE_USED_THIS_CODE); } - await UserGiftCode.createCode(roleId, code, giftCode); - await GiftCodeDetailModel.increaseUsedNum(code); + await GiftCodeDetailModel.increaseUsedNum(code, roleId, roleName, serverId); await GiftCodeModel.increaseUsedNum(giftCode.id); let goods = await addItems(roleId, roleName, sid, giftCode.goods); diff --git a/gm-server/app/controller/users.ts b/gm-server/app/controller/users.ts index c2cb973e3..e7e0491f8 100644 --- a/gm-server/app/controller/users.ts +++ b/gm-server/app/controller/users.ts @@ -148,37 +148,34 @@ export default class UserController extends Controller { ctx.body = await ctx.service.users.getGiftCodeList(page, pageSize, sortField, sortOrder, form); } + public async createAndGenerateGift() { + const { ctx } = this; + const params = ctx.request.body; + ctx.body = await ctx.service.users.createAndGenerateGift(params, params.generateCnt); + } + public async updateGiftCode() { const { ctx } = this; - const { id, values } = ctx.request.body; - ctx.body = await ctx.service.users.updateGiftCode(id, values); + const params = ctx.request.body; + ctx.body = await ctx.service.users.updateGiftCode(params.id, params.values); } public async generateGiftCode() { const { ctx } = this; - const { id, generateType, code, generateNum, codeLen } = ctx.request.body; - if(generateType == 1) { - if(!generateNum) { - ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); - return - } - } else if (generateType == 2) { - if(!code) { - ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); - return - } - } else { - ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); - return - } - - ctx.body = await ctx.service.users.generateGiftCode(id, generateType, code, generateNum, codeLen); + const params = ctx.request.body; + ctx.body = await ctx.service.users.generateGiftCode(params.id, params.count); } - public async getGiftCodeDetails() { + public async cancelGiftCode() { + const { ctx } = this; + const params = ctx.request.body; + ctx.body = await ctx.service.users.cancelGiftCode(params.id, !!params.isEnable); + } + + public async getGiftCodeDetailFile() { const { ctx } = this; const { id } = ctx.params; - ctx.body = await ctx.service.users.getGiftCodeDetails(parseInt(id)); + ctx.body = await ctx.service.users.getGiftCodeDetailFile(parseInt(id)); return } } diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index 8b29f8cc6..734924224 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -45,10 +45,11 @@ export default (app: Application) => { router.post('/api/users/deleteitem', tokenParser, controller.users.deleteItem); router.post('/api/users/setitemcount', tokenParser, controller.users.setItemCount); router.post('/api/users/getgiftcodelist', controller.users.getGiftCodeList); + router.post('/api/users/createandgenerategift', controller.users.createAndGenerateGift) router.post('/api/users/updategiftcode', controller.users.updateGiftCode); router.post('/api/users/generategiftcode', controller.users.generateGiftCode); - // router.post('/api/users/delgiftCode', controller.users.delGiftCode); - router.get('/api/users/getgiftcodedetails/:id/:filename', controller.users.getGiftCodeDetails); + router.post('/api/users/cancelgiftCode', controller.users.cancelGiftCode); + router.get('/api/users/getgiftcodedetailfile/:id/:filename', controller.users.getGiftCodeDetailFile); // router.post('/api/game/getserverlistbyenv', tokenParser, controller.game.getServerListByEnv); // router.post('/api/game/getserverlist', controller.game.getServerList); diff --git a/gm-server/app/service/users.ts b/gm-server/app/service/users.ts index dcfae150a..c226a9238 100644 --- a/gm-server/app/service/users.ts +++ b/gm-server/app/service/users.ts @@ -21,7 +21,9 @@ import { CreateHeroes, deletRole } from '@pubUtils/roleUtil'; import { RScriptRecordModel } from '@db/RScriptRecord'; import { DicWar } from '@pubUtils/dictionary/DicWar'; import { SkinModel } from '@db/Skin'; -import { SearchEquipParam, SearchHeroParam, SearchUserParam } from '@domain/backEndField/search'; +import { SearchEquipParam, SearchHeroParam, SearchUserParam, SearchGiftCodeParam } from '@domain/backEndField/search'; +import { CreateGiftCode, UpdateGiftCode } from '@domain/backEndField/params'; +import { isNumber } from 'util'; // import { resResult } from '@pubUtils/util'; @@ -624,70 +626,65 @@ export default class GMUsers extends Service { } } - public async getGiftCodeList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { name?: string, current?: boolean, } = {}) { + public async getGiftCodeList(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchGiftCodeParam = {}) { const { ctx } = this; const list = await GiftCodeModel.findByCondition(page, pageSize, sortField, sortOrder, form); const total = await GiftCodeModel.countByCondition( form ) return ctx.service.utils.resResult(STATUS.SUCCESS, { - list: list.map(cur => { - return { ...cur, beginTime: cur.beginTime.getTime(), endTime: cur.endTime.getTime() } - }), total + list: list.map(cur => ({...cur, env: ctx.app.config.realEnv })), total }); } - public async updateGiftCode(id: string|number, params: any) { + public async createAndGenerateGift(obj: any, count: number = 1) { const { ctx } = this; - if(params.beginTime) params.beginTime = new Date(params.beginTime); - if(params.endTime) params.endTime = new Date(params.endTime); + let params = new CreateGiftCode(obj); + if(!isNumber(count) || !params.checkParams()) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); + + let giftCode = await GiftCodeModel.createData(params); + await GiftCodeDetailModel.generateMany(giftCode, count, ctx.user?.uid); + return ctx.service.utils.resResult(STATUS.SUCCESS, giftCode); + } + + public async updateGiftCode(id: number, obj: any) { + const { ctx } = this; + let params = new UpdateGiftCode(id, obj); + if(!params.checkParams()) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); - try{ - params.goods = JSON.parse(params.goods); - } catch(e) { - console.error(e); - return ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); - } const result = await GiftCodeModel.updateData(id, params, ctx.user?.uid); if(!result) return ctx.service.utils.resResult(STATUS.INTERNAL_ERR); return ctx.service.utils.resResult(STATUS.SUCCESS); } - public async generateGiftCode(id: number, generateType: 1|2, code: string, generateNum: number, codeLen: number = 8) { + public async generateGiftCode(id: number, count: number) { const { ctx } = this; - - let giftCode = await GiftCodeModel.findData(id); - if(!giftCode) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); + if(!isNumber(id) || !isNumber(count)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); - let length = 0, isLimit = false, count = 0, generateCode = ''; - if(generateType == 1) { - let generateResult = await GiftCodeDetailModel.generateMany(giftCode, generateNum, codeLen, ctx.user?.uid); - length = generateResult.length; - isLimit = true; - count = 1; - } else if (generateType == 2) { - let generateResult = await GiftCodeDetailModel.generateOne(giftCode, code, ctx.user?.uid); - length = generateResult.length; - generateCode = code; - } - if(length <= 0) return ctx.service.utils.resResult(STATUS.INTERNAL_ERR); - giftCode = await GiftCodeModel.updateData(id, { generateCnt: giftCode.generateCnt + length, generateType, isLimit, count, generateCode }, ctx.user?.uid); - return ctx.service.utils.resResult(STATUS.SUCCESS, { giftCode }) + let giftCode = await GiftCodeModel.findByGiftId(id); + if(!giftCode) return ctx.service.utils.resResult(STATUS.DB_DATA_NOT_FOUND); + await GiftCodeDetailModel.generateMany(giftCode, count, ctx.user?.uid); + return ctx.service.utils.resResult(STATUS.SUCCESS, giftCode); } - public async getGiftCodeDetails(id: number) { + public async cancelGiftCode(id: number, isEnable: boolean) { + const { ctx } = this; + if(!isNumber(id)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); + + let giftCode = await GiftCodeModel.findByGiftId(id); + if(!giftCode) return ctx.service.utils.resResult(STATUS.DB_DATA_NOT_FOUND); + await GiftCodeModel.updateData(id, { isEnable }, ctx.user?.uid); + return ctx.service.utils.resResult(STATUS.SUCCESS, giftCode); + } + + public async getGiftCodeDetailFile(id: number) { const { ctx } = this; - let giftCode = await GiftCodeModel.findData(id); + let giftCode = await GiftCodeModel.findByGiftId(id); if(!giftCode) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); - let { generateCnt } = giftCode; - let limit = 1000; - let n = Math.ceil(generateCnt / limit); let codes: string[] = []; - for(let i = 0; i < n; i++) { - let giftCodeDetails = await GiftCodeDetailModel.findByGiftCode(giftCode); - for(let {code} of giftCodeDetails) { - codes.push(code); - } + let giftCodeDetails = await GiftCodeDetailModel.findAllCodeByGiftId(giftCode.id, giftCode.generateCnt); + for(let {code} of giftCodeDetails) { + codes.push(code); } console.log(id, codes.join()) diff --git a/shared/consts/constModules/sysConst.ts b/shared/consts/constModules/sysConst.ts index e7958ef35..35a6d25af 100644 --- a/shared/consts/constModules/sysConst.ts +++ b/shared/consts/constModules/sysConst.ts @@ -770,4 +770,9 @@ export enum SERVER_TIMER { TEN_HALF = 2, // 10:30 FIFTEEN_HALF = 3, // 15:30 NINETEEN_HALF = 4, // 19:30 +} + +export enum GIFT_GENERATE_TYPE { + ONE_TO_ONE = 1, // 一人一码,一条码只能被用一次 + ONE_TO_MANY = 2, // 通码,一条码能被多人使用,每个人只能用一次 } \ No newline at end of file diff --git a/shared/db/GiftCode.ts b/shared/db/GiftCode.ts index cf40d6040..b74301006 100644 --- a/shared/db/GiftCode.ts +++ b/shared/db/GiftCode.ts @@ -1,7 +1,8 @@ import BaseModel from './BaseModel'; import { getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose'; import { CounterModel } from './Counter'; -import { COUNTER } from '../consts'; +import { COUNTER, GIFT_GENERATE_TYPE } from '../consts'; +import { SearchGiftCodeParam } from '../domain/backEndField/search'; class Rewards { @prop({ required: true }) @@ -15,81 +16,84 @@ class Rewards { **/ @modelOptions({ schemaOptions: { id: false } }) export default class GiftCode extends BaseModel { - @prop({ required: true, default: '' }) + @prop({ required: true }) id: number; // 唯一id @prop({ required: true, default: '' }) name: string; // 礼包码名 - @prop({ required: true, default: false }) - isLimit: boolean; // 每个码是否有使用次数限制 - - @prop({ required: true, default: 0 }) - count: number; // 每个码可使用次数 - @prop({ required: true, type: Rewards, _id: false }) goods: Rewards[]; // 奖励 @prop({ required: true }) - beginTime: Date; // 开始时间 + beginTime: number; // 开始时间 @prop({ required: true }) - endTime: Date; // 结束时间 + endTime: number; // 结束时间 + + @prop({ required: true, default: 0 }) + codeLen: number; // 礼包码位数 @prop({ required: true, default: '' }) remark: string; // 备注 - @prop({ required: true, default: 0 }) - generateType: number; // 生成类型 + @prop({ required: true, default: 0, enum: GIFT_GENERATE_TYPE }) + generateType: GIFT_GENERATE_TYPE; // 生成类型 @prop({ required: true, default: 0 }) - generateCnt: number; // 已生成条数,giftCodeDetail的数量 - - @prop({ required: true, default: '' }) - generateCode: string; // 单条的生成的那一个code - + generateCnt: number; // 生成条数,giftCodeDetail的数量 + @prop({ required: true, default: 0 }) usedNum: number; // 使用次数 - public static async findData(id: number) { + @prop({ required: true, default: true }) + isEnable: boolean; // 是否可以使用 + + + public static async findByGiftId(id: number) { let rec: GiftCodeType = await GiftCodeModel.findOne({ id }).lean(); return rec; } - public static async updateData(id: string|number, values: GiftCodeParam, uid = 1) { - if(id == 'new') { - id = await CounterModel.getNewCounter(COUNTER.GIFT_CODE); - } + public static async createData(values: GiftCodeParam, uid = 1) { + let id = await CounterModel.getNewCounter(COUNTER.GIFT_CODE); let doc = new GiftCodeModel(); - let createObj = doc.toJSON(); - delete values.id; - delete createObj._id; - delete createObj.id; - for(let key in values) { - delete createObj[key]; - } + let obj = doc.toJSON(); + let update = Object.assign(obj, values, { id }); - let rec: GiftCodeType = await GiftCodeModel.findOneAndUpdate({ id }, { $set: {...values, updatedBy: uid}, $setOnInsert: { ...createObj, createdBy: uid } }, + let rec: GiftCodeType = await GiftCodeModel.findOneAndUpdate({ id }, { $set: { updatedBy: uid}, $setOnInsert: { ...update, createdBy: uid } }, { new: true, upsert: true }).lean(true); return rec; } + public static async updateData(id: number, values: GiftCodeParam, uid = 1) { + + let rec: GiftCodeType = await GiftCodeModel.findOneAndUpdate({ id }, { $set: {...values, updatedBy: uid} }, + { new: true }).lean(true); + return rec; + } + public static async increaseUsedNum(id: number) { let result: GiftCodeType = await GiftCodeModel.findOneAndUpdate({ id }, { $inc: { usedNum: 1 } }, { new: true }).lean(); return result; } - private static getSearchObj(form: { name?: string, current?: boolean }) { + public static async increateGenerateNum(id: number, count: number) { + let result: GiftCodeType = await GiftCodeModel.findOneAndUpdate({ id }, { $inc: { generateCnt: count } }, { new: true }).lean(); + return result; + } + + private static getSearchObj(form: SearchGiftCodeParam) { let searchObj = {}; + if(form.id) searchObj['id'] = form.id; if (form.name != undefined) searchObj['name'] = { $regex: new RegExp(form.name.toString(), 'i') }; - if (form.current) { - searchObj['beginTime'] = { $lte: new Date }; - searchObj['endTime'] = { $gte: new Date }; + if (form.createTimeStart && form.createTimeEnd) { + searchObj['createdAt'] = { $lte: new Date(form.createTimeEnd * 1000), $gte: new Date(form.createTimeStart * 100) }; } return searchObj } - public static async findByCondition(page: number, pageSize: number, sortField: string, sortOrder: string, form: { name?: string, current?: boolean } = {}) { + public static async findByCondition(page: number, pageSize: number, sortField: string, sortOrder: string, form:SearchGiftCodeParam = {}) { let searchObj = this.getSearchObj(form); let sort = {}; @@ -105,7 +109,7 @@ export default class GiftCode extends BaseModel { } - public static async countByCondition(form: { name?: string, current?: boolean } = {}) { + public static async countByCondition(form: SearchGiftCodeParam = {}) { let searchObj = this.getSearchObj(form); const result = await GiftCodeModel.count(searchObj); @@ -113,7 +117,6 @@ export default class GiftCode extends BaseModel { } } -export const GiftCodeModel = getModelForClass(GiftCode); - +export let GiftCodeModel = getModelForClass(GiftCode); export interface GiftCodeType extends Pick, keyof GiftCode> { } export type GiftCodeParam = Partial; diff --git a/shared/db/GiftCodeDetail.ts b/shared/db/GiftCodeDetail.ts index ecc27dce9..914bfeff4 100644 --- a/shared/db/GiftCodeDetail.ts +++ b/shared/db/GiftCodeDetail.ts @@ -1,7 +1,23 @@ import BaseModel from './BaseModel'; -import { index, getModelForClass, prop, DocumentType, modelOptions, Ref, mongoose } from '@typegoose/typegoose'; -import GiftCode, { GiftCodeType } from './GiftCode'; -import { genCode } from '../pubUtils/util'; +import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose'; +import { GIFT_GENERATE_TYPE } from '../consts'; +import { GiftCodeModel, GiftCodeType } from './GiftCode'; +import { nowSeconds } from '../pubUtils/timeUtil'; +import { genCode } from '@pubUtils/util'; + +class RoleRecord { + @prop({ required: true, default: '' }) + roleId: string; + + @prop({ required: true, default: '' }) + roleName: string; + + @prop({ required: true, default: 0 }) + serverId: number; + + @prop({ required: true, default: 0 }) + time: number; +} /** * 举报记录 @@ -9,15 +25,28 @@ import { genCode } from '../pubUtils/util'; @modelOptions({ schemaOptions: { id: false } }) @index({ code: 1 }) export default class GiftCodeDetail extends BaseModel { + + @prop({ required: true, default: '' }) + giftId: number; // giftCode表的id + + @prop({ required: true, default: '' }) + giftName: string; // giftCode表的name + + @prop({ required: true, default: 0, enum: GIFT_GENERATE_TYPE }) + generateType: GIFT_GENERATE_TYPE; // 一人一码or通码 + @prop({ required: true, default: '' }) code: string; // 兑换码 - @prop({ ref: 'GiftCode', type: mongoose.Schema.Types.ObjectId }) - giftCode: Ref; - @prop({ required: true, default: '' }) usedNum: number; // 该码使用次数 + @prop({ required: true, type: String }) + roleIds: string[]; + + @prop({ required: true, type: RoleRecord, _id: false }) + record: RoleRecord[]; + // 根据code public static async findByCode(code: string) { @@ -25,27 +54,33 @@ export default class GiftCodeDetail extends BaseModel { return result; } - public static async findByGiftCode(giftCode: GiftCodeType) { - let result: GiftCodeDetailType[] = await GiftCodeDetailModel.find({ giftCode: giftCode._id }).lean(); + public static async findAllCodeByGiftId(id: number, cnt: number) { + let n = Math.ceil(cnt/1000); + let result: GiftCodeDetailType[] = []; + for(let i = 0; i < n; i++) { + let codes = await GiftCodeDetailModel.find({ giftId: id }).limit(1000).skip(i * 1000).sort({ _id: 1 }).lean(); + result.push(...codes); + } return result; } - public static async increaseUsedNum(code: string) { - let result: GiftCodeDetailType = await GiftCodeDetailModel.findOneAndUpdate({ code }, { $inc: { usedNum: 1 } }, { new: true }).lean(); + public static async increaseUsedNum(code: string, roleId: string, roleName: string, serverId: number) { + let result: GiftCodeDetailType = await GiftCodeDetailModel.findOneAndUpdate({ code }, { + $inc: { usedNum: 1 }, $push: { roleIds: roleId, record: { roleId, roleName, serverId, time: nowSeconds() } } + }, { new: true }).lean(); return result; } - public static async generateOne(giftCode: GiftCodeType, code: string, uid = 1 ) { - let result = await GiftCodeDetailModel.insertMany([{ giftCode: giftCode._id, code, usedNum: 0, createdBy: uid, updatedBy: uid }]); - return result; - } - - public static async generateMany(giftCode: GiftCodeType, generateNum: number, codeLen: number, uid = 1) { + public static async generateMany(giftCode: GiftCodeType, count = 1, uid = 1) { let insertArr: GiftCodeDetailParam[] = []; - for(let i = 0; i < generateNum; i++) { - insertArr.push({ giftCode: giftCode._id, code: genCode(codeLen), usedNum: 0, createdBy: uid, updatedBy: uid }); + for(let i = 0; i < count; i++) { + insertArr.push({ + giftId: giftCode.id, giftName: giftCode.name, generateType: giftCode.generateType, + code: genCode(giftCode.codeLen), usedNum: 0, createdBy: uid, updatedBy: uid + }); } let result = await GiftCodeDetailModel.insertMany(insertArr); + await GiftCodeModel.increateGenerateNum(giftCode.id, count); return result; } diff --git a/shared/db/UserGiftCode.ts b/shared/db/UserGiftCode.ts deleted file mode 100644 index 3d14971e7..000000000 --- a/shared/db/UserGiftCode.ts +++ /dev/null @@ -1,36 +0,0 @@ -import BaseModel from './BaseModel'; -import { index, getModelForClass, prop, DocumentType, modelOptions, Ref, mongoose } from '@typegoose/typegoose'; -import GiftCode, { GiftCodeType } from './GiftCode'; - -/** - * 举报记录 -**/ -@modelOptions({ schemaOptions: { id: false } }) -@index({ roleId: 1, code: 1 }) -export default class UserGiftCode extends BaseModel { - - @prop({ required: true, default: '' }) - roleId: string; // 玩家id - - @prop({ required: true, default: '' }) - code: string; // 兑换码 - - @prop({ ref: 'GiftCode', type: mongoose.Schema.Types.ObjectId }) - giftCode: Ref; - - // 根据code - public static async findByCode(roleId: string, code: string) { - let result: UserGiftCodeType = await UserGiftCodeModel.findOne({ roleId, code }).lean(); - return result; - } - - public static async createCode(roleId: string, code: string, gitCode: GiftCodeType) { - let result: UserGiftCodeType = await UserGiftCodeModel.findOneAndUpdate({ roleId, code }, { $setOnInsert: { gitCode: gitCode._id } }, { new: true, upsert: true}).lean() - return result; - } -} - -export const UserGiftCodeModel = getModelForClass(UserGiftCode); - -export interface UserGiftCodeType extends Pick, keyof UserGiftCode> { } -export type UserGiftCodeParam = Partial; diff --git a/shared/domain/backEndField/params.ts b/shared/domain/backEndField/params.ts index 43567aee3..9054d8a4d 100644 --- a/shared/domain/backEndField/params.ts +++ b/shared/domain/backEndField/params.ts @@ -1,7 +1,9 @@ -import { GM_MAIL_TYPE, MAIL_TIME_TYPE, SERVER_TIMER } from "../../consts"; -import { isArray } from 'underscore'; +import { GIFT_GENERATE_TYPE, GM_MAIL_TYPE, MAIL_TIME_TYPE, SERVER_TIMER } from "../../consts"; +import { isArray, isNumber, isString } from 'underscore'; import ServerStategy, { GMMail } from "../../db/ServerStategy"; import { RegionType } from "../../db/Region"; +import { RewardInter } from "../../pubUtils/interface"; +import { isTimestamp } from '../../pubUtils/util'; export class UpdateMailParams { hasGoods: boolean = false; // 是否有道具 @@ -156,4 +158,71 @@ export class CreateServerParam { if(this.hasCircleMail && !this.circleMail) return false; return true; } +} + +export class CreateGiftCode { + name: string; // 礼包码名 + goods: RewardInter[]; // 奖励 + beginTime: number; // 开始时间 + endTime: number; // 结束时间 + codeLen: number; // 礼包码位数 + remark: string = ''; // 备注 + generateType: GIFT_GENERATE_TYPE; // 生成类型 + + constructor(obj: any) { + this.name = obj.name; + this.goods = obj.goods; + this.beginTime = obj.beginTime; + this.endTime = obj.endTime; + this.codeLen = obj.codeLen; + this.remark = obj.remark; + this.generateType = obj.generateType; + } + + checkParams() { + if(!isString(this.name)) return false; + if(!isArray(this.goods)) return false; + for(let { id, count } of this.goods) { + if(!isNumber(id) || !isNumber(count)) return false; + } + if(!isTimestamp(this.beginTime) || !isTimestamp(this.endTime)) return false; + if(!isNumber(this.codeLen) || this.codeLen <= 0) return false; + + if(this.generateType != GIFT_GENERATE_TYPE.ONE_TO_MANY && this.generateType != GIFT_GENERATE_TYPE.ONE_TO_ONE) { + return false + } + return true; + } +} + +export class UpdateGiftCode { + id: number; + name: string; // 礼包码名 + goods: RewardInter[]; // 奖励 + beginTime: number; // 开始时间 + endTime: number; // 结束时间 + codeLen: number; // 礼包码位数 + remark: string = ''; // 备注 + + constructor(id: number, obj: any) { + this.id = id; + this.name = obj.name; + this.goods = obj.goods; + this.beginTime = obj.beginTime; + this.endTime = obj.endTime; + this.codeLen = obj.codeLen; + this.remark = obj.remark; + } + + checkParams() { + if(!isNumber(this.id) || this.id <= 0) return false + if(!isString(this.name)) return false; + if(!isArray(this.goods)) return false; + for(let { id, count } of this.goods) { + if(!isNumber(id) || !isNumber(count)) return false; + } + if(!isTimestamp(this.beginTime) || !isTimestamp(this.endTime)) return false; + if(!isNumber(this.codeLen) || this.codeLen <= 0) return false; + return true; + } } \ No newline at end of file diff --git a/shared/domain/backEndField/search.ts b/shared/domain/backEndField/search.ts index 9308474de..06d12a65f 100644 --- a/shared/domain/backEndField/search.ts +++ b/shared/domain/backEndField/search.ts @@ -43,4 +43,12 @@ export interface SearchMarqueeParam { createTimeEnd?: number; sendTimeStart?: number; sendTimeEnd?: number; +} + +export interface SearchGiftCodeParam { + env?: string; + id?: number; + name?: string; + createTimeStart?: number; + createTimeEnd?: number; } \ No newline at end of file diff --git a/shared/pubUtils/roleUtil.ts b/shared/pubUtils/roleUtil.ts index 683fbd737..4aedeca7e 100644 --- a/shared/pubUtils/roleUtil.ts +++ b/shared/pubUtils/roleUtil.ts @@ -90,7 +90,6 @@ import { ScriptBarrageModel } from '../db/ScriptBarrage'; import { ServerMailModel } from '../db/ServerMail'; import { UserGachaModel } from '../db/UserGacha'; import { UserGachaRecModel } from '../db/UserGachaRec'; -import { UserGiftCodeModel } from '../db/UserGiftCode'; import { UserGuildActivityRecModel } from '../db/UserGuildActivityRec'; import { UserOrderModel } from '../db/UserOrder'; import { UserShopModel } from '../db/UserShop'; @@ -462,7 +461,6 @@ export async function deletRole(roleId: string) { await TowerTaskRecModel.deleteMany({ roleId }); await UserGachaModel.deleteMany({ roleId }); await UserGachaRecModel.deleteMany({ roleId }); - await UserGiftCodeModel.deleteMany({ roleId }); await UserGuildModel.deleteMany({ roleId }); await UserGuildActivityRecModel.deleteMany({ roleId }); await UserGuildApplyModel.deleteMany({ roleId }); diff --git a/shared/pubUtils/util.ts b/shared/pubUtils/util.ts index 967989f8f..d1347be52 100644 --- a/shared/pubUtils/util.ts +++ b/shared/pubUtils/util.ts @@ -1,6 +1,7 @@ import { STATUS } from './../consts/statusCode'; import { HeroModel, HeroType } from '../db/Hero'; +import { isNumber } from 'underscore'; const csprng = require('csprng'); import fs = require('fs'); @@ -668,4 +669,10 @@ export async function checkWhiteList(env: string, ip: string, uid: number, serve if(!!result) return true; } return false +} + +export function isTimestamp(time: number, len = 10) { + if(!isNumber(time)) return false; + if(time.toString().length != len) return false; + return true; } \ No newline at end of file From fbd19a5c4c53ec2424ba1bbd43678123c2784a93 Mon Sep 17 00:00:00 2001 From: luying Date: Fri, 10 Dec 2021 18:40:57 +0800 Subject: [PATCH 24/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E7=A4=BC?= =?UTF-8?q?=E5=8C=85=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/role/handler/itemHandler.ts | 10 ++++- gm-server/app/controller/users.ts | 6 +++ gm-server/app/router.ts | 1 + gm-server/app/service/users.ts | 12 ++++- shared/db/GiftCodeDetail.ts | 44 ++++++++++++++++++- shared/domain/backEndField/search.ts | 9 ++++ 6 files changed, 78 insertions(+), 4 deletions(-) diff --git a/game-server/app/servers/role/handler/itemHandler.ts b/game-server/app/servers/role/handler/itemHandler.ts index 8b6b12302..bab3bb15f 100644 --- a/game-server/app/servers/role/handler/itemHandler.ts +++ b/game-server/app/servers/role/handler/itemHandler.ts @@ -152,7 +152,9 @@ export class ItemHandler { if(!giftCode) { return resResult(STATUS.GIFT_CODE_NOT_FOUND); } - + if(giftCode.generateType == GIFT_GENERATE_TYPE.ONE_TO_ONE) { // 一人一条,单条不能被多人使用 + if(giftCodeDetail.usedNum > 0) return resResult(STATUS.GIFT_CODE_USED_NUM_MAX); + } if(!giftCode.isEnable) return resResult(STATUS.GIFT_CODE_HAS_EXPIRED); if (giftCode.beginTime > nowSeconds()) return resResult(STATUS.GIFT_CODE_NOT_START); if (giftCode.endTime < nowSeconds()) return resResult(STATUS.GIFT_CODE_HAS_EXPIRED); @@ -161,6 +163,12 @@ export class ItemHandler { return resResult(STATUS.YOU_HAVE_USED_THIS_CODE); } + let checkHasUse = await GiftCodeDetailModel.checkHasUsed(roleId, giftCodeDetail.giftId) + if(checkHasUse) { + return resResult(STATUS.YOU_HAVE_USED_THIS_CODE); + } + + await GiftCodeDetailModel.increaseUsedNum(code, roleId, roleName, serverId); await GiftCodeModel.increaseUsedNum(giftCode.id); diff --git a/gm-server/app/controller/users.ts b/gm-server/app/controller/users.ts index e7e0491f8..3fdbce300 100644 --- a/gm-server/app/controller/users.ts +++ b/gm-server/app/controller/users.ts @@ -172,6 +172,12 @@ export default class UserController extends Controller { ctx.body = await ctx.service.users.cancelGiftCode(params.id, !!params.isEnable); } + public async getGiftCodeDetailList() { + const { ctx } = this; + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.users.getGiftCodeDetailList(page, pageSize, sortField, sortOrder, form); + } + public async getGiftCodeDetailFile() { const { ctx } = this; const { id } = ctx.params; diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index 734924224..e09606a41 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -49,6 +49,7 @@ export default (app: Application) => { router.post('/api/users/updategiftcode', controller.users.updateGiftCode); router.post('/api/users/generategiftcode', controller.users.generateGiftCode); router.post('/api/users/cancelgiftCode', controller.users.cancelGiftCode); + router.post('/api/users/getgiftcodedetaillist', controller.users.getGiftCodeDetailList); router.get('/api/users/getgiftcodedetailfile/:id/:filename', controller.users.getGiftCodeDetailFile); // router.post('/api/game/getserverlistbyenv', tokenParser, controller.game.getServerListByEnv); diff --git a/gm-server/app/service/users.ts b/gm-server/app/service/users.ts index c226a9238..06d87b9e0 100644 --- a/gm-server/app/service/users.ts +++ b/gm-server/app/service/users.ts @@ -21,7 +21,7 @@ import { CreateHeroes, deletRole } from '@pubUtils/roleUtil'; import { RScriptRecordModel } from '@db/RScriptRecord'; import { DicWar } from '@pubUtils/dictionary/DicWar'; import { SkinModel } from '@db/Skin'; -import { SearchEquipParam, SearchHeroParam, SearchUserParam, SearchGiftCodeParam } from '@domain/backEndField/search'; +import { SearchEquipParam, SearchHeroParam, SearchUserParam, SearchGiftCodeParam, SearchGiftCodeDetailParam } from '@domain/backEndField/search'; import { CreateGiftCode, UpdateGiftCode } from '@domain/backEndField/params'; import { isNumber } from 'util'; @@ -693,6 +693,16 @@ export default class GMUsers extends Service { return Buffer.from(codes.join('\n')); } + public async getGiftCodeDetailList(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchGiftCodeDetailParam = {}) { + const { ctx } = this; + + const list = await GiftCodeDetailModel.findByCondition(page, pageSize, sortField, sortOrder, form); + const total = await GiftCodeDetailModel.countByCondition( form ) + return ctx.service.utils.resResult(STATUS.SUCCESS, { + list: list.map(cur => ({...cur, env: ctx.app.config.realEnv })), total + }); + } + public async setWarRecord(roleIds: string[], _warId: string) { const { ctx } = this; let warId = parseInt(_warId); diff --git a/shared/db/GiftCodeDetail.ts b/shared/db/GiftCodeDetail.ts index 914bfeff4..05f4e2cec 100644 --- a/shared/db/GiftCodeDetail.ts +++ b/shared/db/GiftCodeDetail.ts @@ -3,7 +3,8 @@ import { index, getModelForClass, prop, DocumentType, modelOptions } from '@type import { GIFT_GENERATE_TYPE } from '../consts'; import { GiftCodeModel, GiftCodeType } from './GiftCode'; import { nowSeconds } from '../pubUtils/timeUtil'; -import { genCode } from '@pubUtils/util'; +import { genCode } from '../pubUtils/util'; +import { SearchGiftCodeDetailParam } from '../domain/backEndField/search'; class RoleRecord { @prop({ required: true, default: '' }) @@ -50,7 +51,12 @@ export default class GiftCodeDetail extends BaseModel { // 根据code public static async findByCode(code: string) { - let result: GiftCodeDetailType = await GiftCodeDetailModel.findOne({ code }).populate('giftCode').lean(true); + let result: GiftCodeDetailType = await GiftCodeDetailModel.findOne({ code }).lean(true); + return result; + } + + public static async checkHasUsed(roleId: string, id: number) { + let result = await GiftCodeDetailModel.exists({ giftId: id, 'record.roleId': roleId }); return result; } @@ -84,6 +90,40 @@ export default class GiftCodeDetail extends BaseModel { return result; } + private static getSearchObj(form: SearchGiftCodeDetailParam) { + let searchObj = {}; + if(form.giftId) searchObj['giftId'] = form.giftId; + if (form.giftName != undefined) searchObj['giftName'] = { $regex: new RegExp(form.giftName.toString(), 'i') }; + if(form.generateType) searchObj['generateType'] = form.generateType; + if(form.code) searchObj['code'] = form.code; + if(form.roleId) searchObj['record.roleId'] = form.roleId; + if (form.roleName != undefined) searchObj['record.roleName'] = { $regex: new RegExp(form.roleName.toString(), 'i') }; + return searchObj + } + + public static async findByCondition(page: number, pageSize: number, sortField: string, sortOrder: string, form:SearchGiftCodeDetailParam = {}) { + + let searchObj = this.getSearchObj(form); + let sort = {}; + if (sortField && sortOrder) { + if (sortOrder == 'ascend') { + sort[sortField] = 1; + } else if (sortOrder == 'descend') { + sort[sortField] = -1; + } + } + const result: GiftCodeDetailType[] = await GiftCodeDetailModel.find(searchObj, { _id: 0 }).limit(pageSize).skip((page - 1) * pageSize).sort(sort).lean({ getters: true, virtuals: true }); + return result; + + } + + public static async countByCondition(form: SearchGiftCodeDetailParam = {}) { + + let searchObj = this.getSearchObj(form); + const result = await GiftCodeDetailModel.count(searchObj); + return result; + } + } export const GiftCodeDetailModel = getModelForClass(GiftCodeDetail); diff --git a/shared/domain/backEndField/search.ts b/shared/domain/backEndField/search.ts index 06d12a65f..7f16375dd 100644 --- a/shared/domain/backEndField/search.ts +++ b/shared/domain/backEndField/search.ts @@ -51,4 +51,13 @@ export interface SearchGiftCodeParam { name?: string; createTimeStart?: number; createTimeEnd?: number; +} + +export interface SearchGiftCodeDetailParam { + giftId?: number; + giftName?: string; + generateType?: number; + code?: string; + roleId?: string; + roleName?: string; } \ No newline at end of file From 05e410d28f0d9d7511650a99e7db7e9ecee9c0ea Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 15 Dec 2021 10:41:30 +0800 Subject: [PATCH 25/32] =?UTF-8?q?=E6=95=B0=E6=95=B0=EF=BC=9A=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E5=81=9C=E6=9C=8D=E5=89=8D=E5=85=B3=E9=97=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/activity/remote/activityRemote.ts | 5 +++++ .../app/servers/battle/remote/battleRemote.ts | 5 +++++ game-server/app/servers/chat/remote/chatRemote.ts | 6 +++++- .../servers/connector/remote/connectorRemote.ts | 5 +++++ game-server/app/servers/gm/handler/gmHandler.ts | 14 ++++++++++++++ .../app/servers/gm/handler/gmRoleHandler.ts | 4 ++-- .../app/servers/guild/remote/guildRemote.ts | 6 +++++- .../app/servers/order/remote/orderRemote.ts | 5 +++++ game-server/app/servers/role/remote/roleRemote.ts | 6 +++++- .../app/servers/systimer/remote/systimerRemote.ts | 5 +++++ 10 files changed, 56 insertions(+), 5 deletions(-) diff --git a/game-server/app/servers/activity/remote/activityRemote.ts b/game-server/app/servers/activity/remote/activityRemote.ts index 1aadef38d..b3b624c6d 100644 --- a/game-server/app/servers/activity/remote/activityRemote.ts +++ b/game-server/app/servers/activity/remote/activityRemote.ts @@ -4,6 +4,7 @@ import { ServerlistModel } from '../../../db/Serverlist'; import { reloadResources } from '../../../pubUtils/data'; import { _getActivitiesByType, _getActivityById, _getActivities } from '../../../services/activity/activityService'; import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService'; +import { taflush } from '../../../services/sdkService'; export default function (app: Application) { new HandlerService(app, {}); @@ -129,4 +130,8 @@ export class ActivityRemote { public getServerMainten(serverId: number) { return getServerMainten(serverId); } + + public taflush() { + return taflush(); + } } \ No newline at end of file diff --git a/game-server/app/servers/battle/remote/battleRemote.ts b/game-server/app/servers/battle/remote/battleRemote.ts index e72acdc67..4cf574d24 100644 --- a/game-server/app/servers/battle/remote/battleRemote.ts +++ b/game-server/app/servers/battle/remote/battleRemote.ts @@ -2,6 +2,7 @@ import { Application, ChannelService, FrontendSession, RemoterClass, HandlerServ import { PVPConfigType } from '../../../db/SystemConfig'; import { reloadResources } from '../../../pubUtils/data'; import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService'; +import { taflush } from '../../../services/sdkService'; export default function (app: Application) { new HandlerService(app, {}); @@ -100,4 +101,8 @@ export class BattleRemote { public getServerMainten(serverId: number) { return getServerMainten(serverId); } + + public taflush() { + return taflush(); + } } \ No newline at end of file diff --git a/game-server/app/servers/chat/remote/chatRemote.ts b/game-server/app/servers/chat/remote/chatRemote.ts index c74d68f45..b28caf31a 100644 --- a/game-server/app/servers/chat/remote/chatRemote.ts +++ b/game-server/app/servers/chat/remote/chatRemote.ts @@ -12,7 +12,7 @@ import { getAllGuildActivityStatus } from '../../../services/guildActivityServic import { MailParam } from '../../../domain/roleField/mail'; import { RankFirstType } from '../../../db/RankFirst'; import { LotType } from '../../../db/Lot'; -import { _checkFilterWords, getTire } from '../../../services/sdkService'; +import { _checkFilterWords, getTire, taflush } from '../../../services/sdkService'; import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService'; export default function (app: Application) { @@ -302,4 +302,8 @@ export class ChatRemote { public getServerMainten(serverId: number) { return getServerMainten(serverId); } + + public taflush() { + return taflush(); + } } diff --git a/game-server/app/servers/connector/remote/connectorRemote.ts b/game-server/app/servers/connector/remote/connectorRemote.ts index 87da81832..5dfd3d4ab 100644 --- a/game-server/app/servers/connector/remote/connectorRemote.ts +++ b/game-server/app/servers/connector/remote/connectorRemote.ts @@ -7,6 +7,7 @@ import { kickUser } from '../../../services/connectorService'; import { PVPConfigType } from '../../../db/SystemConfig'; import { setDicAuctionTime } from '../../../services/guildActivityService'; import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService'; +import { taflush } from '../../../services/sdkService'; export default function (app: Application) { new HandlerService(app, {}); return new ConnectorRemote(app); @@ -94,4 +95,8 @@ export class ConnectorRemote { async setDicAuctionTime(startTime: number, endActivity: number, startGuild: number, endGuild: number, startWorld: number, endWorld: number) { setDicAuctionTime(startTime, endActivity, startGuild, endGuild, startWorld, endWorld); } + + public taflush() { + return taflush(); + } } diff --git a/game-server/app/servers/gm/handler/gmHandler.ts b/game-server/app/servers/gm/handler/gmHandler.ts index 6571e041a..268448e98 100644 --- a/game-server/app/servers/gm/handler/gmHandler.ts +++ b/game-server/app/servers/gm/handler/gmHandler.ts @@ -20,6 +20,8 @@ import { GuildActivityCityModel } from '../../../db/GuildActivityCity'; import { GuildActivityRecordModel } from '../../../db/GuildActivityRec'; import { getTimeFunM, nowSeconds } from '../../../pubUtils/timeUtil'; import moment = require('moment'); +import { sendUngotDividend } from '../../../services/auctionService'; +import { taflush } from '../../../services/sdkService'; let timer: NodeJS.Timer; export default function (app: Application) { return new GmHandler(app); @@ -341,4 +343,16 @@ export class GmHandler { await pushCurrentTime(now.getTime()); return resResult(STATUS.SUCCESS); } + + async taflus() { + taflush(); + pinus.app.rpc.activity.activityRemote.taflush.broadcast(); + pinus.app.rpc.battle.battleRemote.taflush.broadcast(); + pinus.app.rpc.chat.chatRemote.taflush.broadcast(); + pinus.app.rpc.connector.connectorRemote.taflush.broadcast(); + pinus.app.rpc.guild.guildRemote.taflush.broadcast(); + pinus.app.rpc.order.orderRemote.taflush.broadcast(); + pinus.app.rpc.role.roleRemote.taflush.broadcast(); + pinus.app.rpc.systimer.systimerRemote.taflush.broadcast(); + } } \ No newline at end of file diff --git a/game-server/app/servers/gm/handler/gmRoleHandler.ts b/game-server/app/servers/gm/handler/gmRoleHandler.ts index 5affed99c..60249fcaf 100644 --- a/game-server/app/servers/gm/handler/gmRoleHandler.ts +++ b/game-server/app/servers/gm/handler/gmRoleHandler.ts @@ -6,7 +6,7 @@ import { addItems, createHeroes } from '../../../services/rewardService'; import { RewardInter } from '../../../pubUtils/interface'; import { getExpByLv } from '../../../pubUtils/data'; import { RoleModel } from '../../../db/Role'; -import { BLOCK_TYPE } from '../../../consts'; +import { BLOCK_TYPE, ITEM_CHANGE_REASON } from '../../../consts'; let timer: NodeJS.Timer; export default function (app: Application) { return new GmRoleHandler(app); @@ -27,7 +27,7 @@ export class GmRoleHandler { let sid = connect.isOnline?connect.sid: null; if(reward &&reward.length > 0) { - await addItems(roleId, roleName, sid, values.reward); + await addItems(roleId, roleName, sid, values.reward, ITEM_CHANGE_REASON.DEBUG); } if(heroes && heroes.length > 0) { await createHeroes(roleId, roleName, sid, serverId, heroes.map(hid => { return { hid, count: 1 }})) diff --git a/game-server/app/servers/guild/remote/guildRemote.ts b/game-server/app/servers/guild/remote/guildRemote.ts index 9d59ed997..dc6c9490f 100644 --- a/game-server/app/servers/guild/remote/guildRemote.ts +++ b/game-server/app/servers/guild/remote/guildRemote.ts @@ -1,6 +1,6 @@ import { Application, ChannelService, HandlerService, } from 'pinus'; import { reloadResources } from '../../../pubUtils/data'; -import { treatGuildName } from '../../../services/sdkService'; +import { taflush, treatGuildName } from '../../../services/sdkService'; import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService'; export default function (app: Application) { @@ -39,4 +39,8 @@ export class GuildRemote { public getServerMainten(serverId: number) { return getServerMainten(serverId); } + + public taflush() { + return taflush(); + } } \ No newline at end of file diff --git a/game-server/app/servers/order/remote/orderRemote.ts b/game-server/app/servers/order/remote/orderRemote.ts index f243022e7..494291b11 100644 --- a/game-server/app/servers/order/remote/orderRemote.ts +++ b/game-server/app/servers/order/remote/orderRemote.ts @@ -2,6 +2,7 @@ import { Application, ChannelService, HandlerService, } from 'pinus'; import { reloadResources } from '../../../pubUtils/data'; import { settleOrderFromRedisPub } from '../../../services/orderService'; import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService'; +import { taflush } from '../../../services/sdkService'; export default function (app: Application) { new HandlerService(app, {}); @@ -39,4 +40,8 @@ export class OrderRemote { public getServerMainten(serverId: number) { return getServerMainten(serverId); } + + public taflush() { + return taflush(); + } } \ No newline at end of file diff --git a/game-server/app/servers/role/remote/roleRemote.ts b/game-server/app/servers/role/remote/roleRemote.ts index a4a376eb7..3049d2aa0 100644 --- a/game-server/app/servers/role/remote/roleRemote.ts +++ b/game-server/app/servers/role/remote/roleRemote.ts @@ -10,7 +10,7 @@ import { DEFAULT_HEROES } from '../../../consts'; import { Figure } from '../../../domain/dbGeneral'; import { getDefaultRoleInfo } from '../../../services/roleService'; import { PVPConfigType } from '../../../db/SystemConfig'; -import { treatRoleName } from '../../../services/sdkService'; +import { treatRoleName, taflush } from '../../../services/sdkService'; import { getServerMainten, setServerMainten, stopServerMainten } from '../../../services/gmService'; export default function (app: Application) { @@ -135,4 +135,8 @@ export class RoleRemote { public getServerMainten(serverId: number) { return getServerMainten(serverId); } + + public taflush() { + return taflush(); + } } diff --git a/game-server/app/servers/systimer/remote/systimerRemote.ts b/game-server/app/servers/systimer/remote/systimerRemote.ts index 05bef4807..5af9ad3dc 100644 --- a/game-server/app/servers/systimer/remote/systimerRemote.ts +++ b/game-server/app/servers/systimer/remote/systimerRemote.ts @@ -8,6 +8,7 @@ import { setDicAuctionTime, setDicGuildActivity } from '../../../services/guildA import { setWeek } from '../../../pubUtils/timeUtil'; import { ServerlistType } from '../../../db/Serverlist'; import { MarqueeType } from '../../../db/Marquee'; +import { taflush } from '../../../services/sdkService'; export default function (app: Application) { return new SystimerRemote(app); @@ -99,4 +100,8 @@ export class SystimerRemote { public async stopMaintenance(batchCode: string, serverIds: number[]) { await stopMaintenance(batchCode, serverIds); } + + public taflush() { + return taflush(); + } } From 15b9d9f97ad64505c32027934f25bb81477d2dda Mon Sep 17 00:00:00 2001 From: luying Date: Wed, 15 Dec 2021 19:54:43 +0800 Subject: [PATCH 26/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E5=86=9B?= =?UTF-8?q?=E5=9B=A2=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app.ts | 2 +- .../app/servers/gm/handler/gmRoleHandler.ts | 105 +++++++++++++++++- .../app/servers/guild/handler/guildHandler.ts | 2 +- game-server/app/services/rankService.ts | 1 + game-server/app/services/redisService.ts | 2 +- gm-server/app.ts | 9 ++ gm-server/app/controller/users.ts | 10 +- gm-server/app/router.ts | 1 + gm-server/app/service/users.ts | 54 +++++---- gm-server/config/config.alpha.ts | 4 + gm-server/config/config.default.ts | 4 + gm-server/config/config.dev.ts | 4 + gm-server/config/config.isbn.ts | 4 + gm-server/config/config.local.ts | 4 + gm-server/config/config.stable.ts | 28 +++++ shared/db/Guild.ts | 39 ++++++- shared/db/Item.ts | 36 ++++-- shared/domain/backEndField/params.ts | 37 ++++++ shared/domain/backEndField/search.ts | 11 ++ 19 files changed, 318 insertions(+), 39 deletions(-) create mode 100644 gm-server/config/config.stable.ts diff --git a/game-server/app.ts b/game-server/app.ts index 9cc8b6505..d61360f4d 100644 --- a/game-server/app.ts +++ b/game-server/app.ts @@ -126,7 +126,7 @@ app.configure(ALL_ENVS, 'guild', function () { }) app.configure(ALL_ENVS, 'systimer', function () { - app.afterStart(async () => { + app.event.on('start_all', async (servers) => { await redisService.initAllRank(); await timeTaskService.init(); redisService.redisSubScribe(); diff --git a/game-server/app/servers/gm/handler/gmRoleHandler.ts b/game-server/app/servers/gm/handler/gmRoleHandler.ts index 60249fcaf..0db0d7324 100644 --- a/game-server/app/servers/gm/handler/gmRoleHandler.ts +++ b/game-server/app/servers/gm/handler/gmRoleHandler.ts @@ -1,12 +1,21 @@ import { Application, BackendSession, pinus } from 'pinus'; import { resResult } from '../../../pubUtils/util'; import { STATUS } from '../../../consts/statusCode'; -import { getRoleOnlineInfo } from '../../../services/redisService'; +import { getRoleOnlineInfo, updateUserInfo } from '../../../services/redisService'; import { addItems, createHeroes } from '../../../services/rewardService'; import { RewardInter } from '../../../pubUtils/interface'; import { getExpByLv } from '../../../pubUtils/data'; -import { RoleModel } from '../../../db/Role'; -import { BLOCK_TYPE, ITEM_CHANGE_REASON } from '../../../consts'; +import { RoleModel, RoleType } from '../../../db/Role'; +import { BLOCK_TYPE, GUILD_DISMISS_WAY, GUILD_STRUCTURE, ITEM_CHANGE_REASON, REDIS_KEY, TA_EVENT } from '../../../consts'; +import { GuildFormParam } from '../../../domain/backEndField/params'; +import { GuildModel, GuildUpdateParam } from '../../../db/Guild'; +import { getGuildChannelSid } from '../../../services/chatService'; +import { pushGuildNoticeUpdateMsg } from '../../../services/sysChatService' +import { Rank } from '../../../services/rankService'; +import { UserGuildModel } from '../../../db/UserGuild'; +import { UserGuildApplyModel } from '../../../db/UserGuildApply'; +import { reportTAEvent } from '../../../services/sdkService'; + let timer: NodeJS.Timer; export default function (app: Application) { return new GmRoleHandler(app); @@ -57,4 +66,94 @@ export class GmRoleHandler { } return resResult(STATUS.SUCCESS); } + + async updateGuild(msg: GuildFormParam, session: BackendSession ) { + const uid = session.get('uid'); + let params = new GuildFormParam(msg); + if(!params.checkParams()) return resResult(STATUS.WRONG_PARMS); + + let guild = await GuildModel.findByCode(params.code); + let structure = guild.structure||[]; + + let updateParams: GuildUpdateParam = { code: params.code }; + if(params.name && guild.name != params.name) updateParams.name = params.name; + if(params.fund != undefined && guild.fund != params.fund) updateParams.fund = params.fund; + if(params.notice && guild.notice != params.notice) updateParams.notice = params.notice; + if(params.lv && guild.lv != params.lv) updateParams.lv = params.lv; + for(let id = GUILD_STRUCTURE.START; id < GUILD_STRUCTURE.END; id ++) { + let curStructure = structure.find(cur => cur.id == id); + let lv = params.lv; + switch(id) { + case GUILD_STRUCTURE.ARMY_CENTER: + lv = params.lv; break; + case GUILD_STRUCTURE.EQUIP_PRODUCE: + lv = params.equipProduce; break; + case GUILD_STRUCTURE.BOSS: + lv = params.boss; break; + case GUILD_STRUCTURE.TRAIN: + lv = params.train; break; + case GUILD_STRUCTURE.DONATE: + lv = params.donate; break; + case GUILD_STRUCTURE.WISH_POOL: + lv = params.wishPool; break; + case GUILD_STRUCTURE.STORE: + lv = params.store; break; + } + if(curStructure) { + curStructure.lv = lv; + } else { + structure.push({ id, lv }); + } + } + updateParams.structure = structure; + let chatSid = await getGuildChannelSid(params.code); + console.log('*****', params.code, updateParams) + this.app.rpc.chat.guildRemote.updateInfo.toServer(chatSid, params.code, updateParams); + // 设置玩家名 + if(updateParams.name != undefined || updateParams.lv != undefined) { + let arr = []; + if(updateParams.name != undefined) arr.push({ field: 'name', value: updateParams.name }); + if(updateParams.lv != undefined) arr.push({ field: 'lv', value: updateParams.lv }); + await updateUserInfo(REDIS_KEY.GUILD_INFO, params.code, arr); + } + if (updateParams.lv != undefined) { + let r = new Rank(REDIS_KEY.GUILD_LV_RANK, { serverId: guild.serverId }); + await r.setRankWithGuildInfo2(guild.code, updateParams.lv, guild.activeWeekly, guild.lvUpdateTime, guild); + } + + guild = await GuildModel.updateInfo(params.code, updateParams); + return resResult(STATUS.SUCCESS); + } + async dismissGuild(msg: { code: string }, session: BackendSession) { + + const { code } = msg; + + let guild = await GuildModel.findByCode(code, null, '+serverId'); + if(!guild) return resResult(STATUS.GUILD_NOT_FOUND); + + let serverId = guild.serverId; + guild = await GuildModel.dismiss(code, serverId); + if (!guild) return resResult(STATUS.GUILD_DELETE_ERROR); + + await UserGuildModel.dismiss(code); + const { members } = guild; + await RoleModel.dissmissGuild(members); + await UserGuildApplyModel.deleteApplyByGuild(code); + + await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.broadcast(members.map(roleId => { return { roleId, userGuild: null } })); // 更新session + + // 删除channel + + let chatSid = await getGuildChannelSid(code); + this.app.rpc.chat.guildRemote.dismiss.toServer(chatSid, code); + + let r = new Rank(REDIS_KEY.GUILD_ACTIVE_RANK, { serverId }); + await r.removeFromRank({ guildCode: code }); + let r2 = new Rank(REDIS_KEY.GUILD_LV_RANK, { serverId }); + await r2.removeFromRank({ guildCode: code }); + let leader = guild.leader; + reportTAEvent(leader.roleId, TA_EVENT.GUILD_DISMISS, { name: guild.name, way: GUILD_DISMISS_WAY.BACKEND }); + + return resResult(STATUS.SUCCESS, { code, status: guild.status }); + } } \ No newline at end of file diff --git a/game-server/app/servers/guild/handler/guildHandler.ts b/game-server/app/servers/guild/handler/guildHandler.ts index 572b02212..dd17adaa3 100644 --- a/game-server/app/servers/guild/handler/guildHandler.ts +++ b/game-server/app/servers/guild/handler/guildHandler.ts @@ -109,7 +109,7 @@ export class GuildHandler { const serverId = session.get('serverId'); const { page = 1, showPeopleMax, name } = msg; - const guildList = await GuildModel.findByCondition(page, showPeopleMax, name, serverId); + const guildList = await GuildModel.getGuildList(page, showPeopleMax, name, serverId); const applyList = await UserGuildApplyModel.findApplyByRole(roleId); const { quitGuildTime: quitTime = 0 } = await RoleModel.findByRoleId(roleId); diff --git a/game-server/app/services/rankService.ts b/game-server/app/services/rankService.ts index f7bb21a31..583695106 100644 --- a/game-server/app/services/rankService.ts +++ b/game-server/app/services/rankService.ts @@ -925,6 +925,7 @@ export async function setRankRedisFromDb(type: string, args?: { serverId?: numbe await r.setRankWithGuildInfo(guild.code, guild.activeWeekly, guild.activeUpdateTime, guild); } } else if (type == REDIS_KEY.GUILD_LV_RANK) { + let serverId = args.serverId; let ranks = await GuildModel.getRank(type, serverId); let r = new Rank(type, { serverId }); diff --git a/game-server/app/services/redisService.ts b/game-server/app/services/redisService.ts index 5c896d69a..9ce64eca6 100644 --- a/game-server/app/services/redisService.ts +++ b/game-server/app/services/redisService.ts @@ -17,7 +17,7 @@ import { getRandSingleEelm } from '../pubUtils/util'; */ export async function initAllRank() { console.log('******* initAllRank ******') - const serverList = await ServerlistModel?.findByEnv(pinus.app.get('env'))||[]; + const serverList = await ServerlistModel.findByEnv(pinus.app.get('env')); await delKeys(REDIS_KEY.ONLINE_USERS); await delKeys(REDIS_KEY.USER_INFO); await delKeys(REDIS_KEY.GUILD_INFO); diff --git a/gm-server/app.ts b/gm-server/app.ts index 7e3ab82ac..eeb6e74a1 100644 --- a/gm-server/app.ts +++ b/gm-server/app.ts @@ -2,6 +2,7 @@ import 'reflect-metadata' import * as mongoose from 'mongoose'; import { Application, IBoot } from 'egg'; import { loadGmDb } from '@db/index'; +import { connectRedis } from '@pubUtils/redis'; export default class FooBoot implements IBoot { private readonly app: Application; @@ -16,6 +17,7 @@ export default class FooBoot implements IBoot { // this is the last chance to modify the config. await this.connectDB(this.app) await this.connectGMDB(this.app); + await this.connectRedis(this.app); this.app.config.realEnv = this.app.config.env; if(this.app.config.env == 'local') { @@ -78,6 +80,13 @@ export default class FooBoot implements IBoot { } } + public async connectRedis(app: Application) { + const { url, pw } = app.config.redis + if (url) { + const redisClient = connectRedis(url, pw); + app.context.redisClient = redisClient; + } + } //#endregion } diff --git a/gm-server/app/controller/users.ts b/gm-server/app/controller/users.ts index 3fdbce300..46cd3edb9 100644 --- a/gm-server/app/controller/users.ts +++ b/gm-server/app/controller/users.ts @@ -120,8 +120,14 @@ export default class UserController extends Controller { public async getItemList() { const { ctx } = this; - const { field, value } = ctx.request.body; - ctx.body = await ctx.service.users.getItemList(field, value); + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.users.getItemList(page, pageSize, sortField, sortOrder, form); + } + + public async getGuildList() { + const { ctx } = this; + const { page, pageSize, sortField, sortOrder, form } = ctx.request.body; + ctx.body = await ctx.service.users.getGuildList(page, pageSize, sortField, sortOrder, form); } public async deleteEquip() { diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index e09606a41..27d348705 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -41,6 +41,7 @@ export default (app: Application) => { // router.post('/api/users/removeherofromdefense',tokenParser, controller.users.removeHeroFromDefense); router.post('/api/users/getequiplist', tokenParser, controller.users.getEquipList); router.post('/api/users/getitemlist', tokenParser, controller.users.getItemList); + router.post('/api/users/getguildlist', controller.users.getGuildList); router.post('/api/users/deleteequip', tokenParser, controller.users.deleteEquip); router.post('/api/users/deleteitem', tokenParser, controller.users.deleteItem); router.post('/api/users/setitemcount', tokenParser, controller.users.setItemCount); diff --git a/gm-server/app/service/users.ts b/gm-server/app/service/users.ts index 06d87b9e0..7826d94df 100644 --- a/gm-server/app/service/users.ts +++ b/gm-server/app/service/users.ts @@ -6,7 +6,7 @@ import { PvpDefenseModel } from '@db/PvpDefense'; import { Service } from 'egg'; import Counter from '@db/Counter'; -import { STATUS, HERO_SYSTEM_TYPE } from '@consts'; +import { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, REDIS_KEY } from '@consts'; import { ITID, COUNTER } from '@consts'; import { ItemModel } from '@db/Item'; import { gameData, getExpByLv } from '@pubUtils/data'; @@ -21,9 +21,11 @@ import { CreateHeroes, deletRole } from '@pubUtils/roleUtil'; import { RScriptRecordModel } from '@db/RScriptRecord'; import { DicWar } from '@pubUtils/dictionary/DicWar'; import { SkinModel } from '@db/Skin'; -import { SearchEquipParam, SearchHeroParam, SearchUserParam, SearchGiftCodeParam, SearchGiftCodeDetailParam } from '@domain/backEndField/search'; +import { SearchEquipParam, SearchHeroParam, SearchUserParam, SearchGiftCodeParam, SearchGiftCodeDetailParam, SearchItemParam, SearchGuildParam } from '@domain/backEndField/search'; import { CreateGiftCode, UpdateGiftCode } from '@domain/backEndField/params'; import { isNumber } from 'util'; +import { GuildModel } from '@db/Guild'; +import { RedisClient } from 'redis'; // import { resResult } from '@pubUtils/util'; @@ -200,7 +202,7 @@ export default class GMUsers extends Service { weapons.push({ id: eid, hid: ehid }); } } - await addEquips(roleId, role.roleName, weapons); + await addEquips(roleId, role.roleName, weapons, ITEM_CHANGE_REASON.DEBUG); } else { flag = 1, msg = '未找到角色' + roleId; } @@ -241,7 +243,7 @@ export default class GMUsers extends Service { for (let roleId of uids) { let role = await RoleModel.findByRoleId(roleId); if (role) { - await addBags(roleId, role.roleName, datas); + await addBags(roleId, role.roleName, datas, ITEM_CHANGE_REASON.DEBUG); } else { flag = 1, msg = '未找到角色' + roleId; } @@ -591,17 +593,10 @@ export default class GMUsers extends Service { public async getEquipList(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchEquipParam) { const { ctx } = this; - const heroes = await EquipModel.findByCondition(page, pageSize, sortField, sortOrder, form); + const equips = await EquipModel.findByCondition(page, pageSize, sortField, sortOrder, form); const total = await EquipModel.countByCondition( form ) - let roleMap = new Map(); - for(let { roleId } of heroes) { - if(!roleMap.has(roleId)) { - let role = await RoleModel.findByRoleId(roleId, 'attr'); - roleMap.set(roleId, role.attr); - } - } - let list = heroes.map(cur => { + let list = equips.map(cur => { return {...cur, env: ctx.app.config.realEnv} }) @@ -612,20 +607,37 @@ export default class GMUsers extends Service { /** * 根据类型等搜索道具 */ - public async getItemList(field: string, value: (string | number)) { + public async getItemList(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchItemParam) { const { ctx } = this; - let items = await ItemModel.findByField(field, value); + const items = await ItemModel.findByCondition(page, pageSize, sortField, sortOrder, form); + const total = await ItemModel.countByCondition( form ) - if (items) { + let list = items.map(cur => { + return {...cur, env: ctx.app.config.realEnv} + }) - return ctx.service.utils.resResult(STATUS.SUCCESS, { list: items }); - } else { - console.error('role list not found'); - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR); - } + return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total }) } + public async getGuildList(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchGuildParam) { + const { ctx } = this; + let redisClient: RedisClient = ctx.app.context.redisClient; + + const guilds = await GuildModel.findByCondition(page, pageSize, sortField, sortOrder, form); + const total = await GuildModel.countByCondition( form ) + + let list = []; + for(let guild of guilds) { + let rank = await redisClient.zrevrankAsync(`${REDIS_KEY.GUILD_LV_RANK}:${guild.serverId}`, guild.code); + + list.push({ ...guild, rank: rank == undefined? '未上榜': rank + 1, env: ctx.app.config.realEnv }) + } + + return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total }) + } + + public async getGiftCodeList(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchGiftCodeParam = {}) { const { ctx } = this; diff --git a/gm-server/config/config.alpha.ts b/gm-server/config/config.alpha.ts index 44c4110b6..9e4a4580d 100644 --- a/gm-server/config/config.alpha.ts +++ b/gm-server/config/config.alpha.ts @@ -11,6 +11,10 @@ export default (appInfo: EggAppInfo) => { options: { useNewUrlParser: true, useUnifiedTopology: true }, }; + config.redis = { + url: 'r-8vbl8okinxn1zhkwh2.redis.zhangbei.rds.aliyuncs.com', // 内网 + pw: 'zyz_alpha_2021' + }; // the return config will combines to EggAppConfig return { ...defaultConfig(appInfo), diff --git a/gm-server/config/config.default.ts b/gm-server/config/config.default.ts index e4930fbb5..65796df9d 100644 --- a/gm-server/config/config.default.ts +++ b/gm-server/config/config.default.ts @@ -29,6 +29,10 @@ export default (appInfo: EggAppInfo) => { url: 'mongodb://dbop:zyzGm2021@dds-8vb9964bb4cc7f241.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb9964bb4cc7f242.mongodb.zhangbei.rds.aliyuncs.com:3717/zyzgm?replicaSet=mgset-507933150', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, }; + config.redis = { + url: 'r-8vb4i2kgl91886fkxd.redis.zhangbei.rds.aliyuncs.com', // 内网 + pw: 'zyz_2020' + }; config.security = { csrf: { diff --git a/gm-server/config/config.dev.ts b/gm-server/config/config.dev.ts index 44c4110b6..40f79f2dd 100644 --- a/gm-server/config/config.dev.ts +++ b/gm-server/config/config.dev.ts @@ -10,6 +10,10 @@ export default (appInfo: EggAppInfo) => { url: 'mongodb://dbop:zyzDev2021@dds-8vb5c74ba4263da41.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb5c74ba4263da42.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb5c74ba4263da43.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?readPreference=secondary&replicaSet=mgset-506991391', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, }; + config.redis = { + url: 'r-8vb418l8kkju9sis8k.redis.zhangbei.rds.aliyuncs.com', // 内网 + pw: 'zyz_dev_2021' + }; // the return config will combines to EggAppConfig return { diff --git a/gm-server/config/config.isbn.ts b/gm-server/config/config.isbn.ts index 49428e217..afc9c55ad 100644 --- a/gm-server/config/config.isbn.ts +++ b/gm-server/config/config.isbn.ts @@ -10,6 +10,10 @@ export default (appInfo: EggAppInfo) => { url: 'mongodb://root:Bantus123@dds-8vb74337eab84d641.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vb74337eab84d642.mongodb.zhangbei.rds.aliyuncs.com:3717/admin?replicaSet=mgset-504694158', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, }; + config.redis = { + url: 'r-8vbekkbb3z8ru2ckuj.redis.zhangbei.rds.aliyuncs.com', // 内网 + pw: 'zyz_isbn_2021' + }; // the return config will combines to EggAppConfig return { diff --git a/gm-server/config/config.local.ts b/gm-server/config/config.local.ts index a89c194f0..4c8fda355 100644 --- a/gm-server/config/config.local.ts +++ b/gm-server/config/config.local.ts @@ -18,6 +18,10 @@ export default (appInfo: EggAppInfo) => { url: 'mongodb://127.0.0.1:27017/zyzgm', // 内网 options: { useNewUrlParser: true, useUnifiedTopology: true }, }; + config.redis = { + url: '127.0.0.1', // 内网 + pw: '' + }; config.proxy = {}; // the return config will combines to EggAppConfig diff --git a/gm-server/config/config.stable.ts b/gm-server/config/config.stable.ts new file mode 100644 index 000000000..7ae29f720 --- /dev/null +++ b/gm-server/config/config.stable.ts @@ -0,0 +1,28 @@ +import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg'; +import defaultConfig from './config.default'; + +export default (appInfo: EggAppInfo) => { + const config = {} as PowerPartial; + + config.mongoose = { + url: 'mongodb://dbop:zyzdbopbantu@dds-8vbdb47c6fb58a541.mongodb.zhangbei.rds.aliyuncs.com:3717,dds-8vbdb47c6fb58a542.mongodb.zhangbei.rds.aliyuncs.com:3717/zyz?replicaSet=mgset-500808098', // 内网 + options: { useNewUrlParser: true, useUnifiedTopology: true }, + }; + config.redis = { + url: 'r-8vb4i2kgl91886fkxd.redis.zhangbei.rds.aliyuncs.com', // 内网 + pw: 'zyz_2020' + }; + + config.xtransit = { + server: 'ws://172.26.117.35:9092', + appId: 3, + appSecret: 'a48ad5ca44e2d02cbd7f4c0326fa3101', + error_log: [ '/root/logs/zyz/zyz-web.log', '/root/logs/zyz/common-error.log', '/root/logs/zyz/egg-agent.log' ], + }; + + // the return config will combines to EggAppConfig + return { + ...defaultConfig(appInfo), + ...config + }; +}; diff --git a/shared/db/Guild.ts b/shared/db/Guild.ts index 20942b85e..91b3970f1 100644 --- a/shared/db/Guild.ts +++ b/shared/db/Guild.ts @@ -5,6 +5,7 @@ import { GUILD_STRUCTURE, GUILD_STATUS, GUILD_PER_PAGE, GUILD_SELECT, REDIS_KEY, import { getZeroPoint, getZeroPointD, nowSeconds } from '../pubUtils/timeUtil'; import { reduceCe } from '../pubUtils/util'; import { gameData } from '../pubUtils/data'; +import { SearchGuildParam } from '../domain/backEndField/search'; class Structure { @prop({ required: true }) @@ -132,7 +133,7 @@ export default class Guild extends BaseModel { return result; } - public static async findByCondition(page: number, showPeopleMax: boolean, name: string, serverId: number) { + public static async getGuildList(page: number, showPeopleMax: boolean, name: string, serverId: number) { const condition = { status: GUILD_STATUS.RUNNING, serverId }; if(!showPeopleMax) { condition['isMemberMax'] = false; @@ -193,6 +194,7 @@ export default class Guild extends BaseModel { public static async dismiss(code: string, serverId: number) { const result: GuildType = await GuildModel.findOneAndUpdate({ code, status: GUILD_STATUS.RUNNING, serverId }, { status: GUILD_STATUS.DISMISSED }, { new: true }) + .populate('leader', {roleId: 1, _id: 0}, 'Role') .select('+members').lean(); return result; } @@ -277,6 +279,41 @@ export default class Guild extends BaseModel { const role: RoleType = await GuildModel.findOneAndUpdate({ code, serverId }, { $set: { sdkMark: true } }, { new: true }).select(select).lean({ getters, virtuals: true }); return role; } + + + private static getSearchObj(form: SearchGuildParam) { + let searchObj = {}; + if (form.serverId) searchObj['serverId'] = form.serverId; + if (form.name) searchObj['name'] = { $regex: new RegExp(form.name.toString(), 'i') }; + return searchObj + } + + public static async findByCondition(page: number, pageSize: number, sortField: string = 'updatedAt', sortOrder: string = 'descend', form: SearchGuildParam = {}) { + + let searchObj = this.getSearchObj(form); + let sort = {}; + if (sortField && sortOrder) { + if (sortOrder == 'ascend') { + sort[sortField] = 1; + } else if (sortOrder == 'descend') { + sort[sortField] = -1; + } + } + const result: GuildType[] = await GuildModel + .find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort) + .select('-_id -__v -createdAt -updatedAt +serverId') + .populate('leader', { roleId: 1, roleName: 1, _id: 0 }, 'Role') + .lean({ getters: true, virtuals: true }); + return result; + + } + + public static async countByCondition(form: SearchGuildParam = {}) { + + let searchObj = this.getSearchObj(form); + const result = await GuildModel.count(searchObj); + return result; + } } export const GuildModel = getModelForClass(Guild); diff --git a/shared/db/Item.ts b/shared/db/Item.ts index e562744d8..adb13ca92 100644 --- a/shared/db/Item.ts +++ b/shared/db/Item.ts @@ -2,6 +2,7 @@ import BaseModel from './BaseModel'; import { index, getModelForClass, prop, DocumentType, modelOptions } from '@typegoose/typegoose'; import { findIndex } from 'underscore'; import { BAG } from '../pubUtils/dicParam'; +import { SearchItemParam } from '../domain/backEndField/search'; // const Transaction = require("mongoose-transactions"); @index({ roleId: 1, id: 1 }) @index({ seqId: 1 }) @@ -101,18 +102,35 @@ export default class Item extends BaseModel { return result; } - public static async findByField(field: string, value?: number|string, lean = true) { + private static getSearchObj(form: SearchItemParam) { let searchObj = {}; - if(field != 'all') { - if(field == 'roleName') { - searchObj['roleName'] = { $regex: new RegExp(value.toString(), 'i') } - } else { - searchObj[field] = value; + if (form.roleId) searchObj['roleId'] = form.roleId; + if (form.roleName) searchObj['roleName'] = { $regex: new RegExp(form.roleName.toString(), 'i') }; + if (form.id) searchObj['id'] = form.id; + return searchObj + } + + public static async findByCondition(page: number, pageSize: number, sortField: string = 'updatedAt', sortOrder: string = 'descend', form: SearchItemParam = {}) { + + let searchObj = this.getSearchObj(form); + let sort = {}; + if (sortField && sortOrder) { + if (sortOrder == 'ascend') { + sort[sortField] = 1; + } else if (sortOrder == 'descend') { + sort[sortField] = -1; } } - //.select('uid tel username') - const user: ItemType[] = await ItemModel.find(searchObj).lean(lean); - return user; + const result: ItemType[] = await ItemModel.find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort).select('-_id -__v -createdAt -updatedAt').lean({ getters: true, virtuals: true }); + return result; + + } + + public static async countByCondition(form: SearchItemParam = {}) { + + let searchObj = this.getSearchObj(form); + const result = await ItemModel.count(searchObj); + return result; } } diff --git a/shared/domain/backEndField/params.ts b/shared/domain/backEndField/params.ts index 9054d8a4d..a065fb244 100644 --- a/shared/domain/backEndField/params.ts +++ b/shared/domain/backEndField/params.ts @@ -225,4 +225,41 @@ export class UpdateGiftCode { if(!isNumber(this.codeLen) || this.codeLen <= 0) return false; return true; } +} + +export class GuildFormParam { + code: string; + name: string; + notice: string; + fund: number; + lv: number; + equipProduce: number; + boss: number; + train: number; + wishPool: number; + store: number; + donate: number; + + constructor(obj?: any) { + if(obj) { + for(let key in obj) { + this[key] = obj[key]; + } + } + } + + checkParams() { + if(!this.code || !isString(this.code)) return false; + if(this.name && !isString(this.name)) return false; + if(this.notice && !isString(this.notice)) return false; + if(this.fund && !isNumber(this.fund)) return false; + if(this.lv && !isNumber(this.lv)) return false; + if(this.equipProduce && !isNumber(this.equipProduce)) return false; + if(this.boss && !isNumber(this.boss)) return false; + if(this.train && !isNumber(this.train)) return false; + if(this.wishPool && !isNumber(this.wishPool)) return false; + if(this.store && !isNumber(this.store)) return false; + if(this.donate && !isNumber(this.donate)) return false; + return true; + } } \ No newline at end of file diff --git a/shared/domain/backEndField/search.ts b/shared/domain/backEndField/search.ts index 7f16375dd..03b324ef5 100644 --- a/shared/domain/backEndField/search.ts +++ b/shared/domain/backEndField/search.ts @@ -24,6 +24,17 @@ export interface SearchEquipParam { id?: number; } +export interface SearchItemParam { + roleId?: string; + roleName?: string; + id?: number; +} + +export interface SearchGuildParam { + serverId?: number; + name?: string; +} + export interface SearchMailParam { createTimeStart?: number; createTimeEnd?: number; From 1628fd50b0aba3237d8b4980c730438bc0df3ada Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 16 Dec 2021 14:36:05 +0800 Subject: [PATCH 27/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E5=86=9B?= =?UTF-8?q?=E5=9B=A2=E7=AE=A1=E7=90=86=E6=88=90=E5=91=98=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/chat/remote/guildRemote.ts | 18 +++++--- .../app/servers/gm/handler/gmRoleHandler.ts | 44 ++++++++++++++++++- .../app/servers/guild/handler/guildHandler.ts | 4 +- game-server/app/services/mailService.ts | 4 +- gm-server/app/controller/users.ts | 6 +++ gm-server/app/router.ts | 1 + gm-server/app/service/users.ts | 11 +++++ shared/consts/statusCode.ts | 1 + shared/db/Guild.ts | 2 +- 9 files changed, 79 insertions(+), 12 deletions(-) diff --git a/game-server/app/servers/chat/remote/guildRemote.ts b/game-server/app/servers/chat/remote/guildRemote.ts index 6b4bcc953..cfa698fef 100644 --- a/game-server/app/servers/chat/remote/guildRemote.ts +++ b/game-server/app/servers/chat/remote/guildRemote.ts @@ -10,6 +10,7 @@ import { MailParam } from '../../../domain/roleField/mail'; import { pick } from 'underscore'; import { LotType } from '../../../db/Lot'; import { DividendType } from '../../../db/Dividend'; +import { getRoleOnlineInfo } from '../../../services/redisService'; export default function (app: Application) { new HandlerService(app, {}); @@ -66,12 +67,13 @@ export class GuildRemote { * @param message 推送信息 * @param sid 玩家服 */ - private pushMessageByUids(guildCode: string, path: string, roleId: string, message: { code: string, roleId?: string }, sid?: string) { + private async pushMessageByUids(guildCode: string, path: string, roleId: string, message: { code: string, roleId?: string }, sid?: string) { let channel = this.getChannel(guildCode); let uids = []; if (!sid) { - sid = channel && channel.getMember(roleId)['sid']; + let onlineUser = await getRoleOnlineInfo(roleId); + sid = onlineUser.sid; } if (sid) { uids.push({ uid: roleId, sid }); @@ -165,10 +167,14 @@ export class GuildRemote { * @param oldLeaderId 旧团长 */ public changeLeader(guildCode: string, managerCnt: number, newLeader: RoleType, oldLeaderId: string) { - let { roleId, roleName, frame, head, spine, lv, quitTime } = newLeader; - this.updateInfo(guildCode, { managerCnt, leader: { roleId, roleName, frame, head, spine, lv, quitTime } }); - this.demotion(guildCode, oldLeaderId); - this.promotion(guildCode, roleId); + try{ + let { roleId, roleName, frame, head, spine, lv, quitTime } = newLeader; + this.updateInfo(guildCode, { managerCnt, leader: { roleId, roleName, frame, head, spine, lv, quitTime } }); + this.demotion(guildCode, oldLeaderId); + this.promotion(guildCode, roleId); + }catch(e) { + console.log(e.stack) + } } /** diff --git a/game-server/app/servers/gm/handler/gmRoleHandler.ts b/game-server/app/servers/gm/handler/gmRoleHandler.ts index 0db0d7324..4c0580846 100644 --- a/game-server/app/servers/gm/handler/gmRoleHandler.ts +++ b/game-server/app/servers/gm/handler/gmRoleHandler.ts @@ -6,7 +6,7 @@ import { addItems, createHeroes } from '../../../services/rewardService'; import { RewardInter } from '../../../pubUtils/interface'; import { getExpByLv } from '../../../pubUtils/data'; import { RoleModel, RoleType } from '../../../db/Role'; -import { BLOCK_TYPE, GUILD_DISMISS_WAY, GUILD_STRUCTURE, ITEM_CHANGE_REASON, REDIS_KEY, TA_EVENT } from '../../../consts'; +import { BLOCK_TYPE, GUILD_AUTH, GUILD_DISMISS_WAY, GUILD_JOB, GUILD_MASTER_CHANGE_WAY, GUILD_STATUS, GUILD_STRUCTURE, ITEM_CHANGE_REASON, MAIL_TYPE, REDIS_KEY, TA_EVENT } from '../../../consts'; import { GuildFormParam } from '../../../domain/backEndField/params'; import { GuildModel, GuildUpdateParam } from '../../../db/Guild'; import { getGuildChannelSid } from '../../../services/chatService'; @@ -15,6 +15,8 @@ import { Rank } from '../../../services/rankService'; import { UserGuildModel } from '../../../db/UserGuild'; import { UserGuildApplyModel } from '../../../db/UserGuildApply'; import { reportTAEvent } from '../../../services/sdkService'; +import { sendMailByContent } from '../../../services/mailService'; +import { GuildLeader } from '../../../domain/rank'; let timer: NodeJS.Timer; export default function (app: Application) { @@ -130,6 +132,7 @@ export class GmRoleHandler { let guild = await GuildModel.findByCode(code, null, '+serverId'); if(!guild) return resResult(STATUS.GUILD_NOT_FOUND); + if(guild.status == GUILD_STATUS.DISMISSED) return resResult(STATUS.GUILD_DELETE_ERROR); let serverId = guild.serverId; guild = await GuildModel.dismiss(code, serverId); @@ -156,4 +159,43 @@ export class GmRoleHandler { return resResult(STATUS.SUCCESS, { code, status: guild.status }); } + + async setGuildLeader(msg: { code: string, roleId: string }, session: BackendSession) { + + const { code, roleId } = msg; + let guild = await GuildModel.findByCode(code, null, '+serverId'); + if(!guild) return resResult(STATUS.GUILD_NOT_FOUND); + if(guild.status == GUILD_STATUS.DISMISSED) return resResult(STATUS.GUILD_DELETE_ERROR); + + let role = await RoleModel.findByRoleId(roleId); + if(!role) return resResult(STATUS.ROLE_NOT_FOUND); + + let userGuild = await UserGuildModel.getMyGuild(roleId); + if(!userGuild || userGuild.guildCode != code) return resResult(STATUS.GUILD_KICK_ERROR); + if(userGuild.auth == GUILD_AUTH.LEADER) return resResult(STATUS.GUILD_USER_IS_LEADER); + + let leader = guild.leader; + // 交换 + let oldLeaderUserGuild = await UserGuildModel.updateInfo(leader.roleId, { auth: GUILD_AUTH.MEMBER, job: GUILD_JOB.SHIBING }, {}, 'auth'); // 团长撤 + await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.broadcast([{ roleId: leader.roleId, userGuild: oldLeaderUserGuild }]); // 更新session + + let newLeaderUserGuild = await UserGuildModel.updateInfo(roleId, { auth: GUILD_AUTH.LEADER, job: GUILD_JOB.DAJIANGJUN }, {}, 'auth'); // 最高功勋人升 + await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.broadcast([{ roleId: roleId, userGuild: newLeaderUserGuild }]); // 更新session + + let managerCntInc = userGuild.auth == GUILD_AUTH.MANAGER ? -1 : 0; // 管理人数 + + guild = await GuildModel.updateInfo(code, { leader: role._id }, { managerCnt: managerCntInc }, 'managerCnt name'); // 如果有转让团长设置leader + + // 添加动态 + let chatSid = await getGuildChannelSid(code); + + this.app.rpc.chat.guildRemote.changeLeader.toServer(chatSid, code, guild.managerCnt, role, leader.roleId); + await sendMailByContent(MAIL_TYPE.GUILD_BE_IMPEACH, leader.roleId, { params: [guild.name] }); + await sendMailByContent(MAIL_TYPE.GUILD_BE_SET_LEADER, roleId, { params: [guild.name] }); + + await updateUserInfo(REDIS_KEY.GUILD_INFO, code, [{ field: 'leader', value: new GuildLeader(role) }]); + reportTAEvent(roleId, TA_EVENT.GUILD_MASTER_CHANGE, { way: GUILD_MASTER_CHANGE_WAY.BACKEND, change_id_after: roleId }) + + return resResult(STATUS.SUCCESS, { code }); + } } \ No newline at end of file diff --git a/game-server/app/servers/guild/handler/guildHandler.ts b/game-server/app/servers/guild/handler/guildHandler.ts index dd17adaa3..601e5912b 100644 --- a/game-server/app/servers/guild/handler/guildHandler.ts +++ b/game-server/app/servers/guild/handler/guildHandler.ts @@ -213,7 +213,7 @@ export class GuildHandler { return resResult(STATUS.GUILD_MANAGER_REACH_MAX); } - const userGuild = await UserGuildModel.updateInfo(memberRoleId, { auth, job: auth == GUILD_AUTH.LEADER ? GUILD_JOB.JIANGJUN : hisUserGuild.job }, {}, 'auth'); // 设置权限 + const userGuild = await UserGuildModel.updateInfo(memberRoleId, { auth, job: auth == GUILD_AUTH.LEADER ? GUILD_JOB.DAJIANGJUN : hisUserGuild.job }, {}, 'auth'); // 设置权限 if (!userGuild) { return resResult(STATUS.GUILD_MEMBER_NOT_FOUND); } @@ -697,7 +697,7 @@ export class GuildHandler { let oldLeaderUserGuild = await UserGuildModel.updateInfo(leaderRoleId, { auth: GUILD_AUTH.MEMBER, job: GUILD_JOB.SHIBING }, {}, 'auth'); // 团长撤 await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.broadcast([{ roleId: leaderRoleId, userGuild: oldLeaderUserGuild }]); // 更新session - let newLeaderUserGuild = await UserGuildModel.updateInfo(topUserGuild.roleId, { auth: GUILD_AUTH.LEADER, job: GUILD_JOB.JIANGJUN }, {}, 'auth'); // 最高功勋人升 + let newLeaderUserGuild = await UserGuildModel.updateInfo(topUserGuild.roleId, { auth: GUILD_AUTH.LEADER, job: GUILD_JOB.DAJIANGJUN }, {}, 'auth'); // 最高功勋人升 await this.app.rpc.connector.connectorRemote.setOtherUserGuildSession.broadcast([{ roleId: topUserGuild.roleId, userGuild: newLeaderUserGuild }]); // 更新session let managerCntInc = topUserGuild.auth == GUILD_AUTH.MANAGER ? -1 : 0; // 管理人数 diff --git a/game-server/app/services/mailService.ts b/game-server/app/services/mailService.ts index bb8cd5cd3..c07bf631a 100644 --- a/game-server/app/services/mailService.ts +++ b/game-server/app/services/mailService.ts @@ -96,8 +96,8 @@ export class SendMailFun { this.content = this.getContent(dicMail.content, params.params); if(dicMail.title) this.title = dicMail.title; if(dicMail.sendName) this.sendName = dicMail.sendName; - this.hasGoods = params.goods.length > 0; - this.goods = params.goods; + this.hasGoods = params.goods?.length > 0; + this.goods = params.goods||[]; } getContent(content: string, params: string[]) { diff --git a/gm-server/app/controller/users.ts b/gm-server/app/controller/users.ts index 46cd3edb9..383ec0148 100644 --- a/gm-server/app/controller/users.ts +++ b/gm-server/app/controller/users.ts @@ -130,6 +130,12 @@ export default class UserController extends Controller { ctx.body = await ctx.service.users.getGuildList(page, pageSize, sortField, sortOrder, form); } + public async getMembersByGuildCode() { + const { ctx } = this; + const { code } = ctx.request.body; + ctx.body = await ctx.service.users.getMembersByGuildCode(code); + } + public async deleteEquip() { const { ctx } = this; const { selectedRowKeys: roleIdAndSeqIds } = ctx.request.body; diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index 27d348705..f84f42f2c 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -42,6 +42,7 @@ export default (app: Application) => { router.post('/api/users/getequiplist', tokenParser, controller.users.getEquipList); router.post('/api/users/getitemlist', tokenParser, controller.users.getItemList); router.post('/api/users/getguildlist', controller.users.getGuildList); + router.post('/api/users/getmembersbyguildcode', controller.users.getMembersByGuildCode); router.post('/api/users/deleteequip', tokenParser, controller.users.deleteEquip); router.post('/api/users/deleteitem', tokenParser, controller.users.deleteItem); router.post('/api/users/setitemcount', tokenParser, controller.users.setItemCount); diff --git a/gm-server/app/service/users.ts b/gm-server/app/service/users.ts index 7826d94df..af62431a2 100644 --- a/gm-server/app/service/users.ts +++ b/gm-server/app/service/users.ts @@ -26,6 +26,7 @@ import { CreateGiftCode, UpdateGiftCode } from '@domain/backEndField/params'; import { isNumber } from 'util'; import { GuildModel } from '@db/Guild'; import { RedisClient } from 'redis'; +import { UserGuildModel } from '@db/UserGuild'; // import { resResult } from '@pubUtils/util'; @@ -637,6 +638,16 @@ export default class GMUsers extends Service { return ctx.service.utils.resResult(STATUS.SUCCESS, { list, total }) } + public async getMembersByGuildCode(code: string) { + const { ctx } = this; + let guild = await GuildModel.findByCode(code); + if(!guild) return ctx.service.utils.resResult(STATUS.GUILD_HAS_DISSMISS); + + let userGuilds = await UserGuildModel.getListByGuild(code); + let list = userGuilds.map(userGuild => ({ ...userGuild, env: ctx.app.config.realEnv })) + + return ctx.service.utils.resResult(STATUS.SUCCESS, { list }) + } public async getGiftCodeList(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchGiftCodeParam = {}) { const { ctx } = this; diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index 580cf4682..9bf188630 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -187,6 +187,7 @@ export const STATUS = { HAS_RECEIVE_WISH_GOOD: { code: 20930, simStr: '玩家已经收到许愿物品' }, NOT_WISH_THE_QUALITY_GOODS: { code: 20931, simStr: '不能够许愿该品质的物品' }, GUILD_PAY_CONDITION: { code: 20932, simStr: '充值金额不足' }, + GUILD_USER_IS_LEADER: { code: 20933, simStr: '该成员已经是团长' }, GUILD_SCRIPT_IS_OPENED_TODAY: { code: 20950, simStr: '今日已开启过演武场' }, GUILD_SCRIPT_NOT_OPENED: { code: 20951, simStr: '演武场未开启' }, diff --git a/shared/db/Guild.ts b/shared/db/Guild.ts index 91b3970f1..40feb8f98 100644 --- a/shared/db/Guild.ts +++ b/shared/db/Guild.ts @@ -301,7 +301,7 @@ export default class Guild extends BaseModel { } const result: GuildType[] = await GuildModel .find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort) - .select('-_id -__v -createdAt -updatedAt +serverId') + .select('-_id -__v -updatedAt +serverId') .populate('leader', { roleId: 1, roleName: 1, _id: 0 }, 'Role') .lean({ getters: true, virtuals: true }); return result; From 5b1e3b6cab97142a0f34ec33b0147d6e97fd2e7b Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 16 Dec 2021 20:48:11 +0800 Subject: [PATCH 28/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E6=B4=BB?= =?UTF-8?q?=E5=8A=A8=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/servers/gm/handler/gmHandler.ts | 34 ++++-- .../app/services/activity/activityService.ts | 14 ++- gm-server/app/controller/activity.ts | 53 ++++----- gm-server/app/router.ts | 9 +- gm-server/app/service/Activity.ts | 110 ++++++------------ shared/db/Activity.ts | 15 +++ shared/db/ActivityGroup.ts | 14 +++ shared/db/ActivityGroupType.ts | 13 +++ 8 files changed, 137 insertions(+), 125 deletions(-) diff --git a/game-server/app/servers/gm/handler/gmHandler.ts b/game-server/app/servers/gm/handler/gmHandler.ts index 268448e98..650f251e1 100644 --- a/game-server/app/servers/gm/handler/gmHandler.ts +++ b/game-server/app/servers/gm/handler/gmHandler.ts @@ -12,7 +12,7 @@ import { RewardInter } from '../../../pubUtils/interface'; import { MarqueeModel } from '../../../db/Marquee'; import { ServerlistModel } from '../../../db/Serverlist'; import { pushCurrentTime } from '../../../services/chatService'; -import { checkActivityEditable, checkActivityGroupType } from '../../../services/activity/activityService'; +import { checkActivityEditable, checkActivityGroupType, checkActivityGroupTypeWithId } from '../../../services/activity/activityService'; import { ActivityModel } from '../../../db/Activity'; import { ActivityGroupModel } from '../../../db/ActivityGroup'; import { ActivityGroupTypeModel } from '../../../db/ActivityGroupType'; @@ -153,7 +153,7 @@ export class GmHandler { let activities = await ActivityModel.findActivityByIds(aids); let checkTimeResult = await checkActivityEditable(activities); if(!checkTimeResult) return resResult(STATUS.GM_CAN_NOT_EDIT_ACT); - let checkGroup = await checkActivityGroupType(groupId, activities); + let checkGroup = await checkActivityGroupTypeWithId(groupId, activities); if(!checkGroup) return resResult(STATUS.GM_ACTIVITY_NOT_FIT_GROUP_TYPE); activities = await ActivityModel.addActivity(aids, groupId, beginTime ? new Date(beginTime) : undefined, endTime ? new Date(endTime) : undefined, type, data, uid); @@ -184,9 +184,25 @@ export class GmHandler { return resResult(STATUS.SUCCESS); } - async saveGroupToServer(msg: { groupId: number, serverIds: number[] }, session: BackendSession) { - const { groupId, serverIds } = msg; + async updateActivityGroup(msg: { groupId: number, groupName: string, serverIds: number[], activities: number[], type: number }, session: BackendSession) { const uid = session.get('uid'); + let { groupId, groupName, serverIds, activities, type } = msg; + let groupTypeObj = await ActivityGroupTypeModel.findByGroupType(type); + if(!groupTypeObj) return resResult(STATUS.GM_ACTIVITY_GROUP_TYPE_NOT_FOUND); + + { + let result = await this.saveActivitiesToGroup(groupId, type, activities, uid); + if(result.code != 0) return result; + } + { + let result = await this.saveGroupToServer(groupId, serverIds, uid); + if(result.code != 0) return result; + } + await ActivityGroupModel.updateGroup(groupId, {groupName, type}, uid); + return resResult(STATUS.SUCCESS); + } + + async saveGroupToServer(groupId: number, serverIds: number[], uid: number) { await ServerlistModel.pullByGroupId(groupId); let servers = await ServerlistModel.findServerByIds(serverIds); @@ -211,12 +227,10 @@ export class GmHandler { /** * 选择活动组内的活动 */ - async saveActivitiesToGroup(msg: { groupId: number, activities: number[] }, session: BackendSession) { - const { groupId, activities: activityIds } = msg; - const uid = session.get('uid'); + async saveActivitiesToGroup(groupId: number, groupType: number, activityIds: number[], uid: number) { let activities = await ActivityModel.findActivityByIds(activityIds); - let checkResult = await checkActivityGroupType(groupId, activities); + let checkResult = await checkActivityGroupType(groupType, activities); if(!checkResult) return resResult(STATUS.GM_ACTIVITY_NOT_FIT_GROUP_TYPE); await ActivityGroupModel.setActivitiesToGroupData(groupId, activityIds, uid); @@ -225,7 +239,7 @@ export class GmHandler { for(let server of activityServers) { pinus.app.rpc.activity.activityRemote.saveActivitiesToGroup.toServer(server.id, groupId, activityIds); } - return resResult(STATUS.SUCCESS) + return resResult(STATUS.SUCCESS); } async saveSingleActivityToGroup(msg: { groupId: number, index: number, activityId: number }, session: BackendSession) { @@ -234,7 +248,7 @@ export class GmHandler { let activity = await ActivityModel.findActivity(activityId); if(!activity) return resResult(STATUS.ACTIVITY_MISSING); - let checkResult = await checkActivityGroupType(groupId, [activity]); + let checkResult = await checkActivityGroupTypeWithId(groupId, [activity]); if(checkResult) return checkResult; let activityGroup = await ActivityGroupModel.findGroupData(groupId); diff --git a/game-server/app/services/activity/activityService.ts b/game-server/app/services/activity/activityService.ts index 745b82eff..83c4e5e32 100644 --- a/game-server/app/services/activity/activityService.ts +++ b/game-server/app/services/activity/activityService.ts @@ -279,12 +279,22 @@ export async function checkActivityEditable(activities: ActivityModelType[]) { return true; } -export async function checkActivityGroupType(groupId: number, activities: ActivityModelType[]) { + +export async function checkActivityGroupTypeWithId(groupId: number, activities: ActivityModelType[]) { let activityGroup = await ActivityGroupModel.findGroupData(groupId); if(!activityGroup) return false; if(activityGroup.type != 0) { - let activityGroupType = await ActivityGroupTypeModel.findByGroupType(activityGroup.type); + return await checkActivityGroupType(activityGroup.type, activities); + } + + return true +} + + +export async function checkActivityGroupType(groupType: number, activities: ActivityModelType[]) { + if(groupType != 0) { + let activityGroupType = await ActivityGroupTypeModel.findByGroupType(groupType); if(!activityGroupType) return false; let dic = activityGroupType.activityTypes; for(let { type } of activities) { diff --git a/gm-server/app/controller/activity.ts b/gm-server/app/controller/activity.ts index b2cd53c9b..130fd0f4a 100644 --- a/gm-server/app/controller/activity.ts +++ b/gm-server/app/controller/activity.ts @@ -4,11 +4,16 @@ export default class ActivityController extends Controller { public async getActivityList() { const { ctx } = this; - const { page, pageSize, type, groupId, current, activityId, sortField, sortOrder } = ctx.request.body; + const { page, pageSize, type, form: {groupId, current, activityId}, sortField, sortOrder } = ctx.request.body; ctx.body = await ctx.service.activity.getActivityList(page, pageSize, sortField, sortOrder, type, groupId, current, activityId); return } + public async getAllActivities() { + const { ctx } = this; + ctx.body = await ctx.service.activity.getAllActivities(); + } + public async updateActivity() { const { ctx } = this; const { activityId, groupId, beginTime, endTime, type, data } = ctx.request.body; @@ -28,11 +33,16 @@ export default class ActivityController extends Controller { public async getActivityGroupList() { const { ctx } = this; - const { page, pageSize, serverId, current, groupId } = ctx.request.body; + const { page, pageSize, form: { serverId, current, groupId} } = ctx.request.body; ctx.body = await ctx.service.activity.getActivityGroupList(page, pageSize, serverId, current, groupId); return } + public async getAllActivityGroups() { + const { ctx } = this; + ctx.body = await ctx.service.activity.getAllActivityGroups(); + } + public async getActivityGroupTypeList() { const { ctx } = this; const { page, pageSize, sortField, sortOrder, groupType, groupTypeName } = ctx.request.body; @@ -40,6 +50,11 @@ export default class ActivityController extends Controller { return } + public async getAllActivityGroupTypes() { + const { ctx } = this; + ctx.body = await ctx.service.activity.getAllActivityGroupTypes(); + } + public async updateActivityGroupType() { const { ctx } = this; const { groupType, groupTypeName, activityTypes } = ctx.request.body; @@ -54,13 +69,6 @@ export default class ActivityController extends Controller { return } - public async saveGroupTypeToActivityGroup() { - const { ctx } = this; - const { groupId, groupType } = ctx.request.body; - ctx.body = await ctx.service.activity.saveGroupTypeToActivityGroup(groupId, groupType); - return - } - public async getGroupDataById() { const { ctx } = this; const { groupId } = ctx.request.body; @@ -68,31 +76,10 @@ export default class ActivityController extends Controller { return } - public async updateActivityGroupName() { + public async updateActivityGroup() { const { ctx } = this; - const { groupId, groupName } = ctx.request.body; - ctx.body = await ctx.service.activity.updateActivityGroupName(groupId, groupName); - return - } - - public async saveActivitiesToGroup() { - const { ctx } = this; - const { groupId, activities } = ctx.request.body; - ctx.body = await ctx.service.activity.saveActivitiesToGroup(groupId, activities); - return - } - - public async saveSingleActivityToGroup() { - const { ctx } = this; - const { groupId, index, activityId } = ctx.request.body; - ctx.body = await ctx.service.activity.saveSingleActivityToGroup(groupId, index, activityId); - return - } - - public async saveGroupToServer() { - const { ctx } = this; - const { groupId, serverIds } = ctx.request.body; - ctx.body = await ctx.service.activity.saveGroupToServer(groupId, serverIds); + const { groupId, groupName, activities, serverIds, type } = ctx.request.body; + ctx.body = await ctx.service.activity.updateActivityGroup(groupId, groupName, activities, serverIds, type); return } diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index f84f42f2c..a51e40d01 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -86,19 +86,18 @@ export default (app: Application) => { router.post('/api/game/getaccuse', controller.game.getAccuse); router.post('/api/activity/getactivitylist', tokenParser, controller.activity.getActivityList); + router.post('/api/activity/getallactivities', controller.activity.getAllActivities); router.post('/api/activity/updateactivity', tokenParser, controller.activity.updateActivity); router.post('/api/activity/deleteactivity', tokenParser, controller.activity.deleteActivity); router.post('/api/activity/getactivitygrouplist', tokenParser, controller.activity.getActivityGroupList); - router.post('/api/activity/updateactivitygroupname', controller.activity.updateActivityGroupName); - // router.post('/api/activity/saveactivitiestogroup', tokenParser, controller.activity.saveActivitiesToGroup); - // router.post('/api/activity/savesingleactivitytogroup', controller.activity.saveSingleActivityToGroup); - // router.post('/api/activity/savegrouptoserver', tokenParser, controller.activity.saveGroupToServer); + router.post('/api/activity/getallactivitygroups', controller.activity.getAllActivityGroups); + router.post('/api/activity/updateactivitygroup', controller.activity.updateActivityGroup); router.post('/api/activity/creategroup', tokenParser, controller.activity.createGroup); router.post('/api/activity/deletegroup', tokenParser, controller.activity.deleteGroup); router.post('/api/activity/getactivitygrouptypelist', controller.activity.getActivityGroupTypeList); + router.post('/api/activity/getallactivitygrouptypes', controller.activity.getAllActivityGroupTypes); router.post('/api/activity/saveactivitygrouptypelist', controller.activity.updateActivityGroupType); router.post('/api/activity/deleteactivitygrouptype', controller.activity.deleteActivityGroupType); - router.post('/api/activity/saveactivitygrouptype', controller.activity.saveGroupTypeToActivityGroup); router.post('/api/activity/getgroupdatabyid', controller.activity.getGroupDataById); router.post('/api/activity/getactivitytaskpoint', controller.activity.getActivityTaskPoint); router.post('/api/activity/createtasktoactivity', controller.activity.createTaskToActivity); diff --git a/gm-server/app/service/Activity.ts b/gm-server/app/service/Activity.ts index 7f8700cf8..f079a25a2 100644 --- a/gm-server/app/service/Activity.ts +++ b/gm-server/app/service/Activity.ts @@ -25,12 +25,33 @@ export default class Activity extends Service { return ctx.service.utils.resResult(STATUS.SUCCESS, { list: list.map(cur => { return { - ...cur, beginTime: cur.beginTime.getTime(), endTime: cur.endTime.getTime() + ...cur, beginTime: cur.beginTime.getTime(), endTime: cur.endTime.getTime(), env: ctx.app.config.realEnv } }), total }); } + public async getAllActivities() { + const { ctx } = this; + let list = await ActivityModel.findAllActivities(); + return ctx.service.utils.resResult(STATUS.SUCCESS, { list }); + } + + public async getAllActivityGroups() { + const { ctx } = this; + let list = await ActivityGroupModel.findAllActivityGroups(); + return ctx.service.utils.resResult(STATUS.SUCCESS, { list }); + } + + public async getAllActivityGroupTypes() { + const { ctx } = this; + // console.log('***', page, pageSize, type, serverId, current, activityId) + const list = await ActivityGroupTypeModel.findAllActivityGroupTypes(); + return ctx.service.utils.resResult(STATUS.SUCCESS, { + list + }); + } + public async checkActivityEditable(activityId: number) { let now = new Date(); let activity = await ActivityModel.findActivity(activityId); @@ -100,7 +121,7 @@ export default class Activity extends Service { }) } catch (e) { - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack); + return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (e).stack); } } @@ -125,7 +146,7 @@ export default class Activity extends Service { return ctx.service.utils.resResult(STATUS.SUCCESS, { list: list.map(cur => { return { - ...cur, beginTime: cur.beginTime?.getTime(), endTime: cur.endTime?.getTime() + ...cur, beginTime: cur.beginTime?.getTime(), endTime: cur.endTime?.getTime(), env: ctx.app.config.realEnv } }), total }); @@ -134,74 +155,20 @@ export default class Activity extends Service { /** * 更新活动组 */ - public async updateActivityGroupName(groupId: number, groupName: string) { + public async updateActivityGroup(groupId: number, groupName: string, activityIds: number[], serverIds: number[], type: number) { const { ctx } = this; try { - await ActivityGroupModel.updateGroup(groupId, {groupName}, ctx.user?.uid); - } catch(e) { - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack); - } - return ctx.service.utils.resResult(STATUS.SUCCESS) - } + let groupTypeObj = await ActivityGroupTypeModel.findByGroupType(type); + if(!groupTypeObj) return ctx.service.utils.resResult(STATUS.GM_ACTIVITY_GROUP_TYPE_NOT_FOUND); + + await ActivityGroupModel.updateGroup(groupId, {groupName, type}, ctx.user?.uid); - /** - * 选择活动组内的活动 - */ - public async saveActivitiesToGroup(groupId: number, activityIds: number[]) { - const { ctx } = this; - try { + // 更新activities let checkResult = await this.checkActivityGroupType(groupId, activityIds, ctx); if(checkResult) return checkResult; - await ActivityGroupModel.setActivitiesToGroupData(groupId, activityIds, ctx.user?.uid); - - } catch(e) { - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack); - } - return ctx.service.utils.resResult(STATUS.SUCCESS) - } - /** - * 选择活动组内的活动 - */ - public async saveSingleActivityToGroup(groupId: number, index: number, activityId: number) { - console.log(groupId, index, activityId); - const { ctx } = this; - try { - let checkResult = await this.checkActivityGroupType(groupId, [activityId], ctx); - if(checkResult) return checkResult; - - let activityGroup = await ActivityGroupModel.findGroupData(groupId); - if(!activityGroup) return ctx.service.utils.resResult(STATUS.GM_ACTIVITY_GROUP_NOT_FOUND); - let activity = await ActivityModel.findActivity(activityId); - if(!activity) return ctx.service.utils.resResult(STATUS.ACTIVITY_MISSING); - - if(activityGroup.type != 0) { - let activityGroupType = await ActivityGroupTypeModel.findByGroupType(activityGroup.type); - if(!activityGroupType) return ctx.service.utils.resResult(STATUS.GM_ACTIVITY_GROUP_TYPE_NOT_FOUND); - let dic = activityGroupType.activityTypes; - let curDic = dic.find(cur => cur.index == index); - console.log(dic, curDic) - if(curDic.activityType != activity.type) return ctx.service.utils.resResult(STATUS.GM_ACTIVITY_NOT_FIT_GROUP_TYPE) - } - - let activityIds = activityGroup.activities||[]; - if(activityIds.indexOf(activityId) == -1) activityIds.push(activityId); - - await ActivityGroupModel.setActivitiesToGroupData(groupId, activityIds, ctx.user?.uid); - - } catch(e) { - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack); - } - return ctx.service.utils.resResult(STATUS.SUCCESS) - } - - /** - * 将活动组添加入服务器内 - */ - public async saveGroupToServer(groupId: number, serverIds: number[]) { - const { ctx } = this; - try { + // 封信servers await ServerlistModel.pullByGroupId(groupId); let servers = await ServerlistModel.findServerByIds(serverIds); for(let server of servers) { @@ -213,8 +180,9 @@ export default class Activity extends Service { await ServerlistModel.updateActivityGroup(server._id, pushArr, pullArr); } await ActivityGroupModel.updateServerData(groupId, serverIds, ctx.user?.uid); + } catch(e) { - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack); + return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (e).stack); } return ctx.service.utils.resResult(STATUS.SUCCESS) } @@ -227,7 +195,7 @@ export default class Activity extends Service { try { await ActivityGroupModel.createGroup(ctx.user?.uid); } catch(e) { - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack); + return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (e).stack); } return ctx.service.utils.resResult(STATUS.SUCCESS) } @@ -243,7 +211,7 @@ export default class Activity extends Service { await ActivityGroupModel.deleteGroup(groupId); } } catch(e) { - return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, e.stack); + return ctx.service.utils.resResult(STATUS.INTERNAL_ERR, null, (e).stack); } return ctx.service.utils.resResult(STATUS.SUCCESS) } @@ -278,14 +246,6 @@ export default class Activity extends Service { await ActivityGroupTypeModel.deleteActivityGroupType(groupType); return ctx.service.utils.resResult(STATUS.SUCCESS); } - - public async saveGroupTypeToActivityGroup(groupId: number, groupType: number) { - const { ctx } = this; - let groupTypeObj = await ActivityGroupTypeModel.findByGroupType(groupType); - if(!groupTypeObj) return ctx.service.utils.resResult(STATUS.GM_ACTIVITY_GROUP_TYPE_NOT_FOUND); - await ActivityGroupModel.updateGroup(groupId, { type: groupType }, ctx.user?.uid); - return ctx.service.utils.resResult(STATUS.SUCCESS); - } public async getGroupDataById(groupId: number) { const { ctx } = this; diff --git a/shared/db/Activity.ts b/shared/db/Activity.ts index 2874d462e..57b4e7e3b 100644 --- a/shared/db/Activity.ts +++ b/shared/db/Activity.ts @@ -107,6 +107,21 @@ export default class Activity extends BaseModel { return result; } + + public static async findAllActivities() { + let all: ActivityModelType[] = []; + let createdAt; + for(let i = 0; i < 9999; i++) { // 防死循环 + let condition = {}; + if(createdAt) condition['createdAt'] = { $gt: createdAt } + let cur: ActivityModelType[] = await ActivityModel.find(condition).limit(1000).sort({ createdAt: 1 }).lean(); + if(cur.length == 0) break; + createdAt = cur[cur.length - 1].createdAt; + all.push(...cur); + } + return all; + } + //查询 public static async findByCondition(page: number, pageSize: number, sortField: string = 'updatedAt', sortOrder: string = 'descend', type: number = 0, groupId: number = 0, current: boolean = false, activityId: number = 0) { let searchObj = {}; diff --git a/shared/db/ActivityGroup.ts b/shared/db/ActivityGroup.ts index 29a72bc67..771bb4d70 100644 --- a/shared/db/ActivityGroup.ts +++ b/shared/db/ActivityGroup.ts @@ -144,6 +144,20 @@ export default class Activity_Group extends BaseModel { const result = await ActivityGroupModel.count(searchObj); return result; } + + public static async findAllActivityGroups() { + let all: ActivityGroupModelType[] = []; + let createdAt; + for(let i = 0; i < 9999; i++) { // 防死循环 + let condition = {}; + if(createdAt) condition['createdAt'] = { $gt: createdAt } + let cur = await ActivityGroupModel.find(condition).limit(1000).sort({ createdAt: 1 }).lean(); + if(cur.length == 0) break; + createdAt = cur[cur.length - 1].createdAt; + all.push(...cur); + } + return all; + } } export const ActivityGroupModel = getModelForClass(Activity_Group); diff --git a/shared/db/ActivityGroupType.ts b/shared/db/ActivityGroupType.ts index 62597d5cd..3e2ff126c 100644 --- a/shared/db/ActivityGroupType.ts +++ b/shared/db/ActivityGroupType.ts @@ -89,6 +89,19 @@ export default class Activity_GroupType extends BaseModel { return result; } + public static async findAllActivityGroupTypes() { + let all: ActivityGroupTypeInter[] = []; + let createdAt; + for(let i = 0; i < 9999; i++) { // 防死循环 + let condition = {}; + if(createdAt) condition['createdAt'] = { $gt: createdAt } + let cur: ActivityGroupTypeInter[] = await ActivityGroupTypeModel.find(condition).limit(1000).sort({ createdAt: 1 }).lean(); + if(cur.length == 0) break; + createdAt = cur[cur.length - 1].createdAt; + all.push(...cur); + } + return all; + } } export const ActivityGroupTypeModel = getModelForClass(Activity_GroupType); From 8c966aaed74f82fe57cf3214c9eba331dd56993b Mon Sep 17 00:00:00 2001 From: luying Date: Fri, 17 Dec 2021 11:08:30 +0800 Subject: [PATCH 29/32] =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gm-server/app/controller/activity.ts | 2 +- gm-server/app/router.ts | 2 +- gm-server/app/service/users.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gm-server/app/controller/activity.ts b/gm-server/app/controller/activity.ts index 130fd0f4a..bf92dff51 100644 --- a/gm-server/app/controller/activity.ts +++ b/gm-server/app/controller/activity.ts @@ -45,7 +45,7 @@ export default class ActivityController extends Controller { public async getActivityGroupTypeList() { const { ctx } = this; - const { page, pageSize, sortField, sortOrder, groupType, groupTypeName } = ctx.request.body; + const { page, pageSize, sortField, sortOrder, form: {groupType, groupTypeName} } = ctx.request.body; ctx.body = await ctx.service.activity.getActivityGroupTypeList(page, pageSize, sortField, sortOrder, groupType, groupTypeName); return } diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index a51e40d01..1332ed1e9 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -98,7 +98,7 @@ export default (app: Application) => { router.post('/api/activity/getallactivitygrouptypes', controller.activity.getAllActivityGroupTypes); router.post('/api/activity/saveactivitygrouptypelist', controller.activity.updateActivityGroupType); router.post('/api/activity/deleteactivitygrouptype', controller.activity.deleteActivityGroupType); - router.post('/api/activity/getgroupdatabyid', controller.activity.getGroupDataById); + // router.post('/api/activity/getgroupdatabyid', controller.activity.getGroupDataById); router.post('/api/activity/getactivitytaskpoint', controller.activity.getActivityTaskPoint); router.post('/api/activity/createtasktoactivity', controller.activity.createTaskToActivity); router.post('/api/activity/updateactivitytaskpoint', controller.activity.updateActivityTaskPoint); diff --git a/gm-server/app/service/users.ts b/gm-server/app/service/users.ts index af62431a2..efec93221 100644 --- a/gm-server/app/service/users.ts +++ b/gm-server/app/service/users.ts @@ -641,7 +641,7 @@ export default class GMUsers extends Service { public async getMembersByGuildCode(code: string) { const { ctx } = this; let guild = await GuildModel.findByCode(code); - if(!guild) return ctx.service.utils.resResult(STATUS.GUILD_HAS_DISSMISS); + if(!guild) return ctx.service.utils.resResult(STATUS.GUILD_NOT_FOUND); let userGuilds = await UserGuildModel.getListByGuild(code); let list = userGuilds.map(userGuild => ({ ...userGuild, env: ctx.app.config.realEnv })) From 07e12ccf9e3b7c1b3aa307d68e2bcb98dd4a77aa Mon Sep 17 00:00:00 2001 From: luying Date: Fri, 17 Dec 2021 19:17:05 +0800 Subject: [PATCH 30/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E8=B5=84=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gm-server/app/controller/game.ts | 6 ++++ gm-server/app/controller/upload.ts | 24 ++++++++++++---- gm-server/app/router.ts | 3 +- gm-server/app/service/Game.ts | 11 ++++++++ gm-server/app/service/Utils.ts | 14 ++++++++++ gm-server/config/config.default.ts | 1 + gm-server/config/config.local.ts | 20 ++++++++++++- gm-server/package-lock.json | 45 ++++++++++++++++++++---------- gm-server/package.json | 6 +++- shared/db/AccuseRec.ts | 4 ++- 10 files changed, 110 insertions(+), 24 deletions(-) diff --git a/gm-server/app/controller/game.ts b/gm-server/app/controller/game.ts index 07080532f..d04334846 100644 --- a/gm-server/app/controller/game.ts +++ b/gm-server/app/controller/game.ts @@ -208,4 +208,10 @@ export default class GameController extends Controller { ctx.body = await ctx.service.game.getDicTaskType(); return } + + public async getServerName() { + const { ctx } = this; + ctx.body = await ctx.service.game.getServerName(); + return + } } diff --git a/gm-server/app/controller/upload.ts b/gm-server/app/controller/upload.ts index e26b9422f..36a8ba1e5 100644 --- a/gm-server/app/controller/upload.ts +++ b/gm-server/app/controller/upload.ts @@ -14,9 +14,9 @@ const hotUpdateAddr = `/root/${folderName}`; const publishPath = '/root/hot_update_backup'; import {exec} from 'child_process' import { reloadResources } from '@pubUtils/data'; +import { decodeArrayStr } from '@pubUtils/util'; const sendToWormhole = require('stream-wormhole'); - export default class UploadController extends Controller { private deleteFolder (path) { @@ -148,7 +148,7 @@ export default class UploadController extends Controller { // 解压上传文件的stream var unzipExtractor = unzip.Extract({ path: dirPath }); unzipExtractor.on('close', function() { - resolve(); + resolve(null); }); unzipExtractor.on('close', function(e) { @@ -170,26 +170,30 @@ export default class UploadController extends Controller { public async uploadJson() { const { ctx } = this; + const parts = ctx.multipart({ }); const files = []; try { let stream; + let writeStream; + while ((stream = await parts()) != null) { + console.log('******', stream); const filename = stream.filename; let filenameWithoutEx = filename?filename.split('.')[0]:''; if (stream.mimeType == 'application/json') { if (filenameWithoutEx.match(/^\d{1,}$/)) { let target1 = path.join(this.config.baseDir, this.warjsonFolder, filename); let target2 = path.join(this.config.baseDir, this.distWarjsonFolder, filename); - const writeStream = fs.createWriteStream(target1); + writeStream = fs.createWriteStream(target1); await pump(stream, writeStream); fs.copyFileSync(target1, target2); files.push(filename); } else { let target1 = path.join(this.config.baseDir, this.jsonFolder, filename); let target2 = path.join(this.config.baseDir, this.distJsonFolder, filename); - const writeStream = fs.createWriteStream(target1); + writeStream = fs.createWriteStream(target1); await pump(stream, writeStream); fs.copyFileSync(target1, target2); files.push(filename); @@ -197,13 +201,23 @@ export default class UploadController extends Controller { } else if (stream.mimeType == 'application/octet-stream') { let target1 = path.join(this.config.baseDir, this.tsFolder, 'dicParam.js'); let target2 = path.join(this.config.baseDir, this.distTsFolder, filename); - const writeStream = fs.createWriteStream(target1); + writeStream = fs.createWriteStream(target1); await pump(stream, writeStream); fs.copyFileSync(target1, target2); files.push(filename); } + + let envs = decodeArrayStr(ctx.request.headers.env||'', ','); + + if(envs.length > 0) { // 转发 + for(let env of envs) { + if(env == ctx.app.config.realEnv) continue; + await ctx.service.utils.transmit(env, ctx.request.url, writeStream); + } + } sendToWormhole(stream); } + }catch(e) { console.error(e); } diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index 1332ed1e9..bb858dda3 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -8,7 +8,7 @@ export default (app: Application) => { router.post('/api/login/account', controller.login.login); router.post('/api/login/changeMyPass', tokenParser, controller.login.changeMyPass); router.post('/api/get_route', controller.login.getMenu); - router.get('/api/currentUser', tokenParser, controller.login.currentUser); + router.post('/api/currentUser', tokenParser, controller.login.currentUser); router.post('/api/upload/hotupdate', tokenParser, controller.upload.upload); router.post('/api/upload/uploadjson', tokenParser, controller.upload.uploadJson); router.post('/api/upload/reloadresource', tokenParser, controller.upload.reloadResource); @@ -73,6 +73,7 @@ export default (app: Application) => { router.post('/api/game/getdicrmb', tokenParser, controller.game.getDicRMB); router.post('/api/game/getdicactivitytype', tokenParser, controller.game.getDicActivityType); router.post('/api/game/getdictasktype', tokenParser, controller.game.getDicTaskType); + router.post('/api/game/getservername', controller.game.getServerName) // router.post('/api/game/getserverstategylist', controller.game.getServerStategyList); // router.post('/api/game/updateserverstategy', controller.game.updateServerStategy); diff --git a/gm-server/app/service/Game.ts b/gm-server/app/service/Game.ts index b0b0e0b54..f628029d4 100644 --- a/gm-server/app/service/Game.ts +++ b/gm-server/app/service/Game.ts @@ -16,6 +16,7 @@ import { nowSeconds } from '@pubUtils/timeUtil'; import { WhiteListModel } from '@db/RegionWhiteList'; import { RoleModel } from '@db/Role'; import { SearchMarqueeParam } from '@domain/backEndField/search'; +import { DicServerName } from '@pubUtils/dictionary/DicServerName'; /** * Test Service @@ -278,6 +279,16 @@ export default class Game extends Service { }) } + public async getServerName() { + let list: DicServerName[] = []; + for(let [_, serverName] of gameData.serverNames) { + list.push(serverName); + } + return this.ctx.service.utils.resResult(STATUS.SUCCESS, { + list + }) + } + public async getNoticeList(page: number, pageSize: number, sortField: string, sortOrder: string, form: { content?: string }) { const { ctx } = this; const list = await NoticeModel.findByCondition(page, pageSize, sortField, sortOrder, form); diff --git a/gm-server/app/service/Utils.ts b/gm-server/app/service/Utils.ts index 009ae8c1d..09714a08f 100644 --- a/gm-server/app/service/Utils.ts +++ b/gm-server/app/service/Utils.ts @@ -72,4 +72,18 @@ export default class Utils extends Service { log.error(`${message}`); } } + + public async transmit(env: string, route: string, stream: any) { + const { ctx } = this; + console.log('****transmit', stream); + const result = await ctx.curl(`http://127.0.0.1:7002${route}`, { + method: 'POST', + files: stream, + + headers: { + token: ctx.request.headers.token + } + }); + console.log(env, result) + } } diff --git a/gm-server/config/config.default.ts b/gm-server/config/config.default.ts index 65796df9d..5218dfc53 100644 --- a/gm-server/config/config.default.ts +++ b/gm-server/config/config.default.ts @@ -81,6 +81,7 @@ export default (appInfo: EggAppInfo) => { { id: 2, env: 'alpha', name: "测试服", domain: 'http://zyz_gm.trgame.cn' }, { id: 3, env: 'dev', name: "开发服", domain: 'http://zyzdev_gm.trgame.cn' } ]; + config.regions = regions; let httpProxy: any = {}; for(let { env, domain } of regions) { diff --git a/gm-server/config/config.local.ts b/gm-server/config/config.local.ts index 4c8fda355..b80a021ec 100644 --- a/gm-server/config/config.local.ts +++ b/gm-server/config/config.local.ts @@ -22,7 +22,25 @@ export default (appInfo: EggAppInfo) => { url: '127.0.0.1', // 内网 pw: '' }; - config.proxy = {}; + + let regions = [ // 大区数据 + { id: 1, env: 'test', name: "测试", domain: 'http://127.0.0.1:7002' }, + ]; + config.regions = regions; + + let httpProxy: any = {}; + for(let { env, domain } of regions) { + httpProxy[`/api/${env}`] = { + target: domain, + changeOrigin: true, + secure: true, + pathRewrite: function(path) { + console.log('proxy', path, path.replace(`/api/${env}`, '/api')) + return path.replace(`/api/${env}`, '/api') + } + } + } + config.proxy = httpProxy; // the return config will combines to EggAppConfig return { diff --git a/gm-server/package-lock.json b/gm-server/package-lock.json index 93dd3800b..cd2db131b 100644 --- a/gm-server/package-lock.json +++ b/gm-server/package-lock.json @@ -1039,8 +1039,7 @@ "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "atob": { "version": "2.1.2", @@ -2894,7 +2893,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "requires": { "delayed-stream": "~1.0.0" } @@ -3291,8 +3289,7 @@ "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "delegates": { "version": "1.0.0", @@ -5471,13 +5468,12 @@ "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=" }, "form-data": { - "version": "2.5.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", - "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", - "dev": true, + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", "requires": { "asynckit": "^0.4.0", - "combined-stream": "^1.0.6", + "combined-stream": "^1.0.8", "mime-types": "^2.1.12" } }, @@ -5488,13 +5484,20 @@ "dev": true }, "formstream": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/formstream/-/formstream-1.1.0.tgz", - "integrity": "sha1-UfOXDyYTbrCtRDBN5M67UCB7RHk=", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/formstream/-/formstream-1.1.1.tgz", + "integrity": "sha512-yHRxt3qLFnhsKAfhReM4w17jP+U1OlhUjnKPPtonwKbIJO7oBP0MvoxkRUwb8AU9n0MIkYy5X5dK6pQnbj+R2Q==", "requires": { "destroy": "^1.0.4", - "mime": "^1.3.4", + "mime": "^2.5.2", "pause-stream": "~0.0.11" + }, + "dependencies": { + "mime": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", + "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==" + } } }, "fragment-cache": { @@ -7123,7 +7126,8 @@ "mime": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", - "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==", + "dev": true }, "mime-db": { "version": "1.44.0", @@ -10445,6 +10449,17 @@ "ms": "^2.1.1" } }, + "form-data": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.5.1.tgz", + "integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==", + "dev": true, + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + } + }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", diff --git a/gm-server/package.json b/gm-server/package.json index 66bb370b8..a07fb77f8 100644 --- a/gm-server/package.json +++ b/gm-server/package.json @@ -21,7 +21,9 @@ "lint": "eslint . --ext .ts", "clean": "ets clean", "local": "EGG_SERVER_ENV=local npm run dev", - "prod": "EGG_SERVER_ENV=prod npm run dev" + "prod": "EGG_SERVER_ENV=prod npm run dev", + "deve": "EGG_SERVER_ENV=dev npm run dev", + "dis": "EGG_SERVER_ENV=dis npm run dev" }, "dependencies": { "await-stream-ready": "^1.0.1", @@ -34,6 +36,8 @@ "egg-cors": "^2.2.3", "egg-http-proxy-middleware": "^1.0.3", "egg-scripts": "^2.6.0", + "form-data": "^4.0.0", + "formstream": "^1.1.1", "moment": "^2.29.0", "pump": "^3.0.0", "reflect-metadata": "^0.1.13", diff --git a/shared/db/AccuseRec.ts b/shared/db/AccuseRec.ts index d22d9abad..31f126af0 100644 --- a/shared/db/AccuseRec.ts +++ b/shared/db/AccuseRec.ts @@ -37,7 +37,8 @@ export default class AccuseRec extends BaseModel { } private static getSearchObj(form: {}) { - let searchObj = form; + let searchObj = {}; + console.log(form); return searchObj } @@ -52,6 +53,7 @@ export default class AccuseRec extends BaseModel { sort[sortField] = -1; } } + console.log('page', page, 'pageSize', pageSize, 'sort', sort) const result: AccuseRecType[] = await AccuseRecModel.find(searchObj).limit(pageSize).skip((page - 1) * pageSize).sort(sort).lean({ getters: true, virtuals: true }); return result; From 3ca6d99dc71a104272770f7d179d8a6be76ac888 Mon Sep 17 00:00:00 2001 From: luying Date: Fri, 17 Dec 2021 20:44:15 +0800 Subject: [PATCH 31/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E5=85=B3=E5=8D=A1=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gm-server/app/controller/users.ts | 25 +++--------------- gm-server/app/router.ts | 2 +- gm-server/app/service/users.ts | 44 ++++++++++++++++++++++--------- shared/db/HangUpRecord.ts | 2 +- shared/db/RScriptRecord.ts | 3 +++ shared/db/TowerRecord.ts | 12 +++++++++ 6 files changed, 52 insertions(+), 36 deletions(-) diff --git a/gm-server/app/controller/users.ts b/gm-server/app/controller/users.ts index 383ec0148..8bc0b3caa 100644 --- a/gm-server/app/controller/users.ts +++ b/gm-server/app/controller/users.ts @@ -1,5 +1,4 @@ import { Controller } from 'egg'; -import { STATUS } from '@consts'; export default class UserController extends Controller { @@ -39,28 +38,10 @@ export default class UserController extends Controller { ctx.body = await ctx.service.users.getrolelist(page, pageSize, sortField, sortOrder, form); } - public async createRoleData() { + public async setWar() { const { ctx } = this; - const { hid, hlv, eid, ecount, itemid, itemcount, count, lv, skinid, selectedRowKeys: uids, optType, ehid, war } = ctx.request.body; - if(optType == 'hero') { - ctx.body = await ctx.service.users.createHero(uids, hid, hlv); - } else if(optType == 'equip') { - ctx.body = await ctx.service.users.createEquip(uids, eid, ecount, ehid); - } else if (optType == 'item') { - ctx.body = await ctx.service.users.createItem(uids, itemid, itemcount); - } else if (optType == 'gold') { - ctx.body = await ctx.service.users.addGold(uids, count); - } else if (optType == 'coin') { - ctx.body = await ctx.service.users.addCoin(uids, count); - } else if (optType == 'lv') { - ctx.body = await ctx.service.users.levelUp(uids, lv); - } else if (optType == 'skin') { - ctx.body = await ctx.service.users.addSkin(uids, skinid); - } else if (optType == 'war') { - ctx.body = await ctx.service.users.setWarRecord(uids, war); - } else { - ctx.body = ctx.service.utils.resResult(STATUS.WRONG_PARMS); - } + const { roleId, warId } = ctx.request.body; + ctx.body = await ctx.service.users.setWarRecord(roleId, warId); } diff --git a/gm-server/app/router.ts b/gm-server/app/router.ts index bb858dda3..74629f9a2 100644 --- a/gm-server/app/router.ts +++ b/gm-server/app/router.ts @@ -30,7 +30,7 @@ export default (app: Application) => { router.post('/api/users/fixsms', tokenParser, controller.users.fixSms); router.post('/api/users/getrolelist',tokenParser, controller.users.getrolelist); router.post('/api/users/deleterole',tokenParser, controller.users.deleteRole); - router.post('/api/users/createroledata',tokenParser, controller.users.createRoleData); + router.post('/api/users/setwar', controller.users.setWar); router.post('/api/users/getpvpdefense',tokenParser, controller.users.getPveDefense); router.post('/api/users/getherolist',tokenParser, controller.users.getHeroList); router.post('/api/users/deletehero', tokenParser, controller.users.deleteHero); diff --git a/gm-server/app/service/users.ts b/gm-server/app/service/users.ts index efec93221..e7f3ca934 100644 --- a/gm-server/app/service/users.ts +++ b/gm-server/app/service/users.ts @@ -6,7 +6,7 @@ import { PvpDefenseModel } from '@db/PvpDefense'; import { Service } from 'egg'; import Counter from '@db/Counter'; -import { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, REDIS_KEY } from '@consts'; +import { STATUS, HERO_SYSTEM_TYPE, ITEM_CHANGE_REASON, REDIS_KEY, WAR_TYPE } from '@consts'; import { ITID, COUNTER } from '@consts'; import { ItemModel } from '@db/Item'; import { gameData, getExpByLv } from '@pubUtils/data'; @@ -27,6 +27,8 @@ import { isNumber } from 'util'; import { GuildModel } from '@db/Guild'; import { RedisClient } from 'redis'; import { UserGuildModel } from '@db/UserGuild'; +import { TowerRecordModel } from '@db/TowerRecord'; +import { HangUpRecordModel } from '@db/HangUpRecord'; // import { resResult } from '@pubUtils/util'; @@ -726,22 +728,36 @@ export default class GMUsers extends Service { }); } - public async setWarRecord(roleIds: string[], _warId: string) { + public async setWarRecord(roleId: string, warId: number) { const { ctx } = this; - let warId = parseInt(_warId); - if(warId < 104) return ctx.service.utils.resResult(STATUS.WRONG_PARMS, null, '不可跳到序章以前') + if(!isNumber(warId)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); + if(warId < 104) return ctx.service.utils.resResult(STATUS.WRONG_PARMS, '不可以跳到序章以前') let dicWar = gameData.war.get(warId); if(!dicWar) return ctx.service.utils.resResult(STATUS.WRONG_PARMS); - for(let roleId of roleIds) { - await this.setSingleWarRecord(roleId, dicWar); + await this.setWarStarAndScript(roleId, dicWar); + if(dicWar.warType == WAR_TYPE.TOWER) { + await this.setTowerWar(roleId, dicWar); } return ctx.service.utils.resResult(STATUS.SUCCESS); } - private async setSingleWarRecord(roleId: string, dicWar: DicWar) { + private async setTowerWar(roleId: string, dicWar: DicWar) { + let towerLv = 1; + for(let [lv, dicTower] of gameData.tower) { + if(dicTower.warArray.indexOf(dicWar.war_id) != -1) { + towerLv = lv; break; + } + } + let role = await RoleModel.updateRoleInfo(roleId, { towerLv }); + await TowerRecordModel.deleteAccount(roleId); + await TowerRecordModel.insertTowerRec(roleId, towerLv); + await HangUpRecordModel.updateRec(roleId, role.roleName, towerLv, new Date(), []); + } + + private async setWarStarAndScript(roleId: string, dicWar: DicWar) { let { warStar } = await RoleModel.findByRoleId(roleId); - let deleteIds: number[] = [], myMaxWarId = 0, insertParams: DicWar[] = []; + let deleteIds: number[] = [], myMaxWarId = 0; for(let i = 0; i < warStar.length; i++) { let { id, warType } = warStar[i]; if(warType == dicWar.warType) { @@ -761,7 +777,6 @@ export default class GMUsers extends Service { let _dicWar = gameData.war.get(id) if(_dicWar && _dicWar.warType == dicWar.warType) { newWarStar.push({ id, warType: _dicWar.warType, star: 0, stars: [] }); - insertParams.push(_dicWar); } } } @@ -771,12 +786,17 @@ export default class GMUsers extends Service { let _dicWar = gameData.war.get(dicWar.previousGk); newWarStar.push({ id: _dicWar.war_id, warType: _dicWar.warType, star: 0, stars: [] }); } + await RScriptRecordModel.deleteByWarType(roleId, dicWar.warType); + let insertParams: DicWar[] = []; + for(let [_, obj] of gameData.war) { + if(dicWar.warType == obj.warType && obj.war_id < dicWar.war_id) { + insertParams.push(obj); + } + } + if(insertParams.length > 0) { await RScriptRecordModel.insertScripts(roleId, insertParams); } - if(deleteIds.length > 0) { - await RScriptRecordModel.deleteByWarId(roleId, deleteIds); - } let role = await RoleModel.updateRoleInfo(roleId, { warStar: newWarStar }); return role; } diff --git a/shared/db/HangUpRecord.ts b/shared/db/HangUpRecord.ts index 3271ba61e..449a8a5bc 100644 --- a/shared/db/HangUpRecord.ts +++ b/shared/db/HangUpRecord.ts @@ -57,7 +57,7 @@ export default class HangUpRecord extends BaseModel { } public static async updateRec(roleId: string, roleName: string, endLv: number, endTime: Date, needReceiveGoods: Array<{gid:number, count: number}>, lean = true) { - await HangUpRecordModel.findOneAndUpdate({roleId, received: false}, {endLv, endTime, received: true, notReceivedGoods: needReceiveGoods}).lean(lean); + await HangUpRecordModel.updateMany({roleId, received: false}, {endLv, endTime, received: true, notReceivedGoods: needReceiveGoods}); const recDoc = new HangUpRecordModel(); const update = Object.assign(recDoc.toJSON(), {roleId, roleName, startTime: endTime, startLv: endLv}); delete update._id; diff --git a/shared/db/RScriptRecord.ts b/shared/db/RScriptRecord.ts index 001821d5d..ade4e79b4 100644 --- a/shared/db/RScriptRecord.ts +++ b/shared/db/RScriptRecord.ts @@ -41,6 +41,9 @@ export default class RScriptRecord extends BaseModel { return items; } + public static async deleteByWarType(roleId: string, warType: number) { + return await RScriptRecordModel.deleteMany({ roleId, warType }); + } public static async deleteByWarId(roleId: string, battleId: number[]) { return await RScriptRecordModel.deleteMany({ roleId, battleId: { $in: battleId } }); } diff --git a/shared/db/TowerRecord.ts b/shared/db/TowerRecord.ts index 6ad94c01f..2ab24d852 100644 --- a/shared/db/TowerRecord.ts +++ b/shared/db/TowerRecord.ts @@ -1,5 +1,6 @@ import BaseModel from './BaseModel'; import { index, getModelForClass, prop, DocumentType } from '@typegoose/typegoose'; +import { gameData } from '../pubUtils/data'; class WarStatus { @prop({ required: true }) @@ -86,6 +87,17 @@ export default class TowerRecord extends BaseModel { return rec; } + public static async insertTowerRec(roleId: string, lv: number) { + let insertParams = []; + let doc = new TowerRecordModel(); + for(let [towerLv, { warArray }] of gameData.tower) { + if(towerLv < lv) { + insertParams.push({...doc.toJSON(), roleId, lv: towerLv, warStatus: warArray.map(warId => ({ warId, status: true })), passed: true}) + } else if (towerLv == lv) { + insertParams.push({...doc.toJSON(), roleId, lv: towerLv, warStatus: warArray.map(warId => ({ warId, status: true })), passed: false}) + } + } + } public static async deleteAccount(roleId: string) { let result = await TowerRecordModel.deleteMany({roleId}); From 4c41224c9b6c1551284100f383ea9fb4945b90c2 Mon Sep 17 00:00:00 2001 From: luying Date: Sat, 18 Dec 2021 13:13:52 +0800 Subject: [PATCH 32/32] =?UTF-8?q?=E5=90=8E=E5=8F=B0=EF=BC=9A=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gm-server/config/config.default.ts | 13 +++++++++++-- shared/db/User.ts | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/gm-server/config/config.default.ts b/gm-server/config/config.default.ts index 5218dfc53..ff9acf677 100644 --- a/gm-server/config/config.default.ts +++ b/gm-server/config/config.default.ts @@ -77,8 +77,8 @@ export default (appInfo: EggAppInfo) => { }; let regions = [ // 大区数据 - { id: 1, env: 'stable', name: "常山少年", domain: 'http://pinus_gm_test.trgame.cn' }, - { id: 2, env: 'alpha', name: "测试服", domain: 'http://zyz_gm.trgame.cn' }, + { id: 1, env: 'stable', name: "常山少年", domain: 'http://zyz_gm.trgame.cn' }, + { id: 2, env: 'alpha', name: "测试服", domain: 'http://pinus_gm_test.trgame.cn' }, { id: 3, env: 'dev', name: "开发服", domain: 'http://zyzdev_gm.trgame.cn' } ]; config.regions = regions; @@ -94,6 +94,15 @@ export default (appInfo: EggAppInfo) => { return path.replace(`/api/${env}`, '/api') } } + httpProxy[`/web/${env}`] = { + target: domain, + changeOrigin: true, + secure: true, + pathRewrite: function(path) { + console.log('proxy', path, path.replace(`/web/${env}`, '/web')) + return path.replace(`/web/${env}`, '/web') + } + } } config.proxy = httpProxy; diff --git a/shared/db/User.ts b/shared/db/User.ts index ba31e99cb..0c00b6505 100644 --- a/shared/db/User.ts +++ b/shared/db/User.ts @@ -44,7 +44,7 @@ export default class User extends BaseModel { @prop({ required: true, _id: false }) channelInfo: LoginValidateData37|{}; // 渠道数据 - @prop({ required: true, set: (val: string) => aesEncryptcfb(val, ENCRYPT_KEY, ENCRYPT_IV), get: (val: string) => aesDecryptcfb(val, ENCRYPT_KEY, ENCRYPT_IV) }) + @prop({ required: true, set: (val: string) => aesEncryptcfb(val, ENCRYPT_KEY, ENCRYPT_IV), get: (val: string) => val?aesDecryptcfb(val, ENCRYPT_KEY, ENCRYPT_IV):'' }) tel: string; // 账号 @prop({ required: true, default: '' })