package haodanku import ( "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md" "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/taobao" zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" "encoding/json" "fmt" "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 } func HaodankuTikTok(params map[string]string) []map[string]string { var goods = make([]map[string]string, 0) reqNew, err := SendReqNew("https://v3.api.haodanku.com/dy_rankitem_list", params) if err != nil { return goods } data := gjson.Get(string(reqNew), "data").String() if data == "" { return goods } var oldGoods []md.HaodankuTikTok json.Unmarshal([]byte(data), &oldGoods) for _, v := range oldGoods { var tmp = map[string]string{ "gid": v.ProductID, "title": v.Itemshorttitle, "img": v.Itempic, "sales": "", "price": v.Itemendprice, "cost_price": v.Itemprice, "coupon": "", "commission_rate": zhios_third_party_utils.AnyToString(v.Dyrates), "commission": zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(v.Itemendprice) * (zhios_third_party_utils.AnyToFloat64(v.Dyrates) / 100)), "pvd": md.PVD_TIKTOK, "share_content": "", } goods = append(goods, tmp) } return goods } func HaodankuTaobaoRankList(params map[string]string) []map[string]string { var goods = make([]map[string]string, 0) reqNew, err := SendReqNew("http://v2.api.haodanku.com/sales_list", params) if err != nil { return goods } data := gjson.Get(string(reqNew), "data").String() if data == "" { return goods } var oldGoods []md.HDKGoodsTaobaoRankList json.Unmarshal([]byte(data), &oldGoods) for _, v := range oldGoods { var tmp = map[string]string{ "gid": v.Itemid, "title": v.Itemtitle, "img": v.Itempic, "sales": "", "price": v.Itemendprice, "cost_price": v.Itemprice, "coupon": v.Couponmoney, "commission_rate": zhios_third_party_utils.AnyToString(v.Tkrates), "commission": zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(v.Itemendprice) * (zhios_third_party_utils.AnyToFloat64(v.Tkrates) / 100)), "pvd": "taobao", "share_content": "", } goods = append(goods, tmp) } return goods } // 好单库详情接口 func HaodankuDetail(Id string) (res *taobao.Material, err error) { params := map[string]string{ "version": "v2.0.0", "itemid": Id, } resp, err := SendReq("http://v2.api.haodanku.com/item_detail", params) if err != nil { return nil, err } var featuredList struct { Data md.HDKDetailStruct `json:"data"` } zhios_third_party_utils.Unserialize(resp, &featuredList) var imgs = strings.Split(featuredList.Data.TaobaoImage, ",") var Shoptype int if featuredList.Data.Shoptype == "B" { Shoptype = 1 } else { Shoptype = 0 } if strings.Contains(featuredList.Data.Itempic, "http") == false { featuredList.Data.Itempic = fmt.Sprintf("https:%s", featuredList.Data.Itempic) } var data = taobao.Material{ CommissionRate: zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(featuredList.Data.Tkrates) * 100), ItemDescription: featuredList.Data.Itemdesc, ItemID: featuredList.Data.Itemid, Nick: featuredList.Data.Shopname, PictURL: featuredList.Data.Itempic, SellerID: featuredList.Data.UserId, ShopTitle: featuredList.Data.Sellernick, Title: featuredList.Data.Itemtitle, TkTotalSales: featuredList.Data.Itemsale, Volume: zhios_third_party_utils.StrToInt(featuredList.Data.Itemsale), ZkFinalPrice: zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(featuredList.Data.Itemendprice) + zhios_third_party_utils.StrToFloat64(featuredList.Data.Couponmoney)), ReservePrice: featuredList.Data.Itemprice, CouponAmount: featuredList.Data.Couponmoney, CouponEndTime: featuredList.Data.Couponendtime, CouponStartTime: featuredList.Data.Couponstarttime, ActivityId: featuredList.Data.Activityid, UserType: Shoptype, } data.SmallImages = struct { String []string `json:"string"` }(struct{ String []string }{String: imgs}) res = &data return res, nil }