|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- package dataoke
-
- 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"
- "net/url"
- )
-
- func DataokeFriendsCircleList(params map[string]string) []map[string]string {
- var goods = make([]map[string]string, 0)
- resp, err := SendReq("https://openapi.dataoke.com/api/goods/friends-circle-list", params)
- if err != nil {
- return goods
- }
- data := gjson.Get(string(resp), "data.list").String()
- if data == "" {
- return goods
- }
- var oldGoods []md.DataokeFriendCircleList
- json.Unmarshal([]byte(data), &oldGoods)
- for _, v := range oldGoods {
- m, _ := url.QueryUnescape(v.CircleText)
- pvd := md.PVD_TB
- if v.ShopType == 1 {
- pvd = md.PVD_TM
- }
- var tmp = map[string]string{
- "gid": v.GoodsID,
- "title": v.Dtitle,
- "img": v.MainPic,
- "sales": zhios_third_party_utils.IntToStr(v.MonthSales),
- "day_sales": zhios_third_party_utils.IntToStr(v.DailySales),
- "price": zhios_third_party_utils.Float64ToStr(v.ActualPrice),
- "cost_price": zhios_third_party_utils.Float64ToStr(v.OriginalPrice),
- "coupon": zhios_third_party_utils.Float64ToStr(v.CouponPrice),
- "commission_rate": zhios_third_party_utils.Float64ToStr(v.CommissionRate),
- "commission": zhios_third_party_utils.Float64ToStr(v.ActualPrice * (v.CommissionRate / 100)),
- "pvd": pvd,
- "share_content": m,
- }
- goods = append(goods, tmp)
- }
- return goods
- }
-
- func DataokeTaobaoRankList(params map[string]string) []map[string]string {
- var goods = make([]map[string]string, 0)
- resp, err := SendReq("https://openapi.dataoke.com/api/goods/get-ranking-list", params)
- if err != nil {
- return goods
- }
- data := gjson.Get(string(resp), "data").String()
- if data == "" {
- return goods
- }
- var oldGoods []md.DataokeTaobaoRankList
- json.Unmarshal([]byte(data), &oldGoods)
- for _, v := range oldGoods {
- pvd := md.PVD_TB
- var tmp = map[string]string{
- "gid": v.Goodsid,
- "title": v.Dtitle,
- "img": v.Mainpic,
- "sales": zhios_third_party_utils.IntToStr(v.Monthsales),
- "day_sales": zhios_third_party_utils.IntToStr(v.Dailysales),
- "price": zhios_third_party_utils.AnyToString(v.Originalprice),
- "cost_price": zhios_third_party_utils.AnyToString(v.Actualprice),
- "coupon": zhios_third_party_utils.AnyToString(v.Couponprice),
- "commission_rate": zhios_third_party_utils.AnyToString(v.Commissionrate),
- "commission": zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.AnyToFloat64(v.Actualprice) * (zhios_third_party_utils.AnyToFloat64(v.Commissionrate) / 100)),
- "pvd": pvd,
- "share_content": v.Desc,
- }
- goods = append(goods, tmp)
- }
- return goods
- }
- func DataokeTikTokRankList(params map[string]string) []map[string]string {
- var goods = make([]map[string]string, 0)
- resp, err := SendReq("https://openapi.dataoke.com/api/tiktok/tiktok-sx-goods-rank", params)
- if err != nil {
- return goods
- }
- data := gjson.Get(string(resp), "data.list").String()
- if data == "" {
- return goods
- }
- var oldGoods []md.DataokeTikTokRankList
- json.Unmarshal([]byte(data), &oldGoods)
- for _, v := range oldGoods {
- pvd := md.PVD_TIKTOK
- if v.Cover != "" {
- v.ItemImg = v.Cover
- }
- if len(v.Imgs) > 0 {
- v.ItemImg = v.Imgs[0]
- }
- var tmp = map[string]string{
- "gid": v.ID,
- "title": v.Title,
- "img": v.ItemImg,
- "sales": zhios_third_party_utils.Int64ToStr(v.Sales),
- "day_sales": "",
- "price": zhios_third_party_utils.AnyToString(v.Price - v.Coupon),
- "cost_price": zhios_third_party_utils.AnyToString(v.Price),
- "coupon": zhios_third_party_utils.AnyToString(v.Coupon),
- "commission_rate": zhios_third_party_utils.AnyToString(v.CosRatio),
- "commission": zhios_third_party_utils.Float64ToStr((v.Price - v.Coupon) * (zhios_third_party_utils.AnyToFloat64(v.CosRatio) / 100)),
- "pvd": pvd,
- "share_content": "",
- }
- goods = append(goods, tmp)
- }
- return goods
- }
|