From 3fa1e698925e89a7fd94a1433f9e61d28dfe13d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 30 Dec 2022 13:43:56 +0800 Subject: [PATCH] 1 --- platformapi/jdapi/store_sku_test.go | 47 +++++++++++++++++++ .../tiktok_shop/tiktok_api/afs_test.go | 4 +- .../tiktok_shop/tiktok_api/sku_test.go | 42 ++++++++++++----- 3 files changed, 78 insertions(+), 15 deletions(-) diff --git a/platformapi/jdapi/store_sku_test.go b/platformapi/jdapi/store_sku_test.go index 63f10501..ddc82f7a 100644 --- a/platformapi/jdapi/store_sku_test.go +++ b/platformapi/jdapi/store_sku_test.go @@ -1,6 +1,8 @@ package jdapi import ( + "fmt" + "sync" "testing" "git.rosy.net.cn/baseapi/utils" @@ -121,3 +123,48 @@ func TestBatchUpdateCurrentQtys(t *testing.T) { t.Log(utils.Format4Output(result, false)) //baseapi.SugarLogger.Debug(utils.Format4Output(result, false)) } + +type Object2222 struct { + Clients map[string]int + *sync.RWMutex +} + +func NewTcpClient222() *Object2222 { + t := &Object2222{ + Clients: make(map[string]int), + } + t.RWMutex = new(sync.RWMutex) + return t +} +func TestLock(t *testing.T) { + obj := NewTcpClient222() + go func() { + fmt.Println("1") + for i := 0; i < 100000; i++ { + obj.setParam(utils.Int2Str(i), i) + } + }() + + go func() { + fmt.Println("2") + for i := 0; i < 100000; i++ { + fmt.Println(obj.getParam(utils.Int2Str(i))) + } + }() + + for i := 0; i < 100000; i++ { + fmt.Println(obj.Clients[utils.Int2Str(i)]) + } +} + +func (t *Object2222) setParam(key string, v int) { + t.Lock() + defer t.Unlock() + t.Clients[key] = v +} + +func (t *Object2222) getParam(key string) int { + t.RLock() + defer t.RUnlock() + return t.Clients[key] +} diff --git a/platformapi/tiktok_shop/tiktok_api/afs_test.go b/platformapi/tiktok_shop/tiktok_api/afs_test.go index d1a3be4f..9e712747 100644 --- a/platformapi/tiktok_shop/tiktok_api/afs_test.go +++ b/platformapi/tiktok_shop/tiktok_api/afs_test.go @@ -18,9 +18,9 @@ import ( // "authority_id": "" //}` -var token = `{"access_token":"84b9ab00-68d0-4b9f-9682-a03f75eaed95","expires_in":1672634978,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"44b1e11e-90a0-4876-b5f9-edd2bf5820e8","authority_id":""}` +// var token = `{"access_token":"84b9ab00-68d0-4b9f-9682-a03f75eaed95","expires_in":1672634978,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"44b1e11e-90a0-4876-b5f9-edd2bf5820e8","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":"83e52462-ad46-4297-98c4-242ee6b7a5c8","expires_in":1672033612,"scope":"SCOPE","shop_id":63141688,"shop_name":"二期-抖音超市小时达测试店铺","refresh_token":"8f690bc3-3f3e-49bd-bbf7-31c9e868e980","authority_id":""}` var a = New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token) // 查询售后单详情 diff --git a/platformapi/tiktok_shop/tiktok_api/sku_test.go b/platformapi/tiktok_shop/tiktok_api/sku_test.go index 0ccd35e6..ef4b9c6a 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku_test.go +++ b/platformapi/tiktok_shop/tiktok_api/sku_test.go @@ -11,10 +11,9 @@ import ( "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/globals" "go.uber.org/zap" - "math/rand" + "net" "strings" "testing" - "time" ) func init() { @@ -56,7 +55,7 @@ func TestGetSkuDetail(t *testing.T) { // 查询商品详情本地商品id func TestGetSkuDetailLocalId(t *testing.T) { - data, err := a.GetSkuDetail("3582156764822536769", "") + data, err := a.GetSkuDetail("3591255127098564258", "") fmt.Println(err) globals.SugarLogger.Debugf("====%s", utils.Format4Output(data, false)) } @@ -155,7 +154,7 @@ func TestGetSkuList(t *testing.T) { for i := 1; i < 100; i++ { result, err := a.GetSkuDetailList(&product_listV2_request.ProductListV2Param{ Status: 0, - CheckStatus: 3, + CheckStatus: 3, // 1 2 3 4 5 7 ProductType: 0, StartTime: 0, EndTime: 0, @@ -163,7 +162,7 @@ func TestGetSkuList(t *testing.T) { Size: 100, UpdateStartTime: 0, UpdateEndTime: 0, - StoreId: 65402632, + StoreId: 63521502, }) if err != nil { globals.SugarLogger.Debugf("=index := %d ,err := %s", i, utils.Format4Output(err, false)) @@ -189,14 +188,31 @@ func TestGetBrandId(t *testing.T) { } func Test11111(t *testing.T) { - rand.Seed(time.Now().UnixNano()) - for i := 0; i < 10; i++ { - randNumber := rand.Int63n(481) - if randNumber < 60 { - randNumber += 60 - } - fmt.Println(randNumber) + // 简历连接 + conn, err := net.Dial("tcp", "www.jxcs.net:8000") + if err != nil { + fmt.Println(err) + return } + clearPrint := fmt.Sprintf(`{"print_no":%s}`, "120220915001012") + // 发送数据 + if _, err := conn.Write([]byte(clearPrint)); err != nil { + fmt.Println(err) + return + } + // 等待数据 + buf := make([]byte, 1024) + n, err := conn.Read(buf) + if err != nil { + fmt.Println(err) + return + } + if string(buf[:n]) != "ok" { + fmt.Println(string(buf[:n])) + return + } + defer conn.Close() + return } func TestGetProductUpdateRule(t *testing.T) { @@ -261,7 +277,7 @@ func TestGetProductAuditList(t *testing.T) { func TestCreateShopData(t *testing.T) { imgs := make([]Imgs, 0, 0) - img := []string{"http://p0.meituan.net/xianfu/83b499974d4507a31f6e654d41cf578149300.jpg"} + img := []string{"https://image.jxc4.com/image/3466882a253817da6787186c358e4e15.jpg", "https://image.jxc4.com/image/df487ad53f3014983b41330755809e60.jpg"} for _, v := range img { if v != "" { imgs = append(imgs, Imgs{