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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
package gome
import (
"context"
"github.com/gogf/gf/container/garray"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
"github.com/gogf/gf/util/gconv"
)
type goodsGome struct {
}
var Goods = goodsGome{}
type GetSkuRes struct {
*CommonRes
Data []struct {
Cat1Id string `json:"cat1Id"`
Cat1Name string `json:"cat1Name"`
Cat2Id string `json:"cat2Id"`
Cat2Name string `json:"cat2Name"`
Cat3Id string `json:"cat3Id"`
Cat3Name string `json:"cat3Name"`
SkuName string `json:"skuName"`
SkuShortName string `json:"skuShortName"`
BarCode string `json:"barCode"`
MchSkuId string `json:"mchSkuId"`
SkuWeight int64 `json:"skuWeight"`
ItemNo string `json:"itemNo"`
OriginalPrice string `json:"originalPrice"`
CostPrice string `json:"costPrice"`
SellPoint string `json:"sellPoint"`
AfterSaleAllowDays int `json:"afterSaleAllowDays"`
Valid int `json:"valid"`
SkuImgs []struct {
Type int `json:"type"`
Url string `json:"url"`
} `json:"skuImgs"`
Props []struct {
Pname string `json:"pname"`
Pvalue string `json:"pvalue"`
} `json:"props"`
Attrs []struct {
Aname string `json:"aname"`
Avalue string `json:"avalue"`
} `json:"attrs"`
} `json:"data"`
}
type SkuListReq struct {
PageNo int `json:"pageNo"`
PageSize int `json:"pageSize"`
BeginUpdateTime string `json:"beginUpdateTime,omitempty"`
EndUpdateTime string `json:"endUpdateTime,omitempty"`
}
type SkuListRes struct {
*CommonRes
Data struct {
*CommonPageRes
Result []struct {
Cat1Id string `json:"cat1Id"`
Cat1Name string `json:"cat1Name"`
Cat2Id string `json:"cat2Id"`
Cat2Name string `json:"cat2Name"`
Cat3Id string `json:"cat3Id"`
Cat3Name string `json:"cat3Name"`
SkuName string `json:"skuName"`
SkuShortName string `json:"skuShortName"`
BarCode string `json:"barCode"`
MchSkuId string `json:"mchSkuId"`
SkuWeight int64 `json:"skuWeight"`
ItemNo string `json:"itemNo"`
OriginalPrice string `json:"originalPrice"`
CostPrice string `json:"costPrice"`
SellPoint string `json:"sellPoint"`
AfterSaleAllowDays int `json:"afterSaleAllowDays"`
Valid int `json:"valid"`
SkuImgs []struct {
Type int `json:"type"`
Url string `json:"url"`
} `json:"skuImgs"`
Props []struct {
Pname string `json:"pname"`
Pvalue string `json:"pvalue"`
} `json:"props"`
Attrs []struct {
Aname string `json:"aname"`
Avalue string `json:"avalue"`
} `json:"attrs"`
} `json:"result"`
} `json:"data"`
}
type GetGoodsRes struct {
*CommonRes
Data struct {
SpuName string `json:"spuName"`
MchSpuId string `json:"mchSpuId"`
Cat1Id string `json:"cat1Id"`
Cat1Name string `json:"cat1Name"`
Cat2Id string `json:"cat2Id"`
Cat2Name string `json:"cat2Name"`
Cat3Id string `json:"cat3Id"`
Cat3Name string `json:"cat3Name"`
BrandCode string `json:"brandCode"`
BrandName string `json:"brandName"`
Unit string `json:"unit"`
SpuModel string `json:"spuModel"`
ImportFlag int `json:"importFlag"`
Place string `json:"place"`
Keyword string `json:"keyword"`
Adword string `json:"adword"`
PackingList string `json:"packingList"`
AfterService string `json:"afterService"`
AfterSaleAllowDays int `json:"afterSaleAllowDays"`
CreateTime string `json:"createTime"`
CoverImg string `json:"coverImg"`
MainImgs []string `json:"mainImgs"`
DetailsImgs []string `json:"detailsImgs"`
Skus []struct {
Cat1Id string `json:"cat1Id"`
Cat1Name string `json:"cat1Name"`
Cat2Id string `json:"cat2Id"`
Cat2Name string `json:"cat2Name"`
Cat3Id string `json:"cat3Id"`
Cat3Name string `json:"cat3Name"`
SkuName string `json:"skuName"`
SkuShortName string `json:"skuShortName"`
BarCode string `json:"barCode"`
MchSkuId string `json:"mchSkuId"`
SkuWeight int64 `json:"skuWeight"`
ItemNo string `json:"itemNo"`
OriginalPrice string `json:"originalPrice"`
CostPrice string `json:"costPrice"`
SellPoint string `json:"sellPoint"`
AfterSaleAllowDays int `json:"afterSaleAllowDays"`
Valid int `json:"valid"`
SkuImgs []struct {
Type int `json:"type"`
Url string `json:"url"`
} `json:"skuImgs"`
Props []struct {
Pname string `json:"pname"`
Pvalue string `json:"pvalue"`
} `json:"props"`
Attrs []struct {
Aname string `json:"aname"`
Avalue string `json:"avalue"`
} `json:"attrs"`
} `json:"skus"`
Props []struct {
Pname string `json:"pname"`
Pvalue string `json:"pvalue"`
} `json:"props"`
} `json:"data"`
}
type GoodsListReq struct {
PageNo int `json:"pageNo"`
PageSize int `json:"pageSize"`
BeginUpdateTime string `json:"beginUpdateTime,omitempty"`
EndUpdateTime string `json:"endUpdateTime,omitempty"`
}
type GoodsListRes struct {
*CommonRes
Data struct {
*CommonPageRes
Result []struct {
SpuName string `json:"spuName"`
MchSpuId string `json:"mchSpuId"`
Cat1Id string `json:"cat1Id"`
Cat1Name string `json:"cat1Name"`
Cat2Id string `json:"cat2Id"`
Cat2Name string `json:"cat2Name"`
Cat3Id string `json:"cat3Id"`
Cat3Name string `json:"cat3Name"`
BrandCode string `json:"brandCode"`
BrandName string `json:"brandName"`
Unit string `json:"unit"`
SpuModel string `json:"spuModel"`
ImportFlag int `json:"importFlag"`
Place string `json:"place"`
Keyword string `json:"keyword"`
Adword string `json:"adword"`
PackingList string `json:"packingList"`
AfterService string `json:"afterService"`
AfterSaleAllowDays int `json:"afterSaleAllowDays"`
CreateTime string `json:"createTime"`
CoverImg string `json:"coverImg"`
MainImgs []string `json:"mainImgs"`
DetailsImgs []string `json:"detailsImgs"`
Skus []struct {
Cat1Id string `json:"cat1Id"`
Cat1Name string `json:"cat1Name"`
Cat2Id string `json:"cat2Id"`
Cat2Name string `json:"cat2Name"`
Cat3Id string `json:"cat3Id"`
Cat3Name string `json:"cat3Name"`
SkuName string `json:"skuName"`
SkuShortName string `json:"skuShortName"`
BarCode string `json:"barCode"`
MchSkuId string `json:"mchSkuId"`
SkuWeight int64 `json:"skuWeight"`
ItemNo string `json:"itemNo"`
OriginalPrice string `json:"originalPrice"`
CostPrice string `json:"costPrice"`
SellPoint string `json:"sellPoint"`
AfterSaleAllowDays int `json:"afterSaleAllowDays"`
Valid int `json:"valid"`
SkuImgs []struct {
Type int `json:"type"`
Url string `json:"url"`
} `json:"skuImgs"`
Props []struct {
Pname string `json:"pname"`
Pvalue string `json:"pvalue"`
} `json:"props"`
Attrs []struct {
Aname string `json:"aname"`
Avalue string `json:"avalue"`
} `json:"attrs"`
} `json:"skus"`
Props []struct {
Pname string `json:"pname"`
Pvalue string `json:"pvalue"`
} `json:"props"`
} `json:"result"`
} `json:"data"`
}
type GoodsPriceRes struct {
*CommonRes
Data []struct {
MchSkuId string `json:"mchSkuId"`
CostPrice int64 `json:"costPrice"`
} `json:"data"`
}
//GetSku 单个 SKU 查询
func (goodsGome) GetSku(ctx context.Context, sku interface{}) (res *GetSkuRes, err error) {
method := "alamein.product.read.querySingleSku"
req := g.Map{
"mchSkuId": gconv.String(sku),
}
result, err := server.requestApi(ctx, method, req)
if err != nil {
return
}
_ = gjson.New(result).Scan(&res)
return
}
//SkuList 分页 SKU 查询
func (goodsGome) SkuList(ctx context.Context, req *SkuListReq) (res *SkuListRes, err error) {
method := "alamein.product.read.pageQuerySku"
result, err := server.requestApi(ctx, method, req)
if err != nil {
return
}
_ = gjson.New(result).Scan(&res)
return
}
// GetGoods 单个 SPU 查询
func (goodsGome) GetGoods(ctx context.Context, GoodsID interface{}) (res *GetGoodsRes, err error) {
method := "alamein.product.read.querySingleSpu"
var req = g.Map{
"mchSpuId": gconv.String(GoodsID),
}
result, err := server.requestApi(ctx, method, req)
if err != nil {
return
}
_ = gjson.New(result).Scan(&res)
return
}
//GoodsList 分页 SPU 查询
func (goodsGome) GoodsList(ctx context.Context, req *GoodsListReq) (res *GoodsListRes, err error) {
method := "alamein.product.read.pageQuerySpu"
result, err := server.requestApi(ctx, method, req)
if err != nil {
return
}
_ = gjson.New(result).Scan(&res)
return
}
//Price 商品价格批量查询
func (goodsGome) Price(ctx context.Context, sku *garray.Array) (res *GoodsPriceRes, err error) {
method := "alamein.price.read.querySkuPrice"
var req = g.Map{
"mchSkuIds": sku.Slice(),
}
result, err := server.requestApi(ctx, method, req)
if err != nil {
return
}
_ = gjson.New(result).Scan(&res)
return
}