作者 唐旭辉

bug 修复

... ... @@ -169,7 +169,7 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord
companyData domain.Company
canCopyOrder bool
)
partnerData, err = partnerRepository.FindOne(domain.PartnerFindOneQuery{UserId: orderBestshop.Id})
partnerData, err = partnerRepository.FindOne(domain.PartnerFindOneQuery{UserId: orderBestshop.PartnerId})
if err != nil {
e := fmt.Sprintf("未找到指定的合伙人(id=%d)数据,%s", orderBestshop.PartnerId, err)
return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, e)
... ...
... ... @@ -18,6 +18,8 @@ type MessageConsumer struct {
groupId string
topics []string
topicsHandles map[string]TopicHandle
beforeHandles []TopicHandle
afterHandles []TopicHandle
}
// func NewMessageConsumer() *MessageConsumer {
... ... @@ -58,7 +60,6 @@ func (c *MessageConsumer) ConsumeClaim(groupSession sarama.ConsumerGroupSession,
groupSession.MarkMessage(message, "")
if topicHandle, err = c.FindTopichandle(groupClaim.Topic()); err != nil {
logs.Error("FindTopichandle err:%s \n", err)
continue
}
if err = topicHandle(message); err != nil {
... ... @@ -93,6 +94,8 @@ func NewRuner() *Runer {
groupId: configs.Cfg.ConsumerId,
topicsHandles: TopicHandleRouters,
topics: topics,
beforeHandles: BeforeHandles,
afterHandles: AfterHandles,
},
}
}
... ... @@ -111,6 +114,11 @@ func (r *Runer) InitConsumer() error {
}
func (r *Runer) Start(ctx context.Context) {
defer func() {
if e := recover(); e != nil {
logs.Error(e)
}
}()
for {
select {
case <-ctx.Done():
... ...
... ... @@ -8,6 +8,9 @@ import (
//TopicHandle 处理kafka中得消息
type TopicHandle func(*sarama.ConsumerMessage) error
var BeforeHandles = []TopicHandle{}
var AfterHandles = []TopicHandle{}
//TopicHandleRouters 根据topic区分消息并进行处理
var TopicHandleRouters = map[string]TopicHandle{
"topic_test": func(message *sarama.ConsumerMessage) error {
... ...