Browse Source

抖音穿山甲

master
huangjiajun 10 months ago
parent
commit
ab7390becd
6 changed files with 37 additions and 39 deletions
  1. +3
    -3
      tik_tok/activity.go
  2. +4
    -4
      tik_tok/csjp_api.go
  3. +15
    -16
      tik_tok/goods.go
  4. +5
    -6
      tik_tok/keyword.go
  5. +5
    -5
      tik_tok/live.go
  6. +5
    -5
      tik_tok/order.go

csjplatform/activity.go → tik_tok/activity.go View File

@@ -1,4 +1,4 @@
package csjplatform
package tik_tok


import ( import (
"fmt" "fmt"
@@ -6,7 +6,7 @@ import (
"github.com/tidwall/gjson" "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{}{ params := map[string]interface{}{
"external_info": args["external_info"], "external_info": args["external_info"],
"material_id": args["material_id"], "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"] 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{} var data = map[string]string{}
if err != nil { if err != nil {
fmt.Println("抖音信息=====", send) fmt.Println("抖音信息=====", send)

csjplatform/api.go → tik_tok/csjp_api.go View File

@@ -1,4 +1,4 @@
package csjplatform
package tik_tok


import ( import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/comm" "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/comm"
@@ -9,7 +9,7 @@ import (
"time" "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 url := "https://ecom.pangolin-sdk-toutiao.com/" + method
paramJson := comm.GetSortJson(params) paramJson := comm.GetSortJson(params)
paramJson = strings.ReplaceAll(paramJson, "\n", "") 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(), "req_id": zhios_third_party_utils.UUIDString(),
} }


sign := GetSign(appSecret, param)
sign := CsjpGetSign(appSecret, param)
param["sign"] = sign param["sign"] = sign
param["sign_type"] = "MD5" param["sign_type"] = "MD5"
data, err := zhios_third_party_utils.CurlPost(url, zhios_third_party_utils.SerializeStr(param), nil) data, err := zhios_third_party_utils.CurlPost(url, zhios_third_party_utils.SerializeStr(param), nil)
return string(data), err 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&timestamp=%v%s", m["app_id"], m["data"], m["req_id"], m["timestamp"], secureKey) 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))) return fmt.Sprintf("%x", md5.Sum([]byte(signStr)))
} }

csjplatform/goods.go → tik_tok/goods.go View File

@@ -1,7 +1,6 @@
package csjplatform
package tik_tok


import ( 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" zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"encoding/json" "encoding/json"
"fmt" "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"])} 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(send)
fmt.Println(err) fmt.Println(err)
return send, err return send, err
} }


//3.2.1 商品列表接口 //3.2.1 商品列表接口
func GoodsList(args map[string]string) []tik_tok.TikTokGoods {
func CsjpGoodsList(args map[string]string) []TikTokGoods {
params := map[string]interface{}{ params := map[string]interface{}{
"page": zhios_third_party_utils.StrToInt(args["page"]), "page": zhios_third_party_utils.StrToInt(args["page"]),
"page_size": zhios_third_party_utils.StrToInt(args["page_size"]), "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"] != "" { if args["activity_id"] != "" {
params["activity_id"] = zhios_third_party_utils.StrToInt(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) fmt.Println(send)
var goodsList = make([]tik_tok.TikTokGoods, 0)
var goodsList = make([]TikTokGoods, 0)
product := gjson.Get(send, "data.products").String() product := gjson.Get(send, "data.products").String()
if err != nil || product == "" { if err != nil || product == "" {
return goodsList return goodsList
} }
var lmData struct { var lmData struct {
Data struct { Data struct {
Products []tik_tok.TikTokGoodsLm `json:"products"`
Products []TikTokGoodsLm `json:"products"`
} `json:"data"` } `json:"data"`
} }
err = json.Unmarshal([]byte(send), &lmData) 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 { for _, v := range lmData.Data.Products {
v.CosRatio = v.CosRatio / 100 v.CosRatio = v.CosRatio / 100
tmp := tik_tok.CommGoodsDetail(v)
tmp := CommGoodsDetail(v)
goodsList = append(goodsList, tmp) goodsList = append(goodsList, tmp)
} }
return goodsList return goodsList
} }


//商品详情接口 //商品详情接口
func GoodsDetail(args map[string]string) tik_tok.TikTokGoods {
func CsjpGoodsDetail(args map[string]string) TikTokGoods {


params := map[string]interface{}{} params := map[string]interface{}{}
if args["product_ids"] != "" { if args["product_ids"] != "" {
@@ -107,15 +106,15 @@ func GoodsDetail(args map[string]string) tik_tok.TikTokGoods {
} }
params["product_ids"] = ids 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() product := gjson.Get(send, "data.products").String()
if err != nil || product == "" { if err != nil || product == "" {
return goodsList return goodsList
} }
var lmData struct { var lmData struct {
Data struct { Data struct {
Products []tik_tok.TikTokGoodsLm `json:"products"`
Products []TikTokGoodsLm `json:"products"`
} `json:"data"` } `json:"data"`
} }
err = json.Unmarshal([]byte(send), &lmData) 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 { for _, v := range lmData.Data.Products {
v.CosRatio = v.CosRatio / 100 v.CosRatio = v.CosRatio / 100
tmp := tik_tok.CommGoodsDetail(v)
tmp := CommGoodsDetail(v)
if tmp.GoodsID == args["product_ids"] { if tmp.GoodsID == args["product_ids"] {
return tmp return tmp
} }
@@ -134,7 +133,7 @@ func GoodsDetail(args map[string]string) tik_tok.TikTokGoods {
} }


//3.2.2 商品转链接口 //3.2.2 商品转链接口
func GoodsLink(args map[string]string) (string, error) {
func CsjpGoodsLink(args map[string]string) (string, error) {
params := map[string]interface{}{ params := map[string]interface{}{
"product_url": args["product_url"], "product_url": args["product_url"],
"product_ext": args["product_ext"], "product_ext": args["product_ext"],
@@ -148,7 +147,7 @@ func GoodsLink(args map[string]string) (string, error) {
} }
params["share_type"] = ids 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(send)
fmt.Println(err) fmt.Println(err)
return send, err return send, err

csjplatform/keyword.go → tik_tok/keyword.go View File

@@ -1,7 +1,6 @@
package csjplatform
package tik_tok


import ( 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" zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
"fmt" "fmt"
"github.com/tidwall/gjson" "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{}{ params := map[string]interface{}{
"command": args["command"], "command": args["command"],
} }
@@ -24,10 +23,10 @@ func Keyword(args map[string]string) tik_tok.TikTokGoods {
} }
params["share_type"] = ids 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(send)
fmt.Println(err) fmt.Println(err)
var goodsList = tik_tok.TikTokGoods{}
var goodsList = TikTokGoods{}
ActivityId := gjson.Get(send, "data.activity_info.material_id").Int() ActivityId := gjson.Get(send, "data.activity_info.material_id").Int()
if ActivityId > 0 { if ActivityId > 0 {
goodsList.ActivityId = zhios_third_party_utils.Int64ToStr(gjson.Get(send, "data.command_info.activity_info.material_id").Int()) 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 return goodsList
} }
args["product_ids"] = gjson.Get(product, "product_id").String() args["product_ids"] = gjson.Get(product, "product_id").String()
goodsList = GoodsDetail(args)
goodsList = CsjpGoodsDetail(args)
return goodsList return goodsList
} }

csjplatform/live.go → tik_tok/live.go View File

@@ -1,4 +1,4 @@
package csjplatform
package tik_tok


import ( import (
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
@@ -6,7 +6,7 @@ import (
"strings" "strings"
) )


func LiveRoom(args map[string]string) (string, error) {
func CsjpLiveRoom(args map[string]string) (string, error) {
params := map[string]interface{}{ params := map[string]interface{}{
"page": zhios_third_party_utils.StrToInt(args["page"]), "page": zhios_third_party_utils.StrToInt(args["page"]),
"page_size": zhios_third_party_utils.StrToInt(args["page_size"]), "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"] != "" { if args["author_info"] != "" {
params["author_info"] = 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(send)
fmt.Println(err) fmt.Println(err)
return send, err return send, err
} }
func LiveRoomLink(args map[string]string) (string, error) {
func CsjpLiveRoomLink(args map[string]string) (string, error) {
params := map[string]interface{}{ params := map[string]interface{}{
"author_buyin_id": args["author_buyin_id"], "author_buyin_id": args["author_buyin_id"],
"external_info": args["external_info"], "external_info": args["external_info"],
@@ -41,7 +41,7 @@ func LiveRoomLink(args map[string]string) (string, error) {
if args["product_id"] != "" { if args["product_id"] != "" {
params["product_id"] = zhios_third_party_utils.StrToInt(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(send)
fmt.Println(err) fmt.Println(err)
return send, err return send, err

csjplatform/order.go → tik_tok/order.go View File

@@ -1,4 +1,4 @@
package csjplatform
package tik_tok


import ( import (
zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
@@ -7,7 +7,7 @@ import (
"strings" "strings"
) )


func OrderList(args map[string]string) map[string]interface{} {
func CsjpOrderList(args map[string]string) map[string]interface{} {
params := map[string]interface{}{ params := map[string]interface{}{
"size": zhios_third_party_utils.StrToInt(args["size"]), "size": zhios_third_party_utils.StrToInt(args["size"]),
"cursor": args["cursor"], "cursor": args["cursor"],
@@ -19,7 +19,7 @@ func OrderList(args map[string]string) map[string]interface{} {
if args["order_ids"] != "" { if args["order_ids"] != "" {
params["order_ids"] = strings.Split(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{}{} var data = map[string]interface{}{}
if err != nil { if err != nil {
return data return data
@@ -40,7 +40,7 @@ func OrderList(args map[string]string) map[string]interface{} {
} }
for _, v := range tmpList { for _, v := range tmpList {


tmp := CommOrder(v, statusArr, "dk")
tmp := CsjpCommOrder(v, statusArr, "dk")
if tmp["oid"] == "" { if tmp["oid"] == "" {
continue continue
} }
@@ -49,7 +49,7 @@ func OrderList(args map[string]string) map[string]interface{} {
data["order"] = orderTmp data["order"] = orderTmp
return data 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) tmp := make(map[string]string)
goods := v.(map[string]interface{}) goods := v.(map[string]interface{})
methodType := "csjp" methodType := "csjp"

Loading…
Cancel
Save