|
|
@@ -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 |
|
|
|
|
|
|
|