Parcourir la source

抖音穿山甲

master
huangjiajun il y a 9 mois
Parent
révision
ee52340177
6 fichiers modifiés avec 266 ajouts et 0 suppressions
  1. +20
    -0
      csjplatform/activity.go
  2. +33
    -0
      csjplatform/api.go
  3. +112
    -0
      csjplatform/goods.go
  4. +29
    -0
      csjplatform/keyword.go
  5. +48
    -0
      csjplatform/live.go
  6. +24
    -0
      csjplatform/order.go

+ 20
- 0
csjplatform/activity.go Voir le fichier

@@ -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
}

+ 33
- 0
csjplatform/api.go Voir le fichier

@@ -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&timestamp=%v%s", m["app_id"], m["data"], m["req_id"], m["timestamp"], secureKey)
return fmt.Sprintf("%x", md5.Sum([]byte(signStr)))
}

+ 112
- 0
csjplatform/goods.go Voir le fichier

@@ -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
}

+ 29
- 0
csjplatform/keyword.go Voir le fichier

@@ -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
}

+ 48
- 0
csjplatform/live.go Voir le fichier

@@ -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
}

+ 24
- 0
csjplatform/order.go Voir le fichier

@@ -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
}

Chargement…
Annuler
Enregistrer