- retrieve errmsg from data in funcs createPromotionSku

This commit is contained in:
gazebo
2018-11-07 11:18:16 +08:00
parent 09bb22a8a6
commit af0896eda9
2 changed files with 6 additions and 11 deletions

View File

@@ -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)
}

View File

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