|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- package zhimeng
-
- import (
- "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
- zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
- "encoding/json"
- )
-
- func KuaiShouGoods(tikTokArgs map[string]interface{}) []map[string]string {
- var goods = make([]map[string]string, 0)
- args := map[string]interface{}{
- "appkey": tikTokArgs["appkey"],
- "secret_key": tikTokArgs["secret_key"],
- "title": tikTokArgs["keyword"],
- "first_cids": tikTokArgs["category_id"],
- "price_min": zhios_third_party_utils.AnyToString(tikTokArgs["start_price"]),
- "price_max": zhios_third_party_utils.AnyToString(tikTokArgs["end_price"]),
- "sell_num_min": zhios_third_party_utils.AnyToString(tikTokArgs["start_sales"]),
- "sell_num_max": zhios_third_party_utils.AnyToString(tikTokArgs["end_sales"]),
- "sort": tikTokArgs["sort"],
- "cos_ratio_min": zhios_third_party_utils.AnyToString(tikTokArgs["start_commission"]),
- "cos_ratio_max": zhios_third_party_utils.AnyToString(tikTokArgs["end_commission"]),
- "page": tikTokArgs["p"],
- "page_size": tikTokArgs["size"],
- }
- for k, v := range args {
- if v == nil || v == "<nil>" {
- args[k] = ""
- }
- }
- resp, err := Send("kuaishou", "getGoods", args)
- if err != nil {
- return goods
- }
- var tmp struct {
- Data []TikTokData `json:"data"`
- }
- if err = json.Unmarshal(resp, &tmp); err != nil {
- return goods
- }
- for _, v := range tmp.Data {
- var tmp = map[string]string{
- "gid": v.GoodsID,
- "title": v.GoodsTitle,
- "img": v.GoodsImg,
- "sales": v.GoodsSales,
- "price": v.Price,
- "cost_price": v.CostPrice,
- "coupon": v.YhqPrice,
- "commission_rate": zhios_third_party_utils.AnyToString(v.Commission),
- "commission": zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(v.Price) * (zhios_third_party_utils.AnyToFloat64(v.Commission) / 100)),
- "pvd": md.PVD_KUAISHOU,
- "share_content": "",
- }
- goods = append(goods, tmp)
- }
- return goods
- }
|