-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgoods.life.cycle.go
55 lines (46 loc) · 1.52 KB
/
goods.life.cycle.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package temu
import (
"context"
"github.com/hiscaler/temu-go/entity"
"github.com/hiscaler/temu-go/normal"
)
// 商品生命周期服务
type goodsLifeCycleService service
// 货品生命周期状态
type GoodsLifeCycleQueryParams struct {
normal.ParameterWithPager
Page int `json:"pageNum"` // 页码
ProductSkuIdList []int64 `json:"productSkuIdList,omitempty"` // 货品 skuId 列表
MallId int64 `json:"mallId,omitempty"` // 商家店铺 ID
}
func (m GoodsLifeCycleQueryParams) validate() error {
return nil
}
// 查询货品生命周期状态(bg.product.search)
// https://seller.kuajingmaihuo.com/sop/view/750197804480663142#CK9soN
func (s goodsLifeCycleService) Query(ctx context.Context, params GoodsLifeCycleQueryParams) (items []entity.GoodsLifeCycle, total, totalPages int, isLastPage bool, err error) {
pager := params.TidyPager()
params.Page = pager.Page
if err = params.validate(); err != nil {
err = invalidInput(err)
return
}
var result = struct {
normal.Response
Result struct {
Total int `json:"total"`
DataList []entity.GoodsLifeCycle `json:"dataList"`
} `json:"result"`
}{}
resp, err := s.httpClient.R().
SetContext(ctx).
SetBody(params).
SetResult(&result).
Post("bg.product.search")
if err = recheckError(resp, result.Response, err); err != nil {
return
}
items = result.Result.DataList
total, totalPages, isLastPage = parseResponseTotal(params.Page, params.PageSize, result.Result.Total)
return
}