添加自动获取品牌
This commit is contained in:
@@ -1038,6 +1038,7 @@ func (a *API) GetJdUpcCodeByName(name, upcCode string, pageNo, pageSize int) (pr
|
|||||||
UpcCode: v.(map[string]interface{})["upcCode"].(string),
|
UpcCode: v.(map[string]interface{})["upcCode"].(string),
|
||||||
Weight: float32(utils.Interface2Float64WithDefault(v.(map[string]interface{})["weight"], 0) * 1000),
|
Weight: float32(utils.Interface2Float64WithDefault(v.(map[string]interface{})["weight"], 0) * 1000),
|
||||||
ImgList: ImgList,
|
ImgList: ImgList,
|
||||||
|
BrandName: v.(map[string]interface{})["brandName"].(string),
|
||||||
}
|
}
|
||||||
productInfos = append(productInfos, productInfo)
|
productInfos = append(productInfos, productInfo)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"git.rosy.net.cn/baseapi"
|
"git.rosy.net.cn/baseapi"
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -208,14 +209,15 @@ func TestC(t *testing.T) {
|
|||||||
// api.GetJdStoreLevel("320406", "11732427", 1)
|
// api.GetJdStoreLevel("320406", "11732427", 1)
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
//func TestGetJdUpcCodeByName(t *testing.T) {
|
func TestGetJdUpcCodeByName(t *testing.T) {
|
||||||
// result, err := api.GetJdUpcCodeByName("", "6920174736731", 1, 5)
|
result, err := api.GetJdUpcCodeByName("", "9556771007300", 1, 5)
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// t.Fatal(err)
|
t.Fatal(err)
|
||||||
// }
|
}
|
||||||
// t.Log(utils.Format4Output(result, false))
|
t.Log(strings.Split(result[0].OriginalName, " ")[0])
|
||||||
//}
|
t.Log(utils.Format4Output(result, false))
|
||||||
//
|
}
|
||||||
|
|
||||||
//func TestGetJdSkuDirectPrice(t *testing.T) {
|
//func TestGetJdSkuDirectPrice(t *testing.T) {
|
||||||
// result, err := api.GetJdSkuDirectPrice(31031)
|
// result, err := api.GetJdSkuDirectPrice(31031)
|
||||||
// fmt.Println("test1", result, err)
|
// fmt.Println("test1", result, err)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestRetailCatList(t *testing.T) {
|
func TestRetailCatList(t *testing.T) {
|
||||||
result, err := api.RetailCatList("16690980")
|
result, err := api.RetailCatList("13262158")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
// "authority_id": ""
|
// "authority_id": ""
|
||||||
//}`
|
//}`
|
||||||
|
|
||||||
var token = `{"access_token":"0befdbfe-b086-49f1-b539-dc39b8bebea0","expires_in":1676494406,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"9ff5b722-77bf-486f-9f26-1751e768aff3","authority_id":""}`
|
var token = `{"access_token":"e1c4333c-6e5e-4db8-83d3-173923e0815f","expires_in":1677450559,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"89d62aee-5bb3-433c-9514-e435172a3263","authority_id":""}`
|
||||||
|
|
||||||
//var token = `{"access_token":"e3173e9f-266f-4d87-88e7-e7cd837bc9d9","expires_in":1672882632,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"5070aae2-493f-46bd-b5d6-6ea0cd64729f","authority_id":""}`
|
//var token = `{"access_token":"e3173e9f-266f-4d87-88e7-e7cd837bc9d9","expires_in":1672882632,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"5070aae2-493f-46bd-b5d6-6ea0cd64729f","authority_id":""}`
|
||||||
|
|
||||||
|
|||||||
@@ -294,9 +294,10 @@ func (a *API) EditPrice(skuPrice *sku_editPrice_request.SkuEditPriceParam) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetSkuBrand 获取商品所属品牌
|
// 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 := brand_list_request.New()
|
||||||
request.Param.CategoryId = categoryId
|
request.Param.CategoryId = categoryId
|
||||||
|
request.Param.Query = brandName
|
||||||
result, err := request.Execute(a.accessTokenObj)
|
result, err := request.Execute(a.accessTokenObj)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
@@ -305,11 +306,29 @@ func (a *API) GetSkuBrand(categoryId int64) (int64, error) {
|
|||||||
return 0, errors.New(result.SubMsg)
|
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 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 用户信息解密
|
// OrderUserInfoDecrypt 用户信息解密
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package tiktok_api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@@ -49,3 +50,9 @@ func GetTiktokImgListTest(api *API, storeId, appOrgCode string, detailImg string
|
|||||||
|
|
||||||
return strings.Join(tiktokImg, "|"), detailTiktok, nil
|
return strings.Join(tiktokImg, "|"), detailTiktok, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetSkuBrand(t *testing.T) {
|
||||||
|
data, err := a.GetSkuBrand(22843, "康师傅")
|
||||||
|
globals.SugarLogger.Debugf("data ========= %v", data)
|
||||||
|
globals.SugarLogger.Debugf("data ========= %s", err)
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user