邮件批处理

This commit is contained in:
meixiongfeng 2023-10-17 11:55:56 +08:00
parent 9df2c3f7b5
commit 292d007e29
3 changed files with 34 additions and 8 deletions

View File

@ -662,6 +662,11 @@ func (this *GM) CreateCmd(session comm.IUserSession, cmd string) (errdata *pb.Er
Check: false, Check: false,
Reward: false, Reward: false,
} }
mail.Items = append(mail.Items, &pb.UserAssets{
A: "attr",
T: "gold",
N: 1,
})
if len(mail.Items) > 0 { if len(mail.Items) > 0 {
mail.Reward = true mail.Reward = true
} }

View File

@ -71,6 +71,8 @@ func (this *apiComp) GetAllMailAttachment(session comm.IUserSession, req *pb.Mai
var ( var (
mailIds []string mailIds []string
atno []*pb.UserAtno
res []*cfg.Gameatn
) )
if errdata = this.GetAllMailAttachmentCheck(session, req); errdata != nil { if errdata = this.GetAllMailAttachmentCheck(session, req); errdata != nil {
return return
@ -91,28 +93,31 @@ func (this *apiComp) GetAllMailAttachment(session comm.IUserSession, req *pb.Mai
} }
return return
} }
fj := make([]*pb.UserAssets, 0)
for _, v := range mails { for _, v := range mails {
res := make([]*cfg.Gameatn, 0) bok := false
for _, v1 := range v.Items { for _, v1 := range v.Items {
d := &cfg.Gameatn{ d := &cfg.Gameatn{
A: v1.A, A: v1.A,
T: v1.T, T: v1.T,
N: v1.N, N: v1.N,
} }
fj = append(fj, v1)
res = append(res, d) res = append(res, d)
bok = true
} }
if errdata = this.module.DispenseRes(session, res, true); errdata == nil { if bok {
this.module.modelMail.MailUpdateMailAttachmentState(v.ObjId)
v.Reward = true v.Reward = true
v.Check = true v.Check = true
mailIds = append(mailIds, v.ObjId) mailIds = append(mailIds, v.ObjId)
} }
} }
if errdata, atno = this.module.DispenseAtno(session, res, true); errdata != nil {
session.SendMsg(string(this.module.GetType()), "getallmailattachment", &pb.MailGetAllMailAttachmentResp{Res: fj, return
Ids: mailIds}) }
this.module.modelMail.MailGetAttachmentMail(mailIds)
session.SendMsg(string(this.module.GetType()), "getallmailattachment", &pb.MailGetAllMailAttachmentResp{
Res: atno,
Ids: mailIds,
})
return return
} }

View File

@ -7,6 +7,7 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
@ -192,3 +193,18 @@ func (this *modelMail) checkReddot30(uid string) bool {
} }
return false 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
}