|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- 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, "<br>", "\r\n")
- var tmp = map[string]string{
- "img_list": zhios_third_party_utils.SerializeStr(v.Image),
- "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
- }
|