邮件:删除邮件

This commit is contained in:
luying
2021-08-24 15:14:41 +08:00
parent 7e8a32f4a6
commit 08395ec957
2 changed files with 11 additions and 6 deletions
+3 -2
View File
@@ -53,10 +53,11 @@ export default class GroupMail extends MailTemp {
const result: GroupMailType = await GroupMailModel.findOneAndUpdate( const result: GroupMailType = await GroupMailModel.findOneAndUpdate(
{ {
_id, sendTime:{ $lte: nowSeconds() }, _id, sendTime:{ $lte: nowSeconds() },
'roleStatus.roleId': roleId,
$or: [{ $or: [{
roleStatus: {$elemMatch: {roleId, status: MAIL_STATUS.READ}}, hasGoods:false 'roleStatus.status': MAIL_STATUS.READ, hasGoods:false
}, { }, {
roleStatus: {$elemMatch: {roleId, status: MAIL_STATUS.RECEIVED}} 'roleStatus.status': MAIL_STATUS.RECEIVED
}] }]
}, },
{ $set:{ 'roleStatus.$.status': MAIL_STATUS.DELETE } }, { $set:{ 'roleStatus.$.status': MAIL_STATUS.DELETE } },
+8 -4
View File
@@ -59,19 +59,23 @@ export default class ServerMail extends MailTemp {
* @param _id * @param _id
* @param lean * @param lean
*/ */
public static async delMailById(_id: string, roleId: string) { public static async delMailById(id: string, roleId: string) {
const result: ServerMailType = await ServerMailModel.findOneAndUpdate( const result: ServerMailType = await ServerMailModel.findOneAndUpdate(
{ {
_id: id,
sendTime:{ $lte: nowSeconds() }, sendTime:{ $lte: nowSeconds() },
'roleStatus.roleId': roleId,
$or: [{ $or: [{
roleStatus: {$elemMatch: {roleId, status: MAIL_STATUS.READ}}, hasGoods:false 'roleStatus.status': MAIL_STATUS.READ, hasGoods:false
}, { }, {
roleStatus: {$elemMatch: {roleId, status: MAIL_STATUS.RECEIVED}} 'roleStatus.status': MAIL_STATUS.RECEIVED
}] }]
}, },
{ $set:{ 'roleStatus.$.status': MAIL_STATUS.DELETE, $push: { 'delRoles': roleId } } }, { $set:{ 'roleStatus.$.status': MAIL_STATUS.DELETE}, $push: { delRoles: roleId } },
{ new: true } { new: true }
).lean(); ).lean();
console.log('*******', result)
return result; return result;
} }