diff --git a/domain/service/event_s/send_gift.go b/domain/service/event_s/send_gift.go index 9125763d467a041dd708fc31cc5381a5429d31dc..6ebe3772d06ec948efa8cbfabfe0457ce3b5f441 100644 --- a/domain/service/event_s/send_gift.go +++ b/domain/service/event_s/send_gift.go @@ -56,17 +56,17 @@ func (s *GiftSendEventService) Consume() error { model.Log.Errorf("json msg fail,event:%v,err:%v", cpEvent, err) return nil } - if err := gift_ev.PublishSendGiftEvent(model, sendGiftEvent); err != nil { - model.Log.Errorf("PublishSendGiftEvent fail,event:%v,err:%v", string(cpEvent.Payload), err) - return err - } - // 标记已经处理 + // 标记已经处理,mark比publish事件提前,尽量避免异步事件重复执行 cpEvent.Model = model err = cpEvent.MarkDone() if err != nil { model.Log.Errorf("consume msg fail,event:%v,err:%v", cpEvent, err) return err } + if err := gift_ev.PublishSendGiftEvent(model, sendGiftEvent); err != nil { + model.Log.Errorf("PublishSendGiftEvent fail,event:%v,err:%v", string(cpEvent.Payload), err) + return err + } return nil }) }