修复:诸侯混战宣战,邮件领取,名将谱去除好感,镇念塔层级下降,求贤若渴碎片,pvp,秘境首通
This commit is contained in:
@@ -39,17 +39,36 @@ export class MailHandler {
|
||||
public async readMail(msg: { id: string, mailType: number }, session: BackendSession) {
|
||||
let roleId: string = session.get('roleId');
|
||||
let { id, mailType } = msg;
|
||||
let mail;
|
||||
let mails = [];
|
||||
if (mailType == GM_MAIL_TYPE.SINGLE) {
|
||||
mail = await MailModel.updateStatusWithCondition(id, MAIL_STATUS.READ, [MAIL_STATUS.CREATE]);
|
||||
let mail = await MailModel.getMailById(id);
|
||||
if(mail && mail.status == MAIL_STATUS.CREATE) {
|
||||
mail = await MailModel.updateStatusWithCondition(id, MAIL_STATUS.READ);
|
||||
mails.push({ id, status: MAIL_STATUS.READ, mailType });
|
||||
}
|
||||
|
||||
} else if (mailType == GM_MAIL_TYPE.GROUP) {
|
||||
mail = await GroupMailModel.updateStatusWithCondition(id, roleId, MAIL_STATUS.READ, [MAIL_STATUS.CREATE]);
|
||||
let mail = await GroupMailModel.getMailById(id);
|
||||
if(mail) {
|
||||
let myStatus = mail.roleStatus.find(cur => cur.roleId == roleId);
|
||||
if(myStatus && myStatus.status == MAIL_STATUS.CREATE) {
|
||||
mail = await GroupMailModel.updateStatusWithCondition(id, roleId, MAIL_STATUS.READ);
|
||||
mails.push({ id, status: MAIL_STATUS.READ, mailType });
|
||||
}
|
||||
}
|
||||
} else if (mailType == GM_MAIL_TYPE.SERVER) {
|
||||
mail = await ServerMailModel.updateStatusWithCondition(id, roleId, MAIL_STATUS.READ, [MAIL_STATUS.CREATE])
|
||||
let mail = await ServerMailModel.getMailById(id);
|
||||
if(mail) {
|
||||
let myStatus = mail.roleStatus.find(cur => cur.roleId == roleId);
|
||||
if(!myStatus || myStatus.status == MAIL_STATUS.CREATE) {
|
||||
mail = await ServerMailModel.updateStatusWithCondition(id, roleId, MAIL_STATUS.READ);
|
||||
mails.push({ id, status: MAIL_STATUS.READ, mailType });
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (!mail)
|
||||
// return resResult(STATUS.WRONG_PARMS);
|
||||
return resResult(STATUS.SUCCESS, { mails: mail?[{ id, status: MAIL_STATUS.READ, mailType }]:[] });
|
||||
return resResult(STATUS.SUCCESS, { mails });
|
||||
}
|
||||
|
||||
public async delMails(msg: { id: string, mailType: number, type: number }, session: BackendSession) {
|
||||
@@ -99,26 +118,40 @@ export class MailHandler {
|
||||
let mail: MailType|GroupMailType|ServerMailType;
|
||||
if (mailType == GM_MAIL_TYPE.SINGLE) {
|
||||
mail = await MailModel.getMailById(id);
|
||||
if (!mail) return resResult(STATUS.WRONG_PARMS);
|
||||
if(mail.status != MAIL_STATUS.READ && mail.status != MAIL_STATUS.CREATE) return resResult(STATUS.WRONG_PARMS);
|
||||
} else if (mailType == GM_MAIL_TYPE.GROUP) {
|
||||
mail = await GroupMailModel.getMailById(id);
|
||||
if (!mail) return resResult(STATUS.WRONG_PARMS);
|
||||
let myStatus = mail.roleStatus.find(cur => cur.roleId == roleId);
|
||||
if(!myStatus) return resResult(STATUS.WRONG_PARMS);
|
||||
if(myStatus.status != MAIL_STATUS.READ && myStatus.status != MAIL_STATUS.CREATE) return resResult(STATUS.WRONG_PARMS);
|
||||
} else if (mailType == GM_MAIL_TYPE.SERVER) {
|
||||
mail = await ServerMailModel.getMailById(id);
|
||||
if (!mail) return resResult(STATUS.WRONG_PARMS);
|
||||
let myStatus = mail.roleStatus.find(cur => cur.roleId == roleId);
|
||||
if(myStatus && myStatus.status != MAIL_STATUS.READ && myStatus.status != MAIL_STATUS.CREATE) return resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
if (!mail) return resResult(STATUS.WRONG_PARMS);
|
||||
originMails.push({ mailType, mail });
|
||||
} else {//一键领取
|
||||
let singlemails = await MailModel.findRewardsMails(roleId);
|
||||
for(let mail of singlemails) {
|
||||
if(mail.status != MAIL_STATUS.READ && mail.status != MAIL_STATUS.CREATE) continue;
|
||||
originMails.push({ mailType: GM_MAIL_TYPE.SINGLE, mail });
|
||||
}
|
||||
let groupMails = await GroupMailModel.findRewardsMails(roleId);
|
||||
for(let mail of groupMails) {
|
||||
let myStatus = mail.roleStatus.find(cur => cur.roleId == roleId);
|
||||
if(!myStatus) continue;
|
||||
if(myStatus.status != MAIL_STATUS.READ && myStatus.status != MAIL_STATUS.CREATE) continue;
|
||||
originMails.push({ mailType: GM_MAIL_TYPE.GROUP, mail })
|
||||
}
|
||||
let servermails = await ServerMailModel.findRewardsMails(serverId, roleId);
|
||||
[
|
||||
{ mails: singlemails, mailType: GM_MAIL_TYPE.SINGLE },
|
||||
{ mails: groupMails, mailType: GM_MAIL_TYPE.GROUP },
|
||||
{ mails: servermails, mailType: GM_MAIL_TYPE.SERVER },
|
||||
].forEach(({ mails, mailType }) => {
|
||||
mails.forEach((mail: MailType|GroupMailType|ServerMailType) => {
|
||||
originMails.push({ mailType, mail })
|
||||
});
|
||||
});
|
||||
for(let mail of servermails) {
|
||||
let myStatus = mail.roleStatus.find(cur => cur.roleId == roleId);
|
||||
if(myStatus && myStatus.status != MAIL_STATUS.READ && myStatus.status != MAIL_STATUS.CREATE) continue;
|
||||
originMails.push({ mailType: GM_MAIL_TYPE.SERVER, mail })
|
||||
}
|
||||
}
|
||||
|
||||
let mailGoods: ItemInter[] = [], mails: MailParam[] = [];
|
||||
@@ -134,11 +167,11 @@ export class MailHandler {
|
||||
equipCount = newEquipCount;
|
||||
|
||||
if(mailType == GM_MAIL_TYPE.SINGLE) {
|
||||
mail = await MailModel.updateStatusWithCondition(mail._id, MAIL_STATUS.RECEIVED, [MAIL_STATUS.READ, MAIL_STATUS.CREATE]);
|
||||
mail = await MailModel.updateStatusWithCondition(mail._id, MAIL_STATUS.RECEIVED);
|
||||
} else if (mailType == GM_MAIL_TYPE.GROUP) {
|
||||
mail = await GroupMailModel.updateStatusWithCondition(mail._id, roleId, MAIL_STATUS.RECEIVED, [MAIL_STATUS.READ, MAIL_STATUS.CREATE]);
|
||||
mail = await GroupMailModel.updateStatusWithCondition(mail._id, roleId, MAIL_STATUS.RECEIVED);
|
||||
} else if (mailType == GM_MAIL_TYPE.SERVER) {
|
||||
mail = await ServerMailModel.updateStatusWithCondition(mail._id, roleId, MAIL_STATUS.RECEIVED, [MAIL_STATUS.READ, MAIL_STATUS.CREATE]);
|
||||
mail = await ServerMailModel.updateStatusWithCondition(mail._id, roleId, MAIL_STATUS.RECEIVED, <ServerMailType>mail);
|
||||
}
|
||||
if(!mail) return resResult(STATUS.MAIL_HAS_RECEIVE);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user