diff --git a/platformapi/weimobapi/goods.go b/platformapi/weimobapi/goods.go index aafd0f51..6f1025aa 100644 --- a/platformapi/weimobapi/goods.go +++ b/platformapi/weimobapi/goods.go @@ -77,7 +77,26 @@ type DeliveryType struct { Selected bool `json:"selected"` } -func (a *API) QueryGoodsList(pageNum, pageSize int, orderBy []map[string]interface{}, queryParameter map[string]interface{}) (retVal []map[string]interface{}, totalCount int, err error) { +type GoodsInfo struct { + AvaliableStockNum int `json:"avaliableStockNum"` + DefaultImageURL string `json:"defaultImageUrl"` + ExistEmptyStock bool `json:"existEmptyStock"` + GoodsID int64 `json:"goodsId"` + IsAllStockEmpty bool `json:"isAllStockEmpty"` + IsCanSell bool `json:"isCanSell"` + IsExistEmptyStock bool `json:"isExistEmptyStock"` + IsMultiSku int `json:"isMultiSku"` + IsPutAway int `json:"isPutAway"` + MaxPrice float64 `json:"maxPrice"` + MinPrice float64 `json:"minPrice"` + PutAwayDate int64 `json:"putAwayDate"` + PutAwayForBackend int `json:"putAwayForBackend"` + SalesNum int `json:"salesNum"` + SortNum int `json:"sortNum"` + Title string `json:"title"` +} + +func (a *API) QueryGoodsList(pageNum, pageSize int, orderBy []map[string]interface{}, queryParameter map[string]interface{}) (goodsList []*GoodsInfo, totalCount int, err error) { apiParams := map[string]interface{}{ "pageNum": pageNum, "pageSize": pageSize, @@ -90,13 +109,11 @@ func (a *API) QueryGoodsList(pageNum, pageSize int, orderBy []map[string]interfa } result, err := a.AccessAPI("goods/queryGoodsList", apiParams) if err == nil { - if pageList, ok := result.(map[string]interface{})["pageList"].([]interface{}); ok { - retVal = utils.Slice2MapSlice(pageList) - } - totalCount = int(utils.MustInterface2Int64(result.(map[string]interface{})["totalCount"])) - return retVal, totalCount, nil + data := result.(map[string]interface{}) + totalCount = int(utils.MustInterface2Int64(data["totalCount"])) + err = utils.Map2StructByJson(data["pageList"], &goodsList, false) } - return nil, 0, err + return goodsList, totalCount, err } func (a *API) QueryGoodsDetail(goodsId int64) (retVal map[string]interface{}, err error) {