切换导航条
此项目
正在载入...
登录
mmm-go
/
partnermg
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
唐旭辉
5 years ago
提交
d8ef03342a45b431f5bdf2bd3c7df7944cae27a3
1 个父辈
4debd391
bug 修复
隐藏空白字符变更
内嵌
并排对比
正在显示
5 个修改的文件
包含
61 行增加
和
45 行删除
pkg/application/orderinfo/service/order_info.go
pkg/domain/order_good.go
pkg/infrastructure/dao/pg_order_base_dao.go
pkg/port/consumer/produce/produce.go
pkg/port/consumer/topic_handle_router.go
pkg/application/orderinfo/service/order_info.go
查看文件 @
d8ef033
...
...
@@ -907,30 +907,9 @@ func (service OrderInfoService) buildOrderBestshopInfoData(orderBase *domain.Ord
goodid
:=
orderBestshop
.
Goods
[
i
]
.
Id
orderGoodBestshopMap
[
goodid
]
=
&
orderBestshop
.
Goods
[
i
]
}
//订单描述
order
:=
map
[
string
]
interface
{}{
"orderId"
:
orderBase
.
Id
,
"orderState"
:
orderBestshop
.
OrderState
,
"customers"
:
orderBestshop
.
BuyerName
,
"address"
:
orderBestshop
.
BuyerAddress
,
"remarks"
:
orderBestshop
.
BuyerRemark
,
"partner"
:
orderBase
.
PartnerInfo
.
PartnerName
,
"phone"
:
orderBestshop
.
BuyerPhone
,
"orderTime"
:
orderBestshop
.
OrderTime
,
"shippingStatus"
:
orderBestshop
.
DeliveryState
,
"partnerDividends"
:
orderBase
.
GetCurrentPartnerBonus
(),
"receivedDividends"
:
orderBase
.
OrderCompute
.
PartnerBonusHas
,
"notReceivedDividend"
:
orderBase
.
OrderCompute
.
PartnerBonusNot
,
"dividendSpending"
:
orderBase
.
OrderCompute
.
PartnerBonusExpense
,
"orderNumber"
:
orderBase
.
OrderCode
,
}
//订单中的商品
product
:=
map
[
string
]
interface
{}{
"orderNumCount"
:
orderBase
.
GetCurrentOrderCount
(),
"partnerDividendsCount"
:
orderBase
.
GetCurrentPartnerBonus
(),
"orderAmountAdjustmentCount"
:
orderBase
.
GetCurrentOrderAmount
(),
}
productDetail
:=
[]
map
[
string
]
interface
{}{}
var
hasPartnerBonusPercent
bool
for
i
:=
range
orderBase
.
Goods
{
detail
:=
map
[
string
]
interface
{}{
"commodityName"
:
orderBase
.
Goods
[
i
]
.
GoodName
,
...
...
@@ -944,6 +923,10 @@ func (service OrderInfoService) buildOrderBestshopInfoData(orderBase *domain.Ord
"paymentStatus"
:
orderBase
.
Goods
[
i
]
.
BonusStatus
,
"partnerRatio"
:
orderBase
.
Goods
[
i
]
.
PartnerBonusPercent
,
}
// if orderBase.Goods[i].PartnerBonusPercent >= 0 {
// hasPartnerBonusPercent = true
// detail["partnerRatio"] = fmt.Sprint(orderBase.Goods[i].PartnerBonusPercent)
// }
goodBestshopId
:=
orderBase
.
Goods
[
i
]
.
DataFrom
.
DataId
if
v
,
ok
:=
orderGoodBestshopMap
[
goodBestshopId
];
ok
{
detail
[
"productCodes"
]
=
v
.
Sn
...
...
@@ -951,7 +934,35 @@ func (service OrderInfoService) buildOrderBestshopInfoData(orderBase *domain.Ord
}
productDetail
=
append
(
productDetail
,
detail
)
}
product
[
"detail"
]
=
productDetail
product
:=
map
[
string
]
interface
{}{
"orderNumCount"
:
orderBase
.
GetCurrentOrderCount
(),
"partnerDividendsCount"
:
orderBase
.
GetCurrentPartnerBonus
(),
"orderAmountAdjustmentCount"
:
orderBase
.
GetCurrentOrderAmount
(),
"detail"
:
productDetail
,
}
//订单描述
order
:=
map
[
string
]
interface
{}{
"orderId"
:
orderBase
.
Id
,
"orderState"
:
orderBestshop
.
OrderState
,
"customers"
:
orderBestshop
.
BuyerName
,
"address"
:
orderBestshop
.
BuyerAddress
,
"remarks"
:
orderBestshop
.
BuyerRemark
,
"partner"
:
orderBase
.
PartnerInfo
.
PartnerName
,
"phone"
:
orderBestshop
.
BuyerPhone
,
"orderTime"
:
orderBestshop
.
OrderTime
,
"shippingStatus"
:
orderBestshop
.
DeliveryState
,
"partnerDividends"
:
"-"
,
"receivedDividends"
:
"-"
,
"notReceivedDividend"
:
"-"
,
"dividendSpending"
:
"-"
,
"orderNumber"
:
orderBase
.
OrderCode
,
}
if
hasPartnerBonusPercent
{
order
[
"partnerDividends"
]
=
fmt
.
Sprint
(
orderBase
.
GetCurrentPartnerBonus
())
order
[
"receivedDividends"
]
=
fmt
.
Sprint
(
orderBase
.
OrderCompute
.
PartnerBonusHas
)
order
[
"notReceivedDividend"
]
=
fmt
.
Sprint
(
orderBase
.
OrderCompute
.
PartnerBonusNot
)
order
[
"dividendSpending"
]
=
fmt
.
Sprint
(
orderBase
.
OrderCompute
.
PartnerBonusExpense
)
}
modifyLog
:=
[]
map
[
string
]
interface
{}{}
for
i
:=
range
orderLogs
{
m
:=
map
[
string
]
interface
{}{
...
...
pkg/domain/order_good.go
查看文件 @
d8ef033
...
...
@@ -197,8 +197,9 @@ func (hasPay OrderGoodBonusHasPay) WartPayPartnerBonus(good *OrderGood) error {
//NewOrderGood 初始值设定
func
NewOrderGood
()
OrderGood
{
return
OrderGood
{
UseGoodNumber
:
-
1
,
BonusStatus
:
OrderGoodWaitPay
,
UseGoodNumber
:
-
1
,
BonusStatus
:
OrderGoodWaitPay
,
PartnerBonusPercent
:
-
1
,
GoodCompute
:
GoodCompute
{
UsePartnerBonus
:
-
1
,
UseAmount
:
-
1
,
...
...
@@ -213,8 +214,12 @@ func (good *OrderGood) Compute() error {
//计算预计合伙人分红
price
:=
decimal
.
NewFromFloat
(
good
.
Price
)
planamount
:=
price
.
Mul
(
decimal
.
NewFromInt
(
int64
(
good
.
PlanGoodNumber
)))
//price*planGoodNumber
var
partnerBonusPercent
float64
if
good
.
PartnerBonusPercent
<
0
{
partnerBonusPercent
=
0
}
//price*useGoodNumber
planPartnerBonus
:=
planamount
.
Mul
(
decimal
.
NewFromFloat
(
good
.
P
artnerBonusPercent
))
.
Div
(
decimal
.
NewFromInt
(
100
))
//price*planGoodNumber*PartnerBonusPercent
planPartnerBonus
:=
planamount
.
Mul
(
decimal
.
NewFromFloat
(
p
artnerBonusPercent
))
.
Div
(
decimal
.
NewFromInt
(
100
))
//price*planGoodNumber*PartnerBonusPercent
good
.
GoodCompute
.
PlanAmount
,
_
=
planamount
.
Round
(
2
)
.
BigFloat
()
.
Float64
()
good
.
GoodCompute
.
PlanPartnerBonus
,
_
=
planPartnerBonus
.
Round
(
2
)
.
BigFloat
()
.
Float64
()
if
good
.
UseGoodNumber
<
0
{
...
...
@@ -224,8 +229,8 @@ func (good *OrderGood) Compute() error {
}
else
{
//计算调整后的货品总值
//计算调整后的合伙人分红
useamount
:=
price
.
Mul
(
decimal
.
NewFromInt
(
int64
(
good
.
UseGoodNumber
)))
//price*useGoodNumber/price*useGoodNumber
usePartnerBonus
:=
useamount
.
Mul
(
decimal
.
NewFromFloat
(
good
.
PartnerBonusPercent
))
.
Div
(
decimal
.
NewFromInt
(
100
))
//price*useGoodNumber*PartnerBonusPercent
useamount
:=
price
.
Mul
(
decimal
.
NewFromInt
(
int64
(
good
.
UseGoodNumber
)))
//price*useGoodNumber/price*useGoodNumber
usePartnerBonus
:=
useamount
.
Mul
(
decimal
.
NewFromFloat
(
partnerBonusPercent
))
.
Div
(
decimal
.
NewFromInt
(
100
))
//price*useGoodNumber*PartnerBonusPercent
good
.
GoodCompute
.
UsePartnerBonus
,
_
=
usePartnerBonus
.
Round
(
2
)
.
BigFloat
()
.
Float64
()
good
.
GoodCompute
.
UseAmount
,
_
=
useamount
.
Round
(
2
)
.
BigFloat
()
.
Float64
()
}
...
...
pkg/infrastructure/dao/pg_order_base_dao.go
查看文件 @
d8ef033
...
...
@@ -67,7 +67,10 @@ func (dao OrderBaseDao) OrderBonusListByCondition(companyId int64, orderType int
return
q
,
nil
})
}
query
=
query
.
Offset
(
offset
)
.
Limit
(
limit
)
query
=
query
.
Order
(
"order_base.update_time DESC"
)
.
Offset
(
offset
)
.
Limit
(
limit
)
cnt
,
err
:=
query
.
SelectAndCount
()
return
orders
,
cnt
,
err
}
...
...
pkg/port/consumer/produce/produce.go
查看文件 @
d8ef033
...
...
@@ -11,12 +11,14 @@ import (
"github.com/astaxie/beego/logs"
)
var
(
producer
sarama
.
SyncProducer
)
func
init
()
{
// var (
// producer sarama.SyncProducer
// )
func
produce
(
topic
string
,
key
string
,
content
string
)
error
{
var
(
producer
sarama
.
SyncProducer
)
logs
.
Info
(
"init kafka producer, it may take a few seconds to init the connection
\n
"
)
var
err
error
mqConfig
:=
sarama
.
NewConfig
()
...
...
@@ -34,10 +36,6 @@ func init() {
logs
.
Info
(
msg
)
panic
(
msg
)
}
}
func
produce
(
topic
string
,
key
string
,
content
string
)
error
{
msg
:=
&
sarama
.
ProducerMessage
{
Topic
:
topic
,
Key
:
sarama
.
StringEncoder
(
key
),
...
...
@@ -45,7 +43,7 @@ func produce(topic string, key string, content string) error {
Timestamp
:
time
.
Now
(),
}
_
,
_
,
err
:
=
producer
.
SendMessage
(
msg
)
_
,
_
,
err
=
producer
.
SendMessage
(
msg
)
if
err
!=
nil
{
msg
:=
fmt
.
Sprintf
(
"Send Error topic: %v. key: %v. content: %v"
,
topic
,
key
,
content
)
logs
.
Info
(
msg
)
...
...
pkg/port/consumer/topic_handle_router.go
查看文件 @
d8ef033
...
...
@@ -4,7 +4,6 @@ import (
"os"
"github.com/Shopify/sarama"
"github.com/astaxie/beego/logs"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/port/consumer/handles"
)
...
...
@@ -13,11 +12,11 @@ type TopicHandle func(*sarama.ConsumerMessage) error
//TopicHandleRouters 根据topic区分消息并进行处理
var
TopicHandleRouters
=
map
[
string
]
TopicHandle
{
"topic_test"
:
func
(
message
*
sarama
.
ConsumerMessage
)
error
{
logs
.
Info
(
"Done Message claimed: timestamp = %v, topic = %s offset = %v value = %v
\n
"
,
message
.
Timestamp
,
message
.
Topic
,
message
.
Offset
,
string
(
message
.
Value
))
return
nil
},
// "topic_test": func(message *sarama.ConsumerMessage) error {
// logs.Info("Done Message claimed: timestamp = %v, topic = %s offset = %v value = %v \n",
// message.Timestamp, message.Topic, message.Offset, string(message.Value))
// return nil
// },
}
func
init
()
{
...
...
请
注册
或
登录
后发表评论