邮件系统bug
This commit is contained in:
@@ -2,11 +2,13 @@ import { Application, ChannelService } 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 } from "../../../consts/constModules/mailConst";
|
||||
import { MAIL_TYPE, MAIL_TEM_TYPE, MAIL_STATUS } from "../../../consts/constModules/mailConst";
|
||||
import { mailData } from "../../../pubUtils/interface";
|
||||
import { getContent } from '../../../services/mailService';
|
||||
import { findWhere } from 'underscore';
|
||||
import { nowSeconds } from '../../../pubUtils/timeUtil';
|
||||
import { GroupMailType } from '../../../db/GroupMail';
|
||||
import { MailType } from '../../../db/Mail';
|
||||
export default function (app: Application) {
|
||||
return new GMRemote(app);
|
||||
}
|
||||
@@ -97,14 +99,14 @@ export class GMRemote {
|
||||
channel.pushMessage('onLeave', resResult(STATUS.SUCCESS, param));
|
||||
}
|
||||
|
||||
public async refreshGmMails(mails:[any]) {
|
||||
public refreshGmMails(mails:[any]) {
|
||||
setGmMails(mails);
|
||||
}
|
||||
|
||||
public async getMailInfos(roleId: string, serverId: number, mails: [any], groupMails: [any]) {
|
||||
public getMailInfos(roleId: string, serverId: number, mails: [any], groupMails: [any]) {
|
||||
let list: mailData[] = [];
|
||||
let nowTime = nowSeconds();
|
||||
mails.map(async function({ mailId, goods, sendTime, params, status, _id, mailTemType, sendName, endTime}) {
|
||||
mails.map(function({ mailId, goods, sendTime, params, status, _id, mailTemType, sendName, endTime}) {
|
||||
if (mailTemType == MAIL_TEM_TYPE.GAMEMAIL) { //模板邮件
|
||||
if (endTime < nowTime)
|
||||
return;
|
||||
@@ -120,7 +122,7 @@ export class GMRemote {
|
||||
list.push({ id: _id, goods, sendTime, endTime, content, status, mailType: MAIL_TYPE.SINGLEMAIL, sendName });
|
||||
}
|
||||
});
|
||||
groupMails.map(async function({ mailId, goods, sendTime, endTime, params, sendRoles, _id, mailTemType, sendName }) {
|
||||
groupMails.map(function({ mailId, goods, sendTime, endTime, params, sendRoles, _id, mailTemType, sendName }) {
|
||||
let { status } = findWhere(sendRoles, {roleId});
|
||||
if (mailTemType == MAIL_TEM_TYPE.GAMEMAIL) { //模板邮件
|
||||
if (endTime < nowTime)
|
||||
@@ -140,13 +142,47 @@ export class GMRemote {
|
||||
return list;
|
||||
}
|
||||
|
||||
public async getMails(updatedMailAt: number, serverId: number) {
|
||||
public getMails(updatedMailAt: number, serverId: number) {
|
||||
let gmMails = getGmMails(updatedMailAt, serverId);
|
||||
return gmMails;
|
||||
}
|
||||
public async getUseMails(serverId: number) {
|
||||
let gmMails = getGmUseMails(serverId);
|
||||
return gmMails;
|
||||
public getUseMails(serverId: number, groupMailRewards: GroupMailType[], mailRewards: MailType[]) {
|
||||
let nowTime = nowSeconds();
|
||||
let mailGoods = [];
|
||||
let mails = [];
|
||||
let mailIds: string[] = [];
|
||||
let groupMailIds: string[] = [];
|
||||
groupMailRewards.map(({_id, goods, mailId, mailTemType})=>{
|
||||
if (mailTemType == MAIL_TEM_TYPE.GMTYPE) {
|
||||
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) {
|
||||
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};
|
||||
}
|
||||
/**
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user