✨ feat(gvg): 组建期聊天和邮件
This commit is contained in:
@@ -193,7 +193,6 @@ async function treatStartLogic(app: _pinus.Application) {
|
||||
if(app.getServerType() == 'guild') {
|
||||
initGuildActivityIndexInPinus()
|
||||
.then(resetJoinWoodenHorse);
|
||||
setGVGServerGroup();
|
||||
}
|
||||
if(app.getServerType() == 'battle'|| app.getServerType() == 'role'|| app.getServerType() == 'connector') {
|
||||
timeTaskService.setPvpSeasonNum();
|
||||
@@ -202,6 +201,9 @@ async function treatStartLogic(app: _pinus.Application) {
|
||||
if(app.getServerType() != 'systimer') {
|
||||
timeTaskService.initHiddenData();
|
||||
}
|
||||
if(app.getServerType() == 'battle'|| app.getServerType() == 'chat'|| app.getServerType() == 'connector') {
|
||||
setGVGServerGroup();
|
||||
}
|
||||
|
||||
if(app.isMaster()) {
|
||||
redisService.initAllRank();
|
||||
|
||||
@@ -2,7 +2,7 @@ import { CHANNEL_PREFIX, MSG_SOURCE, getChannelType } from './../../../consts/co
|
||||
import { Application, BackendSession, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { DEFAULT_MSG_PER_PAGE, STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { createAccuseData, createGroupMsg, createPrivateMsg, getPrivateMessages, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadInfo, recentPrivateChatInfos, recentWorldMsgs, recentSysMsgs, recentGuildMsgs, updatePrivateMsgIsTop, delPrivateMsg } from '../../../services/chatService';
|
||||
import { createAccuseData, createGroupMsg, createPrivateMsg, getPrivateMessages, pushGroupMsgToRoom, pushMsgToRole, updatePrivateMsgReadInfo, recentPrivateChatInfos, recentWorldMsgs, recentSysMsgs, recentGuildMsgs, updatePrivateMsgIsTop, delPrivateMsg, recentServerGroupMsgs } from '../../../services/chatService';
|
||||
import { getSimpleRoleInfo } from '../../../services/roleService';
|
||||
import { checkTask } from '../../../services/task/taskService';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
@@ -107,8 +107,9 @@ export class ChatHandler {
|
||||
const worldMsgs = await recentWorldMsgs(serverId);
|
||||
const sysMsgs = await recentSysMsgs(serverId);
|
||||
const guildMsgs = await recentGuildMsgs(guildCode);
|
||||
const gvgMsgs = await recentServerGroupMsgs(serverId);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { worldMsgs, sysMsgs, guildMsgs })
|
||||
return resResult(STATUS.SUCCESS, { worldMsgs, sysMsgs, guildMsgs, gvgMsgs })
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ import { errlogger } from '../../../util/logger';
|
||||
import { addUserToChannel, sendMessageToChannel, sendMessgeToChannelByBatch, setKvToMemory } from '../../../services/pushService';
|
||||
import { setApiIsClose } from '../../../services/chatService';
|
||||
import { setHiddenData } from '../../../services/dataService';
|
||||
import { setGVGServerGroup } from '../../../services/gvg/gvgService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -173,4 +174,12 @@ export class ChatRemote {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setGVGServerGroup() {
|
||||
try {
|
||||
return setGVGServerGroup();
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import { COM_BTL_QUALITY, HERO_SELECT, DEBUG_MAGIC_WORD, REDIS_KEY, TASK_TYPE, E
|
||||
import { nowSeconds, getZeroPoint } from '../../../pubUtils/timeUtil';
|
||||
import { rmRoleFromQueue, roleLeave, getRoleOnlineInfo, roleLogin, getOnlineRoleByUserCode } from '../../../services/redisService';
|
||||
|
||||
import { addRoleToGuildChannel, addRoleToSysChannel, addRoleToWorldChannel, leaveGroupShopChannel, leaveGuildAuctionChannel, leaveGuildChannel, leaveSysChannel, leaveWorldAuctionChannel, leaveWorldChannel, recentGuildMsgs, recentPrivateChatInfos, recentSysMsgs, recentWorldMsgs } from '../../../services/chatService';
|
||||
import { addRoleToGuildChannel, addRoleToSysChannel, addRoleToWorldChannel, leaveGroupShopChannel, leaveGuildAuctionChannel, leaveGuildChannel, leaveSysChannel, leaveWorldAuctionChannel, leaveWorldChannel } from '../../../services/chatService';
|
||||
import { reportOneOnline, savePlayTime } from '../../../services/authenticateService';
|
||||
import { checkTaskInEntry, } from '../../../services/task/taskService';
|
||||
import { pushData, kickUser, getModuleData, assignServer, leaveServer } from '../../../services/connectorService';
|
||||
|
||||
@@ -13,6 +13,7 @@ import { setApiIsClose } from '../../../services/chatService';
|
||||
import { setPvpSeasonNum, setPvpSettleSeasonNum } from '../../../services/timeTaskService';
|
||||
import { setHiddenData } from '../../../services/dataService';
|
||||
import { setKvToMemory } from '../../../services/pushService';
|
||||
import { setGVGServerGroup } from '../../../services/gvg/gvgService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -202,4 +203,12 @@ export class ConnectorRemote {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
|
||||
public async setGVGServerGroup() {
|
||||
try {
|
||||
return setGVGServerGroup();
|
||||
} catch(e) {
|
||||
errlogger.error(`remote ${__filename} \n ${e.stack}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Application, BackendSession, ChannelService, HandlerService } from "pinus";
|
||||
import { GUILD_AUTH, GVG_APPLY_TYPE, GVG_PERIOD, GVG_SERVER_TYPE, LEAGUE_AUTH, LEAGUE_MANAGE_TYPE, PUSH_ROUTE, STATUS } from "../../../consts";
|
||||
import { CHANNEL_PREFIX, GUILD_AUTH, GVG_APPLY_TYPE, GVG_PERIOD, GVG_SERVER_TYPE, LEAGUE_AUTH, LEAGUE_MANAGE_TYPE, MAIL_TYPE, MSG_SOURCE, MSG_TYPE, PUSH_ROUTE, STATUS } from "../../../consts";
|
||||
import { resResult } from "../../../pubUtils/util";
|
||||
import { GuildModel, GuildType } from "../../../db/Guild";
|
||||
import { UserGuildModel } from "../../../db/UserGuild";
|
||||
import { GVGLeagueModel, GVGLeagueType } from "../../../db/GVGLeague";
|
||||
import { GVGLeagueApplyModel } from "../../../db/GVGLeagueApply";
|
||||
import { getGVGPeriodData, getGVGServerType, getServersOfSameGroup } from "../../../services/gvg/gvgService";
|
||||
import { getGroupIdOfServer, getGVGPeriodData, getGVGServerType, getServersOfSameGroup } from "../../../services/gvg/gvgService";
|
||||
import { checkCanManage, checkGuildLeader, checkLeagueAuth, createLeague, getLeagueApplyData, getLeagueInviteData, getMyAuth, joinGuildToLeague } from "../../../services/gvg/gvgTeamService";
|
||||
import { LeagueGuildInfo, LeagueListInfo, LeagueMemberListInfo, LeagueSimpleInfo } from "../../../domain/gvgField/returnData";
|
||||
import { getAllServerName, getServerName } from "../../../services/redisService";
|
||||
@@ -14,6 +14,8 @@ import { RoleModel } from "../../../db/Role";
|
||||
import { GVGUserDataModel } from "../../../db/GVGUserData";
|
||||
import { sendMessageToGuildWithSuc, sendMessageToUserWithSuc } from "../../../services/pushService";
|
||||
import { GVGLeaguePrepareModel } from "../../../db/GVGLeaguePrepare";
|
||||
import { createGroupMsg, pushGroupMsgToRoom } from "../../../services/chatService";
|
||||
import { sendMailToGuildByContent } from "../../../services/mailService";
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -571,4 +573,56 @@ export class GVGManageHandler {
|
||||
icon: myLeague.icon,
|
||||
});
|
||||
}
|
||||
|
||||
// 团长发送消息给军团内所有成员的邮箱
|
||||
async sendMail(msg: { content: string }, session: BackendSession) {
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const guildCode = session.get('guildCode');
|
||||
const { content } = msg;
|
||||
// 权限
|
||||
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||
if(!myLeague) return resResult(STATUS.GVG_LEAGUE_NOT_EXIST);
|
||||
const checkAuth = await checkLeagueAuth(roleId, myLeague, LEAGUE_MANAGE_TYPE.SEND_MAIL);
|
||||
if(!checkAuth) return resResult(STATUS.GVG_HAS_NO_AUTH);
|
||||
|
||||
|
||||
const { guildCodes } = myLeague;
|
||||
//下发邮件
|
||||
for(let guildCode of guildCodes) {
|
||||
await sendMailToGuildByContent(MAIL_TYPE.GUILD_MAIL, guildCode, { sendName: `${roleName}`, params: [content] });
|
||||
}
|
||||
|
||||
return resResult(STATUS.SUCCESS, { isSuccess: true });
|
||||
}
|
||||
|
||||
// 团长发送世界频道
|
||||
async recruit(msg: { content: string }, session: BackendSession) {
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
const guildCode = session.get('guildCode');
|
||||
|
||||
const { content } = msg;
|
||||
// 检查时间
|
||||
const checkResult = await checkCanManage(serverId);
|
||||
if(checkResult.code != 0) return checkResult;
|
||||
|
||||
// 权限
|
||||
let myLeague = await GVGLeagueModel.findLeagueByGuild(guildCode);
|
||||
if(!myLeague) return resResult(STATUS.GVG_LEAGUE_NOT_EXIST);
|
||||
const checkAuth = await checkLeagueAuth(roleId, myLeague, LEAGUE_MANAGE_TYPE.RERUIT);
|
||||
if(!checkAuth) return resResult(STATUS.GVG_HAS_NO_AUTH);
|
||||
|
||||
// 发送战区频道消息
|
||||
const groupId = await getGroupIdOfServer(serverId);
|
||||
let channelId = `${groupId}`;
|
||||
const msgData = await createGroupMsg(roleId, roleName, CHANNEL_PREFIX.GVG, channelId, MSG_TYPE.RICH_TEXT, MSG_SOURCE.GVG_RECURIT, JSON.stringify({ leagueCode: myLeague.leagueCode, name: myLeague.name, info: content }), '', '');
|
||||
if (!msgData) return resResult(STATUS.WRONG_PARMS);
|
||||
await pushGroupMsgToRoom(msgData);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { isSuccess: true });
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import { sendMessageToAllWithSuc, sendMessageToCityWithSuc, sendMessageToGuildWi
|
||||
import { comBtlLvInvalid } from './comBattleService';
|
||||
import { gameData } from '../pubUtils/data';
|
||||
import { RegionModel } from '../db/Region';
|
||||
import { getGroupIdOfServer, getServersByGroupId } from './gvg/gvgService';
|
||||
|
||||
export * from './chatChannelService';
|
||||
export * from './sysChatService';
|
||||
@@ -163,6 +164,12 @@ export async function pushGroupMsgToRoom(msg: GroupMessageType) {
|
||||
} else if (msg.channel == CHANNEL_PREFIX.CITY) {
|
||||
let arr = msg.channelId.split('_');
|
||||
await sendMessageToCityWithSuc(parseInt(arr[0]), parseInt(arr[1]), PUSH_ROUTE.GROUP_MSG, { ...msg, roleInfo });
|
||||
} else if (msg.channel == CHANNEL_PREFIX.GVG) {
|
||||
let groupId = parseInt(msg.channelId);
|
||||
let serverIds = await getServersByGroupId(groupId);
|
||||
for(let serverId of serverIds) {
|
||||
await sendMessageToServerWithSuc(serverId, PUSH_ROUTE.GROUP_MSG, { ...msg, roleInfo });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,6 +222,20 @@ async function recentGroupMsgs(roomId: string, count?: number) {
|
||||
return result.filter(cur => cur) || [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取最近的战区聊天消息
|
||||
* @export
|
||||
* @param {number} serverId 用区服编号做房间标识
|
||||
* @param {number} [count]
|
||||
* @returns
|
||||
*/
|
||||
export async function recentServerGroupMsgs(serverId: number, count?: number) {
|
||||
let groupId = await getGroupIdOfServer(serverId);
|
||||
console.log('####', groupId);
|
||||
const result = await recentGroupMsgs(groupRoomId(CHANNEL_PREFIX.GVG, groupId), count);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 获取最近的世界聊天消息
|
||||
* @export
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* entry触发后引起的下发
|
||||
*/
|
||||
import { getMails } from './mailService';
|
||||
import { recentGuildMsgs, recentPrivateChatInfos, recentSysMsgs, recentWorldMsgs } from './chatService';
|
||||
import { recentGuildMsgs, recentPrivateChatInfos, recentServerGroupMsgs, recentSysMsgs, recentWorldMsgs } from './chatService';
|
||||
import { getCurTask, getPvpTask } from './task/taskService';
|
||||
|
||||
import { RoleType } from '../db/Role';
|
||||
@@ -203,8 +203,9 @@ export async function getModuleData(type: string, data: { role: RoleType, sessio
|
||||
const worldMsgs = await recentWorldMsgs(serverId);
|
||||
const sysMsgs = await recentSysMsgs(serverId);
|
||||
const guildMsgs = await recentGuildMsgs(guildCode);
|
||||
const gvgMsgs = await recentServerGroupMsgs(serverId);
|
||||
const recentPrivateChats = await recentPrivateChatInfos(roleId, roleName);
|
||||
return { worldMsgs, sysMsgs, guildMsgs, recentPrivateChats };
|
||||
return { worldMsgs, sysMsgs, guildMsgs, gvgMsgs, recentPrivateChats };
|
||||
case 'event':
|
||||
return await getEvent(role.eventStatus, roleId, roleName);
|
||||
case 'battle':
|
||||
|
||||
@@ -19,6 +19,8 @@ export async function createNewGVGConfig() {
|
||||
setGVGConfigToRemote(config);
|
||||
// TODO 每周自动解散一些联军
|
||||
await pinus.app.rpc.guild.guildRemote.setGVGServerGroup.broadcast();
|
||||
await pinus.app.rpc.chat.chatRemote.setGVGServerGroup.broadcast();
|
||||
await pinus.app.rpc.connector.connectorRemote.setGVGServerGroup.broadcast();
|
||||
return config;
|
||||
}
|
||||
|
||||
@@ -157,12 +159,16 @@ export async function getServersOfSameGroup(type: GVG_SERVER_TYPE, id: number) {
|
||||
if(type == GVG_SERVER_TYPE.SINGLE) return [id];
|
||||
|
||||
let groupId = await getGroupIdOfServer(id);
|
||||
return await getServersByGroupId(groupId);
|
||||
}
|
||||
|
||||
export async function getServersByGroupId(groupId: number) {
|
||||
let arr: { serverId: number; groupId: number }[] = pinus.app.get('gvgServerGroup')||[];
|
||||
let serverCreateTimes = await getAllServerCreateTime();
|
||||
|
||||
return arr.filter(obj => {
|
||||
let openTime = parseInt(serverCreateTimes[obj.serverId]);
|
||||
return obj.groupId == groupId && getServerTypeByTime(openTime) == type;
|
||||
return obj.groupId == groupId && getServerTypeByTime(openTime) == GVG_SERVER_TYPE.MULTI;
|
||||
}).map(obj => obj.serverId);
|
||||
}
|
||||
|
||||
|
||||
@@ -190,11 +190,13 @@ function getAuthFromManageType(type: LEAGUE_MANAGE_TYPE) {
|
||||
case LEAGUE_MANAGE_TYPE.KICK:
|
||||
case LEAGUE_MANAGE_TYPE.DISSMISS:
|
||||
case LEAGUE_MANAGE_TYPE.ABDICATE:
|
||||
case LEAGUE_MANAGE_TYPE.RERUIT:
|
||||
return [LEAGUE_AUTH.LEADER];
|
||||
case LEAGUE_MANAGE_TYPE.QUIT:
|
||||
case LEAGUE_MANAGE_TYPE.BE_ABDICATED:
|
||||
return [LEAGUE_AUTH.SUB_LEADER];
|
||||
case LEAGUE_MANAGE_TYPE.SET_INFO:
|
||||
case LEAGUE_MANAGE_TYPE.SEND_MAIL:
|
||||
return [LEAGUE_AUTH.LEADER, LEAGUE_AUTH.SUB_LEADER];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -901,8 +901,9 @@ export async function initGVGConfigSchedule() {
|
||||
let config = await GVGConfigModel.findConfig();
|
||||
if(!config) {
|
||||
config = await createNewGVGConfig();
|
||||
} else {
|
||||
setGVGConfigToRemote(config);
|
||||
}
|
||||
setGVGConfigToRemote(config);
|
||||
|
||||
if(nowSeconds() > config.scheduleTime) {
|
||||
config = await createNewGVGConfig();
|
||||
|
||||
@@ -17,6 +17,7 @@ export const CHANNEL_PREFIX = {
|
||||
SYS: 'sys',
|
||||
WORLD: 'world',
|
||||
GUILD: 'guild',
|
||||
GVG: 'gvg', // 战区
|
||||
TEAM: 'com_btl_team',
|
||||
CITY: 'city', // 军团活动,诸侯混战,按城池分channel
|
||||
GUILD_AUCTION: 'g_auction', // 军团拍卖
|
||||
@@ -36,6 +37,8 @@ export const getChannelType = function(prefix: string) {
|
||||
return 4;
|
||||
case 'private':
|
||||
return 5;
|
||||
case CHANNEL_PREFIX.GVG:
|
||||
return 6;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +86,7 @@ export const MSG_SOURCE = {
|
||||
EQUIP_QUALITY_UP: 26,
|
||||
LADDER_FIRST_CHANGE: 27,
|
||||
GET_UR_HERO: 28,
|
||||
GVG_RECURIT: 29,
|
||||
}
|
||||
|
||||
export const DEFAULT_MSG_PER_PAGE = 10;
|
||||
|
||||
@@ -31,4 +31,6 @@ export enum LEAGUE_MANAGE_TYPE {
|
||||
ABDICATE = 6, // 转让
|
||||
BE_ABDICATED = 7, // 被转让
|
||||
SET_INFO = 8, // 设置信息
|
||||
RERUIT = 9, // 招募
|
||||
SEND_MAIL = 9, // 招募
|
||||
}
|
||||
@@ -241,7 +241,28 @@
|
||||
"id": 34,
|
||||
"title": "&",
|
||||
"sendName": "您忠诚的小跟班",
|
||||
"content": "亲爱的主公,您的背包中宝物数量已满,请及时清理背包哦。溢出装备已通过邮件发放,请查收",
|
||||
"time": 2160
|
||||
"content": "主公很抱歉,您的军团已解散,请寻找新的军团加入吧",
|
||||
"time": 720
|
||||
},
|
||||
{
|
||||
"id": 35,
|
||||
"title": "&",
|
||||
"sendName": "您忠诚的小跟班",
|
||||
"content": "主公很抱歉,您的联军%d已解散",
|
||||
"time": 720
|
||||
},
|
||||
{
|
||||
"id": 36,
|
||||
"title": "&",
|
||||
"sendName": "您忠诚的小跟班",
|
||||
"content": "主公很抱歉,您的军团已被联军%d踢出",
|
||||
"time": 720
|
||||
},
|
||||
{
|
||||
"id": 37,
|
||||
"title": "&",
|
||||
"sendName": "您忠诚的小跟班",
|
||||
"content": "亲爱的主公,您被任命为联军%d的盟主",
|
||||
"time": 720
|
||||
}
|
||||
]
|
||||
@@ -288,5 +288,15 @@
|
||||
"worldchat": "<color=#faf3e0>恭喜</color><color=#7feebd>%d</color><color=#faf3e0>时来运转,获得神话武将%d</color>",
|
||||
"bubble": "<outline color=#1c1613 width=2><color=#faf3e0>恭喜</color><color=#7feebd>%d</color><color=#faf3e0>时来运转,获得神话武将%d</color></outline>",
|
||||
"comments": "1:%d(玩家名);2:%d(武将名)"
|
||||
},
|
||||
{
|
||||
"id": 29,
|
||||
"name": "GVG_RECURIT",
|
||||
"mean": "联军招募",
|
||||
"type": "6&",
|
||||
"template": "<color=#3bbb7e>%d</color><color=#2e190a>正在扩充兵马:%d,欢迎各军团加入建设</color><color=#308909>",
|
||||
"worldchat": "<color=#3bbb7e>%d</color><color=#2e190a>正在扩充兵马:%d,欢迎各军团加入建设</color><color=#308909>",
|
||||
"bubble": "<outline color=#1c1613 width=2><color=#7feebd>%d</color><color=#faf3e0>正在扩充兵马:%d,欢迎各军团加入建设</color></outline>",
|
||||
"comments": "1:%d(联军名);2:%d(联军招募内容)"
|
||||
}
|
||||
]
|
||||
@@ -33,6 +33,6 @@
|
||||
"DEBUG_TIME": 1,
|
||||
"CHECK_WORD": 1,
|
||||
"CAN_PAY": 1,
|
||||
"SKIP_ENCODE": 1,
|
||||
"SKIP_ENCODE": 0,
|
||||
"NEED_REBATE": 0
|
||||
}
|
||||
Reference in New Issue
Block a user