邮件:修改邮件逻辑

This commit is contained in:
luying
2021-06-28 13:31:29 +08:00
parent 2ffe0f7890
commit 3b1d458a87
29 changed files with 932 additions and 626 deletions
+45 -92
View File
@@ -4,7 +4,6 @@ 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 { getContent } from '../../../services/mailService';
import { findWhere } from 'underscore';
import { nowSeconds } from '../../../pubUtils/timeUtil';
import { GroupMailType } from '../../../db/GroupMail';
@@ -104,53 +103,7 @@ export class GMRemote {
public refreshGmMails(mails:[any]) {
setGmMails(mails);
}
/**
* 获得邮件详情信息
* @param roleId
* @param serverId
* @param mails
* @param groupMails
*/
public getMailInfos(roleId: string, serverId: number, mails: [any], groupMails: [any]) {
let list: mailData[] = [];
let nowTime = nowSeconds();
//单个邮件
mails.map(function({ mailId, goods, sendTime, params, status, _id, mailTemType, sendName, endTime}) {
if (mailTemType == MAIL_TEM_TYPE.GAMEMAIL) { //gm邮件,检查是否超时,并获得gm邮件的content,sendName endTime sendTime goods等信息
if (endTime < nowTime)
return;
let { content } = getContent(parseInt(mailId), params);
if (!content)
return;
list.push({ id: _id, goods, sendTime, endTime, content, status, mailType: MAIL_TYPE.SINGLEMAIL, sendName });
} else if (mailTemType == MAIL_TEM_TYPE.GMTYPE) { //系统邮件
let gmMail = getGmMailById(mailId, serverId, nowTime);
if (!gmMail)
return;
let { goods, sendTime, content, endTime, sendName } = gmMail;
list.push({ id: _id, goods, sendTime, endTime, content, status, mailType: MAIL_TYPE.SINGLEMAIL, sendName });
}
});
//群体邮件
groupMails.map(function({ mailId, goods, sendTime, endTime, params, sendRoles, _id, mailTemType, sendName }) {
let { status } = findWhere(sendRoles, {roleId});
if (mailTemType == MAIL_TEM_TYPE.GAMEMAIL) { //gm邮件,检查是否超时,并获得gm邮件的content,sendName endTime sendTime goods等信息
if (endTime < nowTime)
return;
let { content } = getContent( parseInt(mailId), params);
if (!content)
return;
list.push({ id: _id, goods, sendTime, content, endTime, status, mailType: MAIL_TYPE.GROUPMAIL, sendName });
} else if (mailTemType == MAIL_TEM_TYPE.GMTYPE) { //系统邮件
let gmMail = getGmMailById(mailId, serverId, nowTime);
if (!gmMail)
return;
let { goods, sendTime, content, endTime, sendName } = gmMail;
list.push({ id: _id, goods, sendTime, endTime, content, status, mailType: MAIL_TYPE.GROUPMAIL, sendName });
}
});
return list;
}
/**
* 获得据上次刷新后,可以加入的邮件
* @param updatedMailAt
@@ -160,50 +113,50 @@ export class GMRemote {
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};
}
// /**
// * 获得可以领取的邮件奖
// * @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