From 292d007e293de51f92fbf8dbc9e431bd9f9b07c3 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 17 Oct 2023 11:55:56 +0800 Subject: [PATCH] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E6=89=B9=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/gm/module.go | 5 +++++ modules/mail/api_getAttachment.go | 21 +++++++++++++-------- modules/mail/model_mail.go | 16 ++++++++++++++++ 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/modules/gm/module.go b/modules/gm/module.go index b7822ab90..c991356f1 100644 --- a/modules/gm/module.go +++ b/modules/gm/module.go @@ -662,6 +662,11 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (errdata *pb.Er Check: false, Reward: false, } + mail.Items = append(mail.Items, &pb.UserAssets{ + A: "attr", + T: "gold", + N: 1, + }) if len(mail.Items) > 0 { mail.Reward = true } diff --git a/modules/mail/api_getAttachment.go b/modules/mail/api_getAttachment.go index 2782e76db..9fabb2148 100644 --- a/modules/mail/api_getAttachment.go +++ b/modules/mail/api_getAttachment.go @@ -71,6 +71,8 @@ func (this *apiComp) GetAllMailAttachment(session comm.IUserSession, req *pb.Mai var ( mailIds []string + atno []*pb.UserAtno + res []*cfg.Gameatn ) if errdata = this.GetAllMailAttachmentCheck(session, req); errdata != nil { return @@ -91,28 +93,31 @@ func (this *apiComp) GetAllMailAttachment(session comm.IUserSession, req *pb.Mai } return } - fj := make([]*pb.UserAssets, 0) for _, v := range mails { - res := make([]*cfg.Gameatn, 0) + bok := false for _, v1 := range v.Items { d := &cfg.Gameatn{ A: v1.A, T: v1.T, N: v1.N, } - fj = append(fj, v1) res = append(res, d) + bok = true } - if errdata = this.module.DispenseRes(session, res, true); errdata == nil { - this.module.modelMail.MailUpdateMailAttachmentState(v.ObjId) + if bok { v.Reward = true v.Check = true mailIds = append(mailIds, v.ObjId) } } - - session.SendMsg(string(this.module.GetType()), "getallmailattachment", &pb.MailGetAllMailAttachmentResp{Res: fj, - Ids: mailIds}) + if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil { + return + } + this.module.modelMail.MailGetAttachmentMail(mailIds) + session.SendMsg(string(this.module.GetType()), "getallmailattachment", &pb.MailGetAllMailAttachmentResp{ + Res: atno, + Ids: mailIds, + }) return } diff --git a/modules/mail/model_mail.go b/modules/mail/model_mail.go index bbdf4739f..f97c2c103 100644 --- a/modules/mail/model_mail.go +++ b/modules/mail/model_mail.go @@ -7,6 +7,7 @@ import ( "go_dreamfactory/pb" "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" @@ -192,3 +193,18 @@ func (this *modelMail) checkReddot30(uid string) bool { } return false } +func (this *modelMail) MailGetAttachmentMail(objId []string) bool { + Where := bson.M{} + Query := bson.M{ + "reward": true, + "check": true, + } + + Where = bson.M{"_id": bson.M{"$in": objId}} + data, err := this.DB.UpdateMany(core.SqlTable(comm.TableMail), Where, bson.M{"$set": Query}, options.MergeUpdateOptions().SetUpsert(true)) + if err != nil { + log.Errorf("Update : %+v err :%v, ", data, err) + } + + return true +}