- mtwm.RetailGet与ebai.SkuList用struct替换map
This commit is contained in:
@@ -31,6 +31,57 @@ type BareStoreFoodInfo struct {
|
||||
Skus []*BareStoreSkuInfo `json:"skus"`
|
||||
}
|
||||
|
||||
type AvailableTimesInfo struct {
|
||||
Friday string `json:"friday"`
|
||||
Monday string `json:"monday"`
|
||||
Saturday string `json:"saturday"`
|
||||
Sunday string `json:"sunday"`
|
||||
Thursday string `json:"thursday"`
|
||||
Tuesday string `json:"tuesday"`
|
||||
Wednesday string `json:"wednesday"`
|
||||
}
|
||||
|
||||
type SkuInfo struct {
|
||||
AvailableTimes *AvailableTimesInfo `json:"available_times"`
|
||||
BoxNum string `json:"box_num"`
|
||||
BoxPrice string `json:"box_price"`
|
||||
LocationCode string `json:"location_code"`
|
||||
Price string `json:"price"`
|
||||
SkuID string `json:"sku_id"`
|
||||
Spec string `json:"spec"`
|
||||
Stock string `json:"stock"`
|
||||
Upc string `json:"upc"`
|
||||
Weight int `json:"weight"`
|
||||
}
|
||||
|
||||
type AppFood struct {
|
||||
AppFoodCode string `json:"app_food_code"`
|
||||
AppPoiCode string `json:"app_poi_code"`
|
||||
BoxNum float64 `json:"box_num"`
|
||||
BoxPrice float64 `json:"box_price"`
|
||||
CategoryCode string `json:"category_code"`
|
||||
CategoryName string `json:"category_name"`
|
||||
Ctime int `json:"ctime"`
|
||||
Description string `json:"description"`
|
||||
IsSp int `json:"isSp"`
|
||||
IsSoldOut int `json:"is_sold_out"`
|
||||
IsSpecialty int `json:"is_specialty"`
|
||||
MinOrderCount int `json:"min_order_count"`
|
||||
Name string `json:"name"`
|
||||
Picture string `json:"picture"`
|
||||
PictureContents string `json:"picture_contents"`
|
||||
Price float64 `json:"price"`
|
||||
SecondaryCategoryCode string `json:"secondary_category_code"`
|
||||
SecondaryCategoryName string `json:"secondary_category_name"`
|
||||
Sequence int `json:"sequence"`
|
||||
Skus string `json:"skus"`
|
||||
SkuList []*SkuInfo `json:"skuList"`
|
||||
TagID int `json:"tag_id"`
|
||||
Unit string `json:"unit"`
|
||||
Utime int `json:"utime"`
|
||||
ZhName string `json:"zh_name"`
|
||||
}
|
||||
|
||||
// 美团分类没有ID,就以名字为唯一标识,不论级别都必须不能重名
|
||||
// name(和originName)的长度不能超过10个字符(字符,不是字节)
|
||||
// 创建一级分类,originName为空,name为新分类名,secondaryName为空
|
||||
@@ -127,15 +178,17 @@ func (a *API) RetailSkuStock(poiCode string, foodData []*BareStoreFoodInfo) (err
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *API) RetailGet(poiCode, foodCode string) (food map[string]interface{}, err error) {
|
||||
func (a *API) RetailGet(poiCode, foodCode string) (food *AppFood, err error) {
|
||||
result, err := a.AccessAPI("retail/get", true, map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
KeyAppFoodCode: foodCode,
|
||||
})
|
||||
if err == nil {
|
||||
return result.(map[string]interface{}), nil
|
||||
if err = utils.Map2StructByJson(result, &food, true); err == nil && food.Skus != "" {
|
||||
err = utils.UnmarshalUseNumber([]byte(food.Skus), &food.SkuList)
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
return food, err
|
||||
}
|
||||
|
||||
func (a *API) RetailSkuSave(poiCode, foodCode string, standardSkus, unstandardSkus []map[string]interface{}) (err error) {
|
||||
|
||||
@@ -47,7 +47,15 @@ func TestRetailList(t *testing.T) {
|
||||
if len(result) == 0 {
|
||||
t.Fatal("should have items")
|
||||
}
|
||||
// t.Log(utils.Format4Output(result, false))
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestRetailGet(t *testing.T) {
|
||||
result, err := api.RetailGet(testPoiCode, "5246")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(utils.Format4Output(result, false))
|
||||
}
|
||||
|
||||
func TestRetailGetSpTagIds(t *testing.T) {
|
||||
@@ -69,7 +77,7 @@ func TestRetailCatSkuBatchDelete(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRetailDelete(t *testing.T) {
|
||||
err := api.RetailDelete(testPoiCode, "")
|
||||
err := api.RetailDelete(testPoiCode, "614")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user