diff --git a/modules/mail/api_getAttachment.go b/modules/mail/api_getAttachment.go index 478796cca..5369e1e31 100644 --- a/modules/mail/api_getAttachment.go +++ b/modules/mail/api_getAttachment.go @@ -29,7 +29,7 @@ func (this *apiComp) GetUserMailAttachment(session comm.IUserSession, req *pb.Ma if code != pb.ErrorCode_Success { return } - _bGet := this.module.modelMail.Mail_GetMailAttachmentState(req.ObjID) + _bGet := this.module.modelMail.Mail_GetMailAttachmentState(req.ObjID, session.GetUserId()) if !_bGet { code = pb.ErrorCode_StateInvalid return @@ -46,7 +46,7 @@ func (this *apiComp) GetUserMailAttachment(session comm.IUserSession, req *pb.Ma } res = append(res, d) } - code = this.module.api.module.ConsumeRes(session, res, true) // 领取附件 + code = this.module.api.module.DispenseRes(session, res, true) // 领取附件 if code == pb.ErrorCode_Success { // 修改状态 this.module.modelMail.Mail_UpdateMailAttachmentState(req.ObjID) diff --git a/modules/mail/model_mail.go b/modules/mail/model_mail.go index d95d0503c..2364a345a 100644 --- a/modules/mail/model_mail.go +++ b/modules/mail/model_mail.go @@ -53,7 +53,7 @@ func (this *modelMail) Mail_InsertUserMail(mail *pb.DBMailData) (err error) { mail.Reward = false if len(mail.GetItems()) > 0 { - mail.Reward = true + mail.Reward = false } _, err = this.DB.InsertOne(DB_MailTable, mail) @@ -86,13 +86,13 @@ func (this *modelMail) Mail_GetMailAttachment(objId string) (itmes []*pb.UserAss } // 查看领取附件状态 -func (this *modelMail) Mail_GetMailAttachmentState(objId string) bool { +func (this *modelMail) Mail_GetMailAttachmentState(objId string, uid string) bool { var nd *pb.DBMailData - err := this.DB.FindOne(DB_MailTable, bson.M{"_id": objId}).Decode(nd) + err := this.DB.FindOne(DB_MailTable, bson.M{"_id": objId}).Decode(&nd) if err != nil { return false } - return nd.Reward && len(nd.GetItems()) > 0 + return !nd.Reward && len(nd.GetItems()) > 0 && nd.Uid == uid } // 更新领取附件状态