From 47d67bb9d80fb18d72fdee8a49238945411d7a43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 25 Mar 2026 11:46:28 +0800 Subject: [PATCH] 1 --- platformapi/ebaiapi/ebaiapi_test.go | 4 ++-- platformapi/ebaiapi/shop_sku.go | 29 ++++++++++++++++++++++++++++ platformapi/ebaiapi/shop_sku_test.go | 14 ++++++-------- platformapi/mtwmapi/mtwmapi_test.go | 2 +- platformapi/weixinapi/sns_test.go | 7 ++++++- 5 files changed, 44 insertions(+), 12 deletions(-) diff --git a/platformapi/ebaiapi/ebaiapi_test.go b/platformapi/ebaiapi/ebaiapi_test.go index 467decd2..ce86377b 100644 --- a/platformapi/ebaiapi/ebaiapi_test.go +++ b/platformapi/ebaiapi/ebaiapi_test.go @@ -29,13 +29,13 @@ func init() { // api = New("62289", "d3ec2358d6a819ea") // 京西菜市 - api = New("34665", "c3db75b754ea2d89") + //api = New("34665", "c3db75b754ea2d89") //菜市测试 // api = New("62923", "aa4cdc6c1108486b") // 京西果园 - //api = New("35957", "10013fbb7c2ddad7") + api = New("35957", "10013fbb7c2ddad7") // api.SetCookie("PASSPORT_DELIMONT_TOKEN", "PBE_2.0_5cd1c6141c127d4188f026ac01fc93656266683e8dfb3127c2fdf894259e9034125ff3bdd2a997a385802ee3ef1802ba93a04acea34fde2d2b6e802c5dcd4ec6e3f4ad909a1d806e3ceeb349ed726b03d60ed1fe7010d4140aa338d9c5f05e3fec172c78d3d7f0ca579d61b7015af1bf99aa46b04d2b8a64aa50646dc09afe94b6b60e0ba9a933635db5e8b2a035e9b6d693b289acf1b256d5b9a3f8478c87b0b009115bfd1394f20bb5a0dc2c07b8d013a25f286ec6bf7f2d86010d65507e31358834b7a6b58fbd88cb3f1a12cf71c997b91c1527f6f3c10693f7c2bd6073da8633a98cd2dc1114dfa5be5ee0e60b02cf7e4a94d0fb563a8c01717e7c050f02249117219c07a2eb211577c208ba77f4d536fa25139bc249be93b38d6fc495ef67a32aa206835d177db402bc534de1d29caf4f6b4fbcd912c13f167d00d1732222744c336a5189728f72fb5e153c4b1164171cfb0c811f34f4c2fedd43f721b8706b43f8d631251c") //api.SetCookie("WMUSS", "NTE2NDMTAwMDAyNzYxNzAwOTEyTmUzNWJNcDlQ ") //api.SetCookie("WMSTOKEN", "NTE2NDMTAwMDAyNzYxNzAwOTEyTmUzNWJNcDlQ ") diff --git a/platformapi/ebaiapi/shop_sku.go b/platformapi/ebaiapi/shop_sku.go index 1ca22135..7d0725e1 100644 --- a/platformapi/ebaiapi/shop_sku.go +++ b/platformapi/ebaiapi/shop_sku.go @@ -350,6 +350,35 @@ func (a *API) SkuCreate(trackInfo, shopID string, customSkuID int64, params map[ return 0, err } +// 饿百商品名可以相同,不会报错 SkuCreate2 customSkuID改为string +func (a *API) SkuCreate2(trackInfo, shopID string, customSkuID string, params map[string]interface{}) (skuID int64, err error) { + defParams := map[string]interface{}{ + KeyShopID: shopID, + KeyCustomSkuID: customSkuID, + } + if utils.IsNil(params["upc"]) { + params["upc"] = "upc-" + customSkuID + } + /*if params["brand_id"] == nil { + defParams["brand_id"] = 0 + } + if params["brand_name"] == nil { + defParams["brand_name"] = "无" // 很狗血的是,你还必须填个无才行。。。 + }*/ + params = utils.MergeMaps(params, defParams) + result, err := a.AccessAPI2("sku.create", params, trackInfo) + if err == nil && result.Data != nil { + return utils.Interface2Int64WithDefault(result.Data.(map[string]interface{})[KeySkuID], 0), nil + } else if err != nil && strings.Contains(err.Error(), "商品已存在") { + skuIDStr := err.Error() + start := strings.LastIndex(skuIDStr, "sku_id") + end := strings.Index(skuIDStr, "level") + return utils.Str2Int64(skuIDStr[start+7 : end-1]), nil + } + + return 0, err +} + func (a *API) SkuUpdate(trackInfo, shopID string, ebaiSkuID int64, params map[string]interface{}) (skuID int64, err error) { defParams := map[string]interface{}{ KeyShopID: shopID, diff --git a/platformapi/ebaiapi/shop_sku_test.go b/platformapi/ebaiapi/shop_sku_test.go index ffdfd9a5..18821540 100644 --- a/platformapi/ebaiapi/shop_sku_test.go +++ b/platformapi/ebaiapi/shop_sku_test.go @@ -86,19 +86,17 @@ func TestSkuListDelete(t *testing.T) { Page: page, PageSize: 100, } - foodList, err := api.SkuList(utils.Int2Str(667453), param) + foodList, err := api.SkuList(utils.Int2Str(5000100), param) if err != nil { break } for k, v := range foodList.List { - if v.CustomSkuID == "" { - api.AccessAPI2("sku.delete", map[string]interface{}{ - "shop_id": "667453", - "sku_id": v.SkuId, - }, utils.GetUUID()) - globals.SugarLogger.Debugf("---k := %d,delete_name:= %s", k, v.Name) - } + api.AccessAPI2("sku.delete", map[string]interface{}{ + "shop_id": "5000100", + "sku_id": v.SkuId, + }, utils.GetUUID()) + globals.SugarLogger.Debugf("---k := %d,delete_name:= %s", k, v.Name) } globals.SugarLogger.Debugf("------page := %d", foodList.SkuIdOffset) page = page + 1 diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go index 6cb2da72..f6178f9c 100644 --- a/platformapi/mtwmapi/mtwmapi_test.go +++ b/platformapi/mtwmapi/mtwmapi_test.go @@ -25,7 +25,7 @@ func init() { //api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //商超 - api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_uBpkcyJpxPsNSNMdpf1JhQ") + api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_vf8fP3ELY3RQleIw-oxJNg") //cookieStr := ` // acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; //` diff --git a/platformapi/weixinapi/sns_test.go b/platformapi/weixinapi/sns_test.go index b46ad55a..e832f9e5 100644 --- a/platformapi/weixinapi/sns_test.go +++ b/platformapi/weixinapi/sns_test.go @@ -2,6 +2,7 @@ package weixinapi import ( "fmt" + "git.rosy.net.cn/baseapi/utils" "testing" "time" ) @@ -87,5 +88,9 @@ func TestSNSDeliveryGoodsOrder(t *testing.T) { } func TestName(t *testing.T) { - fmt.Println(411 / 50) + vendorId := 113 + fromVendorID := utils.Str2Int(string(utils.Int2Str(vendorId)[0])) + to := utils.Str2Int(string(utils.Int2Str(vendorId)[1:])) + fmt.Println(fromVendorID) + fmt.Println(to) }