@@ -1,21 +1,52 @@ | |||||
package tik_tok | package tik_tok | ||||
type TikTokGoods struct { | type TikTokGoods struct { | ||||
Commission string `json:"commission"` | |||||
CostPrice string `json:"cost_price"` | |||||
DetailURL string `json:"detail_url"` | |||||
GoodsID string `json:"goods_id"` | |||||
GoodsImg string `json:"goods_img"` | |||||
GoodsSales string `json:"goods_sales"` | |||||
GoodsTitle string `json:"goods_title"` | |||||
Imgs []interface{} `json:"imgs"` | |||||
InStock string `json:"in_stock"` | |||||
Price string `json:"price"` | |||||
Sharable string `json:"sharable"` | |||||
ShopID string `json:"shop_id"` | |||||
ShopName string `json:"shop_name"` | |||||
ShopTotalScore string `json:"shop_total_score"` | |||||
YhqPrice string `json:"yhq_price"` | |||||
Commission string `json:"commission"` | |||||
CostPrice string `json:"cost_price"` | |||||
DetailURL string `json:"detail_url"` | |||||
GoodsID string `json:"goods_id"` | |||||
GoodsImg string `json:"goods_img"` | |||||
GoodsSales string `json:"goods_sales"` | |||||
GoodsTitle string `json:"goods_title"` | |||||
Imgs []string `json:"imgs"` | |||||
InStock string `json:"in_stock"` | |||||
Price string `json:"price"` | |||||
Sharable string `json:"sharable"` | |||||
ShopID string `json:"shop_id"` | |||||
ShopName string `json:"shop_name"` | |||||
ShopTotalScore string `json:"shop_total_score"` | |||||
YhqPrice string `json:"yhq_price"` | |||||
} | |||||
type TikTokGoodsLm struct { | |||||
CosFee int64 `json:"cos_fee"` | |||||
CosRatio float64 `json:"cos_ratio"` | |||||
CouponPrice int64 `json:"coupon_price"` | |||||
Cover string `json:"cover"` | |||||
DetailURL string `json:"detail_url"` | |||||
FirstCid int64 `json:"first_cid"` | |||||
InStock interface{} `json:"in_stock"` | |||||
Price int64 `json:"price"` | |||||
ProductID int64 `json:"product_id"` | |||||
Sales int64 `json:"sales"` | |||||
SecondCid int64 `json:"second_cid"` | |||||
Sharable interface{} `json:"sharable"` | |||||
ShopID int64 `json:"shop_id"` | |||||
ShopName string `json:"shop_name"` | |||||
ThirdCid int64 `json:"third_cid"` | |||||
Title string `json:"title"` | |||||
Imgs []string `json:"imgs"` | |||||
ShopTotalScore ShopTotalScore `json:"shop_total_score"` | |||||
} | |||||
type ShopTotalScoreData struct { | |||||
Level string `json:"level"` | |||||
Score string `json:"score"` | |||||
Text string `json:"text"` | |||||
} | |||||
type ShopTotalScore struct { | |||||
LogisticsScore ShopTotalScoreData `json:"logistics_score"` | |||||
ProductScore ShopTotalScoreData `json:"product_score"` | |||||
ServiceScore ShopTotalScoreData `json:"service_score"` | |||||
} | } | ||||
type TikTokLive struct { | type TikTokLive struct { | ||||
LiveId string `json:"live_id"` | LiveId string `json:"live_id"` | ||||
@@ -8,13 +8,7 @@ import ( | |||||
//创建推广位 | //创建推广位 | ||||
func GoodsCreatePid(args map[string]string) map[string]string { | func GoodsCreatePid(args map[string]string) map[string]string { | ||||
//args = map[string]string{ | |||||
// "appkey": "7076371480799348261", | |||||
// "appSecret": "9e58409e-5729-441e-a9f3-c077ec939fbb", | |||||
// "acctoken": "52f7ea67-5267-4874-9e05-a837dd1d6a48", | |||||
// "media_name": "测试", | |||||
// "site_name": "测试", | |||||
//} | |||||
params := map[string]interface{}{"media_type": "4", "media_name": args["media_name"], "site_name": args["site_name"]} | params := map[string]interface{}{"media_type": "4", "media_name": args["media_name"], "site_name": args["site_name"]} | ||||
send, err := Send(args["appkey"], args["appSecret"], "buyin.kolPidCreate", params, args["acctoken"]) | send, err := Send(args["appkey"], args["appSecret"], "buyin.kolPidCreate", params, args["acctoken"]) | ||||
fmt.Println(send) | fmt.Println(send) | ||||
@@ -26,14 +20,7 @@ func GoodsCreatePid(args map[string]string) map[string]string { | |||||
return data | return data | ||||
} | } | ||||
func GoodsConvertUrl(args map[string]string) map[string]string { | func GoodsConvertUrl(args map[string]string) map[string]string { | ||||
//args = map[string]string{ | |||||
// "appkey": "7076371480799348261", | |||||
// "appSecret": "9e58409e-5729-441e-a9f3-c077ec939fbb", | |||||
// "acctoken": "52f7ea67-5267-4874-9e05-a837dd1d6a48", | |||||
// "external_info": "123", | |||||
// "pid": "dy_107018934375430799627_13603_920074249", | |||||
// "product_url": "https://haohuo.jinritemai.com/views/product/item2?id=3378039360158085752", | |||||
//} | |||||
params := map[string]interface{}{"pid": args["pid"], "external_info": args["external_info"], "product_url": args["product_url"]} | params := map[string]interface{}{"pid": args["pid"], "external_info": args["external_info"], "product_url": args["product_url"]} | ||||
send, err := Send(args["appkey"], args["appSecret"], "buyin.kolProductShare", params, args["acctoken"]) | send, err := Send(args["appkey"], args["appSecret"], "buyin.kolProductShare", params, args["acctoken"]) | ||||
fmt.Println(send) | fmt.Println(send) | ||||
@@ -48,13 +35,7 @@ func GoodsConvertUrl(args map[string]string) map[string]string { | |||||
return data | return data | ||||
} | } | ||||
func LiveCreatePid(args map[string]string) map[string]string { | func LiveCreatePid(args map[string]string) map[string]string { | ||||
//args = map[string]string{ | |||||
// "appkey": "7076371480799348261", | |||||
// "appSecret": "9e58409e-5729-441e-a9f3-c077ec939fbb", | |||||
// "acctoken": "52f7ea67-5267-4874-9e05-a837dd1d6a48", | |||||
// "media_name": "测试", | |||||
// "site_name": "测试", | |||||
//} | |||||
params := map[string]interface{}{"media_type": "4", "media_name": args["media_name"], "site_name": args["site_name"]} | params := map[string]interface{}{"media_type": "4", "media_name": args["media_name"], "site_name": args["site_name"]} | ||||
send, err := Send(args["appkey"], args["appSecret"], "buyin.institutePidCreate", params, args["acctoken"]) | send, err := Send(args["appkey"], args["appSecret"], "buyin.institutePidCreate", params, args["acctoken"]) | ||||
fmt.Println(send) | fmt.Println(send) | ||||
@@ -66,14 +47,7 @@ func LiveCreatePid(args map[string]string) map[string]string { | |||||
return data | return data | ||||
} | } | ||||
func LiveConvertUrl(args map[string]string) map[string]string { | func LiveConvertUrl(args map[string]string) map[string]string { | ||||
//args = map[string]string{ | |||||
// "appkey": "7076371480799348261", | |||||
// "appSecret": "9e58409e-5729-441e-a9f3-c077ec939fbb", | |||||
// "acctoken": "52f7ea67-5267-4874-9e05-a837dd1d6a48", | |||||
// "external_info": "123", | |||||
// "pid": "dy_107018934375430799627_13603_920074249", | |||||
// "product_url": "https://haohuo.jinritemai.com/views/product/item2?id=3378039360158085752", | |||||
//} | |||||
params := map[string]interface{}{"pid_info": map[string]interface{}{"pid": args["pid"], "external_info": args["external_info"]}, "open_id": args["open_id"]} | params := map[string]interface{}{"pid_info": map[string]interface{}{"pid": args["pid"], "external_info": args["external_info"]}, "open_id": args["open_id"]} | ||||
send, err := Send(args["appkey"], args["appSecret"], "buyin.instituteLiveShare", params, args["acctoken"]) | send, err := Send(args["appkey"], args["appSecret"], "buyin.instituteLiveShare", params, args["acctoken"]) | ||||
fmt.Println(send) | fmt.Println(send) | ||||
@@ -32,10 +32,10 @@ func GoodsList(args map[string]string) []TikTokGoods { | |||||
params["first_cids"] = []string{args["first_cids"]} | params["first_cids"] = []string{args["first_cids"]} | ||||
} | } | ||||
if args["price_min"] != "" { | if args["price_min"] != "" { | ||||
params["price_min"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(args["price_min"]) * 100) | |||||
params["price_min"] = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(args["price_min"]) * 100)) | |||||
} | } | ||||
if args["price_max"] != "" { | if args["price_max"] != "" { | ||||
params["price_max"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(args["price_max"]) * 100) | |||||
params["price_max"] = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(args["price_max"]) * 100)) | |||||
} | } | ||||
if args["sell_num_min"] != "" { | if args["sell_num_min"] != "" { | ||||
params["sell_num_min"] = args["sell_num_min"] | params["sell_num_min"] = args["sell_num_min"] | ||||
@@ -44,16 +44,16 @@ func GoodsList(args map[string]string) []TikTokGoods { | |||||
params["sell_num_max"] = args["sell_num_max"] | params["sell_num_max"] = args["sell_num_max"] | ||||
} | } | ||||
if args["cos_fee_min"] != "" { | if args["cos_fee_min"] != "" { | ||||
params["cos_fee_min"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(args["cos_fee_min"]) * 100) | |||||
params["cos_fee_min"] = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(args["cos_fee_min"]) * 100)) | |||||
} | } | ||||
if args["cos_fee_max"] != "" { | if args["cos_fee_max"] != "" { | ||||
params["cos_fee_max"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(args["cos_fee_max"]) * 100) | |||||
params["cos_fee_max"] = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(args["cos_fee_max"]) * 100)) | |||||
} | } | ||||
if args["cos_ratio_min"] != "" { | if args["cos_ratio_min"] != "" { | ||||
params["cos_ratio_min"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(args["cos_ratio_min"]) * 100) | |||||
params["cos_ratio_min"] = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(args["cos_ratio_min"]) * 100)) | |||||
} | } | ||||
if args["cos_ratio_max"] != "" { | if args["cos_ratio_max"] != "" { | ||||
params["cos_ratio_max"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(args["cos_ratio_max"]) * 100) | |||||
params["cos_ratio_max"] = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(args["cos_ratio_max"]) * 100)) | |||||
} | } | ||||
send, err := Send(args["appkey"], args["appSecret"], "alliance.materialsProductsSearch", params, args["acctoken"]) | send, err := Send(args["appkey"], args["appSecret"], "alliance.materialsProductsSearch", params, args["acctoken"]) | ||||
var goodsList = make([]TikTokGoods, 0) | var goodsList = make([]TikTokGoods, 0) | ||||
@@ -61,14 +61,17 @@ func GoodsList(args map[string]string) []TikTokGoods { | |||||
if err != nil || product == "" { | if err != nil || product == "" { | ||||
return goodsList | return goodsList | ||||
} | } | ||||
var tmpList = make([]interface{}, 0) | |||||
err = json.Unmarshal([]byte(product), &tmpList) | |||||
var lmData struct { | |||||
Data struct { | |||||
Products []TikTokGoodsLm `json:"products"` | |||||
} `json:"data"` | |||||
} | |||||
err = json.Unmarshal([]byte(send), &lmData) | |||||
if err != nil { | if err != nil { | ||||
return goodsList | return goodsList | ||||
} | } | ||||
for _, v := range tmpList { | |||||
goods := v.(map[string]interface{}) | |||||
tmp := CommGoodsDetail(goods) | |||||
for _, v := range lmData.Data.Products { | |||||
tmp := CommGoodsDetail(v) | |||||
goodsList = append(goodsList, tmp) | goodsList = append(goodsList, tmp) | ||||
} | } | ||||
return goodsList | return goodsList | ||||
@@ -83,14 +86,17 @@ func GetDetail(args map[string]string) TikTokGoods { | |||||
if err != nil || product == "" { | if err != nil || product == "" { | ||||
return goodsList | return goodsList | ||||
} | } | ||||
var tmpList = make([]interface{}, 0) | |||||
err = json.Unmarshal([]byte(product), &tmpList) | |||||
var lmData struct { | |||||
Data struct { | |||||
Products []TikTokGoodsLm `json:"products"` | |||||
} `json:"data"` | |||||
} | |||||
err = json.Unmarshal([]byte(send), &lmData) | |||||
if err != nil { | if err != nil { | ||||
return goodsList | return goodsList | ||||
} | } | ||||
for _, v := range tmpList { | |||||
goods := v.(map[string]interface{}) | |||||
tmp := CommGoodsDetail(goods) | |||||
for _, v := range lmData.Data.Products { | |||||
tmp := CommGoodsDetail(v) | |||||
if tmp.GoodsID == args["id"] { | if tmp.GoodsID == args["id"] { | ||||
return tmp | return tmp | ||||
} | } | ||||
@@ -98,7 +104,8 @@ func GetDetail(args map[string]string) TikTokGoods { | |||||
return goodsList | return goodsList | ||||
} | } | ||||
func GetKlGoods(args map[string]string) TikTokGoods { | func GetKlGoods(args map[string]string) TikTokGoods { | ||||
params := map[string]interface{}{"command": php2go.Base64Encode(args["content"])} | |||||
content, _ := php2go.Base64Decode(args["content"]) | |||||
params := map[string]interface{}{"command": content} | |||||
send, err := Send(args["appkey"], args["appSecret"], "buyin.shareCommandParse", params, args["acctoken"]) | send, err := Send(args["appkey"], args["appSecret"], "buyin.shareCommandParse", params, args["acctoken"]) | ||||
var goodsList = TikTokGoods{} | var goodsList = TikTokGoods{} | ||||
product := gjson.Get(send, "data.product_info").String() | product := gjson.Get(send, "data.product_info").String() | ||||
@@ -109,33 +116,29 @@ func GetKlGoods(args map[string]string) TikTokGoods { | |||||
goodsList = GetDetail(args) | goodsList = GetDetail(args) | ||||
return goodsList | return goodsList | ||||
} | } | ||||
func CommGoodsDetail(goods map[string]interface{}) TikTokGoods { | |||||
img := make([]interface{}, 0) | |||||
imgs, ok := goods["imgs"].([]interface{}) | |||||
if ok { | |||||
img = imgs | |||||
} | |||||
func CommGoodsDetail(goods TikTokGoodsLm) TikTokGoods { | |||||
var tmp = TikTokGoods{ | var tmp = TikTokGoods{ | ||||
Commission: zhios_third_party_utils.AnyToString(goods["cos_ratio"]), | |||||
CostPrice: zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.AnyToFloat64(goods["price"]) / 100), | |||||
DetailURL: zhios_third_party_utils.AnyToString(goods["detail_url"]), | |||||
GoodsID: zhios_third_party_utils.AnyToString(goods["product_id"]), | |||||
GoodsImg: zhios_third_party_utils.AnyToString(goods["cover"]), | |||||
GoodsSales: zhios_third_party_utils.AnyToString(goods["sales"]), | |||||
GoodsTitle: zhios_third_party_utils.AnyToString(goods["title"]), | |||||
Imgs: img, | |||||
InStock: zhios_third_party_utils.AnyToString(goods["in_stock"]), | |||||
Price: zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.AnyToFloat64(goods["coupon_price"]) / 100), | |||||
Sharable: zhios_third_party_utils.AnyToString(goods["sharable"]), | |||||
ShopID: zhios_third_party_utils.AnyToString(goods["shop_id"]), | |||||
ShopName: zhios_third_party_utils.AnyToString(goods["shop_name"]), | |||||
ShopTotalScore: zhios_third_party_utils.AnyToString(goods["shop_total_score"]), | |||||
Commission: zhios_third_party_utils.AnyToString(goods.CosRatio), | |||||
CostPrice: zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.AnyToFloat64(goods.Price) / 100), | |||||
DetailURL: zhios_third_party_utils.AnyToString(goods.DetailURL), | |||||
GoodsID: zhios_third_party_utils.AnyToString(goods.ProductID), | |||||
GoodsImg: zhios_third_party_utils.AnyToString(goods.Cover), | |||||
GoodsSales: zhios_third_party_utils.AnyToString(goods.Sales), | |||||
GoodsTitle: zhios_third_party_utils.AnyToString(goods.Title), | |||||
Imgs: goods.Imgs, | |||||
InStock: zhios_third_party_utils.AnyToString(goods.InStock), | |||||
Price: zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.AnyToFloat64(goods.CouponPrice) / 100), | |||||
Sharable: zhios_third_party_utils.AnyToString(goods.Sharable), | |||||
ShopID: zhios_third_party_utils.AnyToString(goods.ShopID), | |||||
ShopName: zhios_third_party_utils.AnyToString(goods.ShopName), | |||||
ShopTotalScore: zhios_third_party_utils.AnyToString(goods.ShopTotalScore), | |||||
YhqPrice: "0", | YhqPrice: "0", | ||||
} | } | ||||
if zhios_third_party_utils.StrToFloat64(tmp.Price) == 0 { | if zhios_third_party_utils.StrToFloat64(tmp.Price) == 0 { | ||||
tmp.Price = tmp.CostPrice | tmp.Price = tmp.CostPrice | ||||
} else { | } else { | ||||
tmp.YhqPrice = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.AnyToFloat64(goods["price"])/100 - zhios_third_party_utils.AnyToFloat64(goods["coupon_price"])/100) | |||||
tmp.YhqPrice = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.AnyToFloat64(goods.Price)/100 - zhios_third_party_utils.AnyToFloat64(goods.CouponPrice)/100) | |||||
} | } | ||||
return tmp | return tmp | ||||
@@ -9,15 +9,7 @@ import ( | |||||
) | ) | ||||
func GoodsOrder(args map[string]string) map[string]interface{} { | func GoodsOrder(args map[string]string) map[string]interface{} { | ||||
args = map[string]string{ | |||||
"appkey": "7076371480799348261", | |||||
"appSecret": "9e58409e-5729-441e-a9f3-c077ec939fbb", | |||||
"acctoken": "52f7ea67-5267-4874-9e05-a837dd1d6a48", | |||||
"size": "10", | |||||
"cursor": "0", | |||||
"start_time": "2022-08-25 00:00:00", | |||||
"end_time": "2022-08-26 00:00:00", | |||||
} | |||||
params := map[string]interface{}{"size": args["size"], "cursor": args["cursor"], "start_time": args["start_time"], "end_time": args["end_time"], "distribution_type": "ProductDetail"} | params := map[string]interface{}{"size": args["size"], "cursor": args["cursor"], "start_time": args["start_time"], "end_time": args["end_time"], "distribution_type": "ProductDetail"} | ||||
send, err := Send(args["appkey"], args["appSecret"], "buyin.kolOrderAds", params, args["acctoken"]) | send, err := Send(args["appkey"], args["appSecret"], "buyin.kolOrderAds", params, args["acctoken"]) | ||||
fmt.Println(send) | fmt.Println(send) | ||||
@@ -52,15 +44,7 @@ func GoodsOrder(args map[string]string) map[string]interface{} { | |||||
} | } | ||||
func LiveOrder(args map[string]string) map[string]interface{} { | func LiveOrder(args map[string]string) map[string]interface{} { | ||||
//args = map[string]string{ | |||||
// "appkey": "7076371480799348261", | |||||
// "appSecret": "9e58409e-5729-441e-a9f3-c077ec939fbb", | |||||
// "acctoken": "52f7ea67-5267-4874-9e05-a837dd1d6a48", | |||||
// "size": "10", | |||||
// "cursor": "0", | |||||
// "start_time": "2022-08-26 00:00:00", | |||||
// "end_time": "2022-08-27 00:00:00", | |||||
//} | |||||
params := map[string]interface{}{"size": args["size"], "cursor": args["cursor"], "start_time": args["start_time"], "end_time": args["end_time"], "distribution_type": "Live"} | params := map[string]interface{}{"size": args["size"], "cursor": args["cursor"], "start_time": args["start_time"], "end_time": args["end_time"], "distribution_type": "Live"} | ||||
send, err := Send(args["appkey"], args["appSecret"], "buyin.instituteOrderAds", params, args["acctoken"]) | send, err := Send(args["appkey"], args["appSecret"], "buyin.instituteOrderAds", params, args["acctoken"]) | ||||
fmt.Println(send) | fmt.Println(send) | ||||