正在显示
3 个修改的文件
包含
7 行增加
和
2 行删除
@@ -4,6 +4,7 @@ import ( | @@ -4,6 +4,7 @@ import ( | ||
4 | "context" | 4 | "context" |
5 | "os" | 5 | "os" |
6 | "os/signal" | 6 | "os/signal" |
7 | + "sync" | ||
7 | "syscall" | 8 | "syscall" |
8 | 9 | ||
9 | "github.com/astaxie/beego" | 10 | "github.com/astaxie/beego" |
@@ -26,8 +27,11 @@ func main() { | @@ -26,8 +27,11 @@ func main() { | ||
26 | if err := consumerRun.InitConsumer(); err != nil { | 27 | if err := consumerRun.InitConsumer(); err != nil { |
27 | logs.Error("启动kafka消息消费者失败:%s", err) | 28 | logs.Error("启动kafka消息消费者失败:%s", err) |
28 | } | 29 | } |
30 | + wg := &sync.WaitGroup{} | ||
31 | + wg.Add(1) | ||
29 | go func() { | 32 | go func() { |
30 | consumerRun.Start(ctx) | 33 | consumerRun.Start(ctx) |
34 | + wg.Done() | ||
31 | }() | 35 | }() |
32 | go func() { | 36 | go func() { |
33 | <-consumerRun.IsReady() | 37 | <-consumerRun.IsReady() |
@@ -37,6 +41,7 @@ func main() { | @@ -37,6 +41,7 @@ func main() { | ||
37 | select { | 41 | select { |
38 | case <-sigs: | 42 | case <-sigs: |
39 | cancel() | 43 | cancel() |
44 | + wg.wait() | ||
40 | return | 45 | return |
41 | default: | 46 | default: |
42 | } | 47 | } |
@@ -51,7 +51,7 @@ func (s SyncOrderService) SyncOrderFromBestshop(cmd command.CreateOrderFromBests | @@ -51,7 +51,7 @@ func (s SyncOrderService) SyncOrderFromBestshop(cmd command.CreateOrderFromBests | ||
51 | } | 51 | } |
52 | ok, err := orderBestshopDao.OrderExist(cmd.OrderCode) | 52 | ok, err := orderBestshopDao.OrderExist(cmd.OrderCode) |
53 | if err != nil { | 53 | if err != nil { |
54 | - return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error()) | 54 | + return lib.ThrowError(lib.TRANSACTION_ERROR, "orderBestshopDao.OrderExist err:"+err.Error()) |
55 | } | 55 | } |
56 | if ok { | 56 | if ok { |
57 | logs.Info("订单已存在,order_code=%s", cmd.OrderCode) | 57 | logs.Info("订单已存在,order_code=%s", cmd.OrderCode) |
@@ -24,7 +24,7 @@ func NewOrderBestshopDao(transactionContext *transaction.TransactionContext) (*O | @@ -24,7 +24,7 @@ func NewOrderBestshopDao(transactionContext *transaction.TransactionContext) (*O | ||
24 | func (dao OrderBestshopDao) OrderExist(orderCode string) (bool, error) { | 24 | func (dao OrderBestshopDao) OrderExist(orderCode string) (bool, error) { |
25 | tx := dao.transactionContext.GetDB() | 25 | tx := dao.transactionContext.GetDB() |
26 | m := models.OrderBestshop{} | 26 | m := models.OrderBestshop{} |
27 | - query := tx.Model(m).Where("order_code=?", orderCode) | 27 | + query := tx.Model(&m).Where("order_code=?", orderCode) |
28 | ok, err := query.Exists() | 28 | ok, err := query.Exists() |
29 | return ok, err | 29 | return ok, err |
30 | } | 30 | } |
-
请 注册 或 登录 后发表评论