From ab7390becddd34b4b85663edcaef11ebb07877f1 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 31 Jan 2024 09:48:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=96=E9=9F=B3=E7=A9=BF=E5=B1=B1=E7=94=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- {csjplatform => tik_tok}/activity.go | 6 ++--- csjplatform/api.go => tik_tok/csjp_api.go | 8 +++--- {csjplatform => tik_tok}/goods.go | 31 +++++++++++------------ {csjplatform => tik_tok}/keyword.go | 11 ++++---- {csjplatform => tik_tok}/live.go | 10 ++++---- {csjplatform => tik_tok}/order.go | 10 ++++---- 6 files changed, 37 insertions(+), 39 deletions(-) rename {csjplatform => tik_tok}/activity.go (81%) rename csjplatform/api.go => tik_tok/csjp_api.go (80%) rename {csjplatform => tik_tok}/goods.go (80%) rename {csjplatform => tik_tok}/keyword.go (77%) rename {csjplatform => tik_tok}/live.go (81%) rename {csjplatform => tik_tok}/order.go (92%) diff --git a/csjplatform/activity.go b/tik_tok/activity.go similarity index 81% rename from csjplatform/activity.go rename to tik_tok/activity.go index 4363a83..cfa9674 100644 --- a/csjplatform/activity.go +++ b/tik_tok/activity.go @@ -1,4 +1,4 @@ -package csjplatform +package tik_tok import ( "fmt" @@ -6,7 +6,7 @@ import ( "github.com/tidwall/gjson" ) -func Activity(args map[string]string) (map[string]string, string) { +func CsjpActivity(args map[string]string) (map[string]string, string) { params := map[string]interface{}{ "external_info": args["external_info"], "material_id": args["material_id"], @@ -15,7 +15,7 @@ func Activity(args map[string]string) (map[string]string, string) { params["extra_params"] = args["extra_params"] } - send, err := Send(args["app_id"], args["app_secret"], "aggregate/h5", params) + send, err := CsjpSend(args["app_id"], args["app_secret"], "aggregate/h5", params) var data = map[string]string{} if err != nil { fmt.Println("抖音信息=====", send) diff --git a/csjplatform/api.go b/tik_tok/csjp_api.go similarity index 80% rename from csjplatform/api.go rename to tik_tok/csjp_api.go index 78c5711..3d0beba 100644 --- a/csjplatform/api.go +++ b/tik_tok/csjp_api.go @@ -1,4 +1,4 @@ -package csjplatform +package tik_tok import ( "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/comm" @@ -9,7 +9,7 @@ import ( "time" ) -func Send(appkey, appSecret, method string, params map[string]interface{}) (string, error) { +func CsjpSend(appkey, appSecret, method string, params map[string]interface{}) (string, error) { url := "https://ecom.pangolin-sdk-toutiao.com/" + method paramJson := comm.GetSortJson(params) paramJson = strings.ReplaceAll(paramJson, "\n", "") @@ -21,13 +21,13 @@ func Send(appkey, appSecret, method string, params map[string]interface{}) (stri "req_id": zhios_third_party_utils.UUIDString(), } - sign := GetSign(appSecret, param) + sign := CsjpGetSign(appSecret, param) param["sign"] = sign param["sign_type"] = "MD5" data, err := zhios_third_party_utils.CurlPost(url, zhios_third_party_utils.SerializeStr(param), nil) return string(data), err } -func GetSign(secureKey string, m map[string]interface{}) string { +func CsjpGetSign(secureKey string, m map[string]interface{}) string { var signStr = fmt.Sprintf("app_id=%v&data=%v&req_id=%v×tamp=%v%s", m["app_id"], m["data"], m["req_id"], m["timestamp"], secureKey) return fmt.Sprintf("%x", md5.Sum([]byte(signStr))) } diff --git a/csjplatform/goods.go b/tik_tok/goods.go similarity index 80% rename from csjplatform/goods.go rename to tik_tok/goods.go index c305667..00aff13 100644 --- a/csjplatform/goods.go +++ b/tik_tok/goods.go @@ -1,7 +1,6 @@ -package csjplatform +package tik_tok import ( - "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/tik_tok" zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" "encoding/json" "fmt" @@ -10,16 +9,16 @@ import ( ) //商品类目 -func GoodsCate(args map[string]string) (string, error) { +func CsjpGoodsCate(args map[string]string) (string, error) { params := map[string]interface{}{"parent_id": zhios_third_party_utils.StrToInt(args["parent_id"])} - send, err := Send(args["app_id"], args["app_secret"], "product/category", params) + send, err := CsjpSend(args["app_id"], args["app_secret"], "product/category", params) fmt.Println(send) fmt.Println(err) return send, err } //3.2.1 商品列表接口 -func GoodsList(args map[string]string) []tik_tok.TikTokGoods { +func CsjpGoodsList(args map[string]string) []TikTokGoods { params := map[string]interface{}{ "page": zhios_third_party_utils.StrToInt(args["page"]), "page_size": zhios_third_party_utils.StrToInt(args["page_size"]), @@ -69,16 +68,16 @@ func GoodsList(args map[string]string) []tik_tok.TikTokGoods { if args["activity_id"] != "" { params["activity_id"] = zhios_third_party_utils.StrToInt(args["activity_id"]) } - send, err := Send(args["app_id"], args["app_secret"], "product/search", params) + send, err := CsjpSend(args["app_id"], args["app_secret"], "product/search", params) fmt.Println(send) - var goodsList = make([]tik_tok.TikTokGoods, 0) + var goodsList = make([]TikTokGoods, 0) product := gjson.Get(send, "data.products").String() if err != nil || product == "" { return goodsList } var lmData struct { Data struct { - Products []tik_tok.TikTokGoodsLm `json:"products"` + Products []TikTokGoodsLm `json:"products"` } `json:"data"` } err = json.Unmarshal([]byte(send), &lmData) @@ -89,14 +88,14 @@ func GoodsList(args map[string]string) []tik_tok.TikTokGoods { } for _, v := range lmData.Data.Products { v.CosRatio = v.CosRatio / 100 - tmp := tik_tok.CommGoodsDetail(v) + tmp := CommGoodsDetail(v) goodsList = append(goodsList, tmp) } return goodsList } //商品详情接口 -func GoodsDetail(args map[string]string) tik_tok.TikTokGoods { +func CsjpGoodsDetail(args map[string]string) TikTokGoods { params := map[string]interface{}{} if args["product_ids"] != "" { @@ -107,15 +106,15 @@ func GoodsDetail(args map[string]string) tik_tok.TikTokGoods { } params["product_ids"] = ids } - send, err := Send(args["app_id"], args["app_secret"], "product/detail", params) - var goodsList = tik_tok.TikTokGoods{} + send, err := CsjpSend(args["app_id"], args["app_secret"], "product/detail", params) + var goodsList = TikTokGoods{} product := gjson.Get(send, "data.products").String() if err != nil || product == "" { return goodsList } var lmData struct { Data struct { - Products []tik_tok.TikTokGoodsLm `json:"products"` + Products []TikTokGoodsLm `json:"products"` } `json:"data"` } err = json.Unmarshal([]byte(send), &lmData) @@ -124,7 +123,7 @@ func GoodsDetail(args map[string]string) tik_tok.TikTokGoods { } for _, v := range lmData.Data.Products { v.CosRatio = v.CosRatio / 100 - tmp := tik_tok.CommGoodsDetail(v) + tmp := CommGoodsDetail(v) if tmp.GoodsID == args["product_ids"] { return tmp } @@ -134,7 +133,7 @@ func GoodsDetail(args map[string]string) tik_tok.TikTokGoods { } //3.2.2 商品转链接口 -func GoodsLink(args map[string]string) (string, error) { +func CsjpGoodsLink(args map[string]string) (string, error) { params := map[string]interface{}{ "product_url": args["product_url"], "product_ext": args["product_ext"], @@ -148,7 +147,7 @@ func GoodsLink(args map[string]string) (string, error) { } params["share_type"] = ids } - send, err := Send(args["app_id"], args["app_secret"], "product/link", params) + send, err := CsjpSend(args["app_id"], args["app_secret"], "product/link", params) fmt.Println(send) fmt.Println(err) return send, err diff --git a/csjplatform/keyword.go b/tik_tok/keyword.go similarity index 77% rename from csjplatform/keyword.go rename to tik_tok/keyword.go index 764a39d..8e70066 100644 --- a/csjplatform/keyword.go +++ b/tik_tok/keyword.go @@ -1,7 +1,6 @@ -package csjplatform +package tik_tok import ( - "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/tik_tok" zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" "fmt" "github.com/tidwall/gjson" @@ -9,7 +8,7 @@ import ( ) //抖口令解析+二次转链接口 -func Keyword(args map[string]string) tik_tok.TikTokGoods { +func CsjpKeyword(args map[string]string) TikTokGoods { params := map[string]interface{}{ "command": args["command"], } @@ -24,10 +23,10 @@ func Keyword(args map[string]string) tik_tok.TikTokGoods { } params["share_type"] = ids } - send, err := Send(args["app_id"], args["app_secret"], "command_parse", params) + send, err := CsjpSend(args["app_id"], args["app_secret"], "command_parse", params) fmt.Println(send) fmt.Println(err) - var goodsList = tik_tok.TikTokGoods{} + var goodsList = TikTokGoods{} ActivityId := gjson.Get(send, "data.activity_info.material_id").Int() if ActivityId > 0 { goodsList.ActivityId = zhios_third_party_utils.Int64ToStr(gjson.Get(send, "data.command_info.activity_info.material_id").Int()) @@ -38,6 +37,6 @@ func Keyword(args map[string]string) tik_tok.TikTokGoods { return goodsList } args["product_ids"] = gjson.Get(product, "product_id").String() - goodsList = GoodsDetail(args) + goodsList = CsjpGoodsDetail(args) return goodsList } diff --git a/csjplatform/live.go b/tik_tok/live.go similarity index 81% rename from csjplatform/live.go rename to tik_tok/live.go index 4cbc8b8..6bc1a0a 100644 --- a/csjplatform/live.go +++ b/tik_tok/live.go @@ -1,4 +1,4 @@ -package csjplatform +package tik_tok import ( zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" @@ -6,7 +6,7 @@ import ( "strings" ) -func LiveRoom(args map[string]string) (string, error) { +func CsjpLiveRoom(args map[string]string) (string, error) { params := map[string]interface{}{ "page": zhios_third_party_utils.StrToInt(args["page"]), "page_size": zhios_third_party_utils.StrToInt(args["page_size"]), @@ -17,12 +17,12 @@ func LiveRoom(args map[string]string) (string, error) { if args["author_info"] != "" { params["author_info"] = args["author_info"] } - send, err := Send(args["app_id"], args["app_secret"], "live/search", params) + send, err := CsjpSend(args["app_id"], args["app_secret"], "live/search", params) fmt.Println(send) fmt.Println(err) return send, err } -func LiveRoomLink(args map[string]string) (string, error) { +func CsjpLiveRoomLink(args map[string]string) (string, error) { params := map[string]interface{}{ "author_buyin_id": args["author_buyin_id"], "external_info": args["external_info"], @@ -41,7 +41,7 @@ func LiveRoomLink(args map[string]string) (string, error) { if args["product_id"] != "" { params["product_id"] = zhios_third_party_utils.StrToInt(args["product_id"]) } - send, err := Send(args["app_id"], args["app_secret"], "live/link", params) + send, err := CsjpSend(args["app_id"], args["app_secret"], "live/link", params) fmt.Println(send) fmt.Println(err) return send, err diff --git a/csjplatform/order.go b/tik_tok/order.go similarity index 92% rename from csjplatform/order.go rename to tik_tok/order.go index 40b37dc..462becc 100644 --- a/csjplatform/order.go +++ b/tik_tok/order.go @@ -1,4 +1,4 @@ -package csjplatform +package tik_tok import ( zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" @@ -7,7 +7,7 @@ import ( "strings" ) -func OrderList(args map[string]string) map[string]interface{} { +func CsjpOrderList(args map[string]string) map[string]interface{} { params := map[string]interface{}{ "size": zhios_third_party_utils.StrToInt(args["size"]), "cursor": args["cursor"], @@ -19,7 +19,7 @@ func OrderList(args map[string]string) map[string]interface{} { if args["order_ids"] != "" { params["order_ids"] = strings.Split(args["order_ids"], ",") } - send, err := Send(args["app_id"], args["app_secret"], "order/search", params) + send, err := CsjpSend(args["app_id"], args["app_secret"], "order/search", params) var data = map[string]interface{}{} if err != nil { return data @@ -40,7 +40,7 @@ func OrderList(args map[string]string) map[string]interface{} { } for _, v := range tmpList { - tmp := CommOrder(v, statusArr, "dk") + tmp := CsjpCommOrder(v, statusArr, "dk") if tmp["oid"] == "" { continue } @@ -49,7 +49,7 @@ func OrderList(args map[string]string) map[string]interface{} { data["order"] = orderTmp return data } -func CommOrder(v interface{}, statusArr map[string]string, types string) map[string]string { +func CsjpCommOrder(v interface{}, statusArr map[string]string, types string) map[string]string { tmp := make(map[string]string) goods := v.(map[string]interface{}) methodType := "csjp"