package haodanku 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" "github.com/tidwall/gjson" "strings" ) func HaodankuFriendsCircleItems(params map[string]string) []map[string]string { var goods = make([]map[string]string, 0) reqNew, err := SendReqNew("http://v3.api.haodanku.com/friends_circle_items", params) if err != nil { return goods } data := gjson.Get(string(reqNew), "data").String() if data == "" { return goods } var oldGoods []md.HaodankuFriendsCircleItems json.Unmarshal([]byte(data), &oldGoods) for _, v := range oldGoods { v.Comment.CopyContent = strings.ReplaceAll(v.Comment.CopyContent, "
", "\r\n") var tmp = map[string]string{ "gid": v.Items.Itemid, "title": v.Items.Itemshorttitle, "img": v.Items.Itempic, "sales": "", "price": v.Items.Itemendprice, "cost_price": v.Items.Itemprice, "coupon": v.Items.Couponmoney, "commission_rate": v.Items.Tkrates, "commission": v.Items.Tkmoney, "pvd": "taobao", "share_content": v.Comment.CopyContent, } goods = append(goods, tmp) } return goods } func HaodankuSelectedItem(params map[string]string) []map[string]string { var goods = make([]map[string]string, 0) reqNew, err := SendReqNew("http://v2.api.haodanku.com/selected_item", params) if err != nil { return goods } data := gjson.Get(string(reqNew), "data").String() if data == "" { return goods } var oldGoods []md.HaodankuSelectedItem json.Unmarshal([]byte(data), &oldGoods) for _, v := range oldGoods { content := v.CopyContent content = strings.ReplaceAll(content, "<br>", "\r\n") img := "" if len(v.Itempic) > 0 { img = v.Itempic[0] } var tmp = map[string]string{ "gid": v.Itemid, "title": v.Title, "img": img, "sales": "", "price": v.Itemendprice, "cost_price": v.Itemprice, "coupon": v.Couponmoney, "commission_rate": v.Tkrates, "commission": zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(v.Itemendprice) * (zhios_third_party_utils.StrToFloat64(v.Tkrates) / 100)), "pvd": "taobao", "share_content": content, } goods = append(goods, tmp) } return goods }