作者 唐旭辉

bug 修复

... ... @@ -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{}{
... ...
... ... @@ -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.PartnerBonusPercent)).Div(decimal.NewFromInt(100)) //price*planGoodNumber*PartnerBonusPercent
planPartnerBonus := planamount.Mul(decimal.NewFromFloat(partnerBonusPercent)).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()
}
... ...
... ... @@ -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
}
... ...
... ... @@ -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)
... ...
... ... @@ -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() {
... ...