作者 唐旭辉

bug 修复

@@ -169,7 +169,7 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord @@ -169,7 +169,7 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord
169 companyData domain.Company 169 companyData domain.Company
170 canCopyOrder bool 170 canCopyOrder bool
171 ) 171 )
172 - partnerData, err = partnerRepository.FindOne(domain.PartnerFindOneQuery{UserId: orderBestshop.Id}) 172 + partnerData, err = partnerRepository.FindOne(domain.PartnerFindOneQuery{UserId: orderBestshop.PartnerId})
173 if err != nil { 173 if err != nil {
174 e := fmt.Sprintf("未找到指定的合伙人(id=%d)数据,%s", orderBestshop.PartnerId, err) 174 e := fmt.Sprintf("未找到指定的合伙人(id=%d)数据,%s", orderBestshop.PartnerId, err)
175 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e) 175 return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
@@ -18,6 +18,8 @@ type MessageConsumer struct { @@ -18,6 +18,8 @@ type MessageConsumer struct {
18 groupId string 18 groupId string
19 topics []string 19 topics []string
20 topicsHandles map[string]TopicHandle 20 topicsHandles map[string]TopicHandle
  21 + beforeHandles []TopicHandle
  22 + afterHandles []TopicHandle
21 } 23 }
22 24
23 // func NewMessageConsumer() *MessageConsumer { 25 // func NewMessageConsumer() *MessageConsumer {
@@ -58,7 +60,6 @@ func (c *MessageConsumer) ConsumeClaim(groupSession sarama.ConsumerGroupSession, @@ -58,7 +60,6 @@ func (c *MessageConsumer) ConsumeClaim(groupSession sarama.ConsumerGroupSession,
58 groupSession.MarkMessage(message, "") 60 groupSession.MarkMessage(message, "")
59 if topicHandle, err = c.FindTopichandle(groupClaim.Topic()); err != nil { 61 if topicHandle, err = c.FindTopichandle(groupClaim.Topic()); err != nil {
60 logs.Error("FindTopichandle err:%s \n", err) 62 logs.Error("FindTopichandle err:%s \n", err)
61 -  
62 continue 63 continue
63 } 64 }
64 if err = topicHandle(message); err != nil { 65 if err = topicHandle(message); err != nil {
@@ -93,6 +94,8 @@ func NewRuner() *Runer { @@ -93,6 +94,8 @@ func NewRuner() *Runer {
93 groupId: configs.Cfg.ConsumerId, 94 groupId: configs.Cfg.ConsumerId,
94 topicsHandles: TopicHandleRouters, 95 topicsHandles: TopicHandleRouters,
95 topics: topics, 96 topics: topics,
  97 + beforeHandles: BeforeHandles,
  98 + afterHandles: AfterHandles,
96 }, 99 },
97 } 100 }
98 } 101 }
@@ -111,6 +114,11 @@ func (r *Runer) InitConsumer() error { @@ -111,6 +114,11 @@ func (r *Runer) InitConsumer() error {
111 } 114 }
112 115
113 func (r *Runer) Start(ctx context.Context) { 116 func (r *Runer) Start(ctx context.Context) {
  117 + defer func() {
  118 + if e := recover(); e != nil {
  119 + logs.Error(e)
  120 + }
  121 + }()
114 for { 122 for {
115 select { 123 select {
116 case <-ctx.Done(): 124 case <-ctx.Done():
@@ -8,6 +8,9 @@ import ( @@ -8,6 +8,9 @@ import (
8 //TopicHandle 处理kafka中得消息 8 //TopicHandle 处理kafka中得消息
9 type TopicHandle func(*sarama.ConsumerMessage) error 9 type TopicHandle func(*sarama.ConsumerMessage) error
10 10
  11 +var BeforeHandles = []TopicHandle{}
  12 +var AfterHandles = []TopicHandle{}
  13 +
11 //TopicHandleRouters 根据topic区分消息并进行处理 14 //TopicHandleRouters 根据topic区分消息并进行处理
12 var TopicHandleRouters = map[string]TopicHandle{ 15 var TopicHandleRouters = map[string]TopicHandle{
13 "topic_test": func(message *sarama.ConsumerMessage) error { 16 "topic_test": func(message *sarama.ConsumerMessage) error {