diff --git a/platformapi/jdapi/jdapi.go b/platformapi/jdapi/jdapi.go index a1d648ed..041efc22 100644 --- a/platformapi/jdapi/jdapi.go +++ b/platformapi/jdapi/jdapi.go @@ -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 } diff --git a/platformapi/jdapi/store_page_test.go b/platformapi/jdapi/store_page_test.go index e7cf8414..cf47d29d 100644 --- a/platformapi/jdapi/store_page_test.go +++ b/platformapi/jdapi/store_page_test.go @@ -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) diff --git a/platformapi/mtwmapi/retail.go b/platformapi/mtwmapi/retail.go index a4db641a..bc1ccd02 100644 --- a/platformapi/mtwmapi/retail.go +++ b/platformapi/mtwmapi/retail.go @@ -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 diff --git a/platformapi/mtwmapi/retail_test.go b/platformapi/mtwmapi/retail_test.go index 65d6c459..4395e9ee 100644 --- a/platformapi/mtwmapi/retail_test.go +++ b/platformapi/mtwmapi/retail_test.go @@ -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)) +} diff --git a/platformapi/tiktok_shop/tiktok_api/afs_test.go b/platformapi/tiktok_shop/tiktok_api/afs_test.go index ccacf74d..f3c0cab1 100644 --- a/platformapi/tiktok_shop/tiktok_api/afs_test.go +++ b/platformapi/tiktok_shop/tiktok_api/afs_test.go @@ -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":""}` diff --git a/platformapi/tiktok_shop/tiktok_api/sku.go b/platformapi/tiktok_shop/tiktok_api/sku.go index 00aadcba..106b019a 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku.go +++ b/platformapi/tiktok_shop/tiktok_api/sku.go @@ -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 diff --git a/platformapi/tiktok_shop/tiktok_api/sku_test.go b/platformapi/tiktok_shop/tiktok_api/sku_test.go index ffdaeb8f..4b71ade2 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku_test.go +++ b/platformapi/tiktok_shop/tiktok_api/sku_test.go @@ -142,7 +142,42 @@ func TestBatchDecrypt(t *testing.T) { // a.OrderUserInfoSensitive("4988354190732430566") //} -var c = []int64{71199364, 71199363, 71199362, 71199361, 71199360, 71199359, 71199358, 71199357, 71199356, 71199355, 71199354, 71199353, 71199352, 71199351, 71199350, 71199349, 70870848, 70870393, 69608467, 69395217, 66502882, 65585133, 65402632, 65401463, 64363086, 64292416, 64270631, 64270382, 64270381, 64270380, 64270379, 64270378, 64270377, 64270376, 64270375, 64270374, 64270373, 64270372, 64270371, 64270370, 64270369, 64270368, 64270367, 64270366, 64270365, 64270364, 64270363, 64270362, 64270361, 64270360, 64270359, 64270358, 64270357, 64270356, 64270355, 64270354, 64270353, 64270352, 64270351, 64270350, 64270349, 64270348, 64270347, 64270346, 64270345, 64270344, 64270343, 64270342, 64270341, 64270340, 64270339, 64270338, 64270337, 64270336, 64270335, 64270334, 64270333, 64270331, 64270330, 64270329, 64270328, 64270327, 64270326, 64270325, 64270324, 64270323, 64270322, 64270321, 64270320, 64270319, 64270318, 64270317, 64270316, 64270315, 64270314, 64270313, 64270312, 64270311, 64270310, 64270309, 64270308, 64270307, 64270306, 64270305, 64270304, 64270303, 64270302, 64270301, 64270300, 64270299, 64270298, 64270297, 64270296, 64270295, 64270294, 64270293, 64270292, 64270291, 64270290, 64270289, 64270288, 64270287, 64270286, 64270285, 64270284, 64270283, 64270282, 64270281, 64270280, 64270279, 64270278, 64270277, 64270276, 64270275, 64270274, 64270273, 64270272, 64270271, 64270270, 64270269, 64270268, 64270267, 64270266, 64270265, 64270264, 64270263, 64270262, 64270261, 64270260, 64270259, 64270258, 64270257, 64270256, 64270255, 64270254, 64270253, 64270252, 64270251, 64270250, 64270249, 64270248, 64270247, 64270246, 64270245, 64270244, 64270243, 64270242, 64270241, 64270240, 64270239, 64270238, 64270237, 64270236, 64270235, 64270234, 64270233, 64270232, 64270231, 64270230, 64270229, 64270228, 64270227, 64270226, 64270225, 64270224, 64270223, 64270222, 64270221, 64270220, 64270219, 64270217, 64270216, 64270215, 64270214, 64270213, 64270212, 64270211, 64270210, 64270209, 64270208, 64270207, 64270206, 64270205, 64270204, 64270203, 64270202, 64270201, 64270200, 64270199, 64270198, 64270197, 64270196, 64270195, 64270194, 64270193, 64270192, 64270191, 64270190, 64270189, 64270188, 64270187, 64270186, 64270185, 64270184, 64270183, 64270182, 64270181, 64270180, 64270179, 64270178, 64270177, 64270176, 64270175, 64270174, 64270173, 64270172, 64270171, 64270170, 64270169, 64270168, 64270167, 64270166, 64270165, 64270164, 64270163, 64270162, 64270161, 64270160, 64270159, 64270158, 64270157, 64270156, 64270155, 64270154, 64270153, 64270152, 64270151, 64270150, 64270149, 64270148, 64270147, 64270146, 64270145, 64270144, 64270143, 64270142, 64270141, 64270140, 64270139, 64270138, 64270137, 64270136, 64270135, 64270134, 64270133, 64270132, 64270131, 64270130, 64270129, 64270128, 64270127, 64270126, 64270125, 64270124, 64270123, 64270122, 64270121, 64270120, 64270119, 64270118, 64270117, 64270116, 64270115, 64270114, 64270113, 64270112, 64270111, 64270110, 64270109, 64270108, 64270107, 64270106, 64270105, 64270104, 64270103, 64270102, 64270101, 64270100, 64270099, 64270098, 64270097, 64270096, 64270095, 64270094, 64270093, 64270092, 64270091, 64270090, 64270089, 64270088, 64270087, 64270086, 64270085, 64270084, 64270083, 64270082, 64270081, 64270080, 64270079, 64270078, 64270077, 64270076, 64270075, 64270074, 64270073, 64270072, 64270071, 64270070, 64270069, 64270068, 64270067, 64270066, 64270065, 64270064, 64270063, 64270062, 64270061, 64270060, 64270059, 64270058, 64270057, 64270056, 64270055, 64270054, 64270053, 64270052, 64270051, 64270050, 64270049, 64270048, 64270047, 64270046, 64270045, 64270044, 64270043, 64270042, 64270041, 64270040, 64270039, 64270038, 64270037, 64270036, 64270035, 64270034, 64270033, 64270032, 64270031, 64270030, 64270029, 64270028, 64270027, 64270026, 64270025, 64270024, 64270023, 64270022, 64270021, 64270020, 64270019, 64270018, 64270017, 64270016, 64270015, 64270014, 64270013, 64270012, 64270011, 64270010, 64270009, 64270008, 64270007, 64270006, 64270005, 64270004, 64270003, 64270002, 64270001, 64270000, 64269999, 64269998, 64269997, 64269996, 64269995, 64269994, 64269993, 64269992, 64269991, 64269990, 64269989, 64269988, 64269987, 64269986, 64269985, 64269984, 64269983, 64269982, 64269981, 64269980, 64269979, 64269978, 64269977, 64269976, 64269975, 64269974, 64269973, 64269972, 64269971, 64269970, 64269969, 64269968, 64269967, 64269966, 64269965, 64269964, 64269963, 64269962, 64269961, 64269960, 64269959, 64269958, 64269957, 64269956, 64269955, 64269954, 64269953, 64269952, 64269951, 64269950, 64269949, 64269948, 64269947, 64269946, 64269945, 64269944, 64269943, 64269942, 64269941, 64269940, 64269939, 64269938, 64269937, 64269936, 64269935, 64269934, 64269933, 64269932, 64269931, 64269930, 64269929, 64269928, 64269927, 64269926, 64269925, 64269924, 64269923, 64269922, 64252804, 64252803, 64252802, 64252801, 64252800, 64252799, 64252798, 64252797, 64252796, 64252795, 64252794, 64252793, 64252792, 64252791, 64252790, 64252789, 64252788, 64252787, 64252786, 64252785, 64252784, 64252783, 64252782, 64251903, 64251902, 64251901, 64251900, 64251899, 64251898, 64251897, 64251896, 64251895, 64251894, 64251893, 64251892, 64251891, 64251890, 64251889, 64251888, 64251887, 64251886, 64251885, 64251884, 64251883, 64251882, 64251881, 64251880, 64251879, 64251878, 64251877, 64251876, 64251875, 64251874, 64251873, 64251872, 64251871, 64251870, 64251869, 64251868, 64251867, 64251866, 64251865, 64251864, 64251863, 64251862, 64251861, 64251860, 64251859, 64251858, 64251857, 64251856, 64251855, 64251854, 64251853, 64251634, 64251633, 64251632, 64251631, 64251630, 64251629, 64251628, 64251627, 64251626, 64251625, 64251624, 64251623, 64251622, 64251621, 64251620, 64251619, 64251618, 64251617, 64251616, 64251615, 64251614, 64251613, 64251612, 64251611, 64251610, 64251609, 64251608, 64251607, 64251606, 64251605, 64251604, 64251603, 64251602, 64251601, 64251600, 64251599, 64251224, 64251223, 64251222, 64251221, 64251220, 64251219, 64251218, 64251217, 64251216, 64251215, 64251214, 64251213, 64251212, 64251211, 64251210, 64251209, 64251208, 64251207, 64251206, 64251205, 64251204, 64251203, 64251202, 64251201, 64251200, 64251199, 64251198, 64251197, 64251196, 64251195, 64250758, 64250756, 64250755, 64250754, 64250753, 64250751, 64250750, 64250749, 64250748, 64250746, 64250745, 64250744, 64250743, 64250742, 64250741, 64250740, 64250739, 64250738, 64250736, 64250735, 64250734, 64250733, 64250732, 64250731, 64250730, 64250729, 64250728, 64250727, 64250724, 64250722, 64250720, 64250717, 64250715, 64250714, 64250713, 64250712, 64250711, 64250710, 64250709, 64250708, 64250707, 64250704, 64250703, 64212758, 64212030, 64208920, 64208821, 64208482, 64208305, 64208009, 64200572, 64200094, 64199878, 64199719, 64198428, 64176100, 64175830, 64175570, 64174147, 64140100, 64138874, 64138148, 64137635, 64134486, 64091796, 64091449, 64090703, 64089616, 64089252, 64088268, 64042829, 63841927, 63841926, 63841925, 63841924, 63841923, 63841426, 63840545, 63840103, 63837040, 63836369, 63836019, 63835743, 63830250, 63826512, 63825967, 63789725, 63783027, 63783026, 63783025, 63783024, 63783023, 63783022, 63783021, 63521502, 63521394, 63520894, 63520826, 63520432, 63520016, 63519651, 63517900, 63517652, 63517290, 63511878, 63509810, 63509510, 63509364, 63508531, 63508263, 63507300, 63507093, 63504497, 63504222, 63503537, 63503468, 63503199, 63485316, 63468251, 63468130, 63468038, 63467912, 63467783, 63467659, 63467462, 63467326, 63467143, 63467044, 63465423, 63465133, 63463365, 63463026, 63463014, 63462817, 63457010, 63325222, 63224599, 63223727, 63183340, 63183100, 63182898, 63182749, 63182392, 63182200, 63181030, 63179331, 63178998, 63178597, 63177967, 63177531, 63177145, 63172646, 62493432, 62490423} +var c = []int64{ + 87893329, + 87542533, + 86486240, + 86454312, + 85672244, + 85672146, + 85672027, + 85671854, + 85671727, + 85671454, + 85671173, + 85670943, + 84938439, + 84936029, + 83727966, + 81521327, + 80790189} + +//668851, +//668841, +//668711, +//668770, +//668709, +//668708, +//668713, +//668707, +//668712, +//668710, +//668714, +//668723, +//668790, +//668789, +//668785, +//668512, +//667481, // 删除已经创建商品,重新同步 func TestDeleteSkuAndUploadSku(t *testing.T) { @@ -177,6 +212,36 @@ func TestDeleteSkuAndUploadSku(t *testing.T) { } } +// 删除已经创建商品,重新同步封禁 +func TestDeleteSkuAndUploadSkuFengJinBiXu222(t *testing.T) { + var errList = make([]error, 0, 0) + for i := 1; i < 100; i++ { + result, err := a.GetSkuDetailList(&product_listV2_request.ProductListV2Param{ + //Status: 2, + //CheckStatus: 3, // 1-未提交;2-待审核;3-审核通过;4-审核未通过;5-封禁;7-审核通过待上架 + Page: int64(i), + Size: 100, + }) + if err != nil { + globals.SugarLogger.Debugf("=index := %d ,err := %s", i, utils.Format4Output(err, false)) + continue + } + if len(result.Data) == 0 { + break + } + for _, v := range result.Data { + err := a.DeleteStoreCommodity(v.ProductId) + if err != nil { + errList = append(errList, err) + } + } + } + + for _, v := range errList { + globals.SugarLogger.Debugf("err := %s", utils.Format4Output(v, false)) + } +} + // 删除已经创建商品,重新同步 func TestDeleteSkuAndUploadSku55(t *testing.T) { var errList = make([]error, 0, 0) @@ -345,36 +410,6 @@ func TestDeleteSkuAndUploadSkuYanChiBiXu(t *testing.T) { } } -// 删除已经创建商品,重新同步封禁 -func TestDeleteSkuAndUploadSkuFengJinBiXu222(t *testing.T) { - var errList = make([]error, 0, 0) - for i := 1; i < 100; i++ { - result, err := a.GetSkuDetailList(&product_listV2_request.ProductListV2Param{ - Status: 0, - CheckStatus: 3, // 1-未提交;2-待审核;3-审核通过;4-审核未通过;5-封禁;7-审核通过待上架 - Page: int64(i), - Size: 100, - }) - if err != nil { - globals.SugarLogger.Debugf("=index := %d ,err := %s", i, utils.Format4Output(err, false)) - continue - } - if len(result.Data) == 0 { - break - } - for _, v := range result.Data { - err := a.DeleteStoreCommodity(v.ProductId) - if err != nil { - errList = append(errList, err) - } - } - } - - for _, v := range errList { - globals.SugarLogger.Debugf("err := %s", utils.Format4Output(v, false)) - } -} - // 删除已经创建商品,重新同步封禁 func TestDeleteSkuAndUploadSkuFengJinBiXu22332(t *testing.T) { var errList = make([]error, 0, 0)