|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- 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, "<br>", "\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
- }
|