作者 唐旭辉

调试

@@ -224,6 +224,7 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord @@ -224,6 +224,7 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord
224 orderBestshop.Goods[i].CopyToOrderGood(&good) 224 orderBestshop.Goods[i].CopyToOrderGood(&good)
225 good.OrderId = orderbase.Id 225 good.OrderId = orderbase.Id
226 good.Compute() 226 good.Compute()
  227 + good.CurrentBonusStatus.WartPayPartnerBonus(&good)
227 ordergoods = append(ordergoods, good) 228 ordergoods = append(ordergoods, good)
228 } 229 }
229 orderbase.Goods = ordergoods 230 orderbase.Goods = ordergoods
@@ -292,45 +293,51 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord @@ -292,45 +293,51 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord
292 // return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, "获取orderBestshop(order_code=%s)数据失败,err=%s", cmd.OrderCode, err.Error()) 293 // return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, "获取orderBestshop(order_code=%s)数据失败,err=%s", cmd.OrderCode, err.Error())
293 // } 294 // }
294 295
295 -// orderData.OrderCode= cmd.OrderCode,  
296 -// orderData.OrderTime=cmd.OrderTime,  
297 -// orderData.OrderState: cmd.OrderState,  
298 -// orderData.OrderCount: cmd.OrderCount,  
299 -// orderData.OrderAmount: cmd.OrderAmount,  
300 -// orderData.CreateTime: time.Now(),  
301 -// orderData.PartnerId: cmd.PartnerId,  
302 -// BuyerName: cmd.BuyerName,  
303 -// BuyerPhone: cmd.BuyerPhone,  
304 -// BuyerAddress: cmd.BuyerAddress,  
305 -// BuyerRemark: cmd.BuyerRemark,  
306 -// BuyerId: cmd.BuyerId,  
307 -// DeliveryState: cmd.DeliveryState,  
308 -// DeliveryTime: cmd.DeliveryTime,  
309 -// IsCopy: false,  
310 -// CompanyId: cmd.CompanyId,  
311 -// }  
312 -// err = orderBestshopRepository.Add(&order) 296 +// orderData.OrderCode = cmd.OrderCode
  297 +// orderData.OrderTime = cmd.OrderTime
  298 +// orderData.OrderState = cmd.OrderState
  299 +// orderData.OrderCount = cmd.OrderCount
  300 +// orderData.OrderAmount = cmd.OrderAmount
  301 +// orderData.PartnerId = cmd.PartnerId
  302 +// orderData.BuyerName = cmd.BuyerName
  303 +// orderData.BuyerPhone = cmd.BuyerPhone
  304 +// orderData.BuyerAddress = cmd.BuyerAddress
  305 +// orderData.BuyerRemark = cmd.BuyerRemark
  306 +// orderData.BuyerId = cmd.BuyerId
  307 +// orderData.DeliveryState = cmd.DeliveryState
  308 +// orderData.DeliveryTime = cmd.DeliveryTime
  309 +// orderData.CompanyId = cmd.CompanyId
  310 +// err = orderBestshopRepository.Edit(orderData)
313 // if err != nil { 311 // if err != nil {
314 // return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, "添加order_bestshop失败:"+err.Error()) 312 // return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, "添加order_bestshop失败:"+err.Error())
315 // } 313 // }
316 -// goods := []domain.OrderGoodBestShop{}  
317 -// for i := range cmd.Goods {  
318 -// good := domain.OrderGoodBestShop{  
319 -// OrderId: order.Id,  
320 -// Sn: cmd.Goods[i].Sn,  
321 -// Bn: cmd.Goods[i].Bn,  
322 -// Name: cmd.Goods[i].Name,  
323 -// Price: cmd.Goods[i].Price,  
324 -// Nums: cmd.Goods[i].Nums,  
325 -// Amount: cmd.Goods[i].Amount, 314 +// orderGoods, err = orderGoodBestshopRepository.Find(domain.OrderGoodBestshopFindQuery{
  315 +// OrderId: orderData.Id,
  316 +// })
  317 +// if err != nil {
  318 +// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, "获取orderGoodBestshop(order_id=%s)数据失败,err=%s", orderData.Id, err.Error())
326 // } 319 // }
327 -// err = orderGoodBestshopRepository.Add(&good) 320 +
  321 +// for i := range orderGoods {
  322 +// var updated bool
  323 +// for ii := range cmd.Goods {
  324 +// if cmd.Goods[ii].Sn != orderGoods[i].Sn {
  325 +// continue
  326 +// }
  327 +// good := orderGoods[i]
  328 +// good.Sn= cmd.Goods[i].Sn,
  329 +// good.Bn= cmd.Goods[i].Bn,
  330 +// good.Name= cmd.Goods[i].Name,
  331 +// good.Price cmd.Goods[i].Price,
  332 +// good.Nums: cmd.Goods[i].Nums,
  333 +// good.Amount: cmd.Goods[i].Amount,
  334 +// }
  335 +// err = orderGoodBestshopRepository.Edit(&orderGoods[i])
328 // if err != nil { 336 // if err != nil {
329 -// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, "添加order_good失败:"+err.Error()) 337 +// logs.Error("更新order_good_bestshop失败:" + err.Error())
  338 +
330 // } 339 // }
331 -// goods = append(goods, good)  
332 // } 340 // }
333 -// order.Goods = goods  
334 // err = transactionContext.CommitTransaction() 341 // err = transactionContext.CommitTransaction()
335 // if err != nil { 342 // if err != nil {
336 // return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error()) 343 // return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
@@ -98,7 +98,7 @@ func (good OrderGoodBestShop) CopyToOrderGood(g *OrderGood) { @@ -98,7 +98,7 @@ func (good OrderGoodBestShop) CopyToOrderGood(g *OrderGood) {
98 g.GoodCompute.PlanAmount = good.Amount 98 g.GoodCompute.PlanAmount = good.Amount
99 g.BonusStatus = OrderGoodWaitPay 99 g.BonusStatus = OrderGoodWaitPay
100 g.CurrentBonusStatus = OrderGoodBonusWaitPay{} 100 g.CurrentBonusStatus = OrderGoodBonusWaitPay{}
101 - g.CurrentBonusStatus.WartPayPartnerBonus(g) 101 +
102 return 102 return
103 } 103 }
104 104
@@ -108,5 +108,6 @@ type OrderGoodBestshopFindQuery struct { @@ -108,5 +108,6 @@ type OrderGoodBestshopFindQuery struct {
108 108
109 type OrderGoodBestshopRepository interface { 109 type OrderGoodBestshopRepository interface {
110 Add(order *OrderGoodBestShop) error 110 Add(order *OrderGoodBestShop) error
  111 + Edit(good *OrderGoodBestShop) error
111 Find(qureyOptions OrderGoodBestshopFindQuery) ([]OrderGoodBestShop, error) 112 Find(qureyOptions OrderGoodBestshopFindQuery) ([]OrderGoodBestShop, error)
112 } 113 }
@@ -53,6 +53,22 @@ func (respository OrderGoodBestshopRepository) Add(good *domain.OrderGoodBestSho @@ -53,6 +53,22 @@ func (respository OrderGoodBestshopRepository) Add(good *domain.OrderGoodBestSho
53 return err 53 return err
54 } 54 }
55 55
  56 +func (respository OrderGoodBestshopRepository) Edit(good *domain.OrderGoodBestShop) error {
  57 + tx := respository.transactionContext.GetDB()
  58 + m := models.OrderGoodBestshop{
  59 + Id: good.Id,
  60 + OrderId: good.OrderId,
  61 + Sn: good.Sn,
  62 + Bn: good.Bn,
  63 + Name: good.Name,
  64 + Price: good.Price,
  65 + Nums: good.Nums,
  66 + Amount: good.Amount,
  67 + }
  68 + _, err := tx.Model(&m).Update()
  69 + return err
  70 +}
  71 +
56 func (respository OrderGoodBestshopRepository) Find(queryOption domain.OrderGoodBestshopFindQuery) ([]domain.OrderGoodBestShop, error) { 72 func (respository OrderGoodBestshopRepository) Find(queryOption domain.OrderGoodBestshopFindQuery) ([]domain.OrderGoodBestShop, error) {
57 tx := respository.transactionContext.GetDB() 73 tx := respository.transactionContext.GetDB()
58 goodModels := []models.OrderGoodBestshop{} 74 goodModels := []models.OrderGoodBestshop{}
@@ -114,7 +114,11 @@ func (r *Runer) InitConsumer() error { @@ -114,7 +114,11 @@ func (r *Runer) InitConsumer() error {
114 clusterCfg.Consumer.Offsets.Initial = sarama.OffsetOldest 114 clusterCfg.Consumer.Offsets.Initial = sarama.OffsetOldest
115 clusterCfg.Group.Return.Notifications = true 115 clusterCfg.Group.Return.Notifications = true
116 clusterCfg.Version = sarama.V0_10_2_1 116 clusterCfg.Version = sarama.V0_10_2_1
117 - consumer, err := cluster.NewConsumer(r.msgConsumer.kafkaHosts, r.msgConsumer.groupId, r.msgConsumer.topics, clusterCfg) 117 + khosts := []string{"192.168.0.252:9092"}
  118 + groupid := "partnermg_dev"
  119 + topic := []string{"topic_test"}
  120 + // consumer, err := cluster.NewConsumer(r.msgConsumer.kafkaHosts, r.msgConsumer.groupId, r.msgConsumer.topics, clusterCfg)
  121 + consumer, err := cluster.NewConsumer(khosts, groupid, topic, clusterCfg)
118 if err != nil { 122 if err != nil {
119 msg := fmt.Sprintf("Create kafka consumer error: %v. config: %v", err, clusterCfg) 123 msg := fmt.Sprintf("Create kafka consumer error: %v. config: %v", err, clusterCfg)
120 logs.Error(msg) 124 logs.Error(msg)