切换导航条
此项目
正在载入...
登录
mmm-go
/
partnermg
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
唐旭辉
5 years ago
提交
584ac67ad0c1245ef15c4cfeefb5232a2d18e8f3
1 个父辈
23657a38
调试
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
62 行增加
和
34 行删除
pkg/application/syncOrder/service/sync_order.go
pkg/domain/order_bestshop.go
pkg/infrastructure/repository/pg_order_good_bestshop_repository.go
pkg/port/consumer/consumer.go
pkg/application/syncOrder/service/sync_order.go
查看文件 @
584ac67
...
...
@@ -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())
// }
// 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.
Add(&good
)
// 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())
...
...
pkg/domain/order_bestshop.go
查看文件 @
584ac67
...
...
@@ -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
)
}
...
...
pkg/infrastructure/repository/pg_order_good_bestshop_repository.go
查看文件 @
584ac67
...
...
@@ -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
{}
...
...
pkg/port/consumer/consumer.go
查看文件 @
584ac67
...
...
@@ -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
)
...
...
请
注册
或
登录
后发表评论