添加自动获取品牌
This commit is contained in:
@@ -294,9 +294,10 @@ func (a *API) EditPrice(skuPrice *sku_editPrice_request.SkuEditPriceParam) error
|
||||
}
|
||||
|
||||
// GetSkuBrand 获取商品所属品牌
|
||||
func (a *API) GetSkuBrand(categoryId int64) (int64, error) {
|
||||
func (a *API) GetSkuBrand(categoryId int64, brandName string) (int64, error) {
|
||||
request := brand_list_request.New()
|
||||
request.Param.CategoryId = categoryId
|
||||
request.Param.Query = brandName
|
||||
result, err := request.Execute(a.accessTokenObj)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
@@ -305,11 +306,29 @@ func (a *API) GetSkuBrand(categoryId int64) (int64, error) {
|
||||
return 0, errors.New(result.SubMsg)
|
||||
}
|
||||
|
||||
if result.Data == nil || len(result.Data.AuthBrandList) == 0 {
|
||||
if result.Data == nil || len(result.Data.BrandList) == 0 {
|
||||
return 596120136, nil // 无品牌默认值
|
||||
}
|
||||
|
||||
return result.Data.AuthBrandList[0].BrandId, nil
|
||||
var brandNameLen int = 0
|
||||
var BrandNameMap = make(map[int]int64, 0)
|
||||
for _, v := range result.Data.BrandList {
|
||||
BrandNameMap[len(v.NameCn)] = v.BrandId
|
||||
if brandNameLen == 0 {
|
||||
brandNameLen = len(v.NameCn)
|
||||
continue
|
||||
}
|
||||
if len(v.NameCn) < brandNameLen && brandNameLen != 0 {
|
||||
brandNameLen = len(v.NameCn)
|
||||
}
|
||||
}
|
||||
|
||||
//for _, vv := range result.Data.BrandList {
|
||||
// if vv.BrandId == BrandNameMap[brandNameLen] {
|
||||
// globals.SugarLogger.Debugf("brand name :[%s]", vv.NameCn)
|
||||
// }
|
||||
//}
|
||||
return BrandNameMap[brandNameLen], nil
|
||||
}
|
||||
|
||||
// OrderUserInfoDecrypt 用户信息解密
|
||||
|
||||
Reference in New Issue
Block a user