From 6301157379df9ca8e751024de4252be16ed1c7d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 31 Mar 2023 11:32:41 +0800 Subject: [PATCH 01/21] 1'| --- platformapi/alipayapi/utils_test.go | 2 +- platformapi/kuaishou_mini/kuaishou_api.go | 33 +++++++++++++++ platformapi/kuaishou_mini/kuaishou_model.go | 10 ++++- platformapi/kuaishou_mini/kuaishou_pay.go | 45 +++++++++++---------- platformapi/kuaishou_mini/kuaishou_test.go | 23 +++++++++++ 5 files changed, 89 insertions(+), 24 deletions(-) diff --git a/platformapi/alipayapi/utils_test.go b/platformapi/alipayapi/utils_test.go index 2d7222e7..85361334 100644 --- a/platformapi/alipayapi/utils_test.go +++ b/platformapi/alipayapi/utils_test.go @@ -8,7 +8,7 @@ import ( ) func TestSystemAuthToken(t *testing.T) { - result, err := api.SystemAuthToken(GrantTypeCode, "85636904854946afa6890299e0a1VX17", "") + result, err := api.SystemAuthToken(GrantTypeCode, "e4f95e2065a84625aaf01dea2703NA17", "") if err != nil { t.Fatal(err) } diff --git a/platformapi/kuaishou_mini/kuaishou_api.go b/platformapi/kuaishou_mini/kuaishou_api.go index 6d2d7946..d72c3138 100644 --- a/platformapi/kuaishou_mini/kuaishou_api.go +++ b/platformapi/kuaishou_mini/kuaishou_api.go @@ -1,11 +1,13 @@ package kuaishou_mini import ( + "crypto/md5" "errors" "fmt" "git.rosy.net.cn/baseapi/platformapi" "git.rosy.net.cn/baseapi/utils" "net/http" + "sort" "strings" "sync" ) @@ -93,3 +95,34 @@ func (a *API) AccessAPI2(url string, params map[string]interface{}) (retVal map[ }) return retVal, err } + +// sign 签名 +func (a *API) sign(param map[string]interface{}) string { + param["app_id"] = a.appId + var paramsArr []string + for k, v := range param { + if k == "sign" || k == "access_token" { + continue + } + value := strings.TrimSpace(fmt.Sprintf("%v", v)) + if strings.HasPrefix(value, "\"") && strings.HasSuffix(value, "\"") && len(value) > 1 { + value = value[1 : len(value)-1] + } + value = strings.TrimSpace(value) + if value == "" || value == "nil" { + continue + } + paramsArr = append(paramsArr, k) + } + + sort.Strings(paramsArr) + signParma := make([]string, 0, 0) + for k, v := range paramsArr { + if utils.IsNil(param[v]) { + signParma[k] = v + "=" + fmt.Sprintf("%v", param[v]) + } + } + sign := strings.Join(signParma, "&") + a.appSecret + return fmt.Sprintf("%x", md5.Sum([]byte(sign))) + +} diff --git a/platformapi/kuaishou_mini/kuaishou_model.go b/platformapi/kuaishou_mini/kuaishou_model.go index 30d25c1a..35ecb6ee 100644 --- a/platformapi/kuaishou_mini/kuaishou_model.go +++ b/platformapi/kuaishou_mini/kuaishou_model.go @@ -24,8 +24,8 @@ type GetAutoTokenRes struct { TokenType string `json:"token_type"` } -// PreCreateOrderRes 快手预发单 -type PreCreateOrderRes struct { +// PreCreateOrderReq 快手预发单 +type PreCreateOrderReq struct { OutOrderNo string `json:"out_order_no"` // 商户系统内部订单号,只能是数字、大小写字母_-*且在同一个商户号下唯一 OpenId string `json:"open_id"` // 快手用户在当前小程序的open_id TotalAmount int64 `json:"total_amount"` // 用户支付金额,单位为[分]。 @@ -41,3 +41,9 @@ type PreCreateOrderRes struct { MultiCopiesGoodsInfo string `json:"multi_copies_goods_info"` // 单商品购买多份场景 "[{"copies":2}]" CancelOrder int64 `json:"cancel_order"` // 该字段表示创建订单的同时是否覆盖之前已存在的订单。 } + +type PreCreateOrderResponse struct { + Result int `json:"result"` + ErrorMsg string `json:"error_msg"` + OrderInfo string `json:"order_info"` //拉起收银台的 orderInfo +} diff --git a/platformapi/kuaishou_mini/kuaishou_pay.go b/platformapi/kuaishou_mini/kuaishou_pay.go index 7ee833a6..b17443c5 100644 --- a/platformapi/kuaishou_mini/kuaishou_pay.go +++ b/platformapi/kuaishou_mini/kuaishou_pay.go @@ -1,31 +1,34 @@ package kuaishou_mini import ( + "errors" "fmt" + "git.rosy.net.cn/baseapi/utils" ) // PreCreateOrder 预下单生成支付信息 -//func (a *API) PreCreateOrder(param *PreCreateOrderRes) error { -// if a.appId == "" || a.appSecret == "" { -// return error -// } -// -// result, err := a.AccessAPI2(a.FullUrl(KuaiShouPreCreateOrder), utils.Struct2MapByJson(param)) -// if err != nil { -// return "", "", err -// } -// -// auth := GetLoginAuth{} -// if err := utils.Map2StructByJson(result, &auth, false); err != nil { -// return "", "", err -// } -// -// if auth.Error != "" { -// return "", "", errors.New(auth.ErrorMsg) -// } -// -// return auth.SessionKey, auth.OpenId, nil -//} +func (a *API) PreCreateOrder(param *PreCreateOrderReq) (string, error) { + if a.appId == "" || a.appSecret == "" { + return "", errors.New("appId/appSecret 不能为空") + } + + param.Sign = a.sign(utils.Struct2MapByJson(param)) + result, err := a.AccessAPI2(a.FullUrl(KuaiShouPreCreateOrder), utils.Struct2MapByJson(param)) + if err != nil { + return "", err + } + + order := PreCreateOrderResponse{} + if err := utils.Map2StructByJson(result, &order, false); err != nil { + return "", err + } + + if order.Result != 1 { + return "", errors.New(order.ErrorMsg) + } + + return order.OrderInfo, nil +} func (a *API) FullUrl(bashUrl string) string { 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 2461d0d3..d4c10cd0 100644 --- a/platformapi/kuaishou_mini/kuaishou_test.go +++ b/platformapi/kuaishou_mini/kuaishou_test.go @@ -67,3 +67,26 @@ func DecryptUserMsg(sessionKey, iv, msg string) (string, error) { func TestCreateToken(t *testing.T) { api.GetToken() } + +// 快手预下单获取支付参数 +func TestPreCreateOrder(t *testing.T) { + param := &PreCreateOrderReq{ + OutOrderNo: "1024028220", + OpenId: "f198f59711c9785314bf5724f7ab9f47", + TotalAmount: 1, + Subject: "这是一个测试商品", + Detail: "大白菜,小白菜,中白菜", + TypeDetail: 1832, // 素菜 + ExpireTime: 10 * 60, + Sign: "", + Attach: "", + NotifyUrl: "https://callback.jxc4.com/tictoc/tiktokMsg", + GoodsId: "", + GoodsDetailUrl: "", + MultiCopiesGoodsInfo: "", + 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)) +} From abb328f62b9f77af0e1bd4117ae6cb299822eb33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 31 Mar 2023 11:44:42 +0800 Subject: [PATCH 02/21] 1 --- platformapi/alipayapi/alipayapi.go | 3 +++ platformapi/alipayapi/utils.go | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/platformapi/alipayapi/alipayapi.go b/platformapi/alipayapi/alipayapi.go index 883d3f4f..5d7f72ca 100644 --- a/platformapi/alipayapi/alipayapi.go +++ b/platformapi/alipayapi/alipayapi.go @@ -10,6 +10,7 @@ import ( "encoding/pem" "fmt" "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/globals" "io/ioutil" "net/http" "sort" @@ -98,6 +99,7 @@ func (a *API) signParams(params map[string]interface{}) (sign string) { } finalStr := strings.Join(strList, "&") + globals.SugarLogger.Debugf("============finalStr: %s", finalStr) d := sha256.Sum256([]byte(finalStr)) signature, _ := rsa.SignPKCS1v15(rand.Reader, a.privateKey, crypto.SHA256, d[:]) sign = base64.StdEncoding.EncodeToString(signature) @@ -128,6 +130,7 @@ func (a *API) AccessAPI(method string, params, bizContent map[string]interface{} var request *http.Request params["timestamp"] = utils.GetCurTimeStr() params[signKey] = a.signParams(params) + globals.SugarLogger.Debugf("======sginKey := %v", params[signKey]) fullURL := utils.GenerateGetURL(prodURL, "", params) if isPost { diff --git a/platformapi/alipayapi/utils.go b/platformapi/alipayapi/utils.go index 634186bf..1a219b55 100644 --- a/platformapi/alipayapi/utils.go +++ b/platformapi/alipayapi/utils.go @@ -1,6 +1,9 @@ package alipayapi -import "git.rosy.net.cn/baseapi/utils" +import ( + "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/globals" +) const ( GrantTypeCode = "authorization_code" @@ -52,6 +55,8 @@ func (a *API) SystemAuthToken(grantType, code, refreshToken string) (tokenInfo * params["alipay_root_cert_sn"] = aliPayRootCertSN retVal, err := a.AccessAPI("alipay.system.oauth.token", params, nil, false) + globals.SugarLogger.Debugf("======retVal := %v", retVal) + globals.SugarLogger.Debugf("======err := %v", err) if err == nil { err = utils.Map2StructByJson(retVal, &tokenInfo, false) } From e27d0194997e299da729247bd12ac5bcec5ca343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 31 Mar 2023 14:00:21 +0800 Subject: [PATCH 03/21] 1 --- platformapi/alipayapi/utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformapi/alipayapi/utils.go b/platformapi/alipayapi/utils.go index 1a219b55..4faf6c3c 100644 --- a/platformapi/alipayapi/utils.go +++ b/platformapi/alipayapi/utils.go @@ -45,13 +45,13 @@ func (a *API) SystemAuthToken(grantType, code, refreshToken string) (tokenInfo * params["refresh_token"] = refreshToken } // 获取证书 - appCertSN, aliPayRootCertSN, aliPayPublicCertSN, err := SetCertSnByPath(AppCertPath, AliPayRootCertPath, AliPayPublicCertPath) + appCertSN, aliPayRootCertSN, _, err := SetCertSnByPath(AppCertPath, AliPayRootCertPath, AliPayPublicCertPath) if err != nil { return nil, err } params["app_cert_sn"] = appCertSN - params["alipay_public_cert_sn"] = aliPayPublicCertSN + //params["alipay_public_cert_sn"] = aliPayPublicCertSN params["alipay_root_cert_sn"] = aliPayRootCertSN retVal, err := a.AccessAPI("alipay.system.oauth.token", params, nil, false) From 5a4959d47f22425f59c6f049cea05081596f6785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 31 Mar 2023 15:15:36 +0800 Subject: [PATCH 04/21] 1 --- platformapi/alipayapi/alipayapi.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/platformapi/alipayapi/alipayapi.go b/platformapi/alipayapi/alipayapi.go index 5d7f72ca..6457d810 100644 --- a/platformapi/alipayapi/alipayapi.go +++ b/platformapi/alipayapi/alipayapi.go @@ -9,15 +9,14 @@ import ( "encoding/base64" "encoding/pem" "fmt" + "git.rosy.net.cn/baseapi" + "git.rosy.net.cn/baseapi/platformapi" "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/globals" "io/ioutil" "net/http" "sort" "strings" - - "git.rosy.net.cn/baseapi" - "git.rosy.net.cn/baseapi/platformapi" + "time" ) const ( @@ -99,7 +98,6 @@ func (a *API) signParams(params map[string]interface{}) (sign string) { } finalStr := strings.Join(strList, "&") - globals.SugarLogger.Debugf("============finalStr: %s", finalStr) d := sha256.Sum256([]byte(finalStr)) signature, _ := rsa.SignPKCS1v15(rand.Reader, a.privateKey, crypto.SHA256, d[:]) sign = base64.StdEncoding.EncodeToString(signature) @@ -128,9 +126,8 @@ func (a *API) AccessAPI(method string, params, bizContent map[string]interface{} err = platformapi.AccessPlatformAPIWithRetry(a.client, func() *http.Request { var request *http.Request - params["timestamp"] = utils.GetCurTimeStr() + params["timestamp"] = utils.Time2Str(time.Now()) params[signKey] = a.signParams(params) - globals.SugarLogger.Debugf("======sginKey := %v", params[signKey]) fullURL := utils.GenerateGetURL(prodURL, "", params) if isPost { From 4337ab35854f410e238ddc97e4728342a94be1ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 31 Mar 2023 15:41:27 +0800 Subject: [PATCH 05/21] 1 --- platformapi/alipayapi/alipayapi.go | 3 +-- platformapi/alipayapi/utils.go | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/platformapi/alipayapi/alipayapi.go b/platformapi/alipayapi/alipayapi.go index 6457d810..8373cf75 100644 --- a/platformapi/alipayapi/alipayapi.go +++ b/platformapi/alipayapi/alipayapi.go @@ -100,8 +100,7 @@ func (a *API) signParams(params map[string]interface{}) (sign string) { finalStr := strings.Join(strList, "&") d := sha256.Sum256([]byte(finalStr)) signature, _ := rsa.SignPKCS1v15(rand.Reader, a.privateKey, crypto.SHA256, d[:]) - sign = base64.StdEncoding.EncodeToString(signature) - return sign + return base64.StdEncoding.EncodeToString(signature) } func method2ResponseKey(method string) (responseKey string) { diff --git a/platformapi/alipayapi/utils.go b/platformapi/alipayapi/utils.go index 4faf6c3c..41cfdd9b 100644 --- a/platformapi/alipayapi/utils.go +++ b/platformapi/alipayapi/utils.go @@ -2,7 +2,6 @@ package alipayapi import ( "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/globals" ) const ( @@ -55,8 +54,6 @@ func (a *API) SystemAuthToken(grantType, code, refreshToken string) (tokenInfo * params["alipay_root_cert_sn"] = aliPayRootCertSN retVal, err := a.AccessAPI("alipay.system.oauth.token", params, nil, false) - globals.SugarLogger.Debugf("======retVal := %v", retVal) - globals.SugarLogger.Debugf("======err := %v", err) if err == nil { err = utils.Map2StructByJson(retVal, &tokenInfo, false) } From 18572ce0503759aca89e05983c3d06408a3aa453 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 3 Apr 2023 09:22:55 +0800 Subject: [PATCH 06/21] 1 --- platformapi/jdapi/store_page_test.go | 2 +- platformapi/kuaishou_mini/kuaishou_api.go | 29 +++++++++++++++++-- platformapi/kuaishou_mini/kuaishou_pay.go | 6 +++- platformapi/kuaishou_mini/kuaishou_test.go | 21 +++++++++++--- .../tiktok_shop/tiktok_api/afs_test.go | 2 +- .../tiktok_shop/tiktok_api/api_test.go | 2 +- platformapi/tiktok_shop/tiktok_api/sku.go | 2 ++ .../tiktok_shop/tiktok_api/sku_test.go | 12 ++++---- 8 files changed, 60 insertions(+), 16 deletions(-) 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) } //// 脱敏购买用户电话,名字,地址 From 88e7b96fecef06249454f537b61b421d8f766cf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 6 Apr 2023 18:25:24 +0800 Subject: [PATCH 07/21] 1 --- platformapi/kuaishou_mini/kuaishou_api.go | 16 +- .../kuaishou_mini/kuaishou_callback.go | 93 +++++++++++ platformapi/kuaishou_mini/kuaishou_model.go | 150 ++++++++++++++++++ platformapi/kuaishou_mini/kuaishou_pay.go | 122 ++++++++++++++ platformapi/mtwmapi/act_test.go | 7 +- platformapi/mtwmapi/im_test.go | 13 ++ platformapi/mtwmapi/logistics_fee.go | 53 +++++++ platformapi/mtwmapi/mtwmapi_test.go | 10 +- platformapi/mtwmapi/order_test.go | 9 +- .../tiktok_shop/tiktok_api/afs_test.go | 2 +- 10 files changed, 457 insertions(+), 18 deletions(-) create mode 100644 platformapi/kuaishou_mini/kuaishou_callback.go create mode 100644 platformapi/mtwmapi/logistics_fee.go diff --git a/platformapi/kuaishou_mini/kuaishou_api.go b/platformapi/kuaishou_mini/kuaishou_api.go index 9e03569c..d70df6f0 100644 --- a/platformapi/kuaishou_mini/kuaishou_api.go +++ b/platformapi/kuaishou_mini/kuaishou_api.go @@ -17,9 +17,14 @@ const ( // KuaiShouBashUrl 基础域名 KuaiShouBashUrl = "https://open.kuaishou.com" // 域名 - KuaiShouAuthLogin = KuaiShouBashUrl + "/oauth2/mp/code2session" // 授权登录 - KuaiShouGetToken = KuaiShouBashUrl + "/oauth2/access_token" // 获取授权token - KuaiShouPreCreateOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/create_order" // 预下单接口 + KuaiShouAuthLogin = KuaiShouBashUrl + "/oauth2/mp/code2session" // 授权登录 + KuaiShouGetToken = KuaiShouBashUrl + "/oauth2/access_token" // 获取授权token + KuaiShouPreCreateOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/create_order" // 预下单接口 + KuaiShouGetOrderDetail = KuaiShouBashUrl + "/openapi/mp/developer/epay/query_order" // 获取订单详情接口 + KuaiShouRefundOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/apply_refund" // 订单退款 + KuaiShouRefundOrderDetail = KuaiShouBashUrl + "/openapi/mp/developer/epay/query_refund" // 订单退款详情 + KuaiShouGetSettleOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/settle" // 刷新订单结算信息 + KuaiShouQuerySettleOrder = KuaiShouBashUrl + "/openapi/mp/developer/epay/query_settle" // 查询订单的结算信息 ) type API struct { @@ -82,8 +87,9 @@ func (a *API) GetToken() error { func (a *API) AccessAPI1(url string, params map[string]interface{}) (retVal map[string]interface{}, err error) { err = platformapi.AccessPlatformAPIWithRetry(a.client, func() *http.Request { + globals.SugarLogger.Debugf("====param := %s", utils.Format4Output(params, false)) request, _ := http.NewRequest(http.MethodPost, url, strings.NewReader(utils.Map2URLValues(params).Encode())) - request.Header.Set("Content-Type", "application/json") + request.Header.Set("Content-Type", "application/json;charset=UTF-8") return request }, a.config, @@ -137,8 +143,6 @@ func (a *API) sign(param map[string]interface{}) string { sort.Strings(paramsArr) - 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]) { diff --git a/platformapi/kuaishou_mini/kuaishou_callback.go b/platformapi/kuaishou_mini/kuaishou_callback.go new file mode 100644 index 00000000..0c75f743 --- /dev/null +++ b/platformapi/kuaishou_mini/kuaishou_callback.go @@ -0,0 +1,93 @@ +package kuaishou_mini + +import ( + "encoding/json" + "errors" + "git.rosy.net.cn/baseapi/utils" + "io/ioutil" + "net/http" +) + +const ( + CallbackTypePay = "PAYMENT" // 支付回调 + CallbackTypeRefund = "REFUND" // 退款回调 + CallbackTypeSettle = "SETTLE" // 结算回调 + + OrderPayStatusHandleing = "PROCESSING" // 支付订单处理中 + OrderPayStatusSuccess = "SUCCESS" // 订单支付成功 + OrderPayStatusFailed = "FAILED" // 订单支付失败 +) + +// KauiShouCallback 回调处理 +func (a *API) KauiShouCallback(request *http.Request) (*CallBackDetail, *RefundCallBack, string, string, error) { + data, err := ioutil.ReadAll(request.Body) + if err != nil { + return nil, nil, "", "-1", err + } + + var callback *KauiShouCallbackRes + if err := json.Unmarshal(data, &callback); err != nil { + return nil, nil, "", "-1", err + } + + switch callback.BizType { + case CallbackTypePay: + var payCallback *CallBackDetail + if value, ok := callback.Data.(string); ok { + if err := json.Unmarshal([]byte(value), &payCallback); err != nil { + return nil, nil, "", callback.MessageId, err + } + } else { + if err := json.Unmarshal([]byte(utils.Interface2String(value)), &payCallback); err != nil { + return nil, nil, "", callback.MessageId, err + } + } + return payCallback, nil, CallbackTypePay, callback.MessageId, err + case CallbackTypeRefund: + var refundCallback *RefundCallBack + if value, ok := callback.Data.(string); ok { + if err := json.Unmarshal([]byte(value), &refundCallback); err != nil { + return nil, nil, "", callback.MessageId, err + } + } else { + if err := json.Unmarshal([]byte(utils.Interface2String(value)), &refundCallback); err != nil { + return nil, nil, "", callback.MessageId, err + } + } + return nil, refundCallback, CallbackTypeRefund, callback.MessageId, err + case CallbackTypeSettle: + return nil, nil, "", callback.MessageId, errors.New("无效回调类型") + default: + return nil, nil, "", callback.MessageId, errors.New("无效回调类型") + } +} + +// KuaiShouRefundCallBack 快手退款回调 +//func (a *API) KuaiShouRefundCallBack(request *http.Request) (*RefundCallBack, error) { +// data, err := ioutil.ReadAll(request.Body) +// if err != nil { +// return nil, err +// } +// +// var callback *RefundCallBack +// if err := json.Unmarshal(data, &callback); err != nil { +// return nil, err +// } +// +// return callback, err +//} + +// KuaiShouSettleCallBack 当订单结算成功之后,快手小程序服务端会通过 post 方式回调开发者提供的 HTTP 接口 +//func (a *API) KuaiShouSettleCallBack(request *http.Request) (*SettleCallback, error) { +// data, err := ioutil.ReadAll(request.Body) +// if err != nil { +// return nil, err +// } +// +// var callback *SettleCallback +// if err := json.Unmarshal(data, &callback); err != nil { +// return nil, err +// } +// +// return callback, err +//} diff --git a/platformapi/kuaishou_mini/kuaishou_model.go b/platformapi/kuaishou_mini/kuaishou_model.go index 35ecb6ee..0078149f 100644 --- a/platformapi/kuaishou_mini/kuaishou_model.go +++ b/platformapi/kuaishou_mini/kuaishou_model.go @@ -42,8 +42,158 @@ type PreCreateOrderReq struct { CancelOrder int64 `json:"cancel_order"` // 该字段表示创建订单的同时是否覆盖之前已存在的订单。 } +// PreCreateOrderResponse 预下单返回参数 type PreCreateOrderResponse struct { Result int `json:"result"` ErrorMsg string `json:"error_msg"` OrderInfo string `json:"order_info"` //拉起收银台的 orderInfo } + +// GetOrderDetailRes 获取支付订单详情 +type GetOrderDetailRes struct { + Result int `json:"result"` + ErrorMsg string `json:"error_msg"` + PaymentInfo string `json:"payment_info"` //拉起收银台的 orderInfo +} + +type PaymentInfo struct { + TotalAmount int64 `json:"total_amount"` // 预下单用户支付金额 + PayStatus string `json:"pay_status"` // 支付状态。 取值: PROCESSING-处理中|SUCCESS-成功|FAILED-失败 TIMEOUT-超时 + PayTime int64 `json:"pay_time"` // 订单支付时间,单位为毫秒时间戳。 + PayChannel string `json:"pay_channel"` // 支付渠道。取值:UNKNOWN - 未知|WECHAT-微信 |ALIPAY-支付宝。(注:如果用户还未支付,这里返回的是UNKNOWN.) + OutOrderNo string `json:"out_order_no"` // 开发者下单单号 + KsOrderNo string `json:"ks_order_no"` // 快手小程序平台订单号 + ExtraInfo string `json:"extra_info"` // 订单来源信息,历史订单为"" + EnablePromotion bool `json:"enable_promotion"` // 是否参与分销,true:分销,false:非分销 + PromotionAmount int64 `json:"promotion_amount"` // 预计分销金额,单位:分 + OpenId string `json:"open_id"` // 订单对应的用户open id + OrderStatus int64 `json:"order_status"` // 开发者回传的订单同步状态 +} + +// KauiShouCallbackRes 快手支付回调 +type KauiShouCallbackRes struct { + Data interface{} `json:"data"` + MessageId string `json:"message_id"` // 当前回调消息的唯一ID,在同一个消息多次通知时,保持一致。 + BizType string `json:"biz_type"` // 业务类型。取值:PAYMENT-支付 + AppId string `json:"app_id"` // 当前小程序的AppID + Timestamp int64 `json:"timestamp"` // 流程变动的时间戳 +} + +type CallBackDetail struct { + Channel string `json:"channel"` // 支付渠道。取值:UNKNOWN - 未知|WECHAT-微信|ALIPAY-支付宝 + OutOrderNo string `json:"out_order_no"` // 商户系统内部订单号 + Attach string `json:"attach"` // 预下单时携带的开发者自定义信息 + Status string `json:"status"` // 订单支付状态。 取值: PROCESSING-处理中|SUCCESS-成功|FAILED-失败 + KsOrderNo string `json:"ks_order_no"` // 快手小程序平台订单号 + OrderAmount int `json:"order_amount"` // 订单金额 + TradeNo string `json:"trade_no"` // 用户侧支付页交易单号 + ExtraInfo string `json:"extra_info"` // 订单来源信息,同支付查询接口 + EnablePromotion bool `json:"enable_promotion"` // 是否参与分销,true:分销,false:非分销 + PromotionAmount int `json:"promotion_amount"` // 预计分销金额,单位:分 +} + +// RefundParam 申请退单参数 +type RefundParam struct { + OutOrderNo string `json:"out_order_no"` // 开发者需要发起退款的支付订单号 + OutRefundNo string `json:"out_refund_no"` // 开发者的退款单号 + Reason string `json:"reason"` // 退款理由 + Attach string `json:"attach"` // 开发者自定义字段,回调原样回传 + NotifyUrl string `json:"notify_url"` // 通知URL必须为直接可访问的URL,不允许携带查询串。 + RefundAmount int64 `json:"refund_amount"` // 用户退款金额,单位为分。不允许传非整数的数值 + Sign string `json:"sign"` // 签名 + MultiCopiesGoodsInfo string `json:"multi_copies_goods_info"` // 单商品购买多份场景,示例值:[{"copies":2}], 内容见multi_copies_goods_info字段说明 +} + +// RefundRes 申请退款返回参数 +type RefundRes struct { + Result int `json:"result"` + ErrorMsg string `json:"error_msg"` + RefundNo string `json:"refund_no"` +} + +// RefundOrderDetail 获取退款订单详情 +type RefundOrderDetail struct { + Result int `json:"result"` + ErrorMsg string `json:"error_msg"` + RefundInfo string `json:"refund_info"` +} + +// RefundInfo 获取申请退款详情 +type RefundInfo struct { + KsOrderNo string `json:"ks_order_no"` + RefundStatus string `json:"refund_status"` + RefundNo string `json:"refund_no"` + KsRefundType string `json:"ks_refund_type"` + RefundAmount int `json:"refund_amount"` + KsRefundNo string `json:"ks_refund_no"` +} + +// RefundCallBack 快手退款回调 +type RefundCallBack struct { + //Data struct { + OutRefundNo string `json:"out_refund_no"` // 开发者的退款单号 + RefundAmount int `json:"refund_amount"` // 退款金额 + Attach string `json:"attach"` // 预下单时携带的开发者自定义信息 + Status string `json:"status"` // 退款状态。 取值: PROCESSING-处理中,SUCCESS-成功,FAILED-失败 + KsOrderNo string `json:"ks_order_no"` // 快手小程序平台订单号 + KsRefundNo string `json:"ks_refund_no"` // 快手小程序平台退款单号 + KsRefundType string `json:"ks_refund_type"` // 退款账户说明[] + //} `json:"data"` + //MessageId string `json:"message_id"` + //BizType string `json:"biz_type"` + //AppId string `json:"app_id"` + //Timestamp int64 `json:"timestamp"` +} + +// OrderSettleAccountParam 发起订单结算请求参数 +type OrderSettleAccountParam struct { + OutOrderNo string `json:"out_order_no"` + OutSettleNo string `json:"out_settle_no"` + Reason string `json:"reason"` + Attach string `json:"attach"` + NotifyUrl string `json:"notify_url"` + Sign string `json:"sign"` + SettleAmount int64 `json:"settle_amount"` + MultiCopiesGoodsInfo string `json:"multi_copies_goods_info"` +} + +// OrderSettleAccountRes 发起订单结算返回参数 +type OrderSettleAccountRes struct { + Result int `json:"result"` + ErrorMsg string `json:"error_msg"` + SettleNo string `json:"settle_no"` +} + +// QuerySettleInfoRes 查询订单结算信息 +type QuerySettleInfoRes struct { + Result int `json:"result"` + ErrorMsg string `json:"error_msg"` + SettleInfo string `json:"settle_info"` +} + +type SettleInfo struct { + SettleNo string `json:"settle_no"` + TotalAmount int `json:"total_amount"` + SettleAmount int `json:"settle_amount"` + SettleStatus string `json:"settle_status"` + KsOrderNo string `json:"ks_order_no"` + KsSettleNo string `json:"ks_settle_no"` +} + +// SettleCallback 快手结算回调 +type SettleCallback struct { + //Data struct { + OutSettleNo string `json:"out_settle_no"` // 外部结算单号,即开发者结算请求的单号。 + Attach string `json:"attach"` // 预下单时携带的开发者自定义信息 + SettleAmount int `json:"settle_amount"` // 结算后给商户的金额,单位:分 + Status string `json:"status"` // 结算状态。 取值: PROCESSING-处理中,SUCCESS-成功,FAILED-失败 + KsOrderNo string `json:"ks_order_no"` // 快手小程序平台订单号。 + KsSettleNo string `json:"ks_settle_no"` // 快手小程序平台结算单号。 + EnablePromotion bool `json:"enable_promotion"` // 是否参与分销,true:分销,false:非分销 + PromotionAmount int `json:"promotion_amount"` // 预计分销金额,单位:分 + //} `json:"data"` + //BizType string `json:"biz_type"` + //MessageId string `json:"message_id"` + //AppId string `json:"app_id"` + //Timestamp int64 `json:"timestamp"` +} diff --git a/platformapi/kuaishou_mini/kuaishou_pay.go b/platformapi/kuaishou_mini/kuaishou_pay.go index 95f59189..c62a4fff 100644 --- a/platformapi/kuaishou_mini/kuaishou_pay.go +++ b/platformapi/kuaishou_mini/kuaishou_pay.go @@ -1,6 +1,7 @@ package kuaishou_mini import ( + "encoding/json" "errors" "fmt" "git.rosy.net.cn/baseapi/utils" @@ -31,6 +32,127 @@ func (a *API) PreCreateOrder(param *PreCreateOrderReq) (string, error) { return order.OrderInfo, nil } +// GetOrderDetail 订单详情查询接口 +func (a *API) GetOrderDetail(outOrderNo string) (*PaymentInfo, error) { + data, err := a.AccessAPI1(KuaiShouGetOrderDetail, map[string]interface{}{"out_order_no": outOrderNo}) + if err != nil { + return nil, err + } + + orderDetail := &GetOrderDetailRes{} + if err := utils.Map2StructByJson(data, orderDetail, false); err != nil { + return nil, err + } + + if orderDetail.Result != 1 { + return nil, err + } + + if orderDetail.PaymentInfo == "" { + return nil, errors.New("快手支付订单详情返回值为空") + } + + paymentInfo := &PaymentInfo{} + if err := json.Unmarshal([]byte(orderDetail.PaymentInfo), paymentInfo); err != nil { + return nil, err + } + + return paymentInfo, err +} + +// RefundOrder 支付请求退款接口 +// 在途资金中的所有货款均是与订单关联的,只有当该订单在途资金中剩余金额超过退款金额时,才可以进行在途资金的退款。 +// 当可提现金额也不足退款金额时,会退款失败,为了避免出现订单无法退款的情况出现,请根据业务情况自行保留一部分可提现金额在系统中 +func (a *API) RefundOrder(param *RefundParam) (refundNo string, err error) { + data, err := a.AccessAPI1(KuaiShouRefundOrder, utils.Struct2MapByJson(param)) + if err != nil { + return "", err + } + + var result *RefundRes + if err := utils.Map2StructByJson(data, &result, false); err != nil { + return "", err + } + + if result.Result != 1 { + return "", errors.New(result.ErrorMsg) + } + return result.RefundNo, nil +} + +// RefundOrderDetail 查询退款订单详情 +func (a *API) RefundOrderDetail(outRefundNo string) (*RefundInfo, error) { + data, err := a.AccessAPI1(KuaiShouRefundOrderDetail, map[string]interface{}{"out_refund_no": outRefundNo}) + if err != nil { + return nil, err + } + + var refundOrderDetail *RefundOrderDetail + if err := utils.Map2StructByJson(data, &refundOrderDetail, false); err != nil { + return nil, err + } + + if refundOrderDetail.Result != 1 { + return nil, errors.New(refundOrderDetail.ErrorMsg) + } + + var refundInfo *RefundInfo + if err := json.Unmarshal([]byte(refundOrderDetail.RefundInfo), &refundInfo); err != nil { + return nil, err + } + + return refundInfo, nil +} + +// PaySettleAccounts 结算用于确认一笔在途资金,将其转化为可提现资金。 +// 结算规则 +// 1、订单履约完成后发起结算,结算周期为 订单到达核销状态(订单状态为11或15)满3天后可发起结算。核销状态通过订单同步接口 (opens new window)进行同步。 +// 2、需要主动调用结算接口后,才能进行后续资金的提现。 +// 3、结算时,小程序平台会收取整笔交易的平台服务费。若结算后发生退款,则平台服务费不作退还。 + +func (a *API) PaySettleAccounts4Order(param *OrderSettleAccountParam) (string, error) { + data, err := a.AccessAPI1(KuaiShouGetSettleOrder, utils.Struct2MapByJson(param)) + if err != nil { + return "", err + } + + var settle *OrderSettleAccountRes + if err := utils.Map2StructByJson(data, &settle, false); err != nil { + return "", err + } + + if settle.Result != 1 { + return "", err + } + + return settle.SettleNo, nil +} + +// QuerySettleInfo 查询结算信息 +func (a *API) QuerySettleInfo(outSettleNo string) (*SettleInfo, error) { + data, err := a.AccessAPI1(KuaiShouQuerySettleOrder, map[string]interface{}{"out_settle_no": outSettleNo}) + if err != nil { + return nil, err + } + var settle *QuerySettleInfoRes + if err := utils.Map2StructByJson(data, &settle, false); err != nil { + return nil, err + } + if settle.Result != 1 { + return nil, errors.New(settle.ErrorMsg) + } + + if settle.SettleInfo == "" { + return nil, errors.New("数据查询为空") + } + + var result *SettleInfo + if err := json.Unmarshal([]byte(settle.SettleInfo), result); err != nil { + return nil, err + } + return result, err +} + func (a *API) FullUrl(bashUrl string) string { if a.accessToken == "" || a.expiresIn < time.Now().Unix() { a.GetToken() diff --git a/platformapi/mtwmapi/act_test.go b/platformapi/mtwmapi/act_test.go index e9589923..a6381d98 100644 --- a/platformapi/mtwmapi/act_test.go +++ b/platformapi/mtwmapi/act_test.go @@ -129,10 +129,11 @@ func TestSgin(t *testing.T) { func TestBaokuanHuodong(t *testing.T) { // 获取门店所有的爆款活动 - storeId := 668887 - vendorStoreId := "17056471" + storeId := 103201 + vendorStoreId := "8694421" - actList, _ := api.RetailDiscountList(vendorStoreId, 56) + actList, err := api.RetailDiscountList(vendorStoreId, 56) + fmt.Println(err) if len(actList) > 0 { allActivitySkuIdList := make([]string, 0, 0) // 此门店全部的折扣(爆款)活动商品 activationActivitySkuIdList := make([]*StoreSkuInfo, 0, 0) // 此门店正在进行的折扣(爆款)活动商品 diff --git a/platformapi/mtwmapi/im_test.go b/platformapi/mtwmapi/im_test.go index 8052d6a6..01da21a6 100644 --- a/platformapi/mtwmapi/im_test.go +++ b/platformapi/mtwmapi/im_test.go @@ -11,3 +11,16 @@ func TestGetConnectionToken(t *testing.T) { } // t.Log(utils.Format4Output(result, false)) } + +func TestGetWayBillFee(t *testing.T) { + //order, _ := api.OrderGetOrderDetail(1100486451772280163, false) + //globals.SugarLogger.Debugf("order:==%s", utils.Format4Output(order, false)) 2002 + api.GetWayBillFee("1100486451772280163", 2) + api.GetWayBillFee("1100486451772280163", 1) +} + +// 商家没有接入众包配送,无法进行众包配送相关操作 +func TestGetShippingFeeList(t *testing.T) { + api.GetShippingFeeList("1300486314174032613,1100487300210228389", 1) + api.GetShippingFeeList("1300486314174032613,1100487300210228389", 2) +} diff --git a/platformapi/mtwmapi/logistics_fee.go b/platformapi/mtwmapi/logistics_fee.go new file mode 100644 index 00000000..651a5a92 --- /dev/null +++ b/platformapi/mtwmapi/logistics_fee.go @@ -0,0 +1,53 @@ +package mtwmapi + +import ( + "fmt" + "git.rosy.net.cn/jx-callback/globals" +) + +// GetWayBillFee 获取美团众包配送费已经保险费 +func (a *API) GetWayBillFee(orderId string, serviceBrand int) (*GetOrderLogisticsFee, error) { + data, err := a.AccessAPI("order/logistics/pt/preview", true, map[string]interface{}{"order_id": orderId, "service_brand": serviceBrand}) + if err != nil { + globals.SugarLogger.Debugf("err := %v", err) + return nil, err + } + fmt.Println(data) + return nil, nil +} + +type GetOrderLogisticsFeeRes struct { + Code int `json:"code"` + Msg string `json:"msg"` + data string `json:"data"` +} + +type GetOrderLogisticsFee struct { + WmOrderId int64 `json:"wm_order_id"` // 订单id + ShippingFee float64 `json:"shipping_fee"` // 配送费(基础+临时) + OriginalPrice float64 `json:"original_price"` // 订单的总原价,单位为元此字段数据为未扣减所有优惠前订单的总金额,含打包袋、配送费等。 + LogisticsStatus int64 `json:"logistics_status"` // 美团配送订单状态code + ShippingTips string `json:"shipping_tips"` // 配送费浮动说明 + PayAmount float64 `json:"pay_amount"` // 实付金额 + Distance int `json:"distance"` // 配送距离(m) + CouponViewId string `json:"coupon_view_id"` // 配送费优惠券id + CouponName string `json:"coupon_name"` // 优惠券名称 + CouponAmount float64 `json:"coupon_amount"` // 优惠券金额 + ReduceDetail ReduceDetailObj +} + +type ReduceDetailObj struct { + UserTaskId int64 `json:"user_task_id"` // 立减活动id + TaskId int64 `json:"task_id"` // 立减活动task id + BmlAmount float64 `json:"bml_amount"` // 立减金额(元) +} + +func (a *API) GetShippingFeeList(orderIds string, serviceBrand int) (*GetOrderLogisticsFeeRes, error) { + data, err := a.AccessAPI("order/zhongbao/shippingFee", true, map[string]interface{}{"order_id": orderIds, "service_brand": serviceBrand}) + if err != nil { + globals.SugarLogger.Debugf("err := %v", err) + return nil, err + } + fmt.Println(data) + return nil, nil +} diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go index 75a6a131..212e5e4c 100644 --- a/platformapi/mtwmapi/mtwmapi_test.go +++ b/platformapi/mtwmapi/mtwmapi_test.go @@ -20,13 +20,13 @@ func init() { baseapi.Init(sugarLogger) // 菜市 - api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") + //api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") // 果园 - //api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") + // api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //商超 - //api = New("5873", "41c479790a76f86326f89e8048964739", "", "") //token_nH_IlcWQKAkZBqklwItNRw + api = New("5873", "41c479790a76f86326f89e8048964739", "", "") //token_nH_IlcWQKAkZBqklwItNRw cookieStr := ` acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; ` @@ -60,7 +60,7 @@ func TestGetAccessToken(t *testing.T) { } func TestGetAccessToken2(t *testing.T) { - result, err := api.GetAccessToken2("16708848") //refresh_token_pLG7Jw7g9mu7oOzNSuJIUg + result, err := api.GetAccessToken2("17371124") //refresh_token_pLG7Jw7g9mu7oOzNSuJIUg if err != nil { t.Fatal(err) } @@ -69,7 +69,7 @@ func TestGetAccessToken2(t *testing.T) { } func TestRefreshAccessToken(t *testing.T) { - result, err := api.RefreshAccessToken("refresh_token_jOp7ekeHrzjBUvLdVuZHIg") //token_qbAyE3ajWYT8ecwoI-FMjw + result, err := api.RefreshAccessToken("refresh_token_jajfdTMzYvB28v-3q4RFgQ") //token_qbAyE3ajWYT8ecwoI-FMjw if err != nil { t.Fatal(err) } diff --git a/platformapi/mtwmapi/order_test.go b/platformapi/mtwmapi/order_test.go index 59621145..2f5b8684 100644 --- a/platformapi/mtwmapi/order_test.go +++ b/platformapi/mtwmapi/order_test.go @@ -3,7 +3,6 @@ package mtwmapi import ( "fmt" "git.rosy.net.cn/baseapi/utils" - "git.rosy.net.cn/jx-callback/globals" "strings" "testing" "time" @@ -19,14 +18,18 @@ func TestOrderViewStatus(t *testing.T) { } func TestOrderGetOrderDetail(t *testing.T) { - result, err := api.OrderGetOrderDetail(1100449970093397157, false) + result, err := api.OrderGetOrderDetail(1300486314174032613, false) if err != nil { t.Fatal(err) } if len(result) == 0 { t.Fatal("result should have value") } - globals.SugarLogger.Debugf("%s", utils.Format4Output(result, false)) + + for k, v := range result { + fmt.Println(fmt.Sprintf("%s=%v", k, v)) + } + //globals.SugarLogger.Debugf("%s", utils.Format4Output(result, false)) } func TestOrderGetOrderDetail2(t *testing.T) { diff --git a/platformapi/tiktok_shop/tiktok_api/afs_test.go b/platformapi/tiktok_shop/tiktok_api/afs_test.go index a9f7b92f..8e6a999d 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":"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":"d04f3829-3ee5-4886-bdcd-70f928055cbe","expires_in":1681311682,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"e0b7bc95-067c-4cfb-a59a-1c00344ab851","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":""}` From 73a084621e6d6d6ce19a02c21cc3bfc4690e24d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 10 Apr 2023 10:34:07 +0800 Subject: [PATCH 08/21] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8A=96=E9=9F=B3?= =?UTF-8?q?=E4=BA=91=E9=BC=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tiktok_shop/tiktok_api/afs_test.go | 2 +- platformapi/tiktok_shop/tiktok_api/sku.go | 132 ++++++++++++------ 2 files changed, 93 insertions(+), 41 deletions(-) diff --git a/platformapi/tiktok_shop/tiktok_api/afs_test.go b/platformapi/tiktok_shop/tiktok_api/afs_test.go index 8e6a999d..7660e0c8 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":"d04f3829-3ee5-4886-bdcd-70f928055cbe","expires_in":1681311682,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"e0b7bc95-067c-4cfb-a59a-1c00344ab851","authority_id":""}` +var token = `{"access_token":"b558d5bd-d55d-4322-8602-85ba449cbc79","expires_in":1681667840,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"3a3c0ad2-bcbd-4f55-b7af-6b406dabc47a","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 46a314a5..4663b3cc 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku.go +++ b/platformapi/tiktok_shop/tiktok_api/sku.go @@ -1,9 +1,9 @@ package tiktok_api import ( + "encoding/json" "errors" brand_list_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/brand_list/request" - order_batchDecrypt_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_batchDecrypt/request" order_batchSensitive_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/order_batchSensitive/request" product_GetRecommendCategory_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_GetRecommendCategory/request" product_addV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_addV2/request" @@ -30,8 +30,9 @@ 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" + "io/ioutil" + "net/http" "strings" ) @@ -329,52 +330,103 @@ func (a *API) GetSkuBrand(categoryId int64, brandName string) (int64, error) { return BrandNameMap[brandNameLen], nil } -// OrderUserInfoDecrypt 用户信息解密 +type YunDecrypt struct { + Code string `json:"code"` + Data string `json:"data"` + Err string `json:"err"` +} + +// OrderUserInfoDecrypt 用户信息解密(此接口转入云鼎服务器,将不再直接通信) 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 := 1; i <= 3; i++ { - cipher := order_batchDecrypt_request.CipherInfosItem{} - cipher.AuthId = orderId - switch i { - case 1: // 姓名 - cipher.CipherText = name - cipherInfos = append(cipherInfos, cipher) - case 2: // 手机号 - cipher.CipherText = tel - cipherInfos = append(cipherInfos, cipher) - case 3: // 地址 - cipher.CipherText = address - cipherInfos = append(cipherInfos, cipher) - } - } - request.Param.CipherInfos = cipherInfos - - result, err := request.Execute(a.accessTokenObj) - globals.SugarLogger.Debugf("OrderUserInfoDecrypt======:%s", utils.Format4Output(result, false)) + url := "http://ddy.jxc4.com/tt/decrypt" + accessToken, err := json.Marshal(a.accessTokenObj.CreateTokenData) if err != nil { return "", "", "", err } - if result.Code != RequestSuccessCode { - return "", "", "", errors.New(result.SubCode) + + param := make(map[string]string, 5) + param["token"] = string(accessToken) + param["encrypt_post_tel"] = tel + param["encrypt_post_receiver"] = address + param["encrypt_post_name"] = name + param["order_id"] = orderId + param["app_key"] = a.appKey + param["app_secret"] = a.appSecret + + data, err := json.Marshal(param) + if err != nil { + return "", "", "", nil + } + payload := strings.NewReader(string(data)) + req, _ := http.NewRequest("POST", url, payload) + req.Header.Add("content-type", "application/json") + res, err := http.DefaultClient.Do(req) + if err != nil { + return "", "", "", err + } + defer res.Body.Close() + body, _ := ioutil.ReadAll(res.Body) + + var result *YunDecrypt + if err := json.Unmarshal(body, &result); err != nil { + return "", "", "", err + } + if result.Code != "200" { + return "", "", "", errors.New(result.Err) } - 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 + if len(result.Data) != 0 { + var decryData map[string]string + if err := json.Unmarshal([]byte(result.Data), decryData); err != nil { + return "", "", "", err } + return decryData["name"], decryData["tel"], decryData["address"], nil } - return userName, userTel, userAddress, err + return "", "", "", errors.New("返回值为空") + //request := order_batchDecrypt_request.New() + // + //cipherInfos := make([]order_batchDecrypt_request.CipherInfosItem, 0, 0) + //for i := 1; i <= 3; i++ { + // cipher := order_batchDecrypt_request.CipherInfosItem{} + // cipher.AuthId = orderId + // switch i { + // case 1: // 姓名 + // cipher.CipherText = name + // cipherInfos = append(cipherInfos, cipher) + // case 2: // 手机号 + // cipher.CipherText = tel + // cipherInfos = append(cipherInfos, cipher) + // case 3: // 地址 + // cipher.CipherText = address + // cipherInfos = append(cipherInfos, cipher) + // } + //} + //request.Param.CipherInfos = cipherInfos + // + //result, err := request.Execute(a.accessTokenObj) + //globals.SugarLogger.Debugf("OrderUserInfoDecrypt======:%s", utils.Format4Output(result, false)) + //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 用户信息脱敏 From 91f5d89f498ee225d7e6bc9c4ceed0d90591c52c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 10 Apr 2023 11:00:49 +0800 Subject: [PATCH 09/21] 1 --- platformapi/tiktok_shop/tiktok_api/sku.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformapi/tiktok_shop/tiktok_api/sku.go b/platformapi/tiktok_shop/tiktok_api/sku.go index 4663b3cc..b0e9d0af 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku.go +++ b/platformapi/tiktok_shop/tiktok_api/sku.go @@ -377,7 +377,7 @@ func (a *API) OrderUserInfoDecrypt(orderId, name, tel, address string) (string, if len(result.Data) != 0 { var decryData map[string]string - if err := json.Unmarshal([]byte(result.Data), decryData); err != nil { + if err := json.Unmarshal([]byte(result.Data), &decryData); err != nil { return "", "", "", err } return decryData["name"], decryData["tel"], decryData["address"], nil From 5038cbd52cc612bfe5347624fc6b856afa6adb11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 12 Apr 2023 09:44:55 +0800 Subject: [PATCH 10/21] 1 --- platformapi/mtwmapi/mtwmapi_test.go | 4 ++-- platformapi/mtwmapi/order_test.go | 4 +++- platformapi/tiktok_shop/tiktok_api/order.go | 4 ++-- platformapi/tiktok_shop/tiktok_api/order_type.go | 16 ++++++++-------- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go index 212e5e4c..2d653902 100644 --- a/platformapi/mtwmapi/mtwmapi_test.go +++ b/platformapi/mtwmapi/mtwmapi_test.go @@ -20,13 +20,13 @@ func init() { baseapi.Init(sugarLogger) // 菜市 - //api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") + api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") // 果园 // api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //商超 - api = New("5873", "41c479790a76f86326f89e8048964739", "", "") //token_nH_IlcWQKAkZBqklwItNRw + //api = New("5873", "41c479790a76f86326f89e8048964739", "", "") //token_nH_IlcWQKAkZBqklwItNRw cookieStr := ` acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; ` diff --git a/platformapi/mtwmapi/order_test.go b/platformapi/mtwmapi/order_test.go index 2f5b8684..e1571202 100644 --- a/platformapi/mtwmapi/order_test.go +++ b/platformapi/mtwmapi/order_test.go @@ -3,6 +3,7 @@ package mtwmapi import ( "fmt" "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/globals" "strings" "testing" "time" @@ -18,10 +19,11 @@ func TestOrderViewStatus(t *testing.T) { } func TestOrderGetOrderDetail(t *testing.T) { - result, err := api.OrderGetOrderDetail(1300486314174032613, false) + result, err := api.OrderGetOrderDetail(1100496043552579025, false) if err != nil { t.Fatal(err) } + globals.SugarLogger.Debugf("====%s", utils.Format4Output(result["poi_receive_detail_yuan"], false)) if len(result) == 0 { t.Fatal("result should have value") } diff --git a/platformapi/tiktok_shop/tiktok_api/order.go b/platformapi/tiktok_shop/tiktok_api/order.go index e507d7d6..c91b08a8 100644 --- a/platformapi/tiktok_shop/tiktok_api/order.go +++ b/platformapi/tiktok_shop/tiktok_api/order.go @@ -592,11 +592,11 @@ func (a *API) GetCallbackOrderId(msgId string, data interface{}) (string, int64, } return utils.Int64ToStr(create.PId), int64(create.ShopId), Err2CallbackResponse(nil, "") case CallbackReturnRefundAgreedMsgTagId: // 同意退款消息 - create := AppointmentChangeData{} + create := BusinessRefundSuccessData{} if err := utils.Map2StructByJson(data, &create, false); err != nil { return "", 0, CallbackResponseErr(false) } - return create.PId, create.ShopId, Err2CallbackResponse(nil, "") + return utils.Int64ToStr(create.PId), create.ShopId, Err2CallbackResponse(nil, "") case CallbackRefundClosedMsgTagId: // 当买家取消申请或系统超时机制导致退款取消时,会推送此消息 create := UserCancelRefundOrderData{} if err := utils.Map2StructByJson(data, &create, false); err != nil { diff --git a/platformapi/tiktok_shop/tiktok_api/order_type.go b/platformapi/tiktok_shop/tiktok_api/order_type.go index eecb04f6..8018bccd 100644 --- a/platformapi/tiktok_shop/tiktok_api/order_type.go +++ b/platformapi/tiktok_shop/tiktok_api/order_type.go @@ -411,16 +411,16 @@ type BusinessRefundSuccessCallback struct { type BusinessRefundSuccessData struct { AftersaleId int64 `json:"aftersale_id"` - AftersaleStatus int `json:"aftersale_status"` - AftersaleType int `json:"aftersale_type"` + AftersaleStatus int64 `json:"aftersale_status"` + AftersaleType int64 `json:"aftersale_type"` PId int64 `json:"p_id"` - ReasonCode int `json:"reason_code"` - RefundAmount int `json:"refund_amount"` - RefundPostAmount int `json:"refund_post_amount"` - RefundVoucherNum int `json:"refund_voucher_num"` + ReasonCode int64 `json:"reason_code"` + RefundAmount int64 `json:"refund_amount"` + RefundPostAmount int64 `json:"refund_post_amount"` + RefundVoucherNum int64 `json:"refund_voucher_num"` SId int64 `json:"s_id"` - ShopId int `json:"shop_id"` - SuccessTime int `json:"success_time"` + ShopId int64 `json:"shop_id"` + SuccessTime int64 `json:"success_time"` UpdateTime time.Time `json:"update_time"` } From 17ffc17aa6f442c8986870e3ec86e5f997d57561 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 13 Apr 2023 10:33:27 +0800 Subject: [PATCH 11/21] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BE=8E=E5=A5=BD?= =?UTF-8?q?=E8=8F=9C=E5=B8=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/tiktok_shop/tiktok_api/afs_test.go | 2 +- platformapi/tiktok_shop/tiktok_api/sku_type.go | 2 ++ platformapi/tiktok_shop/tiktok_api/sku_warehouse.go | 2 ++ platformapi/tiktok_shop/tiktok_api/sku_warehouse_test.go | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/platformapi/tiktok_shop/tiktok_api/afs_test.go b/platformapi/tiktok_shop/tiktok_api/afs_test.go index 7660e0c8..c500bbca 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":"b558d5bd-d55d-4322-8602-85ba449cbc79","expires_in":1681667840,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"3a3c0ad2-bcbd-4f55-b7af-6b406dabc47a","authority_id":""}` +var token = `{"access_token":"58264f66-1417-455c-ab52-57254ebeae55","expires_in":1681371082,"scope":"SCOPE","shop_id":68032645,"shop_name":"美好菜市","refresh_token":"edc684c0-a7ef-44e0-afdc-1d61689667c3","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_type.go b/platformapi/tiktok_shop/tiktok_api/sku_type.go index b67e0953..61c4e8e1 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku_type.go +++ b/platformapi/tiktok_shop/tiktok_api/sku_type.go @@ -10,10 +10,12 @@ const ( TiktokFolder1 = "71847620611255503751570" // 文件夹(京西菜市) TiktokFolder2 = "71482723234545339291960" TiktokFolder3 = "71762017122139835211688" // (方案二测试文件夹) + TiktokFolder4 = "72213403043425651541645" // (美好菜市) TiktokShoppingFolder = "71802347591117703711619" // (方案二测试文件夹) TiktokFloderKeyVegetableKey = 57939570 // (菜市的文件夹id) TiktokFloderKeyShoppingKey = 68023619 // (商超账号的文件夹id) TiktokFloderKeyTestKey = 63141688 // (测试账号) + TiktokFloderKeyBeautifulKey = 68032645 // (美好菜市) ) // 商品减库存类型 diff --git a/platformapi/tiktok_shop/tiktok_api/sku_warehouse.go b/platformapi/tiktok_shop/tiktok_api/sku_warehouse.go index 0df2b753..ffc2714e 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku_warehouse.go +++ b/platformapi/tiktok_shop/tiktok_api/sku_warehouse.go @@ -55,6 +55,8 @@ func (a *API) BatchUploadImages(imgs []Imgs) (map[string]material_batchUploadIma img.FolderId = TiktokShoppingFolder case TiktokFloderKeyVegetableKey: img.FolderId = TiktokFolder1 + case TiktokFloderKeyBeautifulKey: + img.FolderId = TiktokFolder4 } param = append(param, img) } diff --git a/platformapi/tiktok_shop/tiktok_api/sku_warehouse_test.go b/platformapi/tiktok_shop/tiktok_api/sku_warehouse_test.go index 734cc2f6..26f13c7b 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku_warehouse_test.go +++ b/platformapi/tiktok_shop/tiktok_api/sku_warehouse_test.go @@ -24,7 +24,7 @@ func init() { } func TestCreateFolad(t *testing.T) { - data, err := a.CreateFolder("京西菜市图片文件库2") + data, err := a.CreateFolder("美好菜市图片文件") fmt.Println("err=====", err) fmt.Println("LogId====", data.LogId) //2022092811422001020812109607601B77 fmt.Println("data====", data.Data.Name) // jxcs_folder From d29e336d867955cea639718fc4e5c6c4075f8ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Fri, 14 Apr 2023 14:46:43 +0800 Subject: [PATCH 12/21] 1 --- platformapi/tiktok_shop/tiktok_api/afs_test.go | 5 +++++ platformapi/tiktok_shop/tiktok_api/sku.go | 2 ++ 2 files changed, 7 insertions(+) diff --git a/platformapi/tiktok_shop/tiktok_api/afs_test.go b/platformapi/tiktok_shop/tiktok_api/afs_test.go index c500bbca..6ed1727c 100644 --- a/platformapi/tiktok_shop/tiktok_api/afs_test.go +++ b/platformapi/tiktok_shop/tiktok_api/afs_test.go @@ -52,3 +52,8 @@ func TestName(t *testing.T) { sign := fmt.Sprintf("%X", md5.Sum([]byte(signParam))) fmt.Println(sign) } + +func TestAa(t *testing.T) { + aa := 1842 + 1318 + 1268 + 3441 + 4372 + 4333 + 3669 + 1158 + 2154 + 2639 + 4748 + 3526 + fmt.Println(aa) +} diff --git a/platformapi/tiktok_shop/tiktok_api/sku.go b/platformapi/tiktok_shop/tiktok_api/sku.go index b0e9d0af..22bc9a23 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" "io/ioutil" "net/http" @@ -119,6 +120,7 @@ func (a *API) CreateStoreCommodity(skuParam *product_addV2_request.ProductAddV2P request := product_addV2_request.New() request.Param = skuParam result, err := request.Execute(a.accessTokenObj) + globals.SugarLogger.Debugf("================result: %s", utils.Format4Output(result, false)) if err != nil { return nil, err } From a0503097c8e0ec820bbfa1276d558faad3ea189f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Mon, 17 Apr 2023 14:00:36 +0800 Subject: [PATCH 13/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8A=96=E9=9F=B3?= =?UTF-8?q?=E5=95=86=E5=9F=8E=E5=95=86=E5=93=81=E5=88=9B=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../product_qualificationConfig_response.go | 2 + .../tiktok_shop/tiktok_api/afs_test.go | 2 +- platformapi/tiktok_shop/tiktok_api/order.go | 3 - platformapi/tiktok_shop/tiktok_api/sku.go | 68 ++++++++++++++++++- .../tiktok_shop/tiktok_api/sku_delete_test.go | 4 ++ .../tiktok_shop/tiktok_api/sku_type.go | 15 +++- 6 files changed, 88 insertions(+), 6 deletions(-) diff --git a/platformapi/tiktok_shop/sdk-golang/api/product_qualificationConfig/response/product_qualificationConfig_response.go b/platformapi/tiktok_shop/sdk-golang/api/product_qualificationConfig/response/product_qualificationConfig_response.go index 9a4ea179..7fbf95e0 100644 --- a/platformapi/tiktok_shop/sdk-golang/api/product_qualificationConfig/response/product_qualificationConfig_response.go +++ b/platformapi/tiktok_shop/sdk-golang/api/product_qualificationConfig/response/product_qualificationConfig_response.go @@ -1,5 +1,7 @@ package product_qualificationConfig_response +import doudian_sdk "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/core" + type ProductQualificationConfigResponse struct { doudian_sdk.BaseDoudianOpApiResponse Data *ProductQualificationConfigData `json:"data"` diff --git a/platformapi/tiktok_shop/tiktok_api/afs_test.go b/platformapi/tiktok_shop/tiktok_api/afs_test.go index 6ed1727c..771a24a6 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":"58264f66-1417-455c-ab52-57254ebeae55","expires_in":1681371082,"scope":"SCOPE","shop_id":68032645,"shop_name":"美好菜市","refresh_token":"edc684c0-a7ef-44e0-afdc-1d61689667c3","authority_id":""}` +var token = `{"access_token":"b558d5bd-d55d-4322-8602-85ba449cbc79","expires_in":1681667840,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"3a3c0ad2-bcbd-4f55-b7af-6b406dabc47a","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/order.go b/platformapi/tiktok_shop/tiktok_api/order.go index c91b08a8..cf20d03a 100644 --- a/platformapi/tiktok_shop/tiktok_api/order.go +++ b/platformapi/tiktok_shop/tiktok_api/order.go @@ -298,9 +298,6 @@ func (a *API) ConfirmReceivedReturnGoods(afsOrderId int64, agree bool) { } } -// CancelSendGoodsSuccess 商家在未发货仅退款途中发送取消发货状态 -func (a *API) CancelSendGoodsSuccess() {} - // OrderDelivering 订单发货 // 暂时只支持整单出库,即接口调用时入参只能传父订单号。 // Tips:部分发货状态下的父订单,调此接口发货,会报错:该订单当前为“部分发货”状态,无法调用此接口 diff --git a/platformapi/tiktok_shop/tiktok_api/sku.go b/platformapi/tiktok_shop/tiktok_api/sku.go index 22bc9a23..0e87f9fd 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku.go +++ b/platformapi/tiktok_shop/tiktok_api/sku.go @@ -21,6 +21,8 @@ import ( product_getProductUpdateRule_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_getProductUpdateRule/request" product_listV2_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_listV2/request" product_listV2_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_listV2/response" + product_qualificationConfig_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_qualificationConfig/request" + product_qualificationConfig_response "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_qualificationConfig/response" product_setOffline_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/product_setOffline/request" shop_getShopCategory_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/shop_getShopCategory/request" sku_editPrice_request "git.rosy.net.cn/baseapi/platformapi/tiktok_shop/sdk-golang/api/sku_editPrice/request" @@ -117,10 +119,48 @@ func (a *API) GetCatePropertyV2(categoryLeftId int64) (*product_getCatePropertyV // CreateStoreCommodity (新增总部商品) func (a *API) CreateStoreCommodity(skuParam *product_addV2_request.ProductAddV2Param) (*product_addV2_response.ProductAddV2Data, error) { + qualityList := make([]product_addV2_request.QualityListItem, 0, 0) + switch a.accessTokenObj.ShopId { + case TiktokFloderKeyVegetableKey: // 京西速食 + qualityList = append(qualityList, product_addV2_request.QualityListItem{ + QualityKey: QualificationsSuShiPackageId, + QualityName: QualificationsSuShiPackageName, + QualityAttachments: []product_addV2_request.QualityAttachmentsItem{ + product_addV2_request.QualityAttachmentsItem{ + MediaType: 1, + Url: QualificationsPackageImg, + }, + }, + }) + case TiktokFloderKeyShoppingKey: // 京西超市 + qualityList = append(qualityList, product_addV2_request.QualityListItem{ + QualityKey: QualificationsShopPackageId, + QualityName: QualificationsShopPackageName, + QualityAttachments: []product_addV2_request.QualityAttachmentsItem{ + product_addV2_request.QualityAttachmentsItem{ + MediaType: 1, + Url: QualificationsShopPackageImg, + }, + }, + }) + case TiktokFloderKeyBeautifulKey: // 美好菜市 + qualityList = append(qualityList, product_addV2_request.QualityListItem{ + QualityKey: QualificationsBeautifulPackageId, + QualityName: QualificationsBeautifulPackageName, + QualityAttachments: []product_addV2_request.QualityAttachmentsItem{ + product_addV2_request.QualityAttachmentsItem{ + MediaType: 1, + Url: QualificationsBeautifulPackageImg, + }, + }, + }) + default: + return nil, errors.New("创建商品是,资质获取异常") + } + skuParam.QualityList = qualityList request := product_addV2_request.New() request.Param = skuParam result, err := request.Execute(a.accessTokenObj) - globals.SugarLogger.Debugf("================result: %s", utils.Format4Output(result, false)) if err != nil { return nil, err } @@ -130,6 +170,32 @@ func (a *API) CreateStoreCommodity(skuParam *product_addV2_request.ProductAddV2P return result.Data, nil } +func (a *API) QualityList(categoryId int64) ([]*product_qualificationConfig_response.ConfigListItem, error) { + if categoryId <= 0 { + return nil, errors.New("categoryId 不能为0") + } + + request := product_qualificationConfig_request.New() + request.Param.CategoryId = categoryId + result, err := request.Execute(a.accessTokenObj) + if err != nil { + return nil, err + } + if result.Code != RequestSuccessCode { + return nil, errors.New(result.SubMsg) + } + + configListRequired := make([]*product_qualificationConfig_response.ConfigListItem, 0) + for _, v := range result.Data.ConfigList { + if v.IsRequired == false { + continue + } + configListRequired = append(configListRequired, &v) + } + globals.SugarLogger.Debugf("configListRequired=== :%s", utils.Format4Output(configListRequired, false)) + return configListRequired, nil +} + // SyncStockBatch 库存批量同步 func (a *API) SyncStockBatch(param *sku_syncStockBatch_request.SkuSyncStockBatchParam) error { request := sku_syncStockBatch_request.New() diff --git a/platformapi/tiktok_shop/tiktok_api/sku_delete_test.go b/platformapi/tiktok_shop/tiktok_api/sku_delete_test.go index 7d5796eb..fddca0f6 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku_delete_test.go +++ b/platformapi/tiktok_shop/tiktok_api/sku_delete_test.go @@ -68,3 +68,7 @@ func TestGetSkuBrand(t *testing.T) { globals.SugarLogger.Debugf("data ========= %v", data) globals.SugarLogger.Debugf("data ========= %s", err) } + +func TestQualityList(t *testing.T) { + a.QualityList(33079) +} diff --git a/platformapi/tiktok_shop/tiktok_api/sku_type.go b/platformapi/tiktok_shop/tiktok_api/sku_type.go index 61c4e8e1..dd21b793 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku_type.go +++ b/platformapi/tiktok_shop/tiktok_api/sku_type.go @@ -12,12 +12,25 @@ const ( TiktokFolder3 = "71762017122139835211688" // (方案二测试文件夹) TiktokFolder4 = "72213403043425651541645" // (美好菜市) TiktokShoppingFolder = "71802347591117703711619" // (方案二测试文件夹) - TiktokFloderKeyVegetableKey = 57939570 // (菜市的文件夹id) + TiktokFloderKeyVegetableKey = 57939570 // (菜市的文件夹id)速食 TiktokFloderKeyShoppingKey = 68023619 // (商超账号的文件夹id) TiktokFloderKeyTestKey = 63141688 // (测试账号) TiktokFloderKeyBeautifulKey = 68032645 // (美好菜市) ) +const ( + QualificationsSuShiPackageId = "7129700904345125135" // 京西速食包装标签id + QualificationsSuShiPackageName = "包装标签图_20220809_104106" // 京西速食包装标签名称 + QualificationsPackageImg = "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/VqGYBUaL_m_e40ed809c2231a95197db39c86fe70e6_sx_463300_www1040-1034" // 速食包装标签图 + QualificationsShopPackageId = "7182777418275832098" // 京西超市包装标签id + QualificationsShopPackageName = "包装标签图_20220809_104107" // 京西超市包装标签名称 + QualificationsShopPackageImg = "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/TGUZigMc_m_e40ed809c2231a95197db39c86fe70e6_sx_463300_www1040-1034" // 京西超市包装标签名称 + QualificationsBeautifulPackageId = "7221409845910470964" // 美好菜市包装标签id + QualificationsBeautifulPackageName = "包装标签图_20220809_104106" // 美好菜市包装标签名称 + QualificationsBeautifulPackageImg = "https://p3-aio.ecombdimg.com/obj/ecom-shop-material/yneNVdDN_m_e40ed809c2231a95197db39c86fe70e6_sx_463300_www1040-1034" // 京西超市包装标签名称 + +) + // 商品减库存类型 const ( SkuReduceTypeReduceMakeOrder = 1 // 拍下减库存 From 5eb3a4332a3a5eb05033d3bc02b6984e86ed4003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Tue, 18 Apr 2023 15:51:41 +0800 Subject: [PATCH 14/21] 1 --- platformapi/mtwmapi/retail.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformapi/mtwmapi/retail.go b/platformapi/mtwmapi/retail.go index 9ff2623d..549e05d6 100644 --- a/platformapi/mtwmapi/retail.go +++ b/platformapi/mtwmapi/retail.go @@ -30,7 +30,7 @@ const ( // {"attrId":1200000275,"attrName":"是否有机","valueList":[{"valueId MtwmSkuAttr200000592 = `[{"attrId":1200000088,"attrName":"品牌","valueList":[{"valueId":1000001,"value":"其他品牌"}]}]` //200002704 MtwmSkuAttr200002731 = `[{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]` - MtwmSkuAttr200002716 = `[{"attrId":1200000287,"attrName":"特产品种","valueList":[{"valueId":1300003951,"value":"非特产品种"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]` + MtwmSkuAttr200002716 = `[{"attrId":1200000287,"attrName":"特产品种","valueList":[{"valueId":1300016304,"value":"其他"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]` //200002667,200002713 MtwmSkuAttr200002670 = `[{"attrId":1200000202,"attrName":"品种","valueList":[{"valueId":1300000249,"value":"其他"}]},{"attrId":1200000287,"attrName":"特产品种","valueList":[{"valueId":1300003951,"value":"非特产品种"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]` //MtwmSkuAttr200002680 = `[{"attrId":1200000289,"attrName":"品规","valueList":[{"valueId":1300004255,"value":"未区分品规"}]},{"attrId":1200000202,"attrName":"品种","valueList":[{"valueId":1300000249,"value":"其他"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]` From 4e4b1079508c6668a82929aa7bf9791af6af5430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 19 Apr 2023 15:05:50 +0800 Subject: [PATCH 15/21] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A5=BF=E7=99=BE?= =?UTF-8?q?=E8=87=AA=E9=85=8D=E9=80=81=E9=AA=91=E6=89=8B=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platformapi/ebaiapi/order.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/platformapi/ebaiapi/order.go b/platformapi/ebaiapi/order.go index 7fbd27cc..d32a3213 100644 --- a/platformapi/ebaiapi/order.go +++ b/platformapi/ebaiapi/order.go @@ -362,6 +362,35 @@ func (a *API) OrderselfDeliveryStateSync(orderID, phone string) (err error) { return err } +type PushRiderInfo struct { + DistributorId int `json:"distributor_id"` // 固定值:201 + Knight Knight `json:"knight"` + OrderId string // 订单id + State int // 配送状态,传固定值:21 开始配送(已废弃,已接入商家不影响) + SelfStatus int `json:"selfStatus"` // 配送状态 + SelfStatusDesc string `json:"selfStatusDesc"` // 配送状态文案描述 + SelfSubStatus int `json:"selfSubStatus"` // 配送取消(6)子原因: + SelfSubStatusDesc string `json:"selfSubStatusDesc"` // 配送异常子状态文案描述 + DistributorInfoDTO DistributorInfoDTO `json:"distributorInfoDTO"` // 配送服务商信息 +} +type Knight struct { + Id int64 `json:"id"` // 骑手id,商家自定义 + Name string `json:"name"` // 骑手姓名 + Phone string `json:"phone"` // 骑手手机号码 +} + +type DistributorInfoDTO struct { + DistributorTypeId string `json:"distributorTypeId"` // 配送商类型id: + DistributorName string `json:"distributorName"` // 配送商名称 + DistributorPhone string `json:"distributorPhone"` // 配送商电话 +} + +// OrderselfDeliveryStateSync2 饿了么自配送订单接入骑手状态 +func (a *API) OrderselfDeliveryStateSync2(info *PushRiderInfo) (err error) { + _, err = a.AccessAPI("order.selfDeliveryStateSync", utils.Struct2MapByJson(info)) + return err +} + // 饿了么自配送订单回传订单已送出状态 // 此接口目前只支持饿了么侧订单调用 func (a *API) OrderSendOut(orderID, phone string) (err error) { From 12fbab3dd6cf40dd02b6a6c61dd095b691e11220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Wed, 19 Apr 2023 17:42:03 +0800 Subject: [PATCH 16/21] 1 --- platformapi/mtwmapi/retail.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformapi/mtwmapi/retail.go b/platformapi/mtwmapi/retail.go index 549e05d6..f4e7a38a 100644 --- a/platformapi/mtwmapi/retail.go +++ b/platformapi/mtwmapi/retail.go @@ -32,7 +32,7 @@ const ( // {"attrId":1200000275,"attrName":"是否有机","valueList":[{"valueId MtwmSkuAttr200002731 = `[{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]` MtwmSkuAttr200002716 = `[{"attrId":1200000287,"attrName":"特产品种","valueList":[{"valueId":1300016304,"value":"其他"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]` //200002667,200002713 - MtwmSkuAttr200002670 = `[{"attrId":1200000202,"attrName":"品种","valueList":[{"valueId":1300000249,"value":"其他"}]},{"attrId":1200000287,"attrName":"特产品种","valueList":[{"valueId":1300003951,"value":"非特产品种"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]` + MtwmSkuAttr200002670 = `[{"attrId":1200000202,"attrName":"品种","valueList":[{"valueId":1300000249,"value":"其他"}]},{"attrId":1200000287,"attrName":"特产品种","valueList":[{"valueId":1300016304,"value":"其他"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]` //MtwmSkuAttr200002680 = `[{"attrId":1200000289,"attrName":"品规","valueList":[{"valueId":1300004255,"value":"未区分品规"}]},{"attrId":1200000202,"attrName":"品种","valueList":[{"valueId":1300000249,"value":"其他"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]` MtwmSkuAttr200002680 = `[{"attrId":1200004607,"attrName":"水果形态","valueList":[{"valueId":1300017364,"value":"新鲜整果"}]},{"attrId":1200004608,"attrName":"单果重量","valueList":[{"valueId":1300017449,"value":"约4.5kg~5kg"}]},{"attrId":1200000202,"attrName":"品种","valueList":[{"valueId":1300000249,"value":"其他"}]},{"attrId":1200000094,"attrName":"产地","valueList":[{"valueId":100000050,"value":"中国"}]},{"attrId":1200000132,"attrName":"国产/进口","valueList":[{"valueId":1300000003,"value":"国产"}]},{"attrId":1200000286,"attrName":"果品品牌","valueList":[{"valueId":1300000249,"value":"其他"}]}]` ) From 76fb7fc02809fe2eb0546281e501f805ed994089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Thu, 20 Apr 2023 15:34:15 +0800 Subject: [PATCH 17/21] 1 --- platformapi/mtwmapi/bill_list.go | 121 ++++++++++++++++++++++++++++ platformapi/mtwmapi/mtwmapi_test.go | 4 +- platformapi/mtwmapi/poi_test.go | 5 +- 3 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 platformapi/mtwmapi/bill_list.go diff --git a/platformapi/mtwmapi/bill_list.go b/platformapi/mtwmapi/bill_list.go new file mode 100644 index 00000000..abaf44ac --- /dev/null +++ b/platformapi/mtwmapi/bill_list.go @@ -0,0 +1,121 @@ +package mtwmapi + +// GetStoreBillList 获取门店的订单账单 +/* +1.金额类字段单位使用“分” +2.当日10点前不能查询昨日账单。 +3.开始日期和结束日期相隔不能超过7天。 +4.仅支持查询90天内的账单。 +5.如订单在状态完成之前取消了,则该订单不会记账,本接口不会查询到该订单的账单信息。 +6.商家如需对接,请按如下流程申请开通接口权限:请商家发送邮件至 MT.lingshou.open@meituan.com邮件标题:【appid+appname】开通日账单接口权限申请 邮件内容:需包括但不限于以下几点: +1)需开通账单接口调用权限的应用appid、appname; +2)开通的目的或背景; +3)想要实现的效果; +4)预计开发周期和上线时间; +5)商家公司授权开通日账单接口的证明。(点击下载授权证明模板,授权证明以附件形式提供。)*/ +func (a *API) GetStoreBillList() { + +} + +// StoreBillListReq 门店结算查询条件 +type StoreBillListReq struct { + AppPoiCode string `json:"app_poi_code"` // APP方门店id + StartDate int64 `json:"start_date"` // 开始时间 + EndDate int64 `json:"end_date"` // 结束时间 + Offset int64 `json:"offset"` // 偏移量 + Limit int64 `json:"limit"` // 最大返回条数 (200) +} + +// StoreBillListRes 门店结算返回值 +type StoreBillListRes struct { + ExtraInfo ExtraInfoData `json:"extra_info"` +} + +type ExtraInfoData struct { + TotalCount int `json:"total_count"` // 当前查询时间条件下返回的账单数据总条数 + SettleSum string `json:"settle_sum"` // 当前查询时间条件下返回的账单数据总结算金额(settleMilli汇总),单位分 +} + +type BillListData struct { + Id string `json:"id"` // 账单的唯一标识id + WmPoiName string `json:"wmPoiName"` // 门店名称 + BillChargeType int `json:"billChargeType"` // 结算类型 + ChargeFeeDesc string `json:"chargeFeeDesc"` // 结算类型描述 + UserPayType int `json:"userPayType"` // 用户支付方式 + WmPoiOrderPushDayseq string `json:"wmPoiOrderPushDayseq"` // 订单流水号 + WmOrderViewId string `json:"wmOrderViewId"` // 订单展示ID + OrderTime string `json:"orderTime"` // 下单时间 + FinishTime string `json:"finishTime"` // 完成时间 + RefundTime string `json:"refundTime"` // 退款时间 + OrderState int `json:"orderState"` // 订单当前状态 + ShippingType int `json:"shippingType"` // 订单配送方式,以订单完成时刻的配送方式为准。参考值:10-商家自配;20-美团快送;30-美团跑腿;40-美团专送;50-代理商配送;60-到店取餐;70-聚合配送;80-企客光速达;90-企客快速达;100-企客及时达;120-企客全城送。 + ShippingStatus int `json:"shippingStatus"` // 配送状态,参考值:0-未知;1-已推单;10-已抢单;15-已取餐;20-派送中;40-已送达;100-已取消。如为自配送订单,则配送状态默认为0。 + AccountState int `json:"accountState"` // 结算状态,参考值:0-已入账;1-未入账。 + DaliyBillDate string `json:"daliyBillDate"` // 账单日期 + SettleBillDesc string `json:"settleBillDesc"` // 归账日期,返回结算周期。商家在美团平台上建店时,与美团协议约定的门店结算周期(自外卖信息首次发布之日起算)。如订单未入账(accountState=1),此字段返回null。 + SettleAmount int64 `json:"settleAmount"` // 商家应收款,单位分。 + TotalFoodAmount int64 `json:"totalFoodAmount"` // 商品总价(不含商品包装盒费),单位分。公式:商品总价=商品原价+赠品原价 + BoxAmount int64 `json:"boxAmount"` // 商品包装盒费总价,单位分。 + ActivityPoiAmount int64 `json:"activityPoiAmount"` // 商家活动总支出金额(含赠品成本),单位分。 + ActivityMeituanAmount int64 `json:"activityMeituanAmount"` // 美团活动补贴总金额,单位分。 + ActivityAgentAmount int64 `json:"activityAgentAmount"` // 代理商活动承担金额,单位分。 + PlatformChargeFee int64 `json:"platformChargeFee"` // 平台服务费,单位分。 + PerformanceServiceFee int64 `json:"performanceServiceFee"` // 订单履约服务费金额,单位分。如订单无履约服务费,则返回0。(订单履约服务费金额=基础价格+距离收费+重量收费+节假日收费+品类收费+时段收费) + BaseShippingAmount int64 `json:"baseShippingAmount"` // 履约服务费-基础价格,单位分 + Distance int64 `json:"distance"` // 履约服务费-导航距离,获取的导航距离,单位米 + DistanceFee int64 `json:"distanceFee"` // 履约服务费-距离收费,距离加价费用,单位分 + WeightChargeFee int64 `json:"weightChargeFee"` // 履约服务费-重量收费,重量加价费用,单位分 + HolidayChargeFee int64 `json:"holidayChargeFee"` // 履约服务费-节假日收费,单位分 + CategoryChargeFee int64 `json:"categoryChargeFee"` // 履约服务费-品类收费,单位分 + SlaFee int64 `json:"slaFee"` // 履约服务费-时段收费,时段加价费用,单位分 + UserPayShippingAmount int64 `json:"userPayShippingAmount"` // 用户支付配送费,为运费优惠前的金额,单位分。 + UserOnlinePayAmount int64 `json:"userOnlinePayAmount"` // 用户在线支付金额,为用户实际支付的订单总金额,单位分。 + UserOfflinePayAmount int64 `json:"userOfflinePayAmount"` // 用户线下支付金额,单位分。目前美团订单仅支持在线支付。 + Rate int64 `json:"rate"` // 平台服务费的费率,单位百分比(%)。是商家在美团平台建店时,与美团协议约定的每单抽佣比例。 + Bottom int64 `json:"bottom"` // 保底金额,单位元。是商家在美团平台建店时,与美团协议约定的每单保底抽佣金额。 + RefundId int64 `json:"refund_id"` // 退款id,与订单退款消息接口中退款id的值相对应。 目前只有在结算类型(billChargeType)为:2,6,7,26,27时,该字段会有合法值;其他结算类型下,该字段值无意义。当billChargeType=2时,该字段的取值与订单ID相同。 + Discount int64 `json:"discount"` // 分成折扣,目前默认返回100。 + SettleMilli int64 `json:"settleMilli"` // 结算金额,单位毫。 + SettleSettingId string `json:"settleSettingId"` // 结算id,表示账期等信息的结算设置id。同一门店的结算设置不变的情况下,结算id不变。 + WmDonationAmount int64 `json:"wmDonationAmount"` // 青山计划-公益捐赠金额,单位分。 + WmDoggyBagAmount int64 `json:"wmDoggyBagAmount"` // 商超-打包袋金额,单位分。注意,打包袋费用规则为: (1)订单打包袋如由美团提供给商家,费用结算美团平台,则打包袋字段wmDoggyBagAmount为0; (2)订单打包袋如由商家自己提供,费用结算给商家,则打包袋字段wmDoggyBagAmount为商家设置金额。 + DealTip int64 `json:"dealTip"` // 配送小费,单位分。 + ProductPreferences float64 `json:"productPreferences"` // 商家活动支出分摊到商品上的优惠总金额,单位分。 + NotProductPreferences float64 `json:"notProductPreferences"` // 商家活动支出的未分摊到商品上的总金额,单位分。 + WmAppOrderSkuBenefitDetailList []WmAppOrderSkuBenefitDetailList `json:"wmAppOrderSkuBenefitDetailList"` // 商家承担成本的商品优惠分摊明细,json格式数组。 + WmAppOrderSkuShippingDetailList []MedicalInsuranceFee `json:"wmAppOrderSkuShippingDetailList"` // 商家承担配送费活动分摊明细。 + ChargeFeeType int64 `json:"chargeFeeType"` // 用来标识退款是部分退还是退差价,billChargeType为26时,该值为1代表 退差价,0为部分退。billChargeType为其他值得情况,忽略该字段 + MedicalInsuranceFee string `json:"medicalInsuranceFee"` // 医保报销费用字段(单位分),只有医保报销的商家这个字段有值 +} + +type WmAppOrderSkuBenefitDetailList struct { + AppSpuCode string `json:"app_spu_code"` // (原app_food_code字段)APP方商品的id,即商家中台系统里商品的编码:(1) 同一门店内商品id不允许重复;(2)字段信息限定长度不超过128个字符。 + Name string `json:"name"` // 商品名称。 + SkuId string `json:"sku_id"` // 商品sku的规格编码,SKU码/货号。 + Count int `json:"count"` // 商品数量 注:当字段count=0时,此账单记录为商家发起的按重量退差价,但结算类型仍为“26-闪购品类订单部分退款”(billChargeType=26)。 + TotalOriginPrice float64 `json:"totalOriginPrice"` // 商品原价总价(含商品包装盒费),单位分。 + TotalActivityPrice float64 `json:"totalActivityPrice"` //商品优惠总金额,包括商家承担金额和美团承担金额,单位分。 + TotalReducePrice float64 `json:"totalReducePrice"` // 商品优惠总金额,包括商家承担金额和美团承担金额,单位分。 + WmAppOrderActDetails []wmAppOrderActDetails // 商品参与活动详情,json格式数组。 + +} + +type wmAppOrderActDetails struct { + actId int64 `json:"act_id"` // 商品参与活动的活动id + MTType int `json:"type"` // 参与活动的活动类型,参考值:1-首单立减;2-满减优惠;4-套餐惠赠优惠;9-美团红包;11-提前下单减优惠;17-折扣商品;18-美团专送再减;20-第二份半价优惠;22-门店新客立减;27-指定商品满减;40-加价购;43-X元M件;46-超值换购;66-会员折扣商品;101-商家代金券优惠;117-商品优惠券;118-商品折扣券;900-首单红包优惠。 + PoiCharge float64 `json:"poiCharge"` // 本活动id及活动类型下商家承担的金额,单位分。 +} + +type MedicalInsuranceFee struct { + Name string `json:"name"` // 商品名称。 + SkuId string `json:"sku_id"` // 商品sku的规格编码,SKU码/货号。 + Count int `json:"count"` // 商品数量 注:当字段count=0时,此账单记录为商家发起的按重量退差价,但结算类型仍为“26-闪购品类订单部分退款”(billChargeType=26)。 + totalOriginPrice float64 `json:"totalOriginPrice"` // 商品原价总价(含商品包装盒费),单位分。 + totalPoiCharge float64 `json:"totalPoiCharge"` // 配送费优惠商家承担总金额,单位分。 + wmAppOrderShippingActDetailList []wmAppOrderShippingActDetailList `json:"wmAppOrderShippingActDetailList"` // sku商品参与的配送费活动详情。 +} + +type wmAppOrderShippingActDetailList struct { + MTType int `json:"type"` // 参与配送费活动的活动类型,参考值:9-美团红包,21-会员免配送费,25-立减配送费,30-满减配送费,36-新人减配送费,54-新客专享减配送费,59-新客专享减配送费,300-商家会员减配送费,302-预订单减配送费,304-减免运费券,101-商家代金券优惠,305-津贴优惠。 + PoiCharge float64 `json:"poiCharge"` // 商家承担金额,单位分。 +} diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go index 2d653902..4a72298b 100644 --- a/platformapi/mtwmapi/mtwmapi_test.go +++ b/platformapi/mtwmapi/mtwmapi_test.go @@ -20,13 +20,13 @@ func init() { baseapi.Init(sugarLogger) // 菜市 - api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") + //api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") // 果园 // api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //商超 - //api = New("5873", "41c479790a76f86326f89e8048964739", "", "") //token_nH_IlcWQKAkZBqklwItNRw + api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_n4TwqCntWWuvQwAawzxC0w") //token_n4TwqCntWWuvQwAawzxC0w cookieStr := ` acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; ` diff --git a/platformapi/mtwmapi/poi_test.go b/platformapi/mtwmapi/poi_test.go index c63ddf7c..8187609d 100644 --- a/platformapi/mtwmapi/poi_test.go +++ b/platformapi/mtwmapi/poi_test.go @@ -45,8 +45,9 @@ func TestPoiSave(t *testing.T) { poiParams := map[string]interface{}{} //utils.FilterMapNilMembers(utils.Struct2FlatMap(result[0])) //poiParams["address"] = "成都市温江区柳城学海路585号" - poiParams["pic_url"] = "http://image.jxc4.com/image/5c9fc4fffb4d5ff1aecf85a2d2543e00.jpg" - err := api.PoiSave("17218722", poiParams) + //poiParams["pic_url"] = "http://image.jxc4.com/image/5c9fc4fffb4d5ff1aecf85a2d2543e00.jpg" + poiParams["name"] = "京西到家(犀浦店)" + err := api.PoiSave("17371124", poiParams) fmt.Println(err) } From 61d9da631cf26f52d9d589b5d964d5abbeed41cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Sun, 23 Apr 2023 15:44:48 +0800 Subject: [PATCH 18/21] 1 --- platformapi/mtwmapi/bill_list.go | 26 +++++++++++++++++-- platformapi/mtwmapi/bill_list_test.go | 26 +++++++++++++++++++ platformapi/mtwmapi/mtwmapi.go | 18 ++++++++++--- platformapi/mtwmapi/mtwmapi_test.go | 8 +++--- platformapi/mtwmapi/poi_test.go | 4 +-- .../tiktok_shop/tiktok_api/afs_test.go | 2 +- platformapi/tiktok_shop/tiktok_api/sku.go | 2 +- .../tiktok_shop/tiktok_api/sku_test.go | 6 ++--- 8 files changed, 75 insertions(+), 17 deletions(-) create mode 100644 platformapi/mtwmapi/bill_list_test.go diff --git a/platformapi/mtwmapi/bill_list.go b/platformapi/mtwmapi/bill_list.go index abaf44ac..9a2975fc 100644 --- a/platformapi/mtwmapi/bill_list.go +++ b/platformapi/mtwmapi/bill_list.go @@ -1,5 +1,17 @@ package mtwmapi +import ( + "git.rosy.net.cn/baseapi/utils" +) + +type Bill struct { + AppPoiCode string `json:"app_poi_code"` // APP方门店id,传商家中台系统里门店的编码。如商家在操作绑定门店至开放平台应用中时,未绑定三方门店id信息,则默认APP方门店id与美团门店id相同。 + StartDate int64 `json:"start_date"` // 秒级时间戳 + EndDate int64 `json:"end_date"` // 秒级时间戳 + Offset int64 `json:"offset"` + Limit int64 `json:"limit"` +} + // GetStoreBillList 获取门店的订单账单 /* 1.金额类字段单位使用“分” @@ -13,8 +25,17 @@ package mtwmapi 3)想要实现的效果; 4)预计开发周期和上线时间; 5)商家公司授权开通日账单接口的证明。(点击下载授权证明模板,授权证明以附件形式提供。)*/ -func (a *API) GetStoreBillList() { +func (a *API) GetStoreBillList(param *Bill) (*StoreBillListRes, error) { + result, err := a.AccessAPI3("bill/list", true, utils.Struct2Map(param, "", false)) + if err != nil { + return nil, err + } + var data *StoreBillListRes + if err := utils.Map2StructByJson(result, &data, false); err != nil { + return nil, err + } + return data, nil } // StoreBillListReq 门店结算查询条件 @@ -28,7 +49,8 @@ type StoreBillListReq struct { // StoreBillListRes 门店结算返回值 type StoreBillListRes struct { - ExtraInfo ExtraInfoData `json:"extra_info"` + ExtraInfo ExtraInfoData `json:"extra_info"` + Data []*BillListData `json:"data"` } type ExtraInfoData struct { diff --git a/platformapi/mtwmapi/bill_list_test.go b/platformapi/mtwmapi/bill_list_test.go new file mode 100644 index 00000000..51d43c52 --- /dev/null +++ b/platformapi/mtwmapi/bill_list_test.go @@ -0,0 +1,26 @@ +package mtwmapi + +import ( + "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/globals" + "testing" + "time" +) + +func TestBillList(t *testing.T) { + now := time.Now() + from := time.Date(now.Year(), now.Month(), now.Day()-5, 0, 0, 0, 0, time.Local) + to := time.Date(now.Year(), now.Month(), now.Day()-5, 23, 59, 59, 59, time.Local) + param := &Bill{ + AppPoiCode: "16967920", + StartDate: from.Unix(), + EndDate: to.Unix(), + Offset: 0, + Limit: 200, + } + + data, _ := api.GetStoreBillList(param) + globals.SugarLogger.Debugf("data := %s", utils.Format4Output(data.Data[0], false)) + // performanceServiceFee 订单配送费 + // userPayShippingAmount 用户支付配送费 +} diff --git a/platformapi/mtwmapi/mtwmapi.go b/platformapi/mtwmapi/mtwmapi.go index b88a9197..d46d0efe 100644 --- a/platformapi/mtwmapi/mtwmapi.go +++ b/platformapi/mtwmapi/mtwmapi.go @@ -245,11 +245,21 @@ func (a *API) AccessAPI3(cmd string, isGet bool, bizParams map[string]interface{ // 不管有无错误,都尝试取得数据(因为有出错,但有有效数据返回的情况),比如ecommerce/order/getOrderIdByDaySeq retVal = jsonResult1 if errObj, ok := jsonResult1["data"]; ok { - errorInfo := errObj.(string) - if errorInfo != "ok" { - newErr := utils.NewErrorIntCode(jsonResult1["error_list"].([]interface{})[0].(map[string]interface{})["msg"].(string), int(utils.MustInterface2Int64(jsonResult1["error_list"].([]interface{})[0].(map[string]interface{})["code"]))) - return errLevel, newErr + switch errObj.(type) { + case string: + errorInfo := errObj.(string) + if errorInfo != "ok" { + var newErr *utils.ErrorWithCode + if cmd == "bill/list" { + newErr = utils.NewErrorIntCode(jsonResult1["error"].(interface{}).(map[string]interface{})["msg"].(string), int(utils.MustInterface2Int64(jsonResult1["error"].(interface{}).(map[string]interface{})["code"]))) + } else { + newErr = utils.NewErrorIntCode(jsonResult1["error_list"].([]interface{})[0].(map[string]interface{})["msg"].(string), int(utils.MustInterface2Int64(jsonResult1["error_list"].([]interface{})[0].(map[string]interface{})["code"]))) + } + return errLevel, newErr + } + case interface{}: } + } return platformapi.ErrLevelSuccess, nil }) diff --git a/platformapi/mtwmapi/mtwmapi_test.go b/platformapi/mtwmapi/mtwmapi_test.go index 4a72298b..d453e22a 100644 --- a/platformapi/mtwmapi/mtwmapi_test.go +++ b/platformapi/mtwmapi/mtwmapi_test.go @@ -20,13 +20,13 @@ func init() { baseapi.Init(sugarLogger) // 菜市 - //api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") + api = New("589", "a81eb3df418d83d6a1a4b7c572156d2f", "", "") // 果园 // api = New("4123", "df2c88338b85f830cebce2a9eab56628", "", "") //商超 - api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_n4TwqCntWWuvQwAawzxC0w") //token_n4TwqCntWWuvQwAawzxC0w + //api = New("5873", "41c479790a76f86326f89e8048964739", "", "token_n4TwqCntWWuvQwAawzxC0w") //token_n4TwqCntWWuvQwAawzxC0w cookieStr := ` acctId=57396785; token=0bWbK5VbK50E2BmIhIH2zHB-am_y7mB37yXHm6RLZWx4*; wmPoiId=-1; ` @@ -42,7 +42,7 @@ func TestAccessAPI(t *testing.T) { } func TestGetOAuthCode(t *testing.T) { - result, err := api.GetOAuthCode("12422751") + result, err := api.GetOAuthCode("17395411") if err != nil { t.Fatal(err) } @@ -60,7 +60,7 @@ func TestGetAccessToken(t *testing.T) { } func TestGetAccessToken2(t *testing.T) { - result, err := api.GetAccessToken2("17371124") //refresh_token_pLG7Jw7g9mu7oOzNSuJIUg + result, err := api.GetAccessToken2("17395411") //refresh_token_pLG7Jw7g9mu7oOzNSuJIUg if err != nil { t.Fatal(err) } diff --git a/platformapi/mtwmapi/poi_test.go b/platformapi/mtwmapi/poi_test.go index 8187609d..dcf87303 100644 --- a/platformapi/mtwmapi/poi_test.go +++ b/platformapi/mtwmapi/poi_test.go @@ -46,8 +46,8 @@ func TestPoiSave(t *testing.T) { //utils.FilterMapNilMembers(utils.Struct2FlatMap(result[0])) //poiParams["address"] = "成都市温江区柳城学海路585号" //poiParams["pic_url"] = "http://image.jxc4.com/image/5c9fc4fffb4d5ff1aecf85a2d2543e00.jpg" - poiParams["name"] = "京西到家(犀浦店)" - err := api.PoiSave("17371124", poiParams) + poiParams["name"] = "京西菜市(礼嘉桥村市场店)" + err := api.PoiSave("17395411", poiParams) fmt.Println(err) } diff --git a/platformapi/tiktok_shop/tiktok_api/afs_test.go b/platformapi/tiktok_shop/tiktok_api/afs_test.go index 771a24a6..566bc7e7 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":"b558d5bd-d55d-4322-8602-85ba449cbc79","expires_in":1681667840,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"3a3c0ad2-bcbd-4f55-b7af-6b406dabc47a","authority_id":""}` +var token = `{"access_token":"c2c6e258-847d-4e8f-a695-b20488a5a667","expires_in":1682270239,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"ebf0e9f1-b200-47c2-a2bb-bafefbdaed47","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 0e87f9fd..e892bdea 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku.go +++ b/platformapi/tiktok_shop/tiktok_api/sku.go @@ -53,7 +53,7 @@ func (a *API) UpdateSkuStock(param *sku_syncStock_request.SkuSyncStockParam) err return err } if resp.Code != RequestSuccessCode { - return errors.New(resp.Msg) + return errors.New(resp.SubMsg) } return nil } diff --git a/platformapi/tiktok_shop/tiktok_api/sku_test.go b/platformapi/tiktok_shop/tiktok_api/sku_test.go index 5e70749d..4e6cdf26 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku_test.go +++ b/platformapi/tiktok_shop/tiktok_api/sku_test.go @@ -62,9 +62,9 @@ func TestGetSkuDetailLocalId(t *testing.T) { func TestUpdateSkuStore(t *testing.T) { err := a.UpdateSkuStock(&sku_syncStock_request.SkuSyncStockParam{ - ProductId: 3605142143867471418, - OutSkuId: 6045168, - StockNum: 2, + ProductId: 3612015462742906941, + OutSkuId: 6094281, + StockNum: 9999, Incremental: false, }) fmt.Println(err) From 2e7f2d9328e46e8776812dfafba0d723f74f3f3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Sun, 23 Apr 2023 16:15:00 +0800 Subject: [PATCH 19/21] 1 --- platformapi/tiktok_shop/tiktok_api/sku.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformapi/tiktok_shop/tiktok_api/sku.go b/platformapi/tiktok_shop/tiktok_api/sku.go index e892bdea..26637517 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku.go +++ b/platformapi/tiktok_shop/tiktok_api/sku.go @@ -165,7 +165,7 @@ func (a *API) CreateStoreCommodity(skuParam *product_addV2_request.ProductAddV2P return nil, err } if result.Code != RequestSuccessCode { - return nil, errors.New(result.SubMsg) + return nil, errors.New(result.SubMsg + ":" + result.LogId) } return result.Data, nil } @@ -644,7 +644,7 @@ func (a *API) CreateSubProduct(mainProductId int64, storeId int64) (int64, error } if result.Code != RequestSuccessCode { - return 0, errors.New(result.SubMsg) + return 0, errors.New(result.SubMsg + ":" + result.LogId) } return result.Data.SubProductId, nil From 3a3c5887b4b411a49970066a70c6ffa7d9ce3ace Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Sun, 23 Apr 2023 17:03:29 +0800 Subject: [PATCH 20/21] 1 --- .../tiktok_shop/tiktok_api/afs_test.go | 2 +- platformapi/tiktok_shop/tiktok_api/api.go | 2 +- .../tiktok_api/logistics_express.go | 6 +-- platformapi/tiktok_shop/tiktok_api/order.go | 20 +++++----- .../tiktok_api/settle_bill_detail.go | 2 +- platformapi/tiktok_shop/tiktok_api/sku.go | 39 +++++++++---------- .../tiktok_shop/tiktok_api/sku_test.go | 6 +-- .../tiktok_shop/tiktok_api/sku_warehouse.go | 2 +- platformapi/tiktok_shop/tiktok_api/store.go | 28 ++++++------- .../tiktok_shop/tiktok_api/transport.go | 18 ++++----- 10 files changed, 61 insertions(+), 64 deletions(-) diff --git a/platformapi/tiktok_shop/tiktok_api/afs_test.go b/platformapi/tiktok_shop/tiktok_api/afs_test.go index 566bc7e7..578bee8d 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":"c2c6e258-847d-4e8f-a695-b20488a5a667","expires_in":1682270239,"scope":"SCOPE","shop_id":57939570,"shop_name":"京西菜市速食","refresh_token":"ebf0e9f1-b200-47c2-a2bb-bafefbdaed47","authority_id":""}` +var token = `{"access_token":"cfb17c78-6aad-47db-80a3-a9ed9f7b3482","expires_in":1682516556,"scope":"SCOPE","shop_id":68023619,"shop_name":"京西到家","refresh_token":"d921257a-1c39-491d-a691-bbf9850ed926","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.go b/platformapi/tiktok_shop/tiktok_api/api.go index e28f188f..bbf004bc 100644 --- a/platformapi/tiktok_shop/tiktok_api/api.go +++ b/platformapi/tiktok_shop/tiktok_api/api.go @@ -95,7 +95,7 @@ func (a *API) RefreshToken() (*doudian_sdk.CreateTokenData, error) { return nil, err } if createToken.Code != RequestSuccessCode { - return nil, errors.New(createToken.SubMsg) + return nil, errors.New(createToken.SubMsg + ":" + createToken.LogId) } a.accessToken = createToken.Data.AccessToken a.refreshToken = createToken.Data.RefreshToken diff --git a/platformapi/tiktok_shop/tiktok_api/logistics_express.go b/platformapi/tiktok_shop/tiktok_api/logistics_express.go index c61eed4f..2ac9db80 100644 --- a/platformapi/tiktok_shop/tiktok_api/logistics_express.go +++ b/platformapi/tiktok_shop/tiktok_api/logistics_express.go @@ -66,7 +66,7 @@ func (a *APIExpress) CreateToken() (*token_create_response.TokenCreateData, erro return nil, err } if response.Code != RequestSuccessCode { - return nil, errors.New(response.SubMsg) + return nil, errors.New(response.SubMsg + ":" + response.LogId) } a.accessToken = response.Data.AccessToken @@ -98,7 +98,7 @@ func (a *APIExpress) RefreshToken() (*doudian_sdk.CreateTokenData, error) { return nil, err } if createToken.Code != RequestSuccessCode { - return nil, errors.New(createToken.SubMsg) + return nil, errors.New(createToken.SubMsg + ":" + createToken.LogId) } a.accessToken = createToken.Data.AccessToken a.refreshToken = createToken.Data.RefreshToken @@ -160,7 +160,7 @@ func (a *APIExpress) OrderStatusAndPsInfo(param map[string]interface{}) error { return err } if result.Code != RequestSuccessCode { - return errors.New(result.SubMsg) + return errors.New(result.SubMsg + ":" + result.LogId) } return nil } diff --git a/platformapi/tiktok_shop/tiktok_api/order.go b/platformapi/tiktok_shop/tiktok_api/order.go index cf20d03a..c1b16381 100644 --- a/platformapi/tiktok_shop/tiktok_api/order.go +++ b/platformapi/tiktok_shop/tiktok_api/order.go @@ -35,7 +35,7 @@ func (a *API) GetTiktokOrderDetail(orderId string) (*order_orderDetail_response. return nil, err } if orderDetail.Code != RequestSuccessCode { - return nil, errors.New(orderDetail.SubMsg) + return nil, errors.New(orderDetail.SubMsg + ":" + orderDetail.LogId) } return orderDetail.Data.ShopOrderDetail, nil @@ -54,7 +54,7 @@ func (a *API) QueryAfsOrderDetail(afterSaleId string, needOperationRecord bool) return nil, err } if result.Code != RequestSuccessCode { - return nil, errors.New(result.SubMsg) + return nil, errors.New(result.SubMsg + ":" + result.LogId) } return result, nil } @@ -72,7 +72,7 @@ func (a *API) ApplyMarketAfterSale(skuOrderId, count int64, afterSaleReason int3 return "", err } if result.Code != RequestSuccessCode { - return "", errors.New(result.SubMsg) + return "", errors.New(result.SubMsg + ":" + result.LogId) } return result.Data.AfterSaleId, nil } @@ -155,7 +155,7 @@ func (a *API) AfterSaleOperate(refundType int32, refundId, remark string, storeI return err } if result.Code != RequestSuccessCode { - return errors.New(result.SubMsg) + return errors.New(result.SubMsg + ":" + result.LogId) } return nil } @@ -175,7 +175,7 @@ func (a *API) GetRefundAddressId(storeID int64) (int64, error) { return 0, err } if result.Code != RequestSuccessCode { - return 0, errors.New(result.SubMsg) + return 0, errors.New(result.SubMsg + ":" + result.LogId) } if len(result.Data.AddressList) < 1 { return 0, errors.New("门店详细地址获取错误") @@ -196,7 +196,7 @@ func (a *API) QueryAllReason(afterSaleId int64) ([]afterSale_rejectReasonCodeLis return nil, err } if result.Code != RequestSuccessCode { - return nil, errors.New(result.SubMsg) + return nil, errors.New(result.SubMsg + ":" + result.LogId) } return result.Data.Items, nil } @@ -218,7 +218,7 @@ func (a *API) GetStoreOrderList(queryData time.Time, storeId int64) ([]string, e return nil, err } if orderDetailList.Code != RequestSuccessCode { - return nil, errors.New(orderDetailList.Msg) + return nil, errors.New(orderDetailList.Msg + ":" + orderDetailList.LogId) } orderList := make([]string, 0, 0) @@ -251,7 +251,7 @@ func (a *API) GetStoreOrderList(queryData time.Time, storeId int64) ([]string, e return nil, err } if orderDetailList.Code != RequestSuccessCode { - return nil, errors.New(orderDetailList.Msg) + return nil, errors.New(orderDetailList.Msg + ":" + orderDetailList.LogId) } for _, v := range orderDetailList.Data.ShopOrderList { if v.ShopId == storeId { @@ -278,7 +278,7 @@ func (a *API) ReturnGoodsToWareHouseSuccess(afsOrderId string) error { return err // 202210141114300102101071350D6F3847 } if result.Code != RequestSuccessCode { - return errors.New(result.SubMsg) + return errors.New(result.SubMsg + ":" + result.LogId) } return nil } @@ -314,7 +314,7 @@ func (a *API) OrderDelivering(param *order_logisticsAdd_request.OrderLogisticsAd return nil } if result.Code != RequestSuccessCode { - return errors.New(result.SubMsg) + return errors.New(result.SubMsg + ":" + result.LogId) } return nil } diff --git a/platformapi/tiktok_shop/tiktok_api/settle_bill_detail.go b/platformapi/tiktok_shop/tiktok_api/settle_bill_detail.go index 34184326..f8a8c870 100644 --- a/platformapi/tiktok_shop/tiktok_api/settle_bill_detail.go +++ b/platformapi/tiktok_shop/tiktok_api/settle_bill_detail.go @@ -17,7 +17,7 @@ func (a *API) GetSettleBillDetailV3(param *order_getSettleBillDetailV3_request.O return 0, "", err } if result.Code != RequestSuccessCode { - return 0, "", errors.New(result.SubMsg) + return 0, "", errors.New(result.SubMsg + ":" + result.LogId) } if len(result.Data.Data) == 0 { diff --git a/platformapi/tiktok_shop/tiktok_api/sku.go b/platformapi/tiktok_shop/tiktok_api/sku.go index 26637517..56a739f7 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku.go +++ b/platformapi/tiktok_shop/tiktok_api/sku.go @@ -53,7 +53,7 @@ func (a *API) UpdateSkuStock(param *sku_syncStock_request.SkuSyncStockParam) err return err } if resp.Code != RequestSuccessCode { - return errors.New(resp.SubMsg) + return errors.New(resp.SubMsg + ":" + resp.LogId) } return nil } @@ -74,7 +74,7 @@ func (a *API) GetShopCategory(cid int64) ([]*RetailCategoryInfo, error) { return nil, err } if result.Code != RequestSuccessCode { - return nil, errors.New(result.SubMsg) + return nil, errors.New(result.SubMsg + ":" + result.LogId) } categoryAll := make([]*RetailCategoryInfo, 0, 0) @@ -112,7 +112,7 @@ func (a *API) GetCatePropertyV2(categoryLeftId int64) (*product_getCatePropertyV return nil, err } if result.Code != RequestSuccessCode { - return nil, errors.New(result.SubMsg) + return nil, errors.New(result.SubMsg + ":" + result.LogId) } return result, nil } @@ -182,7 +182,7 @@ func (a *API) QualityList(categoryId int64) ([]*product_qualificationConfig_resp return nil, err } if result.Code != RequestSuccessCode { - return nil, errors.New(result.SubMsg) + return nil, errors.New(result.SubMsg + ":" + result.LogId) } configListRequired := make([]*product_qualificationConfig_response.ConfigListItem, 0) @@ -205,7 +205,7 @@ func (a *API) SyncStockBatch(param *sku_syncStockBatch_request.SkuSyncStockBatch return err } if result.Code != RequestSuccessCode { - return errors.New(result.SubMsg) + return errors.New(result.SubMsg + ":" + result.LogId) } return nil } @@ -220,7 +220,7 @@ func (a *API) EditStoreCommodity(sku *product_editV2_request.ProductEditV2Param) return err } if result.Code != RequestSuccessCode { - return errors.New(result.SubMsg) + return errors.New(result.SubMsg + ":" + result.LogId) } return nil } @@ -235,16 +235,13 @@ func (a *API) EditStoreCommodityCommit(sku *product_editV2_commit_request.Produc return err } if result.Code != RequestSuccessCode { - return errors.New(result.SubMsg) + return errors.New(result.SubMsg + ":" + result.LogId) } return nil } // DeleteStoreCommodity 删除商品 func (a *API) DeleteStoreCommodity(productId int64) error { - globals.SugarLogger.Debugf("----打印看看是否是定时任务删除:%d", productId) - return nil - request := product_del_request.New() param := request.GetParams() param.ProductId = productId @@ -255,7 +252,7 @@ func (a *API) DeleteStoreCommodity(productId int64) error { return err } if result.Code != RequestSuccessCode { - return errors.New(result.SubMsg) + return errors.New(result.SubMsg + ":" + result.LogId) } return nil @@ -272,7 +269,7 @@ func (a *API) ProductSetOffline(productId int64) error { return err } if result.Code != RequestSuccessCode { - return errors.New(result.SubMsg) + return errors.New(result.SubMsg + ":" + result.LogId) } return nil } @@ -294,7 +291,7 @@ func (a *API) GetSkuDetail(productId, outProductId string) (*product_detail_resp return nil, nil } if result.Code != RequestSuccessCode { - return nil, errors.New(result.SubMsg) + return nil, errors.New(result.SubMsg + ":" + result.LogId) } if result.Data.Status == 2 { return nil, nil @@ -320,7 +317,7 @@ func (a *API) GetSkuDetailLocalID(productId, outProductId string) (*product_deta return nil, err } if result.Code != RequestSuccessCode { - return nil, errors.New(result.SubMsg) + return nil, errors.New(result.SubMsg + ":" + result.LogId) } if result.Data.Status == 2 { return nil, nil @@ -339,7 +336,7 @@ func (a *API) GetSkuDetailList(param *product_listV2_request.ProductListV2Param) return nil, err } if result.Code != RequestSuccessCode { - return nil, errors.New(result.SubMsg) + return nil, errors.New(result.SubMsg + ":" + result.LogId) } return result.Data, nil @@ -355,7 +352,7 @@ func (a *API) EditPrice(skuPrice *sku_editPrice_request.SkuEditPriceParam) error return err } if result.Code != RequestSuccessCode { - return errors.New(result.SubMsg) + return errors.New(result.SubMsg + ":" + result.LogId) } return nil } @@ -567,7 +564,7 @@ func (a *API) GetProductAuditList(page, pageSize, status int64) ([]product_audit return nil, 0, err } if result.Code != RequestSuccessCode { - return nil, 0, errors.New(result.SubMsg) + return nil, 0, errors.New(result.SubMsg + ":" + result.LogId) } return result.Data.Records, result.Data.Total, nil @@ -591,7 +588,7 @@ func (a *API) GetRecommendCategory(picParams []string) (int64, error) { return 0, err } if result.Code != RequestSuccessCode { - return 0, errors.New(result.SubMsg) + return 0, errors.New(result.SubMsg + ":" + result.LogId) } if len(result.Data.CategoryDetails) == 0 { @@ -660,7 +657,7 @@ func (a *API) BatchRedistributeStoreProduct(param *superm_product_batchRedistrib return 0, err } if result.Code != RequestSuccessCode { - return 0, err + return 0, errors.New(result.SubMsg + ":" + result.LogId) } return result.Data.RootTaskId, nil @@ -676,7 +673,7 @@ func (a *API) BatchApplyStoreProductPrice(mainProductId int64) (int64, error) { return 0, err } if result.Code != RequestSuccessCode { - return 0, errors.New(result.SubMsg) + return 0, errors.New(result.SubMsg + ":" + result.LogId) } return result.Data.RootTaskId, nil @@ -691,7 +688,7 @@ func (a *API) LaunchProduct(productId int64) error { return err } if result.Code != RequestSuccessCode { - return errors.New(result.SubMsg) + return errors.New(result.SubMsg + ":" + result.LogId) } return nil } diff --git a/platformapi/tiktok_shop/tiktok_api/sku_test.go b/platformapi/tiktok_shop/tiktok_api/sku_test.go index 4e6cdf26..379f87ed 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku_test.go +++ b/platformapi/tiktok_shop/tiktok_api/sku_test.go @@ -62,9 +62,9 @@ func TestGetSkuDetailLocalId(t *testing.T) { func TestUpdateSkuStore(t *testing.T) { err := a.UpdateSkuStock(&sku_syncStock_request.SkuSyncStockParam{ - ProductId: 3612015462742906941, - OutSkuId: 6094281, - StockNum: 9999, + ProductId: 3602878545761816498, + OutSkuId: 25250, + StockNum: 0, Incremental: false, }) fmt.Println(err) diff --git a/platformapi/tiktok_shop/tiktok_api/sku_warehouse.go b/platformapi/tiktok_shop/tiktok_api/sku_warehouse.go index ffc2714e..f85b6f61 100644 --- a/platformapi/tiktok_shop/tiktok_api/sku_warehouse.go +++ b/platformapi/tiktok_shop/tiktok_api/sku_warehouse.go @@ -28,7 +28,7 @@ func (a *API) CreateFolder(fileName string) (*material_createFolder_response.Mat return nil, err } if result.Code != RequestSuccessCode { - return nil, errors.New(result.SubMsg) + return nil, errors.New(result.SubMsg + ":" + result.LogId) } return result, nil } diff --git a/platformapi/tiktok_shop/tiktok_api/store.go b/platformapi/tiktok_shop/tiktok_api/store.go index ccf7bc35..d9b75fcc 100644 --- a/platformapi/tiktok_shop/tiktok_api/store.go +++ b/platformapi/tiktok_shop/tiktok_api/store.go @@ -72,7 +72,7 @@ func (a *API) GetStoreDetail(param *shop_getStoreDetail_request.ShopGetStoreDeta return nil, err } if response.Code != RequestSuccessCode { - return nil, errors.New(response.SubMsg) + return nil, errors.New(response.SubMsg + ":" + response.LogId) } return response.Data, nil } @@ -87,7 +87,7 @@ func (a *API) BatchCreateStore(param *shop_batchCreateStore_request.ShopBatchCre } if response.Code != RequestSuccessCode { //return nil, errors.New(response.Data.ResultList[0].Msg) - return nil, errors.New(response.Msg) + return nil, errors.New(response.Msg + ":" + response.LogId) } //if response.Data.ResultList[0].Store.StoreId == 0 { // return nil, errors.New(response.Msg + "," + response.SubMsg) @@ -104,7 +104,7 @@ func (a *API) EditStore(param *shop_editStore_request.ShopEditStoreParam) error return err } if response.Code != RequestSuccessCode { - return errors.New(response.SubMsg) + return errors.New(response.SubMsg + ":" + response.LogId) } return nil } @@ -118,7 +118,7 @@ func (a *API) StoreSuspend(param *shop_storeSuspend_request.ShopStoreSuspendPara return nil, err } if response.Code != RequestSuccessCode { - return nil, errors.New(response.SubMsg) + return nil, errors.New(response.SubMsg + ":" + response.LogId) } return response.Data, nil } @@ -131,7 +131,7 @@ func (a *API) StoreSuspend2(storeID int64) (*shop_storeSuspend_response.ShopStor return nil, err } if response.Code != RequestSuccessCode { - return nil, errors.New(response.SubMsg) + return nil, errors.New(response.SubMsg + ":" + response.LogId) } return response.Data, nil } @@ -145,7 +145,7 @@ func (a *API) UnsuspendStore(param *shop_unsuspendStore_request.ShopUnsuspendSto return nil, err } if response.Code != RequestSuccessCode { - return nil, errors.New(response.SubMsg) + return nil, errors.New(response.SubMsg + ":" + response.LogId) } return response.Data, nil } @@ -157,7 +157,7 @@ func (a *API) UnsuspendStore2(storeID int64) (*shop_unsuspendStore_response.Shop return nil, err } if response.Code != RequestSuccessCode { - return nil, errors.New(response.SubMsg) + return nil, errors.New(response.SubMsg + ":" + response.LogId) } return response.Data, nil } @@ -176,7 +176,7 @@ func (a *API) GetStoreList(param *shop_getStoreList_request.ShopGetStoreListPara return nil, err } if response.Code != RequestSuccessCode { - return nil, errors.New(response.SubMsg) + return nil, errors.New(response.SubMsg + ":" + response.LogId) } //测试用 resp := map[int64]string{} @@ -197,7 +197,7 @@ func (a *API) GetStoreList2(param *shop_getStoreList_request.ShopGetStoreListPar return nil, err } if response.Code != RequestSuccessCode { - return nil, errors.New(response.SubMsg) + return nil, errors.New(response.SubMsg + ":" + response.LogId) } return response, err @@ -212,7 +212,7 @@ func (a *API) CreateTradeLimitTemplate(param *trade_createTradeLimitTemplate_req return nil, err } if response.Code != RequestSuccessCode { - return nil, errors.New(response.SubMsg) + return nil, errors.New(response.SubMsg + ":" + response.LogId) } return response.Data, nil } @@ -226,7 +226,7 @@ func (a *API) UpdateTradeLimitTemplate(param *trade_UpdateTradeLimitTemplate_req return nil, err } if response.Code != RequestSuccessCode { - return nil, errors.New(response.SubMsg) + return nil, errors.New(response.SubMsg + ":" + response.LogId) } return response.Data, nil } @@ -240,7 +240,7 @@ func (a *API) BindStoreSaleLimit(param *shop_bindStoreSaleLimit_request.ShopBind return err } if response.Code != RequestSuccessCode { - return errors.New(response.SubMsg) + return errors.New(response.SubMsg + ":" + response.LogId) } return nil } @@ -254,7 +254,7 @@ func (a *API) StoreQuerySaleLimitTemp(storeId int64) (int64, error) { return 0, err } if result.Code != RequestSuccessCode { - return 0, errors.New(result.SubMsg) + return 0, errors.New(result.SubMsg + ":" + result.LogId) } if result.Data == nil || len(result.Data.StoreSaleLimits) == 0 { return 0, errors.New("未绑定限售模板,请先绑定") @@ -271,7 +271,7 @@ func (a *API) GetSaleLimitDetail(saleLimitId *[]int64) (*trade_batchGetTradeLimi return nil, err } if result.Code != RequestSuccessCode { - return nil, errors.New(result.SubMsg) + return nil, errors.New(result.SubMsg + ":" + result.LogId) } if result.Data == nil || len(result.Data.TradeLimitTemplateList) == 0 { return nil, errors.New("未查找到限售模板详情") diff --git a/platformapi/tiktok_shop/tiktok_api/transport.go b/platformapi/tiktok_shop/tiktok_api/transport.go index 0dcc549e..914268a2 100644 --- a/platformapi/tiktok_shop/tiktok_api/transport.go +++ b/platformapi/tiktok_shop/tiktok_api/transport.go @@ -30,7 +30,7 @@ func (a *API) GetDispatcherInfo(storeID int64, shopOrderID string, dispatcherFee return 0, err } if response.Code != RequestSuccessCode { - return 0, errors.New(response.SubMsg) + return 0, errors.New(response.SubMsg + ":" + response.LogId) } return response.Data.DispatcherFee, nil } @@ -48,7 +48,7 @@ func (a *API) ShopOrderDispatcher(storeID int64, shopOrderID string, dispatcherT return err } if response.Code != RequestSuccessCode { - return errors.New(response.SubMsg) + return errors.New(response.SubMsg + ":" + response.LogId) } return nil } @@ -62,7 +62,7 @@ func (a *API) SetStoreAutoCallRider(params *superm_setStoreAutoCallRider_request return err } if response.Code != RequestSuccessCode { - return errors.New(response.SubMsg) + return errors.New(response.SubMsg + ":" + response.LogId) } return nil } @@ -78,7 +78,7 @@ func (a *API) GetStoreAutoCallRiderInfo(storeID int64) (*superm_getStoreAutoCall return nil, err } if response.Code != RequestSuccessCode { - return nil, errors.New(response.SubMsg) + return nil, errors.New(response.SubMsg + ":" + response.LogId) } return response.Data.AutoCallInfo, nil } @@ -94,7 +94,7 @@ func (a *API) CreateVirtualMobile(shopOrderID int64) (*superm_createVirtualMobil return nil, err } if response.Code != RequestSuccessCode { - return nil, errors.New(response.SubMsg) + return nil, errors.New(response.SubMsg + ":" + response.LogId) } return response.Data, nil } @@ -111,7 +111,7 @@ func (a *API) GetPlatformPickUpEstimatedCharge(afterSaleID int64, inquiryType in return 0, err } if response.Code != RequestSuccessCode { - return 0, errors.New(response.SubMsg) + return 0, errors.New(response.SubMsg + ":" + response.LogId) } return response.Data.PlatformPickupEstimatedCharge, err } @@ -127,7 +127,7 @@ func (a *API) ApplyPlatformPickUp(afterSaleID int64) (string, error) { return "", err } if response.Code != RequestSuccessCode { - return "", errors.New(response.SubMsg) + return "", errors.New(response.SubMsg + ":" + response.LogId) } return response.Data.LogisticsID, err } @@ -161,7 +161,7 @@ func (a *API) GetShipmentInfo(shopOrderID, afterSaleID, shipmentType int64) (*su } if response.Code != RequestSuccessCode { - return nil, errors.New(response.SubMsg) + return nil, errors.New(response.SubMsg + ":" + response.LogId) } return response.Data.ShipmentInfo, err } @@ -177,7 +177,7 @@ func (a *API) CancelPlatformPickUp(afterSaleID int64) error { return err } if response.Code != RequestSuccessCode { - return errors.New(response.SubMsg) + return errors.New(response.SubMsg + ":" + response.LogId) } return err } From 98a74e5379491a57c319b064608643b284bed82e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E5=AE=97=E6=A5=A0?= Date: Sun, 23 Apr 2023 18:03:48 +0800 Subject: [PATCH 21/21] 1 --- platformapi/mtwmapi/callback.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformapi/mtwmapi/callback.go b/platformapi/mtwmapi/callback.go index dc3c4aad..f6a097ab 100644 --- a/platformapi/mtwmapi/callback.go +++ b/platformapi/mtwmapi/callback.go @@ -27,7 +27,7 @@ const ( MsgTypeUserUrgeOrder = "userUrgeOrder" MsgTypePrivateNumberDowngrade = "numberDowngrade" MsgTypeOrderModified = "orderModified" // 这个不是订单调整,是订单信息(地址、联系人等)变化后推送的消息 - MsgTypeOrderRefund = "orderRefund" // 订单退款 + MsgTypeOrderRefund = "orderRefund" // 订单退款(全额) MsgTypeOrderPartialRefund = "orderPartialRefund" // /订单部分退款 MsgTypeOrderFinishedPickup = "orderFinishedPickup"