From 533c34fa48d8817953b3f2e307651f279542fb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Tue, 15 Sep 2020 17:34:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E4=BA=AC=E4=B8=9C=E8=B4=A6=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/partner/purchase/jdshop/callback.go | 34 ++++++++++++++------ 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/business/partner/purchase/jdshop/callback.go b/business/partner/purchase/jdshop/callback.go index 8db21adc9..11ddb3581 100644 --- a/business/partner/purchase/jdshop/callback.go +++ b/business/partner/purchase/jdshop/callback.go @@ -43,16 +43,18 @@ func OnCallbackMsg(msg *jdshopapi.CallBackResult) (err error) { }) case jcqapi.TopicOrderOut: utils.CallFuncAsync(func() { - order := getRealOrderID(msg.OrderID) - if order != nil { - if order.ActualPayPrice == 0 { - if jxutils.StandardPrice2Int(utils.Str2Float64(msg.OrderPayment)) == 0 { - order.ActualPayPrice = jxutils.StandardPrice2Int(utils.Str2Float64(msg.OrderTotalPrice) + utils.Str2Float64(msg.FreightPrice) - utils.Str2Float64(msg.SellerDiscount)) - } else { - order.ActualPayPrice = jxutils.StandardPrice2Int(utils.Str2Float64(msg.OrderPayment)) + orders := getAllRealOrderID(msg.OrderID) + if len(orders) > 0 { + for _, order := range orders { + if order.ActualPayPrice == 0 { + if jxutils.StandardPrice2Int(utils.Str2Float64(msg.OrderPayment)) == 0 { + order.ActualPayPrice = jxutils.StandardPrice2Int(utils.Str2Float64(msg.OrderTotalPrice) + utils.Str2Float64(msg.FreightPrice) - utils.Str2Float64(msg.SellerDiscount)) + } else { + order.ActualPayPrice = jxutils.StandardPrice2Int(utils.Str2Float64(msg.OrderPayment)) + } + order.TotalShopMoney = utils.Float64TwoInt64(float64(order.ActualPayPrice) * jdshopapi.JdsPayPercentage) + partner.CurOrderManager.UpdateOrderFields(order, []string{"ActualPayPrice", "TotalShopMoney"}) } - order.TotalShopMoney = utils.Float64TwoInt64(float64(order.ActualPayPrice) * jdshopapi.JdsPayPercentage) - partner.CurOrderManager.UpdateOrderFields(order, []string{"ActualPayPrice", "TotalShopMoney"}) } } }) @@ -255,3 +257,17 @@ func getRealOrderID(orderID string) (order *model.GoodsOrder) { dao.GetRow(db, &order, sql, sqlParams) return order } + +func getAllRealOrderID(orderID string) (orders []*model.GoodsOrder) { + var ( + db = dao.GetDB() + ) + sql := ` + SELECT * FROM goods_order WHERE vendor_order_id2 = ? + ` + sqlParams := []interface{}{ + orderID, + } + dao.GetRows(db, &orders, sql, sqlParams) + return orders +}