正在显示
7 个修改的文件
包含
26 行增加
和
11 行删除
@@ -19,16 +19,16 @@ func main() { | @@ -19,16 +19,16 @@ func main() { | ||
19 | sigs := make(chan os.Signal, 1) | 19 | sigs := make(chan os.Signal, 1) |
20 | signal.Notify(sigs, os.Interrupt, os.Kill, syscall.SIGINT, syscall.SIGTERM) | 20 | signal.Notify(sigs, os.Interrupt, os.Kill, syscall.SIGINT, syscall.SIGTERM) |
21 | ctx, cancel := context.WithCancel(context.Background()) | 21 | ctx, cancel := context.WithCancel(context.Background()) |
22 | + go func() { | ||
23 | + logs.Info("应用启动") | ||
24 | + beego.Run() | ||
25 | + }() | ||
22 | closeConsumer, err := consumer.StartConsumer(ctx) | 26 | closeConsumer, err := consumer.StartConsumer(ctx) |
23 | if err != nil { | 27 | if err != nil { |
24 | fmt.Printf("启动kafka消息消费者失败 err%s \n", err) | 28 | fmt.Printf("启动kafka消息消费者失败 err%s \n", err) |
25 | logs.Error("启动kafka消息消费者失败:%s", err) | 29 | logs.Error("启动kafka消息消费者失败:%s", err) |
26 | return | 30 | return |
27 | } | 31 | } |
28 | - go func() { | ||
29 | - logs.Info("应用启动") | ||
30 | - beego.Run() | ||
31 | - }() | ||
32 | for { | 32 | for { |
33 | select { | 33 | select { |
34 | case <-sigs: | 34 | case <-sigs: |
@@ -78,7 +78,7 @@ func CreateBusinessBonusRepository(options map[string]interface{}) (domain.Busin | @@ -78,7 +78,7 @@ func CreateBusinessBonusRepository(options map[string]interface{}) (domain.Busin | ||
78 | return repository.NewBusinessBonusRepository(transactionContext) | 78 | return repository.NewBusinessBonusRepository(transactionContext) |
79 | } | 79 | } |
80 | 80 | ||
81 | -//CreateOrderGoodBestshopRepository 海鲜干货订单商品信息 | 81 | +//CreateOrderGoodBestshopRepository 小米(海鲜干货改)的订单商品信息 |
82 | func CreateOrderGoodBestshopRepository(options map[string]interface{}) (domain.OrderGoodBestshopRepository, error) { | 82 | func CreateOrderGoodBestshopRepository(options map[string]interface{}) (domain.OrderGoodBestshopRepository, error) { |
83 | var transactionContext *transaction.TransactionContext | 83 | var transactionContext *transaction.TransactionContext |
84 | if value, ok := options["transactionContext"]; ok { | 84 | if value, ok := options["transactionContext"]; ok { |
@@ -87,7 +87,7 @@ func CreateOrderGoodBestshopRepository(options map[string]interface{}) (domain.O | @@ -87,7 +87,7 @@ func CreateOrderGoodBestshopRepository(options map[string]interface{}) (domain.O | ||
87 | return repository.NewOrderGoodBestshopRepository(transactionContext) | 87 | return repository.NewOrderGoodBestshopRepository(transactionContext) |
88 | } | 88 | } |
89 | 89 | ||
90 | -//CreateOrderGoodBestshopRepository 海鲜干货订单信息 | 90 | +//CreateOrderGoodBestshopRepository 小米(海鲜干货改)订单信息 |
91 | func CreateOrderBestshopRepository(options map[string]interface{}) (domain.OrderBestshopRepository, error) { | 91 | func CreateOrderBestshopRepository(options map[string]interface{}) (domain.OrderBestshopRepository, error) { |
92 | var transactionContext *transaction.TransactionContext | 92 | var transactionContext *transaction.TransactionContext |
93 | if value, ok := options["transactionContext"]; ok { | 93 | if value, ok := options["transactionContext"]; ok { |
@@ -96,7 +96,7 @@ func CreateOrderBestshopRepository(options map[string]interface{}) (domain.Order | @@ -96,7 +96,7 @@ func CreateOrderBestshopRepository(options map[string]interface{}) (domain.Order | ||
96 | return repository.NewOrderBestshopRepository(transactionContext) | 96 | return repository.NewOrderBestshopRepository(transactionContext) |
97 | } | 97 | } |
98 | 98 | ||
99 | -//CreateOrderGoodBestshopRepository 海鲜干货订单信息 | 99 | +//CreateOrderGoodBestshopRepository小米(海鲜干货改)订单信息 |
100 | func CreateOrderLogRepository(options map[string]interface{}) (domain.OrderLogRepository, error) { | 100 | func CreateOrderLogRepository(options map[string]interface{}) (domain.OrderLogRepository, error) { |
101 | var transactionContext *transaction.TransactionContext | 101 | var transactionContext *transaction.TransactionContext |
102 | if value, ok := options["transactionContext"]; ok { | 102 | if value, ok := options["transactionContext"]; ok { |
@@ -28,13 +28,14 @@ type OrderBestShop struct { | @@ -28,13 +28,14 @@ type OrderBestShop struct { | ||
28 | //d订单总额 | 28 | //d订单总额 |
29 | OrderAmount float64 `json:"orderAmount"` | 29 | OrderAmount float64 `json:"orderAmount"` |
30 | //发货时间 | 30 | //发货时间 |
31 | - DeliveryTime time.Time `json:"deliveryTime"` | 31 | + DeliveryTime string `json:"deliveryTime"` |
32 | //创建时间 | 32 | //创建时间 |
33 | CreateTime time.Time `json:"createTime"` | 33 | CreateTime time.Time `json:"createTime"` |
34 | PartnerId int64 `json:"partnerId"` | 34 | PartnerId int64 `json:"partnerId"` |
35 | Goods []OrderGoodBestShop `json:"goods"` | 35 | Goods []OrderGoodBestShop `json:"goods"` |
36 | //是否将数据同步到 order_base ,order_good | 36 | //是否将数据同步到 order_base ,order_good |
37 | IsCopy bool `json:"isCopy"` | 37 | IsCopy bool `json:"isCopy"` |
38 | + CompanyId int64 `json:"companyId"` | ||
38 | } | 39 | } |
39 | 40 | ||
40 | func (order OrderBestShop) CopyToOrderBase(o *OrderBase) { | 41 | func (order OrderBestShop) CopyToOrderBase(o *OrderBase) { |
@@ -51,7 +52,7 @@ func (order OrderBestShop) CopyToOrderBase(o *OrderBase) { | @@ -51,7 +52,7 @@ func (order OrderBestShop) CopyToOrderBase(o *OrderBase) { | ||
51 | o.OrderCode = order.OrderCode | 52 | o.OrderCode = order.OrderCode |
52 | o.OrderCompute.PlanOrderAmount = order.OrderAmount | 53 | o.OrderCompute.PlanOrderAmount = order.OrderAmount |
53 | o.OrderCompute.PlanOrderCount = order.OrderCount | 54 | o.OrderCompute.PlanOrderCount = order.OrderCount |
54 | - o.DeliveryTime = order.DeliveryTime | 55 | + o.DeliveryTime, _ = time.Parse("2006-01-02 15:04:05", order.DeliveryTime) |
55 | return | 56 | return |
56 | } | 57 | } |
57 | 58 |
@@ -28,10 +28,11 @@ type OrderBestshop struct { | @@ -28,10 +28,11 @@ type OrderBestshop struct { | ||
28 | //d订单总额 | 28 | //d订单总额 |
29 | OrderAmount float64 | 29 | OrderAmount float64 |
30 | //发货时间 | 30 | //发货时间 |
31 | - DeliveryTime time.Time | 31 | + DeliveryTime string |
32 | //创建时间 | 32 | //创建时间 |
33 | CreateTime time.Time | 33 | CreateTime time.Time |
34 | PartnerId int64 | 34 | PartnerId int64 |
35 | //是否将数据同步到 order_base ,order_good | 35 | //是否将数据同步到 order_base ,order_good |
36 | IsCopy bool `pg:",use_zero"` | 36 | IsCopy bool `pg:",use_zero"` |
37 | + CompanyId int64 | ||
37 | } | 38 | } |
@@ -42,6 +42,7 @@ func (respository OrderBestshopRepository) transformPgModelToDomainModel(orderMo | @@ -42,6 +42,7 @@ func (respository OrderBestshopRepository) transformPgModelToDomainModel(orderMo | ||
42 | CreateTime: orderModel.CreateTime, | 42 | CreateTime: orderModel.CreateTime, |
43 | PartnerId: orderModel.PartnerId, | 43 | PartnerId: orderModel.PartnerId, |
44 | IsCopy: orderModel.IsCopy, | 44 | IsCopy: orderModel.IsCopy, |
45 | + CompanyId: orderModel.CompanyId, | ||
45 | }, nil | 46 | }, nil |
46 | } | 47 | } |
47 | 48 | ||
@@ -63,6 +64,7 @@ func (respository OrderBestshopRepository) Add(order *domain.OrderBestShop) erro | @@ -63,6 +64,7 @@ func (respository OrderBestshopRepository) Add(order *domain.OrderBestShop) erro | ||
63 | CreateTime: time.Now(), | 64 | CreateTime: time.Now(), |
64 | PartnerId: order.PartnerId, | 65 | PartnerId: order.PartnerId, |
65 | IsCopy: order.IsCopy, | 66 | IsCopy: order.IsCopy, |
67 | + CompanyId: order.CompanyId, | ||
66 | } | 68 | } |
67 | _, err := tx.Model(&m).Insert() | 69 | _, err := tx.Model(&m).Insert() |
68 | order.Id = m.Id | 70 | order.Id = m.Id |
@@ -88,6 +90,7 @@ func (respository OrderBestshopRepository) Edit(order *domain.OrderBestShop) err | @@ -88,6 +90,7 @@ func (respository OrderBestshopRepository) Edit(order *domain.OrderBestShop) err | ||
88 | CreateTime: order.CreateTime, | 90 | CreateTime: order.CreateTime, |
89 | PartnerId: order.PartnerId, | 91 | PartnerId: order.PartnerId, |
90 | IsCopy: order.IsCopy, | 92 | IsCopy: order.IsCopy, |
93 | + CompanyId: order.CompanyId, | ||
91 | } | 94 | } |
92 | _, err := tx.Model(&m).Where("id=?", order.Id).Update() | 95 | _, err := tx.Model(&m).Where("id=?", order.Id).Update() |
93 | order.Id = m.Id | 96 | order.Id = m.Id |
1 | package configs | 1 | package configs |
2 | 2 | ||
3 | +import ( | ||
4 | + "os" | ||
5 | + "strings" | ||
6 | +) | ||
7 | + | ||
3 | type MqConfig struct { | 8 | type MqConfig struct { |
4 | Servers []string `json:"servers"` | 9 | Servers []string `json:"servers"` |
5 | ConsumerId string `json:"consumerGroup"` | 10 | ConsumerId string `json:"consumerGroup"` |
@@ -8,10 +13,15 @@ type MqConfig struct { | @@ -8,10 +13,15 @@ type MqConfig struct { | ||
8 | var Cfg MqConfig | 13 | var Cfg MqConfig |
9 | 14 | ||
10 | func init() { | 15 | func init() { |
16 | + | ||
11 | Cfg = MqConfig{ | 17 | Cfg = MqConfig{ |
12 | Servers: []string{"106.52.15.41:9092"}, | 18 | Servers: []string{"106.52.15.41:9092"}, |
13 | ConsumerId: "partnermg", | 19 | ConsumerId: "partnermg", |
14 | } | 20 | } |
21 | + if os.Getenv("KAFKA_HOST") != "" { | ||
22 | + kafkaHost := os.Getenv("KAFKA_HOST") | ||
23 | + Cfg.Servers = strings.Split(kafkaHost, ";") | ||
24 | + } | ||
15 | } | 25 | } |
16 | 26 | ||
17 | // "192.168.190.136:9092", | 27 | // "192.168.190.136:9092", |
@@ -16,5 +16,5 @@ var TopicHandleRouters = map[string]TopicHandle{ | @@ -16,5 +16,5 @@ var TopicHandleRouters = map[string]TopicHandle{ | ||
16 | message.Timestamp, message.Topic, message.Offset, string(message.Value)) | 16 | message.Timestamp, message.Topic, message.Offset, string(message.Value)) |
17 | return nil | 17 | return nil |
18 | }, | 18 | }, |
19 | - "bestshop_order": SyncBestshopOrder, | 19 | + "xiangmi-orders": SyncBestshopOrder, |
20 | } | 20 | } |
-
请 注册 或 登录 后发表评论