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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
package tm
import (
"context"
"encoding/json"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/util/gconv"
)
type goodsTm struct {
}
var Goods = goodsTm{}
type GoodsInventoryReq struct {
ItemId string `json:"ItemId"`
SkuIdList []string `json:"SkuIdList"`
}
type GoodsInventoryRes struct {
Code string `json:"Code"`
Success bool `json:"Success"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
ItemList struct {
Item []struct {
ItemId int `json:"ItemId"`
SkuList struct {
Sku []struct {
SkuId int `json:"SkuId"`
Inventory struct {
Quantity int `json:"Quantity"`
} `json:"Inventory"`
} `json:"Sku"`
} `json:"SkuList"`
} `json:"Item"`
} `json:"ItemList"`
}
//Inventory 查询库存
func (s *goodsTm) Inventory(ctx context.Context, DivisionCode string, req []GoodsInventoryReq) (res *GoodsInventoryRes, err error) {
method := "queryItemInventory"
request := convert("ItemList", gconv.Maps(req))
request["DivisionCode"] = DivisionCode
result, err := post(ctx, method, request)
_ = json.Unmarshal([]byte(result), &res)
return
}
type GoodsDetailRes struct {
Code string `json:"Code"`
Success bool `json:"Success"`
Message string `json:"Message"`
RequestId string `json:"RequestId"`
Item struct {
ItemId int `json:"ItemId"`
ItemTitle string `json:"ItemTitle"`
CanSell bool `json:"IsCanSell"`
ReservePrice int `json:"ReservePrice"` //
Quantity int `json:"Quantity"`
MinPrice int `json:"MinPrice"`
TotalSoldQuantity int `json:"TotalSoldQuantity"` //销量
DescOption string `json:"DescOption"`
SellerId int `json:"SellerId"`
CategoryId int `json:"CategoryId"`
MainPicUrl string `json:"MainPicUrl"`
TbShopName string `json:"TbShopName"`
SellerPayPostfee bool `json:"SellerPayPostfee"` //是否包邮
PropertiesJson string `json:"PropertiesJson"` //属性
Properties map[string][]string `json:"Properties"` //属性
Skus struct {
Sku []struct {
ItemId int `json:"ItemId"`
Quantity int `json:"Quantity"`
ReservePrice int `json:"ReservePrice"`
CanSell bool `json:"CanSell"`
SkuId int `json:"SkuId"`
PriceCent int `json:"PriceCent"` //售价
SkuProperties map[string]string `json:"SkuProperties"`
SkuPropertiesJson string `json:"SkuPropertiesJson"`
SkuPicUrl string `json:"SkuPicUrl"`
} `json:"Sku"`
} `json:"Skus"`
ItemImages struct {
ItemImage []string `json:"ItemImage"`
} `json:"ItemImages"`
} `json:"Item"`
}
//Detail 详情
func (*goodsTm) Detail(ctx context.Context, req interface{}) (res *GoodsDetailRes, err error) {
method := "QueryItemDetail"
request := g.MapStrStr{
"ItemId": gconv.String(req),
}
result, err := post(ctx, method, request)
_ = json.Unmarshal([]byte(result), &res)
return
}