From af0896eda9a8fa2a288aea6077d23176d22c9b38 Mon Sep 17 00:00:00 2001 From: gazebo Date: Wed, 7 Nov 2018 11:18:16 +0800 Subject: [PATCH] - retrieve errmsg from data in funcs createPromotionSku --- platformapi/jdapi/jdapi.go | 2 +- platformapi/jdapi/promotion.go | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/platformapi/jdapi/jdapi.go b/platformapi/jdapi/jdapi.go index e74cc5c5..2a9ec26b 100644 --- a/platformapi/jdapi/jdapi.go +++ b/platformapi/jdapi/jdapi.go @@ -215,7 +215,7 @@ func genNoPageResultParser(codeKey, msgKey, resultKey, okCode string) func(data return nil, nil } if msg, ok := data[msgKey]; ok { - errMsg := msg.(string) + errMsg := utils.Format4Output(msg, true) if innerCode == ResponseInnerCodePartialFailed { errMsg += ", " + utils.Format4Output(data[resultKey], true) } diff --git a/platformapi/jdapi/promotion.go b/platformapi/jdapi/promotion.go index 7f32674c..e8af6e06 100644 --- a/platformapi/jdapi/promotion.go +++ b/platformapi/jdapi/promotion.go @@ -68,7 +68,7 @@ func (a *API) CreatePromotionRules(infoId int64, outInfoId string, limitDevice, } else { jdParams[KeyOutInfoId] = outInfoId } - _, err = a.AccessAPINoPage("limitTime/createPromotionRules", jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "data", "0")) + _, err = a.AccessAPINoPage("limitTime/createPromotionRules", jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "", "0")) return err } @@ -119,6 +119,7 @@ func (a *API) createPromotionInfos(promotionType int, name string, beginDate, en return 0, err } +// todo skusResult 返回值没有意义,为了兼容暂时保留 func (a *API) createPromotionSku(promotionType int, infoId int64, outInfoId string, skus []map[string]interface{}) (skusResult []map[string]interface{}, err error) { jdParams := map[string]interface{}{ "skus": skus, @@ -137,13 +138,7 @@ func (a *API) createPromotionSku(promotionType int, infoId int64, outInfoId stri } else { panic("unknow promotionType!") } - result, err := a.AccessAPINoPage(cmd, jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "data", "0")) - if err == nil { - if result != nil { - return utils.Slice2MapSlice(result.([]interface{})), nil - } - return nil, nil - } + _, err = a.AccessAPINoPage(cmd, jdParams, nil, nil, genNoPageResultParser("errorCode", "data", "", "0")) return nil, err } @@ -164,7 +159,7 @@ func (a *API) confirmPromotion(promotionType int, infoId int64, outInfoId string } else { panic("unknow promotionType!") } - _, err = a.AccessAPINoPage(cmd, jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "data", "0")) + _, err = a.AccessAPINoPage(cmd, jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "", "0")) return err } @@ -185,6 +180,6 @@ func (a *API) cancelPromotion(promotionType int, infoId int64, outInfoId string) } else { panic("unknow promotionType!") } - _, err = a.AccessAPINoPage(cmd, jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "data", "0")) + _, err = a.AccessAPINoPage(cmd, jdParams, nil, nil, genNoPageResultParser("errorCode", "errorInfos", "", "0")) return err }