From ee5234017797800117d9b80baec31d3c44273064 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 26 Jan 2024 16:01:12 +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/activity.go | 20 +++++++ csjplatform/api.go | 33 ++++++++++++ csjplatform/goods.go | 112 ++++++++++++++++++++++++++++++++++++++++ csjplatform/keyword.go | 29 +++++++++++ csjplatform/live.go | 48 +++++++++++++++++ csjplatform/order.go | 24 +++++++++ 6 files changed, 266 insertions(+) create mode 100644 csjplatform/activity.go create mode 100644 csjplatform/api.go create mode 100644 csjplatform/goods.go create mode 100644 csjplatform/keyword.go create mode 100644 csjplatform/live.go create mode 100644 csjplatform/order.go diff --git a/csjplatform/activity.go b/csjplatform/activity.go new file mode 100644 index 0000000..e1af1d0 --- /dev/null +++ b/csjplatform/activity.go @@ -0,0 +1,20 @@ +package csjplatform + +import ( + "fmt" +) + +func Activity(args map[string]string) (string, error) { + params := map[string]interface{}{ + "external_info": args["external_info"], + "material_id": args["material_id"], + } + if args["extra_params"] != "" { + params["extra_params"] = args["extra_params"] + } + + send, err := Send(args["app_id"], args["app_secret"], "aggregate/h5", params) + fmt.Println(send) + fmt.Println(err) + return send, err +} diff --git a/csjplatform/api.go b/csjplatform/api.go new file mode 100644 index 0000000..78c5711 --- /dev/null +++ b/csjplatform/api.go @@ -0,0 +1,33 @@ +package csjplatform + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/comm" + zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" + "crypto/md5" + "fmt" + "strings" + "time" +) + +func Send(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", "") + param := map[string]interface{}{ + "app_id": appkey, + "data": paramJson, + "timestamp": time.Now().Unix(), + "version": "1", + "req_id": zhios_third_party_utils.UUIDString(), + } + + sign := GetSign(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 { + 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/csjplatform/goods.go new file mode 100644 index 0000000..ce66780 --- /dev/null +++ b/csjplatform/goods.go @@ -0,0 +1,112 @@ +package csjplatform + +import ( + zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" + "fmt" + "strings" +) + +//商品类目 +func GoodsCate(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) + fmt.Println(send) + fmt.Println(err) + return send, err +} + +//3.2.1 商品列表接口 +func GoodsList(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"]), + } + if args["title"] != "" { + params["title"] = args["title"] + } + if args["first_cids"] != "" { + ex := strings.Split(args["first_cids"], ",") + ids := make([]int, 0) + for _, v := range ex { + ids = append(ids, zhios_third_party_utils.StrToInt(v)) + } + params["first_cids"] = ids + } + if args["price_min"] != "" { + params["price_min"] = int(zhios_third_party_utils.StrToFloat64(args["price_min"]) * 100) + } + if args["price_max"] != "" { + params["price_max"] = int(zhios_third_party_utils.StrToFloat64(args["price_max"]) * 100) + } + if args["sell_num_min"] != "" { + params["sell_num_min"] = zhios_third_party_utils.StrToInt(args["sell_num_min"]) + } + if args["sell_num_max"] != "" { + params["sell_num_max"] = zhios_third_party_utils.StrToInt(args["sell_num_max"]) + } + if args["search_type"] != "" { + params["search_type"] = zhios_third_party_utils.StrToInt(args["search_type"]) + } + if args["order_type"] != "" { + params["order_type"] = zhios_third_party_utils.StrToInt(args["order_type"]) + } + + if args["cos_fee_min"] != "" { + params["cos_fee_min"] = int(zhios_third_party_utils.StrToFloat64(args["cos_fee_min"]) * 100) + } + if args["cos_fee_max"] != "" { + params["cos_fee_max"] = int(zhios_third_party_utils.StrToFloat64(args["cos_fee_max"]) * 100) + } + if args["cos_ratio_min"] != "" { + params["cos_ratio_min"] = int(zhios_third_party_utils.StrToFloat64(args["cos_ratio_min"]) * 100) + } + if args["cos_ratio_max"] != "" { + params["cos_ratio_max"] = int(zhios_third_party_utils.StrToFloat64(args["cos_ratio_max"]) * 100) + } + 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) + fmt.Println(send) + fmt.Println(err) + return send, err +} + +//商品详情接口 +func GoodsDetail(args map[string]string) (string, error) { + + params := map[string]interface{}{} + if args["product_ids"] != "" { + ex := strings.Split(args["product_ids"], ",") + ids := make([]int, 0) + for _, v := range ex { + ids = append(ids, zhios_third_party_utils.StrToInt(v)) + } + params["product_ids"] = ids + } + send, err := Send(args["app_id"], args["app_secret"], "product/detail", params) + fmt.Println(send) + fmt.Println(err) + return send, err +} + +//3.2.2 商品转链接口 +func GoodsLink(args map[string]string) (string, error) { + params := map[string]interface{}{ + "product_url": args["product_url"], + "product_ext": args["product_ext"], + "external_info": args["external_info"], + } + if args["share_type"] != "" { + ex := strings.Split(args["share_type"], ",") + ids := make([]int, 0) + for _, v := range ex { + ids = append(ids, zhios_third_party_utils.StrToInt(v)) + } + params["share_type"] = ids + } + send, err := Send(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/csjplatform/keyword.go new file mode 100644 index 0000000..086f424 --- /dev/null +++ b/csjplatform/keyword.go @@ -0,0 +1,29 @@ +package csjplatform + +import ( + zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" + "fmt" + "strings" +) + +//抖口令解析+二次转链接口 +func Keyword(args map[string]string) (string, error) { + params := map[string]interface{}{ + "command": args["command"], + } + if args["external_info"] != "" { + params["external_info"] = args["external_info"] + } + if args["share_type"] != "" { + ex := strings.Split(args["share_type"], ",") + ids := make([]int, 0) + for _, v := range ex { + ids = append(ids, zhios_third_party_utils.StrToInt(v)) + } + params["share_type"] = ids + } + send, err := Send(args["app_id"], args["app_secret"], "command_parse", params) + fmt.Println(send) + fmt.Println(err) + return send, err +} diff --git a/csjplatform/live.go b/csjplatform/live.go new file mode 100644 index 0000000..4cbc8b8 --- /dev/null +++ b/csjplatform/live.go @@ -0,0 +1,48 @@ +package csjplatform + +import ( + zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" + "fmt" + "strings" +) + +func LiveRoom(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"]), + "sort_type": zhios_third_party_utils.StrToInt(args["sort_type"]), + "sort_by": zhios_third_party_utils.StrToInt(args["sort_by"]), + "status": zhios_third_party_utils.StrToInt(args["status"]), + } + if args["author_info"] != "" { + params["author_info"] = args["author_info"] + } + send, err := Send(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) { + params := map[string]interface{}{ + "author_buyin_id": args["author_buyin_id"], + "external_info": args["external_info"], + "live_ext": args["live_ext"], + "sort_by": zhios_third_party_utils.StrToInt(args["sort_by"]), + "status": zhios_third_party_utils.StrToInt(args["status"]), + } + if args["share_type"] != "" { + ex := strings.Split(args["share_type"], ",") + ids := make([]int, 0) + for _, v := range ex { + ids = append(ids, zhios_third_party_utils.StrToInt(v)) + } + params["share_type"] = ids + } + 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) + fmt.Println(send) + fmt.Println(err) + return send, err +} diff --git a/csjplatform/order.go b/csjplatform/order.go new file mode 100644 index 0000000..bec32a2 --- /dev/null +++ b/csjplatform/order.go @@ -0,0 +1,24 @@ +package csjplatform + +import ( + zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" + "fmt" + "strings" +) + +func OrderList(args map[string]string) (string, error) { + params := map[string]interface{}{ + "size": zhios_third_party_utils.StrToInt(args["size"]), + "cursor": args["cursor"], + "start_time": zhios_third_party_utils.StrToInt(args["start_time"]), + "end_time": zhios_third_party_utils.StrToInt(args["end_time"]), + "time_type": args["time_type"], + } + if args["order_ids"] != "" { + params["order_ids"] = strings.Split(args["order_ids"], ",") + } + send, err := Send(args["app_id"], args["app_secret"], "order/search", params) + fmt.Println(send) + fmt.Println(err) + return send, err +}