添加美团服务商,和自动获取品牌

This commit is contained in:
邹宗楠
2023-02-28 14:14:26 +08:00
parent 855ba4e00d
commit 462334d0c1
7 changed files with 129 additions and 38 deletions

View File

@@ -301,7 +301,6 @@ func (a *API) AccessAPINoPage2(apiStr string, jdParams map[string]interface{}, k
return utils.DictKeysMan(result, keyToRemove, keyToKeep), nil
}
err = platformapi.RebuildError(err, jdParams, watchKeys)
baseapi.SugarLogger.Infof("AccessAPINoPage failed, apiStr:%s, jdParams:%s, data:%s, error:%v", apiStr, utils.Format4Output(jdParams, true), utils.Format4Output(jsonResult, true), err)
return result, err
}

View File

@@ -4,6 +4,7 @@ import (
"fmt"
"git.rosy.net.cn/baseapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals"
"strings"
"testing"
)
@@ -218,6 +219,18 @@ func TestGetJdUpcCodeByName(t *testing.T) {
t.Log(utils.Format4Output(result, false))
}
func TestGetAllCities(t *testing.T) {
citys, err := api.GetAllCities()
globals.SugarLogger.Debug("=========err %v", err)
globals.SugarLogger.Debug("=========len %d", len(citys))
for _, v := range citys {
if v.AreaName == "通辽市" {
}
globals.SugarLogger.Debugf("=========data %s", utils.Format4Output(v, false))
}
}
//func TestGetJdSkuDirectPrice(t *testing.T) {
// result, err := api.GetJdSkuDirectPrice(31031)
// fmt.Println("test1", result, err)

View File

@@ -187,7 +187,7 @@ func (a *API) RetailCatUpdate(poiCode, catName string, updateParams *Param4Updat
// 删除商品分类
// 当分类下存在子级分类或商品时,不允许直接删除此分类。
func (a *API) RetailCatDelete(poiCode, code, name string) (err error) {
func (a *API) RetailCatDelete(poiCode, code, name string, moveProductToUncate int) (err error) {
params := map[string]interface{}{
KeyAppPoiCode: poiCode,
}
@@ -196,6 +196,10 @@ func (a *API) RetailCatDelete(poiCode, code, name string) (err error) {
} else {
params["category_name"] = name
}
if moveProductToUncate != 0 {
params["move_product_to_uncate"] = 1 // 分类存在商品时将商品转移到未分类当中
}
_, err = a.AccessAPI("retailCat/delete", false, params)
return err

View File

@@ -5,6 +5,7 @@ import (
"fmt"
"git.rosy.net.cn/baseapi/utils/errlist"
"git.rosy.net.cn/jx-callback/globals"
"strings"
"testing"
"git.rosy.net.cn/baseapi/utils"
@@ -34,7 +35,7 @@ func TestRetailCatList(t *testing.T) {
// 测试删除门店分类列表
func TestDeleteCat(t *testing.T) {
err := api.RetailCatDelete("12663480", "", "火锅底料")
err := api.RetailCatDelete("12663480", "", "火锅底料", 1)
if err != nil {
t.Fatal(err)
}
@@ -59,11 +60,11 @@ func TestRetailCatDelete(t *testing.T) {
var errStr1 string
var errStr2 string
for _, v := range str {
if err := api.RetailCatDelete(v, "" /*utils.GetUpperUUID()*/, "热销"); err != nil {
if err := api.RetailCatDelete(v, "" /*utils.GetUpperUUID()*/, "热销", 1); err != nil {
errList.AddErr(err)
errStr1 += v + ","
}
if err1 := api.RetailCatDelete(v, "" /*utils.GetUpperUUID()*/, "底料"); err1 != nil {
if err1 := api.RetailCatDelete(v, "" /*utils.GetUpperUUID()*/, "底料", 1); err1 != nil {
errList1.AddErr(err1)
errStr2 += v + ","
}
@@ -368,3 +369,40 @@ func TestCategoryAttrValueList(t *testing.T) {
}
t.Log(utils.Format4Output(result, false))
}
func TestSplit(t *testing.T) {
param := "门店内存在重复的分类:【柑桔柚类】 【底料】 【火锅】,请先删除重复分类后再操作。"
firstIndex := strings.Index(param, "【")
lastIndex := strings.LastIndex(param, "】")
newParam := param[firstIndex:lastIndex]
new2 := strings.Split(newParam, "【")
cc := make([]string, 0, 0)
for _, v := range new2 {
if strings.TrimSpace(v) == "" {
continue
} else if strings.Contains(v, "【") {
for _, v2 := range strings.Split(v, "【") {
if strings.TrimSpace(v) == "" {
continue
}
if strings.TrimSpace(v2) != "" {
cc = append(cc, v2)
}
}
} else if strings.Contains(v, "】") {
for _, v3 := range strings.Split(v, "】") {
if strings.TrimSpace(v3) == "" {
continue
}
if strings.TrimSpace(v3) != "" {
cc = append(cc, v3)
}
}
} else {
cc = append(cc, v)
}
}
fmt.Println("len-======", len(cc))
globals.SugarLogger.Debugf("cc %s", utils.Format4Output(cc, false))
}

View File

@@ -18,7 +18,7 @@ import (
// "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":"1ae389c0-f28f-4339-9a46-f58cca218148","expires_in":1677698819,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"d97b7fb4-3601-4d66-ae0f-bd44892cd4d7","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

@@ -30,6 +30,7 @@ import (
superm_product_batchRedistributeStoreProduct_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_product_batchRedistributeStoreProduct/request"
superm_product_createSubProduct_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_product_createSubProduct/request"
superm_product_launchProduct_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/superm_product_launchProduct/request"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/globals"
"strings"
)
@@ -114,6 +115,7 @@ func (a *API) GetCatePropertyV2(categoryLeftId int64) (*product_getCatePropertyV
// CreateStoreCommodity (新增总部商品)
func (a *API) CreateStoreCommodity(skuParam *product_addV2_request.ProductAddV2Param) (*product_addV2_response.ProductAddV2Data, error) {
globals.SugarLogger.Debugf("CreateStoreCommodity===== %s", utils.Format4Output(skuParam, false))
request := product_addV2_request.New()
request.Param = skuParam
result, err := request.Execute(a.accessTokenObj)
@@ -142,7 +144,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 ========")
globals.SugarLogger.Debugf("EditStoreCommodity===== %s", utils.Format4Output(sku, false))
request := product_editV2_request.New()
request.Param = sku

File diff suppressed because one or more lines are too long