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); - }); -}