diff --git a/third_tikTok_team_goods/md_novajo.go b/third_tikTok_team_goods/md_novajo.go new file mode 100644 index 0000000..27c3630 --- /dev/null +++ b/third_tikTok_team_goods/md_novajo.go @@ -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"` +} diff --git a/third_tikTok_team_goods/novajo.go b/third_tikTok_team_goods/novajo.go new file mode 100644 index 0000000..2b561bc --- /dev/null +++ b/third_tikTok_team_goods/novajo.go @@ -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 +}