From c49b25f0fc142d939d1ba9a8b5fc755f30d8029f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 13 Oct 2022 09:50:13 +0800 Subject: [PATCH] 1 --- .../response/order_orderDetail_response.go | 16 +++---- .../tiktok_shop/tiktok_api/api_test.go | 2 +- platformapi/tiktok_shop/tiktok_api/order.go | 5 +++ platformapi/tiktok_shop/tiktok_api/sku.go | 42 ++++++++++++++----- .../tiktok_shop/tiktok_api/sku_test.go | 32 +++++++++++--- 5 files changed, 72 insertions(+), 25 deletions(-) diff --git a/platformapi/tiktok_shop/sdk-golang/api/order_orderDetail/response/order_orderDetail_response.go b/platformapi/tiktok_shop/sdk-golang/api/order_orderDetail/response/order_orderDetail_response.go index 5ae4bd51..15dc1e4b 100644 --- a/platformapi/tiktok_shop/sdk-golang/api/order_orderDetail/response/order_orderDetail_response.go +++ b/platformapi/tiktok_shop/sdk-golang/api/order_orderDetail/response/order_orderDetail_response.go @@ -219,10 +219,10 @@ type ShopOrderDetail struct { PromotionPayAmount int64 `json:"promotion_pay_amount"` // 收件人电话 PostTel string `json:"post_tel"` - encryptPostTel string `json:"encrypt_post_tel"` + EncryptPostTel string `json:"encrypt_post_tel"` // 收件人姓名 PostReceiver string `json:"post_receiver"` - encryptPostReceiver string `json:"encrypt_post_receiver"` + EncryptPostReceiver string `json:"encrypt_post_receiver"` // 收件人地址 PostAddr *PostAddr `json:"post_addr"` // 预计发货时间,时间戳,秒 @@ -299,7 +299,7 @@ type PostAddr struct { Street *Street `json:"street"` // 详细地址 Detail string `json:"detail"` - encryptDetail string `json:"encrypt_detail"` + EncryptDetail string `json:"encrypt_detail"` } type SkuSpecsItem struct { // 规格名称 @@ -324,7 +324,7 @@ type AccountInfoItem struct { AccountType string `json:"account_type"` // 账号值 AccountId string `json:"account_id"` - encryptAccountId string `json:"encrypt_account_id"` + EncryptAccountId string `json:"encrypt_account_id"` } type LogisticsInfoItem struct { // 物流单号 @@ -551,10 +551,10 @@ type SkuOrderListItem struct { Code string `json:"code"` // 收件人电话 PostTel string `json:"post_tel"` - encryptPostTel string `json:"encrypt_post_tel"` + EncryptPostTel string `json:"encrypt_post_tel"` // 收件人姓名 PostReceiver string `json:"post_receiver"` - encryptPostReceiver string `json:"encrypt_post_receiver"` + EncryptPostReceiver string `json:"encrypt_post_receiver"` // 收件人地址 PostAddr *PostAddr `json:"post_addr"` // 预计发货时间 @@ -741,10 +741,10 @@ type OrderPhaseListItem struct { type UserIdInfo struct { // 证件号 IdCardNo string `json:"id_card_no"` - encryptIdCardNo string `json:"encrypt_id_card_no"` + EncryptIdCardNo string `json:"encrypt_id_card_no"` // 证件姓名 IdCardName string `json:"id_card_name"` - encryptIdCardName string `json:"encrypt_id_card_name"` + EncryptIdCardName string `json:"encrypt_id_card_name"` } type ShopOrderTagUiItem struct { // 标签key diff --git a/platformapi/tiktok_shop/tiktok_api/api_test.go b/platformapi/tiktok_shop/tiktok_api/api_test.go index 1ef51b79..7d92939b 100644 --- a/platformapi/tiktok_shop/tiktok_api/api_test.go +++ b/platformapi/tiktok_shop/tiktok_api/api_test.go @@ -22,7 +22,7 @@ func TestApi(t *testing.T) { func TestQueryOrderDetail(t *testing.T) { token := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652230,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authority_id":""}` a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token) - data, err := a.GetTiktokOrderDetail("4988354190732430566") + data, err := a.GetTiktokOrderDetail("4988546918828606694") globals.SugarLogger.Debugf("=====%s", utils.Format4Output(data, false)) globals.SugarLogger.Debugf("=====%s", err) } diff --git a/platformapi/tiktok_shop/tiktok_api/order.go b/platformapi/tiktok_shop/tiktok_api/order.go index 2f7e6097..70829924 100644 --- a/platformapi/tiktok_shop/tiktok_api/order.go +++ b/platformapi/tiktok_shop/tiktok_api/order.go @@ -594,3 +594,8 @@ func (a *API) GetCallbackOrderId(msgId string, data interface{}) (string, *Callb return "", &CallbackResponse{Code: CallbackSuccessCode, Msg: CallbackSuccess} } + +// OrderStatusAndPsInfo 三方配送同步骑手位置信息 +func (a *API) OrderStatusAndPsInfo() error { + return nil +} diff --git a/platformapi/tiktok_shop/tiktok_api/sku.go b/platformapi/tiktok_shop/tiktok_api/sku.go index 16788979..8fc57de8 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku.go +++ b/platformapi/tiktok_shop/tiktok_api/sku.go @@ -292,34 +292,54 @@ func (a *API) GetSkuBrand(categoryId int64) (int64, error) { } // OrderUserInfoDecrypt 用户信息解密 -func (a *API) OrderUserInfoDecrypt(orderId string) { +func (a *API) OrderUserInfoDecrypt(orderId, name, tel, address string) (string, string, string, error) { request := order_batchDecrypt_request.New() cipherInfos := make([]order_batchDecrypt_request.CipherInfosItem, 0, 0) - for i := 0; i < 3; i++ { + for i := 1; i <= 3; i++ { cipher := order_batchDecrypt_request.CipherInfosItem{} cipher.AuthId = orderId switch i { case 1: // 姓名 - cipher.CipherText = `#4/6R5x2e#yNZ5R4x+4YGk4yVVUVj5wDFNcIO8SPEjbXC7v55AV0oJKDafFKn9onnavg==&CgwIARDmDhjXESAEKAESPgo8UJvXDogRQo6o/CTNf5vPfN8ncAvwDTZrf4nw4v5BDusLnWFb0kH6vvl6qtlZ6MwEph9vT9DIHobUFoQxGgA=#1##` + cipher.CipherText = name cipherInfos = append(cipherInfos, cipher) case 2: // 手机号 - cipher.CipherText = `$L2ixwE3gFa/PhQeeN1Hxc0+TIImkbdVAcjdvVK1+BKE=$CT/fyQwDSEZskk3rWaxj5Je4w871eh1YBvge+aAv1chQ8pZsVBvJsQhRj+Rs&CgwIARDmDhjXESAEKAESPgo8Hs17yiBRdtnvUSwCjYO5fFyy/b8/ihLznxEgZeFaSO0LpVZrlIqHcNmBMrh3g0WNi3fLMAwFfi0v8qpoGgA=$1$$` + cipher.CipherText = tel cipherInfos = append(cipherInfos, cipher) case 3: // 地址 - cipher.CipherText = `#UK1DDyGyV7AafNwBv0jMYdu1SxWkQlvD8/jN1W36QM/2y1hzIUVLCYMDhJWgAbEWCYMDUnbMaB6m0Rx7#ztuYzQyi68RWDzQGHNQwgNW4/aC19tCAyTJKZFTA5vd5YdBbzllK6lXCA58ulHB9FyvxzpUDAtWUVgywqCPsaDYsaDTjCo0g4RbUyyuRGoYz/BY=&CgwIARDmDhjXESAEKAESPgo8lmOxB5Al56WzV1wV3mupjuiJEnavXuyPyFoMJ0WexY9pCI56tSyZN78zvqrnqSSLrdt3V4Q0OugOv8seGgA=#1##` + cipher.CipherText = address cipherInfos = append(cipherInfos, cipher) } } request.Param.CipherInfos = cipherInfos result, err := request.Execute(a.accessTokenObj) - fmt.Println(result) - fmt.Println(err) + if err != nil { + return "", "", "", err + } + if result.Code != RequestSuccessCode { + return "", "", "", errors.New(result.SubCode) + } + + var ( + userName, userTel, userAddress = "", "", "" + ) + for _, v := range result.Data.DecryptInfos { + if v.CipherText != "" && v.CipherText == name { + userName = v.DecryptText + } + if v.CipherText != "" && v.CipherText == tel { + userTel = v.DecryptText + } + if v.CipherText != "" && v.CipherText == address { + userAddress = v.DecryptText + } + } + return userName, userTel, userAddress, err } // OrderUserInfoSensitive 用户信息脱敏 -func (a *API) OrderUserInfoSensitive(orderId string) { +func (a *API) OrderUserInfoSensitive(orderId, name, tel, address string) { request := order_batchSensitive_request.New() paramItems := make([]order_batchSensitive_request.CipherInfosItem, 0, 0) @@ -328,13 +348,13 @@ func (a *API) OrderUserInfoSensitive(orderId string) { cipher.AuthId = orderId switch i { case 1: // 姓名 - cipher.CipherText = `#4/6R5x2e#yNZ5R4x+4YGk4yVVUVj5wDFNcIO8SPEjbXC7v55AV0oJKDafFKn9onnavg==&CgwIARDmDhjXESAEKAESPgo8UJvXDogRQo6o/CTNf5vPfN8ncAvwDTZrf4nw4v5BDusLnWFb0kH6vvl6qtlZ6MwEph9vT9DIHobUFoQxGgA=#1##` + cipher.CipherText = name paramItems = append(paramItems, cipher) case 2: // 手机号 - cipher.CipherText = `$L2ixwE3gFa/PhQeeN1Hxc0+TIImkbdVAcjdvVK1+BKE=$CT/fyQwDSEZskk3rWaxj5Je4w871eh1YBvge+aAv1chQ8pZsVBvJsQhRj+Rs&CgwIARDmDhjXESAEKAESPgo8Hs17yiBRdtnvUSwCjYO5fFyy/b8/ihLznxEgZeFaSO0LpVZrlIqHcNmBMrh3g0WNi3fLMAwFfi0v8qpoGgA=$1$$` + cipher.CipherText = tel paramItems = append(paramItems, cipher) case 3: // 地址 - cipher.CipherText = `#UK1DDyGyV7AafNwBv0jMYdu1SxWkQlvD8/jN1W36QM/2y1hzIUVLCYMDhJWgAbEWCYMDUnbMaB6m0Rx7#ztuYzQyi68RWDzQGHNQwgNW4/aC19tCAyTJKZFTA5vd5YdBbzllK6lXCA58ulHB9FyvxzpUDAtWUVgywqCPsaDYsaDTjCo0g4RbUyyuRGoYz/BY=&CgwIARDmDhjXESAEKAESPgo8lmOxB5Al56WzV1wV3mupjuiJEnavXuyPyFoMJ0WexY9pCI56tSyZN78zvqrnqSSLrdt3V4Q0OugOv8seGgA=#1##` + cipher.CipherText = address paramItems = append(paramItems, cipher) } } diff --git a/platformapi/tiktok_shop/tiktok_api/sku_test.go b/platformapi/tiktok_shop/tiktok_api/sku_test.go index 86c2bd1d..724ab830 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku_test.go +++ b/platformapi/tiktok_shop/tiktok_api/sku_test.go @@ -7,6 +7,7 @@ import ( product_addV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_addV2/request" product_editV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_editV2/request" product_editV2_commit_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_editV2_commit/request" + product_listV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_listV2/request" sku_editPrice_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_editPrice/request" sku_syncStock_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_syncStock/request" "git.rosy.net.cn/baseapi/utils" @@ -224,7 +225,7 @@ func TestGetSkuDetail(t *testing.T) { token := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652230,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authority_id":""}` a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token) - data, err := a.GetSkuDetail("3576377564144516403", "") + data, err := a.GetSkuDetail("3576590519251398269", "") fmt.Println(err) globals.SugarLogger.Debugf("====%s", utils.Format4Output(data, false)) } @@ -300,13 +301,34 @@ func TestBatchDecrypt(t *testing.T) { token := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652230,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authority_id":""}` a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token) - a.OrderUserInfoDecrypt("4988354190732430566") + encrypt_post_tel := `##3aVwfhe5fJHdlO0UijiOA3GbeZYsIZppi+Y9bpYZ9gRBshpl555DP9B1FFp8R0fbyiTaeU9LAck8nkzKNMp5frZUO0w2ba8lsm+1zwYZrBkFlQ==*CgkIARCtHCABKAESPgo8d1IWxRMUZ/3UM2wAbb6m8jXa0z/h/RDf4NnIrUK3Zfiqg+/rrvoo/3DX9DQfmAW/5DkNVk2beqYZx0tYGgA=#1##` + encrypt_post_receiver := `##K3dJts44TlQGmLNQAHud1Iivzu6rWDeFx8EwQYK35oMXVtlLGgN+ZmQDIa7K6rVzXYReq3dgKz8Vi4VGVR8kR45BpHZdaVJUx2tCwM0=*CgkIARCtHCABKAESPgo8X7FrpSxbV2yGA29uxewKEdHW+Rp1tiqWGxRZgwirlJX2uOILTwCWTN6Q1sT3JHeTjXgXslRTEqqWcdd/GgA=#1##` + encrypt_post_name := `` + a.OrderUserInfoDecrypt("4988546918828606694", encrypt_post_name, encrypt_post_tel, encrypt_post_receiver) } -// 脱敏购买用户电话,名字,地址 -func TestOrderUserInfoSensitive(t *testing.T) { +//// 脱敏购买用户电话,名字,地址 +//func TestOrderUserInfoSensitive(t *testing.T) { +// token := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652230,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authority_id":""}` +// +// a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token) +// a.OrderUserInfoSensitive("4988354190732430566") +//} + +func TestGetSkuList(t *testing.T) { token := `{"access_token":"a1746210-a8a3-4497-a87b-09d1f10dbb95","expires_in":1665652230,"scope":"SCOPE","shop_id":"","shop_name":"小时达开放平台对接专用店","refresh_token":"c1cf8d88-0983-4f2a-b969-3746fae6b0cd","authority_id":""}` a := New("7136048270014416392", "c397aa9f-3927-47c4-8cfe-4d84e02602e0", token) - a.OrderUserInfoSensitive("4988354190732430566") + a.GetSkuDetailList(&product_listV2_request.ProductListV2Param{ + Status: 0, + CheckStatus: 0, + ProductType: 0, + StartTime: 0, + EndTime: 0, + Page: 1, + Size: 100, + UpdateStartTime: 0, + UpdateEndTime: 0, + //StoreId: 63114504, + }) }