You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

159 lines
5.5 KiB

3 years ago
package supply
const (
skuLists = "/sku/lists" // 商品列表
skuDetails = "/sku/details" // 商品详情
skuPrices = "/sku/prices" // 商品价格
skuGroups = "/sku/groups" // 商品分组信息
skuStock = "/sku/stock" // 商品库存
3 years ago
)
type sku struct {
}
type ArgsSkuLists struct {
ScrollId string `json:"scrollId"` // 游标,上次请求返回
Status uint `json:"status"` // 商品状态 0=全部 1=上架商品 2=下架商品
SkuName string `json:"skuName"` // 商品名称筛选
AfterUpdateTime string `json:"afterUpdateTime"` // 大于最后更新时间筛选 格式 2006-01-02 15:04:05
PageSize uint `json:"pageSize"` // 商品数量 max=100
}
type SkuLists struct {
List []SkuItem `json:"list"`
Total uint `json:"total"`
ScrollId string `json:"scrollId"`
}
type SkuItem struct {
Id uint `json:"id"`
Name string `json:"name"`
BrandId uint `json:"brandId"`
BrandName string `json:"brandName"`
FirstCategoryId uint `json:"firstCategoryId"`
FirstCategoryName string `json:"firstCategoryName"`
SecondCategoryId uint `json:"secondCategoryId"`
SecondCategoryName string `json:"secondCategoryName"`
ThirdCategoryId uint `json:"thirdCategoryId"`
ThirdCategoryName string `json:"thirdCategoryName"`
Price string `json:"price"`
GuidePrice string `json:"guidePrice"`
ImgUrl string `json:"imgUrl"`
Profit string `json:"profit"`
Size string `json:"size"`
Color string `json:"color"`
Tax string `json:"tax"`
Unit string `json:"unit"`
UpcCode string `json:"upcCode"`
TaxName string `json:"taxName"`
TaxCode string `json:"taxCode"`
Status uint `json:"status"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
}
// Lists @Title 获取商品列表用于初次接入全量同步后续新增上架商品可通过商品信息变动mq获取
func (s *sku) Lists(data ArgsSkuLists) (result SkuLists, err error) {
err = exec(skuLists, data, &result)
return
}
type SkuInfo struct {
Id uint `json:"id"`
Name string `json:"name"`
BrandId uint `json:"brandId"`
BrandName string `json:"brandName"`
FirstCategoryId uint `json:"firstCategoryId"`
FirstCategoryName string `json:"firstCategoryName"`
SecondCategoryId uint `json:"secondCategoryId"`
SecondCategoryName string `json:"secondCategoryName"`
ThirdCategoryId uint `json:"thirdCategoryId"`
ThirdCategoryName string `json:"thirdCategoryName"`
Price float64 `json:"price"`
GuidePrice float64 `json:"guidePrice"`
ImgUrl string `json:"imgUrl"`
Profit float64 `json:"profit"`
Size string `json:"size"`
Color string `json:"color"`
Tax string `json:"tax"`
Unit string `json:"unit"`
UpcCode string `json:"upcCode"`
TaxName string `json:"taxName"`
TaxCode string `json:"taxCode"`
Status uint `json:"status"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
Content string `json:"content"`
Imgs []SkuImg `json:"imgs"`
Specifications []SkuSpecification `json:"specifications"`
GroupSkuIds []int `json:"groupSkuIds"`
}
type SkuImg struct {
Path string `json:"path"`
}
type SkuSpecification struct {
Name string `json:"name"`
Attributes []SkuAttribute `json:"attributes"`
}
type SkuAttribute struct {
Name string `json:"name"`
Value []string `json:"value"`
}
// Details @Title 商品详情
func (s *sku) Details(skuIds []uint) (result []SkuInfo, err error) {
err = exec(skuDetails, map[string]interface{}{
"skuIds": skuIds,
}, &result)
return
}
type SkuPrice struct {
Id uint `json:"id"`
Name string `json:"name"`
Price float64 `json:"price"`
GuidePrice float64 `json:"guidePrice"`
Profit float64 `json:"profit"`
Status uint `json:"status"`
CreatedAt int64 `json:"createdAt"`
UpdatedAt int64 `json:"updatedAt"`
}
// Prices @Title 获取商品价格
func (s *sku) Prices(skuIds []uint) (result []SkuPrice, err error) {
err = exec(skuPrices, map[string]interface{}{
"skuIds": skuIds,
}, &result)
return
}
type SkuGroup struct {
SkuId int `json:"skuId"`
GroupSkuIds []int `json:"groupSkuIds"`
}
// Groups @Title 获取商品分组信息
func (s *sku) Groups(skuIds []uint) (result []SkuGroup, err error) {
err = exec(skuGroups, map[string]interface{}{
"skuIds": skuIds,
}, &result)
return
}
type SkuStockItem struct {
SkuId uint `json:"skuId"`
Quantity uint `json:"quantity"`
}
type SkuStock struct {
SkuId uint `json:"skuId"` // skuId
State uint `json:"state"` // 库存状态
}
// Stock @Title 获取商品库存
func (s *sku) Stock(address string, skus []SkuStockItem) (result []SkuStock, err error) {
err = exec(skuStock, map[string]interface{}{
"address": address,
"skus": skus,
}, &result)
return
}