邮件系统bug
This commit is contained in:
@@ -83,11 +83,11 @@ export class RoleHandler {
|
||||
if (type == 1) {//单个领取
|
||||
let mail;
|
||||
if (mailType == MAIL_TYPE.SINGLEMAIL) {
|
||||
mail = await MailModel.updateMailByStatus(id, [MAIL_STATUS.READ], { status: MAIL_STATUS.RECEIVED });
|
||||
mail = await MailModel.updateMailByStatus(id, [MAIL_STATUS.READ, MAIL_STATUS.CREATE], { status: MAIL_STATUS.RECEIVED });
|
||||
if (!mail)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
} else if (mailType == MAIL_TYPE.GROUPMAIL) {
|
||||
mail = await GroupMailModel.updateMailByStatus(id, roleId, MAIL_STATUS.RECEIVED, [MAIL_STATUS.READ]);
|
||||
mail = await GroupMailModel.updateMailByStatus(id, roleId, MAIL_STATUS.RECEIVED, [MAIL_STATUS.READ, MAIL_STATUS.CREATE]);
|
||||
if (!mail)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
} else {
|
||||
@@ -95,7 +95,7 @@ export class RoleHandler {
|
||||
}
|
||||
mails.push({ id, status: MAIL_STATUS.RECEIVED, mailType });
|
||||
if (mail.mailTemType == MAIL_TEM_TYPE.GMTYPE) {
|
||||
let gmMail = await this.app.rpc.gm.gmRemote.getUseGmMailById.toServer('gm-server-1', id, serverId, nowTime);
|
||||
let gmMail = await this.app.rpc.gm.gmRemote.getUseGmMailById.toServer('gm-server-1', mail.mailId, serverId, nowTime);
|
||||
if (!gmMail)
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
mailGoods.push(...gmMail.goods);
|
||||
@@ -103,45 +103,15 @@ export class RoleHandler {
|
||||
mailGoods.push(...mail.goods);
|
||||
}
|
||||
} else {//一键领取
|
||||
let ids = [];
|
||||
let gmMails = await this.app.rpc.gm.gmRemote.getUseMails.toServer('gm-server-1', serverId);
|
||||
let groupMailRewards = await GroupMailModel.findRewardsMails(roleId);
|
||||
groupMailRewards.map(({_id, goods, mailTemType})=>{
|
||||
if (mailTemType == MAIL_TEM_TYPE.GMTYPE) {
|
||||
let gmMail = gmMails.get(id);
|
||||
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});
|
||||
ids.push(_id);
|
||||
});
|
||||
if (!!ids.length)
|
||||
await GroupMailModel.updateMailStatus(ids, MAIL_STATUS.RECEIVED, roleId);
|
||||
let mailRewards = await MailModel.findRewardsMails(roleId);
|
||||
ids = [];
|
||||
mailRewards.map(({_id, goods, mailTemType})=>{
|
||||
if (mailTemType == MAIL_TEM_TYPE.GMTYPE) {
|
||||
let gmMail = gmMails.get(id);
|
||||
if (!gmMail || !gmMail.goods.length|| gmMail.endTime < nowSeconds()) {
|
||||
return;
|
||||
}
|
||||
mailGoods.push(...gmMail.goods);
|
||||
} else {
|
||||
if (goods.length)
|
||||
return;
|
||||
mailGoods.push(...goods);
|
||||
}
|
||||
mails.push({id, status: MAIL_STATUS.RECEIVED, mailType: MAIL_TYPE.SINGLEMAIL});
|
||||
ids.push(_id);
|
||||
});
|
||||
if (!!ids.length)
|
||||
await MailModel.updateMailStatus(ids, MAIL_STATUS.RECEIVED);
|
||||
let { mailGoods: goods, mailIds, groupMailIds, mails: resMails} = await this.app.rpc.gm.gmRemote.getUseMails.toServer('gm-server-1', serverId, groupMailRewards, mailRewards);
|
||||
mailGoods = goods;
|
||||
mails = resMails;
|
||||
if (!!mailIds.length)
|
||||
await GroupMailModel.updateMailStatus(mailIds, MAIL_STATUS.RECEIVED, roleId);
|
||||
if (!!groupMailIds.length)
|
||||
await MailModel.updateMailStatus(groupMailIds, MAIL_STATUS.RECEIVED);
|
||||
}
|
||||
let resGoods = [];
|
||||
if (!!mailGoods && !!mailGoods.length)
|
||||
|
||||
Reference in New Issue
Block a user