-
Notifications
You must be signed in to change notification settings - Fork 7
/
商品-获取商品.go
executable file
·83 lines (74 loc) · 2.08 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package apis
import (
"encoding/json"
)
// 获取商品
// 文档:https://developers.weixin.qq.com/doc/channels/API/product/get.html
type ReqProductGet struct {
DataType int `json:"data_type"`
ProductID string `json:"product_id"`
}
var _ bodyer = ReqProductGet{}
func (x ReqProductGet) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}
type RespProductGet struct {
CommonResp
Product struct {
Attrs []struct {
AttrKey string `json:"attr_key"`
AttrValue string `json:"attr_value"`
} `json:"attrs"`
Cats []struct {
CatID string `json:"cat_id"`
} `json:"cats"`
DescInfo struct {
Imgs []string `json:"imgs"`
} `json:"desc_info"`
EditStatus int `json:"edit_status"`
ExpressInfo struct {
TemplateID string `json:"template_id"`
} `json:"express_info"`
HeadImgs []string `json:"head_imgs"`
MinPrice int `json:"min_price"`
OutProductID string `json:"out_product_id"`
ProductID string `json:"product_id"`
Skus []struct {
OutSkuID string `json:"out_sku_id"`
SalePrice int `json:"sale_price"`
SkuAttrs []interface{} `json:"sku_attrs"`
SkuCode string `json:"sku_code"`
SkuID string `json:"sku_id"`
Status int `json:"status"`
StockNum int `json:"stock_num"`
ThumbImg string `json:"thumb_img"`
} `json:"skus"`
SpuCode string `json:"spu_code"`
Status int `json:"status"`
SubTitle string `json:"sub_title"`
Title string `json:"title"`
} `json:"product"`
}
var _ bodyer = RespProductGet{}
func (x RespProductGet) intoBody() ([]byte, error) {
result, err := json.Marshal(x)
if err != nil {
return nil, err
}
return result, nil
}
func (c *ApiClient) ExecProductGet(req ReqProductGet) (RespProductGet, error) {
var resp RespProductGet
err := c.executeWXApiPost("/channels/ec/product/get", req, &resp, true)
if err != nil {
return RespProductGet{}, err
}
if bizErr := resp.TryIntoErr(); bizErr != nil {
return RespProductGet{}, bizErr
}
return resp, nil
}