From 0cbad2f4cb053483bf2e0d405b6da54d42aad109 Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 8 Jun 2023 18:47:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=BB=E5=8A=A1=E6=BF=80?= =?UTF-8?q?=E6=B4=BB=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/buried/module.go | 41 ++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/modules/buried/module.go b/modules/buried/module.go index dccbc37d5..6440fddd0 100644 --- a/modules/buried/module.go +++ b/modules/buried/module.go @@ -80,28 +80,34 @@ func (this *Buried) ActiveCondition(uid string, condiIds ...int32) (err error) { if model, err = this.modelBuried.getburiedModel(uid); err != nil { return } - if bdatas, err = model.getUserBurieds(uid); err != nil { - return - } + for _, v := range condiIds { if conf, err = this.configure.getburiedcondidata(v); err != nil { return } - if bdata, ok = bdatas.Items[conf.Type]; ok { - if conf.Rtype == rtype2 { - ok = false - for _, v1 := range bdata.Condi { - if v1.Conid == v { - ok = true - v1.Value = 0 - v1.Statistics = make([]string, 0) - v1.Timestamp = time.Now().Unix() - v1.State = pb.BuriedItemState_Activated - break - } - } - + if conf.Rtype != rtype2 { //非接取任务 不处理 + continue + } + if bdatas == nil { //放在后面 可以减少网络io + if bdatas, err = model.getUserBurieds(uid); err != nil { + return } + } + + if bdata, ok = bdatas.Items[conf.Type]; ok { + ok = false + for _, v1 := range bdata.Condi { + if v1.Conid == v { + ok = true + v1.Value = 0 + v1.Statistics = make([]string, 0) + v1.Timestamp = time.Now().Unix() + v1.State = pb.BuriedItemState_Activated + chanage = true + break + } + } + } else { bdata = &pb.DBBuriedItem{ Btype: conf.Type, @@ -120,7 +126,6 @@ func (this *Buried) ActiveCondition(uid string, condiIds ...int32) (err error) { }) chanage = true } - } if chanage { err = model.updateUserBurieds(uid, bdatas)