-
Notifications
You must be signed in to change notification settings - Fork 7
/
商品-获取实时库存.go
executable file
·58 lines (49 loc) · 1.38 KB
/
商品-获取实时库存.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
56
57
58
package apis
import (
"encoding/json"
)
// 获取实时库存
// 文档:https://developers.weixin.qq.com/doc/channels/API/product/get_stock.html
type ReqProductStockGet struct {
ProductId string `json:"product_id"`
SkuId string `json:"sku_id"`
}
var _ bodyer = ReqProductStockGet{}
func (x ReqProductStockGet) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}
type RespProductStockGet struct {
Data struct {
NormalStockNum int `json:"normal_stock_num"`
LimitedDiscountStockNum int `json:"limited_discount_stock_num"`
WarehouseStocks []struct {
OutWarehouseId string `json:"out_warehouse_id"`
Num int `json:"num"`
} `json:"warehouse_stocks"`
TotalStockNum int `json:"total_stock_num"`
} `json:"data"`
CommonResp
}
var _ bodyer = RespProductStockGet{}
func (x RespProductStockGet) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}
func (c *ApiClient) ExecProductStockGet(req ReqProductStockGet) (RespProductStockGet, error) {
var resp RespProductStockGet
err := c.executeWXApiPost("/channels/ec/product/stock/get", req, &resp, true)
if err != nil {
return RespProductStockGet{}, err
}
if bizErr := resp.TryIntoErr(); bizErr != nil {
return RespProductStockGet{}, bizErr
}
return resp, nil
}