From 546a5696eb711e20f007555beba4eae36f256f5c Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Thu, 9 May 2024 09:16:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=AC=E4=B8=9C=E8=81=94=E7=9B=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jd_union/api.go | 40 ++++++++++++++++++++++++++++++++++++++++ jd_union/goods.go | 12 ++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 jd_union/api.go create mode 100644 jd_union/goods.go diff --git a/jd_union/api.go b/jd_union/api.go new file mode 100644 index 0000000..5a7cde3 --- /dev/null +++ b/jd_union/api.go @@ -0,0 +1,40 @@ +package jd_union + +import ( + zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" + "github.com/syyongx/php2go" + "sort" + "strings" + "time" +) + +func Send(keyArr map[string]string, method, paramJson, version string) (string, error) { + args := map[string]interface{}{ + "method": method, + "app_key": keyArr["app_key"], + "access_token": keyArr["access_token"], + "timestamp": time.Now().Format("2006-01-02 15:04:05"), + "format": "json", + "v": version, + "param_json": paramJson, + "sign_method": "md5", + } + // 获取Key + var keys []string + for k := range args { + keys = append(keys, k) + } + // 排序asc + sort.Strings(keys) + str := "" + for _, v := range keys { + if args[v] == "" { + continue + } + str += v + zhios_third_party_utils.AnyToString(args[v]) + } + args["sign"] = strings.ToUpper(php2go.Md5(keyArr["app_secret"] + str + keyArr["app_secret"])) + url := "https://router.jd.com/api" + post, err := zhios_third_party_utils.CurlPost(url, args, nil) + return string(post), err +} diff --git a/jd_union/goods.go b/jd_union/goods.go new file mode 100644 index 0000000..a7b08ed --- /dev/null +++ b/jd_union/goods.go @@ -0,0 +1,12 @@ +package jd_union + +import zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" + +func SearchGoods(keyArr map[string]string, goodsReq map[string]interface{}) (string, error) { + param := map[string]interface{}{ + "goodsReqDTO": goodsReq, + } + paramJson := zhios_third_party_utils.SerializeStr(param) + send, err := Send(keyArr, "", paramJson, "1.0") + return send, err +}