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 == "" { 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 } func KuaiShouKlGoods(tikTokArgs map[string]interface{}) (*TikTokDetailData, error) { args := map[string]interface{}{ "appkey": tikTokArgs["appkey"], "secret_key": tikTokArgs["secret_key"], "content": tikTokArgs["content"], } resp, err := Send("kuaishou", "getKlGoods", args) if err != nil { return nil, err } var tmp struct { Data TikTokDetailData `json:"data"` } if err = json.Unmarshal(resp, &tmp); err != nil { return nil, err } return &tmp.Data, nil } func KuaiShouDetail(tikTokArgs map[string]interface{}) (*TikTokDetailData, error) { args := map[string]interface{}{ "appkey": tikTokArgs["appkey"], "secret_key": tikTokArgs["secret_key"], "id": tikTokArgs["gid"], } resp, err := Send("kuaishou", "getGoodsDetail", args) if err != nil { return nil, err } var tmp struct { Data TikTokDetailData `json:"data"` } if err = json.Unmarshal(resp, &tmp); err != nil { return nil, err } return &tmp.Data, nil }