附件领取用户校验

This commit is contained in:
meixiongfeng 2022-07-22 10:50:07 +08:00
parent 477bfd265a
commit fc3420bfb8
2 changed files with 6 additions and 6 deletions

View File

@ -29,7 +29,7 @@ func (this *apiComp) GetUserMailAttachment(session comm.IUserSession, req *pb.Ma
if code != pb.ErrorCode_Success { if code != pb.ErrorCode_Success {
return return
} }
_bGet := this.module.modelMail.Mail_GetMailAttachmentState(req.ObjID) _bGet := this.module.modelMail.Mail_GetMailAttachmentState(req.ObjID, session.GetUserId())
if !_bGet { if !_bGet {
code = pb.ErrorCode_StateInvalid code = pb.ErrorCode_StateInvalid
return return
@ -46,7 +46,7 @@ func (this *apiComp) GetUserMailAttachment(session comm.IUserSession, req *pb.Ma
} }
res = append(res, d) 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 { if code == pb.ErrorCode_Success {
// 修改状态 // 修改状态
this.module.modelMail.Mail_UpdateMailAttachmentState(req.ObjID) this.module.modelMail.Mail_UpdateMailAttachmentState(req.ObjID)

View File

@ -53,7 +53,7 @@ func (this *modelMail) Mail_InsertUserMail(mail *pb.DBMailData) (err error) {
mail.Reward = false mail.Reward = false
if len(mail.GetItems()) > 0 { if len(mail.GetItems()) > 0 {
mail.Reward = true mail.Reward = false
} }
_, err = this.DB.InsertOne(DB_MailTable, mail) _, 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 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 { if err != nil {
return false return false
} }
return nd.Reward && len(nd.GetItems()) > 0 return !nd.Reward && len(nd.GetItems()) > 0 && nd.Uid == uid
} }
// 更新领取附件状态 // 更新领取附件状态