添加自动获取分类id
This commit is contained in:
@@ -774,7 +774,6 @@ func interface2CatList(data interface{}, level int, interface2CatHandler func(da
|
||||
// attr = fmt.Sprintf("约%dg", int(math.Round(float64(weight*1000))))
|
||||
// return attr
|
||||
// }
|
||||
|
||||
func genAttrMapList(kgAttr string) (attrList []map[string]interface{}) {
|
||||
return []map[string]interface{}{
|
||||
map[string]interface{}{
|
||||
@@ -793,3 +792,26 @@ func GetJdSkuIDFromError(err error) int64 {
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// GetSkuCategoryBySkuName 根据商品名称获取商品分类
|
||||
func (a *API) GetSkuCategoryBySkuName(productName string) (*GetSkuCategoryBySkuName, error) {
|
||||
result, err := a.AccessAPINoPage("pms/getSkuCateBrandBySkuName", map[string]interface{}{
|
||||
"productName": productName,
|
||||
"fields": []string{"category"},
|
||||
}, nil, nil, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var recommendSku *GetSkuCategoryBySkuName
|
||||
if err := utils.Map2StructByJson(result, &recommendSku, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return recommendSku, nil
|
||||
}
|
||||
|
||||
type GetSkuCategoryBySkuName struct {
|
||||
ProductName string `json:"productName"`
|
||||
CategoryId int `json:"categoryId"`
|
||||
BrandId int `json:"brandId"`
|
||||
}
|
||||
|
||||
@@ -1,19 +1,12 @@
|
||||
package jdapi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"testing"
|
||||
)
|
||||
|
||||
//
|
||||
//import (
|
||||
// "fmt"
|
||||
// "testing"
|
||||
//
|
||||
// "git.rosy.net.cn/baseapi"
|
||||
// "git.rosy.net.cn/baseapi/utils"
|
||||
//)
|
||||
//
|
||||
//func TestQueryPageBrandInfo(t *testing.T) {
|
||||
// result, _, err := api.QueryPageBrandInfo(0, 0, 0, "京西")
|
||||
// if err != nil {
|
||||
@@ -40,6 +33,16 @@ func TestChangeShopCategoryOrder(t *testing.T) {
|
||||
api.ChangeShopCategoryOrder(0, aa)
|
||||
}
|
||||
|
||||
func TestGetSkuCategoryByName(t *testing.T) {
|
||||
data, err := api.GetSkuCategoryBySkuName("九龙醉 42度 浓香型 白贴九龙白酒")
|
||||
globals.SugarLogger.Debugf("data:=%s", utils.Format4Output(data, false))
|
||||
globals.SugarLogger.Debugf("data:=%v", err)
|
||||
}
|
||||
|
||||
func Test222(t *testing.T) {
|
||||
fmt.Println(1&256 == 0)
|
||||
}
|
||||
|
||||
//
|
||||
//func TestQueryChildCategoriesForOP(t *testing.T) {
|
||||
// result, err := api.QueryChildCategoriesForOP(0)
|
||||
|
||||
Reference in New Issue
Block a user