作者 唐旭辉

bug 修复

@@ -907,30 +907,9 @@ func (service OrderInfoService) buildOrderBestshopInfoData(orderBase *domain.Ord @@ -907,30 +907,9 @@ func (service OrderInfoService) buildOrderBestshopInfoData(orderBase *domain.Ord
907 goodid := orderBestshop.Goods[i].Id 907 goodid := orderBestshop.Goods[i].Id
908 orderGoodBestshopMap[goodid] = &orderBestshop.Goods[i] 908 orderGoodBestshopMap[goodid] = &orderBestshop.Goods[i]
909 } 909 }
910 - //订单描述  
911 - order := map[string]interface{}{  
912 - "orderId": orderBase.Id,  
913 - "orderState": orderBestshop.OrderState,  
914 - "customers": orderBestshop.BuyerName,  
915 - "address": orderBestshop.BuyerAddress,  
916 - "remarks": orderBestshop.BuyerRemark,  
917 - "partner": orderBase.PartnerInfo.PartnerName,  
918 - "phone": orderBestshop.BuyerPhone,  
919 - "orderTime": orderBestshop.OrderTime,  
920 - "shippingStatus": orderBestshop.DeliveryState,  
921 - "partnerDividends": orderBase.GetCurrentPartnerBonus(),  
922 - "receivedDividends": orderBase.OrderCompute.PartnerBonusHas,  
923 - "notReceivedDividend": orderBase.OrderCompute.PartnerBonusNot,  
924 - "dividendSpending": orderBase.OrderCompute.PartnerBonusExpense,  
925 - "orderNumber": orderBase.OrderCode,  
926 - }  
927 //订单中的商品 910 //订单中的商品
928 - product := map[string]interface{}{  
929 - "orderNumCount": orderBase.GetCurrentOrderCount(),  
930 - "partnerDividendsCount": orderBase.GetCurrentPartnerBonus(),  
931 - "orderAmountAdjustmentCount": orderBase.GetCurrentOrderAmount(),  
932 - }  
933 productDetail := []map[string]interface{}{} 911 productDetail := []map[string]interface{}{}
  912 + var hasPartnerBonusPercent bool
934 for i := range orderBase.Goods { 913 for i := range orderBase.Goods {
935 detail := map[string]interface{}{ 914 detail := map[string]interface{}{
936 "commodityName": orderBase.Goods[i].GoodName, 915 "commodityName": orderBase.Goods[i].GoodName,
@@ -944,6 +923,10 @@ func (service OrderInfoService) buildOrderBestshopInfoData(orderBase *domain.Ord @@ -944,6 +923,10 @@ func (service OrderInfoService) buildOrderBestshopInfoData(orderBase *domain.Ord
944 "paymentStatus": orderBase.Goods[i].BonusStatus, 923 "paymentStatus": orderBase.Goods[i].BonusStatus,
945 "partnerRatio": orderBase.Goods[i].PartnerBonusPercent, 924 "partnerRatio": orderBase.Goods[i].PartnerBonusPercent,
946 } 925 }
  926 + // if orderBase.Goods[i].PartnerBonusPercent >= 0 {
  927 + // hasPartnerBonusPercent = true
  928 + // detail["partnerRatio"] = fmt.Sprint(orderBase.Goods[i].PartnerBonusPercent)
  929 + // }
947 goodBestshopId := orderBase.Goods[i].DataFrom.DataId 930 goodBestshopId := orderBase.Goods[i].DataFrom.DataId
948 if v, ok := orderGoodBestshopMap[goodBestshopId]; ok { 931 if v, ok := orderGoodBestshopMap[goodBestshopId]; ok {
949 detail["productCodes"] = v.Sn 932 detail["productCodes"] = v.Sn
@@ -951,7 +934,35 @@ func (service OrderInfoService) buildOrderBestshopInfoData(orderBase *domain.Ord @@ -951,7 +934,35 @@ func (service OrderInfoService) buildOrderBestshopInfoData(orderBase *domain.Ord
951 } 934 }
952 productDetail = append(productDetail, detail) 935 productDetail = append(productDetail, detail)
953 } 936 }
954 - product["detail"] = productDetail 937 + product := map[string]interface{}{
  938 + "orderNumCount": orderBase.GetCurrentOrderCount(),
  939 + "partnerDividendsCount": orderBase.GetCurrentPartnerBonus(),
  940 + "orderAmountAdjustmentCount": orderBase.GetCurrentOrderAmount(),
  941 + "detail": productDetail,
  942 + }
  943 + //订单描述
  944 + order := map[string]interface{}{
  945 + "orderId": orderBase.Id,
  946 + "orderState": orderBestshop.OrderState,
  947 + "customers": orderBestshop.BuyerName,
  948 + "address": orderBestshop.BuyerAddress,
  949 + "remarks": orderBestshop.BuyerRemark,
  950 + "partner": orderBase.PartnerInfo.PartnerName,
  951 + "phone": orderBestshop.BuyerPhone,
  952 + "orderTime": orderBestshop.OrderTime,
  953 + "shippingStatus": orderBestshop.DeliveryState,
  954 + "partnerDividends": "-",
  955 + "receivedDividends": "-",
  956 + "notReceivedDividend": "-",
  957 + "dividendSpending": "-",
  958 + "orderNumber": orderBase.OrderCode,
  959 + }
  960 + if hasPartnerBonusPercent {
  961 + order["partnerDividends"] = fmt.Sprint(orderBase.GetCurrentPartnerBonus())
  962 + order["receivedDividends"] = fmt.Sprint(orderBase.OrderCompute.PartnerBonusHas)
  963 + order["notReceivedDividend"] = fmt.Sprint(orderBase.OrderCompute.PartnerBonusNot)
  964 + order["dividendSpending"] = fmt.Sprint(orderBase.OrderCompute.PartnerBonusExpense)
  965 + }
955 modifyLog := []map[string]interface{}{} 966 modifyLog := []map[string]interface{}{}
956 for i := range orderLogs { 967 for i := range orderLogs {
957 m := map[string]interface{}{ 968 m := map[string]interface{}{
@@ -199,6 +199,7 @@ func NewOrderGood() OrderGood { @@ -199,6 +199,7 @@ func NewOrderGood() OrderGood {
199 return OrderGood{ 199 return OrderGood{
200 UseGoodNumber: -1, 200 UseGoodNumber: -1,
201 BonusStatus: OrderGoodWaitPay, 201 BonusStatus: OrderGoodWaitPay,
  202 + PartnerBonusPercent: -1,
202 GoodCompute: GoodCompute{ 203 GoodCompute: GoodCompute{
203 UsePartnerBonus: -1, 204 UsePartnerBonus: -1,
204 UseAmount: -1, 205 UseAmount: -1,
@@ -213,8 +214,12 @@ func (good *OrderGood) Compute() error { @@ -213,8 +214,12 @@ func (good *OrderGood) Compute() error {
213 //计算预计合伙人分红 214 //计算预计合伙人分红
214 price := decimal.NewFromFloat(good.Price) 215 price := decimal.NewFromFloat(good.Price)
215 planamount := price.Mul(decimal.NewFromInt(int64(good.PlanGoodNumber))) //price*planGoodNumber 216 planamount := price.Mul(decimal.NewFromInt(int64(good.PlanGoodNumber))) //price*planGoodNumber
  217 + var partnerBonusPercent float64
  218 + if good.PartnerBonusPercent < 0 {
  219 + partnerBonusPercent = 0
  220 + }
216 //price*useGoodNumber 221 //price*useGoodNumber
217 - planPartnerBonus := planamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)).Div(decimal.NewFromInt(100)) //price*planGoodNumber*PartnerBonusPercent 222 + planPartnerBonus := planamount.Mul(decimal.NewFromFloat(partnerBonusPercent)).Div(decimal.NewFromInt(100)) //price*planGoodNumber*PartnerBonusPercent
218 good.GoodCompute.PlanAmount, _ = planamount.Round(2).BigFloat().Float64() 223 good.GoodCompute.PlanAmount, _ = planamount.Round(2).BigFloat().Float64()
219 good.GoodCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).BigFloat().Float64() 224 good.GoodCompute.PlanPartnerBonus, _ = planPartnerBonus.Round(2).BigFloat().Float64()
220 if good.UseGoodNumber < 0 { 225 if good.UseGoodNumber < 0 {
@@ -225,7 +230,7 @@ func (good *OrderGood) Compute() error { @@ -225,7 +230,7 @@ func (good *OrderGood) Compute() error {
225 //计算调整后的货品总值 230 //计算调整后的货品总值
226 //计算调整后的合伙人分红 231 //计算调整后的合伙人分红
227 useamount := price.Mul(decimal.NewFromInt(int64(good.UseGoodNumber))) //price*useGoodNumber/price*useGoodNumber 232 useamount := price.Mul(decimal.NewFromInt(int64(good.UseGoodNumber))) //price*useGoodNumber/price*useGoodNumber
228 - usePartnerBonus := useamount.Mul(decimal.NewFromFloat(good.PartnerBonusPercent)).Div(decimal.NewFromInt(100)) //price*useGoodNumber*PartnerBonusPercent 233 + usePartnerBonus := useamount.Mul(decimal.NewFromFloat(partnerBonusPercent)).Div(decimal.NewFromInt(100)) //price*useGoodNumber*PartnerBonusPercent
229 good.GoodCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).BigFloat().Float64() 234 good.GoodCompute.UsePartnerBonus, _ = usePartnerBonus.Round(2).BigFloat().Float64()
230 good.GoodCompute.UseAmount, _ = useamount.Round(2).BigFloat().Float64() 235 good.GoodCompute.UseAmount, _ = useamount.Round(2).BigFloat().Float64()
231 } 236 }
@@ -67,7 +67,10 @@ func (dao OrderBaseDao) OrderBonusListByCondition(companyId int64, orderType int @@ -67,7 +67,10 @@ func (dao OrderBaseDao) OrderBonusListByCondition(companyId int64, orderType int
67 return q, nil 67 return q, nil
68 }) 68 })
69 } 69 }
70 - query = query.Offset(offset).Limit(limit) 70 + query = query.Order("order_base.update_time DESC").
  71 + Offset(offset).
  72 + Limit(limit)
  73 +
71 cnt, err := query.SelectAndCount() 74 cnt, err := query.SelectAndCount()
72 return orders, cnt, err 75 return orders, cnt, err
73 } 76 }
@@ -11,12 +11,14 @@ import ( @@ -11,12 +11,14 @@ import (
11 "github.com/astaxie/beego/logs" 11 "github.com/astaxie/beego/logs"
12 ) 12 )
13 13
14 -var (  
15 - producer sarama.SyncProducer  
16 -)  
17 -  
18 -func init() { 14 +// var (
  15 +// producer sarama.SyncProducer
  16 +// )
19 17
  18 +func produce(topic string, key string, content string) error {
  19 + var (
  20 + producer sarama.SyncProducer
  21 + )
20 logs.Info("init kafka producer, it may take a few seconds to init the connection\n") 22 logs.Info("init kafka producer, it may take a few seconds to init the connection\n")
21 var err error 23 var err error
22 mqConfig := sarama.NewConfig() 24 mqConfig := sarama.NewConfig()
@@ -34,10 +36,6 @@ func init() { @@ -34,10 +36,6 @@ func init() {
34 logs.Info(msg) 36 logs.Info(msg)
35 panic(msg) 37 panic(msg)
36 } 38 }
37 -  
38 -}  
39 -  
40 -func produce(topic string, key string, content string) error {  
41 msg := &sarama.ProducerMessage{ 39 msg := &sarama.ProducerMessage{
42 Topic: topic, 40 Topic: topic,
43 Key: sarama.StringEncoder(key), 41 Key: sarama.StringEncoder(key),
@@ -45,7 +43,7 @@ func produce(topic string, key string, content string) error { @@ -45,7 +43,7 @@ func produce(topic string, key string, content string) error {
45 Timestamp: time.Now(), 43 Timestamp: time.Now(),
46 } 44 }
47 45
48 - _, _, err := producer.SendMessage(msg) 46 + _, _, err = producer.SendMessage(msg)
49 if err != nil { 47 if err != nil {
50 msg := fmt.Sprintf("Send Error topic: %v. key: %v. content: %v", topic, key, content) 48 msg := fmt.Sprintf("Send Error topic: %v. key: %v. content: %v", topic, key, content)
51 logs.Info(msg) 49 logs.Info(msg)
@@ -4,7 +4,6 @@ import ( @@ -4,7 +4,6 @@ import (
4 "os" 4 "os"
5 5
6 "github.com/Shopify/sarama" 6 "github.com/Shopify/sarama"
7 - "github.com/astaxie/beego/logs"  
8 "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/port/consumer/handles" 7 "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/port/consumer/handles"
9 ) 8 )
10 9
@@ -13,11 +12,11 @@ type TopicHandle func(*sarama.ConsumerMessage) error @@ -13,11 +12,11 @@ type TopicHandle func(*sarama.ConsumerMessage) error
13 12
14 //TopicHandleRouters 根据topic区分消息并进行处理 13 //TopicHandleRouters 根据topic区分消息并进行处理
15 var TopicHandleRouters = map[string]TopicHandle{ 14 var TopicHandleRouters = map[string]TopicHandle{
16 - "topic_test": func(message *sarama.ConsumerMessage) error {  
17 - logs.Info("Done Message claimed: timestamp = %v, topic = %s offset = %v value = %v \n",  
18 - message.Timestamp, message.Topic, message.Offset, string(message.Value))  
19 - return nil  
20 - }, 15 + // "topic_test": func(message *sarama.ConsumerMessage) error {
  16 + // logs.Info("Done Message claimed: timestamp = %v, topic = %s offset = %v value = %v \n",
  17 + // message.Timestamp, message.Topic, message.Offset, string(message.Value))
  18 + // return nil
  19 + // },
21 } 20 }
22 21
23 func init() { 22 func init() {