作者 唐旭辉

更新

... ... @@ -4,6 +4,7 @@ import (
"context"
"os"
"os/signal"
"sync"
"syscall"
"github.com/astaxie/beego"
... ... @@ -26,8 +27,11 @@ func main() {
if err := consumerRun.InitConsumer(); err != nil {
logs.Error("启动kafka消息消费者失败:%s", err)
}
wg := &sync.WaitGroup{}
wg.Add(1)
go func() {
consumerRun.Start(ctx)
wg.Done()
}()
go func() {
<-consumerRun.IsReady()
... ... @@ -37,6 +41,7 @@ func main() {
select {
case <-sigs:
cancel()
wg.wait()
return
default:
}
... ...
... ... @@ -51,7 +51,7 @@ func (s SyncOrderService) SyncOrderFromBestshop(cmd command.CreateOrderFromBests
}
ok, err := orderBestshopDao.OrderExist(cmd.OrderCode)
if err != nil {
return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
return lib.ThrowError(lib.TRANSACTION_ERROR, "orderBestshopDao.OrderExist err:"+err.Error())
}
if ok {
logs.Info("订单已存在,order_code=%s", cmd.OrderCode)
... ...
... ... @@ -24,7 +24,7 @@ func NewOrderBestshopDao(transactionContext *transaction.TransactionContext) (*O
func (dao OrderBestshopDao) OrderExist(orderCode string) (bool, error) {
tx := dao.transactionContext.GetDB()
m := models.OrderBestshop{}
query := tx.Model(m).Where("order_code=?", orderCode)
query := tx.Model(&m).Where("order_code=?", orderCode)
ok, err := query.Exists()
return ok, err
}
... ...