Quellcode durchsuchen

团长商品

master
huangjiajun vor 6 Monaten
Ursprung
Commit
30fa7d0b66
2 geänderte Dateien mit 84 neuen und 0 gelöschten Zeilen
  1. +20
    -0
      third_tikTok_team_goods/md_novajo.go
  2. +64
    -0
      third_tikTok_team_goods/novajo.go

+ 20
- 0
third_tikTok_team_goods/md_novajo.go Datei anzeigen

@@ -0,0 +1,20 @@
package third_tikTok_team_goods

type NovajoGoods struct {
ProductId string `json:"productId"`
Name string `json:"name"`
Image string `json:"image"`
Link string `json:"link"`
ShopId int `json:"shopId"`
ShopName string `json:"shopName"`
Price int `json:"price"`
Discount int `json:"discount"`
StartTime int64 `json:"startTime"`
EndTime int64 `json:"endTime"`
CategoryId int `json:"categoryId"`
Sales int `json:"sales"`
CommonRatio float64 `json:"commonRatio"`
Service float64 `json:"service"`
CosRatio float64 `json:"cosRatio"`
CosFee int `json:"cosFee"`
}

+ 64
- 0
third_tikTok_team_goods/novajo.go Datei anzeigen

@@ -0,0 +1,64 @@
package third_tikTok_team_goods

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"
"encoding/json"
"fmt"
"github.com/syyongx/php2go"
"github.com/tidwall/gjson"
"strings"
"time"
)

func GetGoods(id, secret string, param map[string]interface{}) []NovajoGoods {
send, _ := Send("/kol/", id, secret, param)
data := gjson.Get(send, "response.list").String()
var list = make([]NovajoGoods, 0)
if gjson.Get(send, "status").Int() != 0 {
return list
}
json.Unmarshal([]byte(data), &list)
return list
}
func GetGoodsDetail(id, secret string, param map[string]interface{}) *NovajoGoods {
send, _ := Send("/kol/detail", id, secret, param)
data := gjson.Get(send, "response").String()
if gjson.Get(send, "status").Int() != 0 {
return nil
}
var list NovajoGoods
json.Unmarshal([]byte(data), &list)
return &list
}

//https://dyb.novajo.cn/open/kol-api
func Send(method string, id, secret string, param map[string]interface{}) (string, error) {
url := "https://api.novajo.cn/api" + method
now := time.Now().Unix() * 1000
keys := comm.KsortToStrInterface(param)
str := id
for _, k := range keys {
str += k + "=" + zhios_third_party_utils.AnyToString(param[k])
}
str += zhios_third_party_utils.Int64ToStr(now)
sign := php2go.Md5(secret + str + secret)
fmt.Println(secret + str + secret)
fmt.Println(sign)
params := param
params["id"] = id
params["time"] = now
params["sign"] = sign
for k, v := range params {
if strings.Contains(url, "?") == false {
url += "?" + k + "=" + zhios_third_party_utils.AnyToString(v)
} else {
url += "&" + k + "=" + zhios_third_party_utils.AnyToString(v)
}
}
fmt.Println(url)
json, err := zhios_third_party_utils.CurlGet(url, nil)
fmt.Println(string(json))
fmt.Println(err)
return string(json), err
}

Laden…
Abbrechen
Speichern