作者 唐旭辉

调试

... ... @@ -224,6 +224,7 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord
orderBestshop.Goods[i].CopyToOrderGood(&good)
good.OrderId = orderbase.Id
good.Compute()
good.CurrentBonusStatus.WartPayPartnerBonus(&good)
ordergoods = append(ordergoods, good)
}
orderbase.Goods = ordergoods
... ... @@ -292,45 +293,51 @@ func (s SyncOrderService) copyOrderBestshopToOrderBase(orderBestshop *domain.Ord
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, "获取orderBestshop(order_code=%s)数据失败,err=%s", cmd.OrderCode, err.Error())
// }
// orderData.OrderCode= cmd.OrderCode,
// orderData.OrderTime=cmd.OrderTime,
// orderData.OrderState: cmd.OrderState,
// orderData.OrderCount: cmd.OrderCount,
// orderData.OrderAmount: cmd.OrderAmount,
// orderData.CreateTime: time.Now(),
// orderData.PartnerId: cmd.PartnerId,
// BuyerName: cmd.BuyerName,
// BuyerPhone: cmd.BuyerPhone,
// BuyerAddress: cmd.BuyerAddress,
// BuyerRemark: cmd.BuyerRemark,
// BuyerId: cmd.BuyerId,
// DeliveryState: cmd.DeliveryState,
// DeliveryTime: cmd.DeliveryTime,
// IsCopy: false,
// CompanyId: cmd.CompanyId,
// }
// err = orderBestshopRepository.Add(&order)
// orderData.OrderCode = cmd.OrderCode
// orderData.OrderTime = cmd.OrderTime
// orderData.OrderState = cmd.OrderState
// orderData.OrderCount = cmd.OrderCount
// orderData.OrderAmount = cmd.OrderAmount
// orderData.PartnerId = cmd.PartnerId
// orderData.BuyerName = cmd.BuyerName
// orderData.BuyerPhone = cmd.BuyerPhone
// orderData.BuyerAddress = cmd.BuyerAddress
// orderData.BuyerRemark = cmd.BuyerRemark
// orderData.BuyerId = cmd.BuyerId
// orderData.DeliveryState = cmd.DeliveryState
// orderData.DeliveryTime = cmd.DeliveryTime
// orderData.CompanyId = cmd.CompanyId
// err = orderBestshopRepository.Edit(orderData)
// if err != nil {
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, "添加order_bestshop失败:"+err.Error())
// }
// goods := []domain.OrderGoodBestShop{}
// for i := range cmd.Goods {
// good := domain.OrderGoodBestShop{
// OrderId: order.Id,
// Sn: cmd.Goods[i].Sn,
// Bn: cmd.Goods[i].Bn,
// Name: cmd.Goods[i].Name,
// Price: cmd.Goods[i].Price,
// Nums: cmd.Goods[i].Nums,
// Amount: cmd.Goods[i].Amount,
// orderGoods, err = orderGoodBestshopRepository.Find(domain.OrderGoodBestshopFindQuery{
// OrderId: orderData.Id,
// })
// if err != nil {
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, "获取orderGoodBestshop(order_id=%s)数据失败,err=%s", orderData.Id, err.Error())
// }
// err = orderGoodBestshopRepository.Add(&good)
// for i := range orderGoods {
// var updated bool
// for ii := range cmd.Goods {
// if cmd.Goods[ii].Sn != orderGoods[i].Sn {
// continue
// }
// good := orderGoods[i]
// good.Sn= cmd.Goods[i].Sn,
// good.Bn= cmd.Goods[i].Bn,
// good.Name= cmd.Goods[i].Name,
// good.Price cmd.Goods[i].Price,
// good.Nums: cmd.Goods[i].Nums,
// good.Amount: cmd.Goods[i].Amount,
// }
// err = orderGoodBestshopRepository.Edit(&orderGoods[i])
// if err != nil {
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, "添加order_good失败:"+err.Error())
// logs.Error("更新order_good_bestshop失败:" + err.Error())
// }
// goods = append(goods, good)
// }
// order.Goods = goods
// err = transactionContext.CommitTransaction()
// if err != nil {
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -98,7 +98,7 @@ func (good OrderGoodBestShop) CopyToOrderGood(g *OrderGood) {
g.GoodCompute.PlanAmount = good.Amount
g.BonusStatus = OrderGoodWaitPay
g.CurrentBonusStatus = OrderGoodBonusWaitPay{}
g.CurrentBonusStatus.WartPayPartnerBonus(g)
return
}
... ... @@ -108,5 +108,6 @@ type OrderGoodBestshopFindQuery struct {
type OrderGoodBestshopRepository interface {
Add(order *OrderGoodBestShop) error
Edit(good *OrderGoodBestShop) error
Find(qureyOptions OrderGoodBestshopFindQuery) ([]OrderGoodBestShop, error)
}
... ...
... ... @@ -53,6 +53,22 @@ func (respository OrderGoodBestshopRepository) Add(good *domain.OrderGoodBestSho
return err
}
func (respository OrderGoodBestshopRepository) Edit(good *domain.OrderGoodBestShop) error {
tx := respository.transactionContext.GetDB()
m := models.OrderGoodBestshop{
Id: good.Id,
OrderId: good.OrderId,
Sn: good.Sn,
Bn: good.Bn,
Name: good.Name,
Price: good.Price,
Nums: good.Nums,
Amount: good.Amount,
}
_, err := tx.Model(&m).Update()
return err
}
func (respository OrderGoodBestshopRepository) Find(queryOption domain.OrderGoodBestshopFindQuery) ([]domain.OrderGoodBestShop, error) {
tx := respository.transactionContext.GetDB()
goodModels := []models.OrderGoodBestshop{}
... ...
... ... @@ -114,7 +114,11 @@ func (r *Runer) InitConsumer() error {
clusterCfg.Consumer.Offsets.Initial = sarama.OffsetOldest
clusterCfg.Group.Return.Notifications = true
clusterCfg.Version = sarama.V0_10_2_1
consumer, err := cluster.NewConsumer(r.msgConsumer.kafkaHosts, r.msgConsumer.groupId, r.msgConsumer.topics, clusterCfg)
khosts := []string{"192.168.0.252:9092"}
groupid := "partnermg_dev"
topic := []string{"topic_test"}
// consumer, err := cluster.NewConsumer(r.msgConsumer.kafkaHosts, r.msgConsumer.groupId, r.msgConsumer.topics, clusterCfg)
consumer, err := cluster.NewConsumer(khosts, groupid, topic, clusterCfg)
if err != nil {
msg := fmt.Sprintf("Create kafka consumer error: %v. config: %v", err, clusterCfg)
logs.Error(msg)
... ...