From bd3a51b0a9ef019c53b42929bece97fe99e5b28f Mon Sep 17 00:00:00 2001 From: gazebo Date: Mon, 13 Aug 2018 15:50:11 +0800 Subject: [PATCH] - avoid panic in setOrederDetailFee. --- business/controller/elm/order.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/business/controller/elm/order.go b/business/controller/elm/order.go index aef73b72d..cd6da03ea 100644 --- a/business/controller/elm/order.go +++ b/business/controller/elm/order.go @@ -197,18 +197,20 @@ func (c *OrderController) GetOrder(orderID string) (order *model.GoodsOrder, err } func setOrederDetailFee(result map[string]interface{}, order *model.GoodsOrder) { - orderActivities := result["orderActivities"].([]interface{}) - for _, value := range orderActivities { - activity := value.(map[string]interface{}) - categoryId := utils.MustInterface2Int64(activity["categoryId"]) - restaurantPart := -jxutils.StandardPrice2Int(utils.MustInterface2Float64(activity["restaurantPart"])) - elemePart := -jxutils.StandardPrice2Int(utils.MustInterface2Float64(activity["elemePart"])) - if _, ok := model.ElmSkuPromotion[int(categoryId)]; ok { - order.SkuPmFee += restaurantPart - order.SkuPmSubsidy += elemePart - } else { - order.OrderPmFee += restaurantPart - order.OrderPmSubsidy += elemePart + orderActivities, ok := result["orderActivities"].([]interface{}) + if ok { + for _, value := range orderActivities { + activity := value.(map[string]interface{}) + categoryId := utils.MustInterface2Int64(activity["categoryId"]) + restaurantPart := -jxutils.StandardPrice2Int(utils.MustInterface2Float64(activity["restaurantPart"])) + elemePart := -jxutils.StandardPrice2Int(utils.MustInterface2Float64(activity["elemePart"])) + if _, ok := model.ElmSkuPromotion[int(categoryId)]; ok { + order.SkuPmFee += restaurantPart + order.SkuPmSubsidy += elemePart + } else { + order.OrderPmFee += restaurantPart + order.OrderPmSubsidy += elemePart + } } } order.PlatformFeeRate = int16(utils.MustInterface2Float64(result["serviceRate"]))