Kaynağa Gözat

add reverse:for v1.0.1 更新

tags/v1.0.1
huangjiajun 2 yıl önce
ebeveyn
işleme
3cb4237f52
4 değiştirilmiş dosya ile 93 ekleme ve 101 silme
  1. +46
    -15
      tik_tok/md_tik_tok_goods.go
  2. +4
    -30
      tik_tok/svc_tik_tok_convert.go
  3. +41
    -38
      tik_tok/svc_tik_tok_goods.go
  4. +2
    -18
      tik_tok/svc_tik_tok_order.go

+ 46
- 15
tik_tok/md_tik_tok_goods.go Dosyayı Görüntüle

@@ -1,21 +1,52 @@
package tik_tok

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 {
LiveId string `json:"live_id"`


+ 4
- 30
tik_tok/svc_tik_tok_convert.go Dosyayı Görüntüle

@@ -8,13 +8,7 @@ import (

//创建推广位
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"]}
send, err := Send(args["appkey"], args["appSecret"], "buyin.kolPidCreate", params, args["acctoken"])
fmt.Println(send)
@@ -26,14 +20,7 @@ func GoodsCreatePid(args map[string]string) map[string]string {
return data
}
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"]}
send, err := Send(args["appkey"], args["appSecret"], "buyin.kolProductShare", params, args["acctoken"])
fmt.Println(send)
@@ -48,13 +35,7 @@ func GoodsConvertUrl(args map[string]string) map[string]string {
return data
}
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"]}
send, err := Send(args["appkey"], args["appSecret"], "buyin.institutePidCreate", params, args["acctoken"])
fmt.Println(send)
@@ -66,14 +47,7 @@ func LiveCreatePid(args map[string]string) map[string]string {
return data
}
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"]}
send, err := Send(args["appkey"], args["appSecret"], "buyin.instituteLiveShare", params, args["acctoken"])
fmt.Println(send)


+ 41
- 38
tik_tok/svc_tik_tok_goods.go Dosyayı Görüntüle

@@ -32,10 +32,10 @@ func GoodsList(args map[string]string) []TikTokGoods {
params["first_cids"] = []string{args["first_cids"]}
}
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"] != "" {
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"] != "" {
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"]
}
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"] != "" {
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"] != "" {
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"] != "" {
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"])
var goodsList = make([]TikTokGoods, 0)
@@ -61,14 +61,17 @@ func GoodsList(args map[string]string) []TikTokGoods {
if err != nil || product == "" {
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 {
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)
}
return goodsList
@@ -83,14 +86,17 @@ func GetDetail(args map[string]string) TikTokGoods {
if err != nil || product == "" {
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 {
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"] {
return tmp
}
@@ -98,7 +104,8 @@ func GetDetail(args map[string]string) TikTokGoods {
return goodsList
}
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"])
var goodsList = TikTokGoods{}
product := gjson.Get(send, "data.product_info").String()
@@ -109,33 +116,29 @@ func GetKlGoods(args map[string]string) TikTokGoods {
goodsList = GetDetail(args)
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{
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",
}
if zhios_third_party_utils.StrToFloat64(tmp.Price) == 0 {
tmp.Price = tmp.CostPrice
} 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



+ 2
- 18
tik_tok/svc_tik_tok_order.go Dosyayı Görüntüle

@@ -9,15 +9,7 @@ import (
)

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"}
send, err := Send(args["appkey"], args["appSecret"], "buyin.kolOrderAds", params, args["acctoken"])
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{} {
//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"}
send, err := Send(args["appkey"], args["appSecret"], "buyin.instituteOrderAds", params, args["acctoken"])
fmt.Println(send)


Yükleniyor…
İptal
Kaydet