- avoid panic in setOrederDetailFee.

This commit is contained in:
gazebo
2018-08-13 15:50:11 +08:00
parent ff1d223933
commit bd3a51b0a9

View File

@@ -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"]))