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 +}