From 967fb1c16a22a1ce17b2cd6a13c2364e384405b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Mon, 11 Nov 2019 09:59:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2goodslist=E5=BE=AE=E7=9B=9Fap?= =?UTF-8?q?i=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/weimobapi/goods.go | 35 +++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/platformapi/weimobapi/goods.go b/platformapi/weimobapi/goods.go index 6f1025aa..7b9218b1 100644 --- a/platformapi/weimobapi/goods.go +++ b/platformapi/weimobapi/goods.go @@ -96,18 +96,31 @@ type GoodsInfo struct { 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, +type QueryGoodsListParam struct { + PageNum int `json:"pageNum"` + PageSize int `json:"pageSize"` + OrderBy + GoodsParameter +} + +type OrderBy struct { + Field string `json:"field"` //排序字段名: sortNum:按照sort字段排序 putAwayDate:按照上下架时间排序 salesNum:按照销量排序 availableStockNum:按照库存排序 price:按照价格排序 + Sort string `json:"sort"` //升降/降序 DESC/ASC,只能是这两个值,不区分大小写 +} + +type GoodsParameter struct { + GoodsStatus int `json:"goodsStatus"` //商品状态:0-上架中 1-下架中 2-已售罄 + GoodsClassifyID int `json:"goodsClassifyId"` //分组id + Search string `json:"search"` //搜索框输入内容商品名称 + GoodsPrice float32 `json:"goodsPrice"` +} + +func (a *API) QueryGoodsList(queryParam *QueryGoodsListParam) (goodsList []*GoodsInfo, totalCount int, err error) { + param := make(map[string]interface{}) + if queryParam != nil { + param = utils.Struct2FlatMap(queryParam) } - if orderBy != nil { - apiParams["orderBy"] = orderBy - } - if queryParameter != nil { - apiParams["queryParameter"] = queryParameter - } - result, err := a.AccessAPI("goods/queryGoodsList", apiParams) + result, err := a.AccessAPI("goods/queryGoodsList", param) if err == nil { data := result.(map[string]interface{}) totalCount = int(utils.MustInterface2Int64(data["totalCount"]))