diff --git a/platformapi/jdapi/store_page_test.go b/platformapi/jdapi/store_page_test.go index bbc0458b..ca04ad11 100644 --- a/platformapi/jdapi/store_page_test.go +++ b/platformapi/jdapi/store_page_test.go @@ -211,7 +211,7 @@ func TestC(t *testing.T) { //} // func TestGetJdUpcCodeByName(t *testing.T) { - result, err := api.GetJdUpcCodeByName("", "6909931247116", 1, 5) + result, err := api.GetJdUpcCodeByName("", "6924343516087", 1, 5) if err != nil { t.Fatal(err) } diff --git a/platformapi/kuaishou_mini/kuaishou_api.go b/platformapi/kuaishou_mini/kuaishou_api.go index d72c3138..9e03569c 100644 --- a/platformapi/kuaishou_mini/kuaishou_api.go +++ b/platformapi/kuaishou_mini/kuaishou_api.go @@ -6,6 +6,7 @@ import ( "fmt" "git.rosy.net.cn/baseapi/platformapi" "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/globals" "net/http" "sort" "strings" @@ -77,7 +78,26 @@ func (a *API) GetToken() error { return nil } -// AccessAPI2 发送请求 +// AccessAPI1 发送请求(支付) +func (a *API) AccessAPI1(url string, params map[string]interface{}) (retVal map[string]interface{}, err error) { + err = platformapi.AccessPlatformAPIWithRetry(a.client, + func() *http.Request { + request, _ := http.NewRequest(http.MethodPost, url, strings.NewReader(utils.Map2URLValues(params).Encode())) + request.Header.Set("Content-Type", "application/json") + return request + }, + a.config, + func(response *http.Response, bodyStr string, jsonResult1 map[string]interface{}) (errLevel string, err error) { + if jsonResult1 == nil { + return platformapi.ErrLevelRecoverableErr, fmt.Errorf("mapData is nil") + } + retVal = jsonResult1 + return platformapi.ErrLevelSuccess, nil + }) + return retVal, err +} + +// AccessAPI2 发送请求(登录) func (a *API) AccessAPI2(url string, params map[string]interface{}) (retVal map[string]interface{}, err error) { err = platformapi.AccessPlatformAPIWithRetry(a.client, func() *http.Request { @@ -116,9 +136,12 @@ func (a *API) sign(param map[string]interface{}) string { } sort.Strings(paramsArr) - signParma := make([]string, 0, 0) + + globals.SugarLogger.Debugf("param := %s", utils.Format4Output(param, false)) + globals.SugarLogger.Debugf("paramsArr := %s", utils.Format4Output(paramsArr, false)) + signParma := make([]string, len(paramsArr)) for k, v := range paramsArr { - if utils.IsNil(param[v]) { + if !utils.IsNil(param[v]) { signParma[k] = v + "=" + fmt.Sprintf("%v", param[v]) } } diff --git a/platformapi/kuaishou_mini/kuaishou_pay.go b/platformapi/kuaishou_mini/kuaishou_pay.go index b17443c5..95f59189 100644 --- a/platformapi/kuaishou_mini/kuaishou_pay.go +++ b/platformapi/kuaishou_mini/kuaishou_pay.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" "git.rosy.net.cn/baseapi/utils" + "time" ) // PreCreateOrder 预下单生成支付信息 @@ -13,7 +14,7 @@ func (a *API) PreCreateOrder(param *PreCreateOrderReq) (string, error) { } param.Sign = a.sign(utils.Struct2MapByJson(param)) - result, err := a.AccessAPI2(a.FullUrl(KuaiShouPreCreateOrder), utils.Struct2MapByJson(param)) + result, err := a.AccessAPI1(a.FullUrl(KuaiShouPreCreateOrder), utils.Struct2MapByJson(param)) if err != nil { return "", err } @@ -31,5 +32,8 @@ func (a *API) PreCreateOrder(param *PreCreateOrderReq) (string, error) { } func (a *API) FullUrl(bashUrl string) string { + if a.accessToken == "" || a.expiresIn < time.Now().Unix() { + a.GetToken() + } return fmt.Sprintf(bashUrl+"?app_id=%s&access_token=%s", a.appId, a.accessToken) } diff --git a/platformapi/kuaishou_mini/kuaishou_test.go b/platformapi/kuaishou_mini/kuaishou_test.go index d4c10cd0..a5401dca 100644 --- a/platformapi/kuaishou_mini/kuaishou_test.go +++ b/platformapi/kuaishou_mini/kuaishou_test.go @@ -2,6 +2,7 @@ package kuaishou_mini import ( "encoding/base64" + "fmt" "git.rosy.net.cn/baseapi" "git.rosy.net.cn/baseapi/utils" "git.rosy.net.cn/jx-callback/globals" @@ -79,14 +80,26 @@ func TestPreCreateOrder(t *testing.T) { TypeDetail: 1832, // 素菜 ExpireTime: 10 * 60, Sign: "", - Attach: "", + Attach: "1111", NotifyUrl: "https://callback.jxc4.com/tictoc/tiktokMsg", - GoodsId: "", - GoodsDetailUrl: "", - MultiCopiesGoodsInfo: "", + GoodsId: "1122", + GoodsDetailUrl: "/page/index/anima", + MultiCopiesGoodsInfo: "[{\"copies\":2}]", CancelOrder: 0, } data, err := api.PreCreateOrder(param) globals.SugarLogger.Debugf("data := %s", utils.Format4Output(data, false)) globals.SugarLogger.Debugf("err := %s", utils.Format4Output(err, false)) } + +func TestAaww(t *testing.T) { + aa := make(map[string]interface{}, 1) + aa["a"] = "" + if value, ok := aa["a"].(int64); ok { + fmt.Println(value) + } + if value, ok := aa["a"].(string); ok { + + fmt.Println(utils.Str2Int64(value)) + } +} diff --git a/platformapi/tiktok_shop/tiktok_api/afs_test.go b/platformapi/tiktok_shop/tiktok_api/afs_test.go index 243cfe48..a9f7b92f 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":"2edc427e-9ab8-430b-a502-6802f1dee387","expires_in":1679861437,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"dda56ad5-521b-4b87-9d74-bd6df13df1aa","authority_id":""}` +var token = `{"access_token":"cf5c39a7-969a-4a54-8528-e3d9479c202f","expires_in":1681065425,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"4f54e08d-1d62-4f96-935d-20b938c19f96","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/api_test.go b/platformapi/tiktok_shop/tiktok_api/api_test.go index 89b5955a..bf166ea9 100644 --- a/platformapi/tiktok_shop/tiktok_api/api_test.go +++ b/platformapi/tiktok_shop/tiktok_api/api_test.go @@ -21,7 +21,7 @@ func TestApi(t *testing.T) { } func TestQueryOrderDetail(t *testing.T) { - data, err := a.GetTiktokOrderDetail("5042953882665211095") + data, err := a.GetTiktokOrderDetail("6917547162766021688") globals.SugarLogger.Debugf("=====%s", utils.Format4Output(data, false)) globals.SugarLogger.Debugf("=====%s", err) } diff --git a/platformapi/tiktok_shop/tiktok_api/sku.go b/platformapi/tiktok_shop/tiktok_api/sku.go index a86551d8..46a314a5 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" ) @@ -351,6 +352,7 @@ func (a *API) OrderUserInfoDecrypt(orderId, name, tel, address string) (string, request.Param.CipherInfos = cipherInfos result, err := request.Execute(a.accessTokenObj) + globals.SugarLogger.Debugf("OrderUserInfoDecrypt======:%s", utils.Format4Output(result, false)) if err != nil { return "", "", "", err } diff --git a/platformapi/tiktok_shop/tiktok_api/sku_test.go b/platformapi/tiktok_shop/tiktok_api/sku_test.go index 737980b3..5e70749d 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku_test.go +++ b/platformapi/tiktok_shop/tiktok_api/sku_test.go @@ -120,13 +120,15 @@ func TestProductSetOffline(t *testing.T) { // 解密购买用户电话,名字,地址 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) - 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_tel := "##mjApaTO5LNGFDnAU2UmRwu1zhlDQH2+NjIc9kTlQzUYpf1XXrxyxUzd1nWdTPb9H3iFNAdFG66zReSdhf6qUtNVBwNEn5RnIM8wQapxFjh4v+g==*CgkIARCtHCABKAESPgo81dqD65kMclp62fAJBLUpNOP22AKtaL8/7CHDPtDCS8wVtCp/TWhRNLsuFrq/Pmhhz+fe3GDtG8R/L0O0GgA=#1##" + encrypt_post_receiver := "##Cg8e7Ks78U0rSX7AO6NxoD9pPtISczJdulakYdCJDNqXLsFMfhG/0mz7CoxJJyY7zRvx1dkFKahgRk0NCsAxApns7NaaGDu9tyEXloBu9Sc=*CgkIARCtHCABKAESPgo8ja2mXE+INEhReF2W0+deMN0qb/ZoPtaxS98YbR4a1smRO4WPj+jSiYsBv00+DxiXfJTW3DdxusF6TVS3GgA=#1##" encrypt_post_name := `` - a.OrderUserInfoDecrypt("4988546918828606694", encrypt_post_name, encrypt_post_tel, encrypt_post_receiver) + name, tel, address, err := a.OrderUserInfoDecrypt("6917547162766021688", encrypt_post_name, encrypt_post_tel, encrypt_post_receiver) + fmt.Println(name) + fmt.Println(tel) + fmt.Println(address) + fmt.Println(err) } //// 脱敏购买用户电话,名字,地址