- mtwm.RetailList返回结果改为[]*AppFood
This commit is contained in:
@@ -2,7 +2,6 @@ package ebaiapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
@@ -96,10 +95,6 @@ type PageDataInfo struct {
|
||||
List []*SkuInfo `json:"List"`
|
||||
}
|
||||
|
||||
var (
|
||||
skuExistReg = regexp.MustCompile(`\s?,\s?sku_id:(\d+)`)
|
||||
)
|
||||
|
||||
func genSkuIDParams(skuID int64, customSkuID, upc string) map[string]interface{} {
|
||||
params := map[string]interface{}{}
|
||||
if skuID != 0 {
|
||||
|
||||
@@ -9,8 +9,9 @@ import (
|
||||
const (
|
||||
MaxSkuNameCharCount = 30 // SkuName的最大字符数
|
||||
|
||||
MaxStoreSkuBatchSize = 200 // retail/sku/stock, retail/sku/sellStatus和retail/sku/price这些批量操作的最大值
|
||||
MaxBatchDeleteSize = 100 // retailCat/batchdelete/catandretail这个接口的批量最大值
|
||||
MaxStoreSkuBatchSize = 200 // retail/sku/stock, retail/sku/sellStatus和retail/sku/price这些批量操作的最大值
|
||||
MaxRetailListPageSize = 200
|
||||
MaxBatchDeleteSize = 100 // retailCat/batchdelete/catandretail这个接口的批量最大值
|
||||
)
|
||||
|
||||
type RetailCategoryInfo struct {
|
||||
@@ -76,6 +77,7 @@ type AppFood struct {
|
||||
MinOrderCount int `json:"min_order_count"`
|
||||
Name string `json:"name"`
|
||||
Picture string `json:"picture"`
|
||||
PictureList []string `json:"pictureList"`
|
||||
PictureContents string `json:"picture_contents"`
|
||||
Price float64 `json:"price"`
|
||||
SecondaryCategoryCode string `json:"secondary_category_code"`
|
||||
@@ -149,16 +151,21 @@ func (a *API) RetailInitData(poiCode, foodCode string, params map[string]interfa
|
||||
|
||||
// offset 从0开始,limit最大不能超过200
|
||||
// 返回的app_poi_code始终是空,手动建的商品app_food_code也为空(导致无法通过API删除)
|
||||
func (a *API) RetailList(poiCode string, offset, limit int) (foodList []map[string]interface{}, err error) {
|
||||
func (a *API) RetailList(poiCode string, offset, limit int) (foodList []*AppFood, err error) {
|
||||
result, err := a.AccessAPI("retail/list", true, map[string]interface{}{
|
||||
KeyAppPoiCode: poiCode,
|
||||
"offset": offset,
|
||||
"limit": limit,
|
||||
})
|
||||
if err == nil {
|
||||
return utils.Slice2MapSlice(result.([]interface{})), nil
|
||||
if err = utils.Map2StructByJson(result, &foodList, true); err == nil {
|
||||
for _, food := range foodList {
|
||||
utils.UnmarshalUseNumber([]byte(food.Skus), &food.SkuList)
|
||||
food.PictureList = strings.Split(food.Picture, ",")
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
return foodList, err
|
||||
}
|
||||
|
||||
func (a *API) RetailBatchInitData(poiCode string, foodDataList []map[string]interface{}) (err error) {
|
||||
@@ -192,7 +199,8 @@ func (a *API) RetailGet(poiCode, foodCode string) (food *AppFood, err error) {
|
||||
})
|
||||
if err == nil {
|
||||
if err = utils.Map2StructByJson(result, &food, true); err == nil && food.Skus != "" {
|
||||
err = utils.UnmarshalUseNumber([]byte(food.Skus), &food.SkuList)
|
||||
utils.UnmarshalUseNumber([]byte(food.Skus), &food.SkuList)
|
||||
food.PictureList = strings.Split(food.Picture, ",")
|
||||
}
|
||||
}
|
||||
return food, err
|
||||
|
||||
@@ -51,7 +51,7 @@ func TestRetailList(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestRetailGet(t *testing.T) {
|
||||
result, err := api.RetailGet(testPoiCode, "5246")
|
||||
result, err := api.RetailGet(testPoiCode, "4267")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user