This commit is contained in:
richboo111
2023-02-21 16:26:55 +08:00
9 changed files with 66 additions and 34 deletions

View File

@@ -34,7 +34,7 @@ func init() {
//api = New("0e12f461-2e6b-49ca-bce6-935c6672362d", "f2ed33075faf4773a47e065acd79532b", "aed14cbbecac4456843570e90c5f46ec")
// 京东超市 381564
api = New("f99d25b8-33a6-4251-a97c-5e24b80b0005", "d2d1e2e3213d4320bc2712a684307831", "1750f5b9848d4a6492c1c20b487074da")
api = New("fe07cad2-d366-424b-8e85-9b81d7987cba", "8376b3071c5b49fb96a4c82be0dbc104", "a55b47042d5845018834f42d42ffafb7")
//prod zs
// api = New("6f8d3290-0120-4ad7-8b53-943c67c84f3f", "789279b9ae814ba091ac52815566b54d", "5d668cd227644637bb0fd73ed8118ec8")
// const cookieValue = "YYJV3NHVBPHLD36FWP6F3EM5PTXJ2XZQS7U4HWRIDPP4IWGUKUIB4XG5N26CZRDLDF7PKOXBPD6BNTUAJLETLZOIWMCVFI3K6MYZIY4QBIXIMXYDJNUKFGJVQTN5356SAD6WPCIHWNQAG7DDMF7L7S3SHCT3RM3CQG7IJIPUQ3THS5UIUYWMKINM7ETUOQB7OBPOPZVCT3ZJY55243TDVXLO25PP4UYSPTTPMNQ7HPMWOJKJ3BJWGVHD243MXH7NZWW264TKN5UOCJBSSSOKD2QQII"

View File

@@ -1038,6 +1038,7 @@ func (a *API) GetJdUpcCodeByName(name, upcCode string, pageNo, pageSize int) (pr
UpcCode: v.(map[string]interface{})["upcCode"].(string),
Weight: float32(utils.Interface2Float64WithDefault(v.(map[string]interface{})["weight"], 0) * 1000),
ImgList: ImgList,
BrandName: v.(map[string]interface{})["brandName"].(string),
}
productInfos = append(productInfos, productInfo)
}

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"git.rosy.net.cn/baseapi"
"git.rosy.net.cn/baseapi/utils"
"strings"
"testing"
)
@@ -208,14 +209,15 @@ func TestC(t *testing.T) {
// api.GetJdStoreLevel("320406", "11732427", 1)
//}
//
//func TestGetJdUpcCodeByName(t *testing.T) {
// result, err := api.GetJdUpcCodeByName("", "6920174736731", 1, 5)
// if err != nil {
// t.Fatal(err)
// }
// t.Log(utils.Format4Output(result, false))
//}
//
func TestGetJdUpcCodeByName(t *testing.T) {
result, err := api.GetJdUpcCodeByName("", "9556771007300", 1, 5)
if err != nil {
t.Fatal(err)
}
t.Log(strings.Split(result[0].OriginalName, " ")[0])
t.Log(utils.Format4Output(result, false))
}
//func TestGetJdSkuDirectPrice(t *testing.T) {
// result, err := api.GetJdSkuDirectPrice(31031)
// fmt.Println("test1", result, err)

View File

@@ -32,23 +32,14 @@ import (
// t.Log(utils.Format4Output(result, false))
//}
//
//func TestGetStationsByVenderId(t *testing.T) {
// result, err := api.GetStationsByVenderId()
// if err != nil {
// t.Fatal(err)
// }
// findStore := false
// for _, v := range result {
// if v == mustExistStoreID {
// findStore = true
// break
// }
// }
// if !findStore {
// baseapi.SugarLogger.Fatalf("result have no store:%s", mustExistStoreID)
// }
//}
//
func TestGetStationsByVenderId(t *testing.T) {
result, err := api.GetStationsByVenderId()
if err != nil {
t.Fatal(err)
}
t.Log(utils.Format4Output(result, false))
}
func TestGetStoreInfoByStationNo(t *testing.T) {
result, err := api.GetStoreInfoByStationNo2("12535376")
if err != nil {

View File

@@ -184,6 +184,8 @@ func (a *API) RetailCatUpdate(poiCode, catName string, updateParams *Param4Updat
// 删除商品分类
// 当分类下存在子级分类或商品时,不允许直接删除此分类。
func (a *API) RetailCatDelete(poiCode, code, name string) (err error) {
globals.SugarLogger.Debugf("RetailCatDelete======poiCode %s", poiCode)
globals.SugarLogger.Debugf("RetailCatDelete======name %s", name)
params := map[string]interface{}{
KeyAppPoiCode: poiCode,
}
@@ -193,6 +195,9 @@ func (a *API) RetailCatDelete(poiCode, code, name string) (err error) {
params["category_name"] = name
}
_, err = a.AccessAPI("retailCat/delete", false, params)
if err != nil {
globals.SugarLogger.Debugf("RetailCatDelete======err %s", err.Error())
}
return err
}
@@ -200,6 +205,11 @@ func (a *API) RetailCatList(poiCode string) (retailCatList []*RetailCategoryInfo
result, err := a.AccessAPI("retailCat/list", true, map[string]interface{}{
KeyAppPoiCode: poiCode,
})
if err != nil {
globals.SugarLogger.Debugf("RetailCatList==========err %v", err)
}
globals.SugarLogger.Debugf("result==========err %s", utils.Format4Output(result, false))
if err == nil {
return interface2CatList(result, 1, nil), nil
}

View File

@@ -11,7 +11,7 @@ import (
)
func TestRetailCatList(t *testing.T) {
result, err := api.RetailCatList("8694203 ")
result, err := api.RetailCatList("13262158")
if err != nil {
t.Fatal(err)
}
@@ -19,9 +19,9 @@ func TestRetailCatList(t *testing.T) {
}
func TestRetailCatUpdate(t *testing.T) {
err := api.RetailCatUpdate("8694203", "时令鲜蔬", &Param4UpdateCat{
CategoryNameOrigin: "1",
CategoryCodeOrigin: "1",
err := api.RetailCatUpdate("16690980", "咸菜罐头", &Param4UpdateCat{
CategoryNameOrigin: "咸菜罐头",
CategoryCodeOrigin: "",
CategoryCode: "1",
Sequence: 3,
})

View File

@@ -18,7 +18,7 @@ import (
// "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":""}`

View File

@@ -145,6 +145,7 @@ func (a *API) SyncStockBatch(param *sku_syncStockBatch_request.SkuSyncStockBatch
// EditStoreCommodity 编辑商品
func (a *API) EditStoreCommodity(sku *product_editV2_request.ProductEditV2Param) error {
globals.SugarLogger.Debugf("EditStoreCommodity ========")
request := product_editV2_request.New()
request.Param = sku
@@ -154,6 +155,7 @@ func (a *API) EditStoreCommodity(sku *product_editV2_request.ProductEditV2Param)
return err
}
if result.Code != RequestSuccessCode {
globals.SugarLogger.Debugf("result err := %s", utils.Format4Output(result, false))
return errors.New(result.SubMsg)
}
return nil
@@ -292,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
@@ -303,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 用户信息解密

View File

@@ -2,6 +2,7 @@ package tiktok_api
import (
"fmt"
"git.rosy.net.cn/jx-callback/globals"
"strings"
"testing"
)
@@ -49,3 +50,9 @@ func GetTiktokImgListTest(api *API, storeId, appOrgCode string, detailImg string
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)
}