|
- package pdd_union
-
- import (
- "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md/cps_pdd"
- zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
- "encoding/json"
- "strings"
- )
-
- func GetRecommendGoods(keyArr map[string]string, param map[string]interface{}) []map[string]interface{} {
- send, _ := Send(keyArr, "pdd.ddk.oauth.goods.recommend.get", param)
- var res cps_pdd.RecommendGoods
- json.Unmarshal([]byte(send), &res)
- data := make([]map[string]interface{}, 0)
- for _, v := range res.GoodsBasicDetailResponse.List {
- tmp := make(map[string]interface{})
- tmp["gid"] = zhios_third_party_utils.Int64ToStr(v.GoodsId)
- tmp["goods_title"] = v.GoodsName
- tmp["commission"] = float64(v.PromotionRate) / 10
- tmp["coupon_start_time"] = 0
- tmp["coupon_end_time"] = 0
- if v.CouponStartTime > 0 {
- tmp["coupon_start_time"] = v.CouponStartTime
- }
- if v.CouponEndTime > 0 {
- tmp["coupon_end_time"] = v.CouponEndTime
- }
- tmp["coupon_price"] = float64(v.CouponDiscount) / 100
- tmp["shop_name"] = v.MallName
- tmp["mall_id"] = v.MallId
- tmp["min_normal_price"] = float64(v.MinNormalPrice) / 100
- tmp["min_group_price"] = float64(v.MinGroupPrice) / 100
- //销量处理
- goodsSale := v.SalesTip
- if strings.Contains(goodsSale, "万+") {
- goodsSale = strings.ReplaceAll(goodsSale, "万+", "")
- goodsSale = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(goodsSale) * 10000))
- }
- if strings.Contains(goodsSale, "万") {
- goodsSale = strings.ReplaceAll(goodsSale, "万", "")
- goodsSale = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(goodsSale) * 10000))
- }
- tmp["goods_sales"] = goodsSale
-
- tmp["goods_img"] = v.GoodsImageUrl
- tmp["goods_min_img"] = v.GoodsThumbnailUrl
- tmp["goods_desc"] = v.GoodsDesc
- tmp["goods_sign"] = v.GoodsSign
- data = append(data, tmp)
- }
- return data
- }
- func GetSearchGoods(keyArr map[string]string, param map[string]interface{}) []map[string]interface{} {
- send, _ := Send(keyArr, "pdd.ddk.oauth.goods.search", param)
- var res cps_pdd.SearchGoods
- json.Unmarshal([]byte(send), &res)
- data := make([]map[string]interface{}, 0)
- for _, v := range res.GoodsSearchResponse.GoodsList {
- tmp := make(map[string]interface{})
- tmp["gid"] = zhios_third_party_utils.Int64ToStr(v.GoodsId)
- tmp["goods_title"] = v.GoodsName
- tmp["commission"] = float64(v.PromotionRate) / 10
- tmp["coupon_start_time"] = 0
- tmp["coupon_end_time"] = 0
- if v.CouponStartTime > 0 {
- tmp["coupon_start_time"] = v.CouponStartTime
- }
- if v.CouponEndTime > 0 {
- tmp["coupon_end_time"] = v.CouponEndTime
- }
- tmp["coupon_price"] = float64(v.CouponDiscount) / 100
- tmp["shop_name"] = v.MallName
- tmp["mall_id"] = v.MallId
- tmp["min_normal_price"] = float64(v.MinNormalPrice) / 100
- tmp["min_group_price"] = float64(v.MinGroupPrice) / 100
- //销量处理
- goodsSale := v.SalesTip
- if strings.Contains(goodsSale, "万+") {
- goodsSale = strings.ReplaceAll(goodsSale, "万+", "")
- goodsSale = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(goodsSale) * 10000))
- }
- if strings.Contains(goodsSale, "万") {
- goodsSale = strings.ReplaceAll(goodsSale, "万", "")
- goodsSale = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(goodsSale) * 10000))
- }
- tmp["goods_sales"] = goodsSale
-
- tmp["goods_img"] = v.GoodsImageUrl
- tmp["goods_min_img"] = v.GoodsThumbnailUrl
- tmp["goods_desc"] = v.GoodsDesc
- tmp["goods_sign"] = v.GoodsSign
- data = append(data, tmp)
- }
- return data
- }
-
- func GetSearchGoodsDetail(keyArr map[string]string, param map[string]interface{}) []map[string]string {
- send, _ := Send(keyArr, "pdd.ddk.oauth.goods.search", param)
- var res cps_pdd.SearchGoods
- json.Unmarshal([]byte(send), &res)
- data := make([]map[string]string, 0)
- for _, v := range res.GoodsSearchResponse.GoodsList {
- tmp := make(map[string]string)
- tmp["gid"] = zhios_third_party_utils.Int64ToStr(v.GoodsId)
- tmp["goods_title"] = v.GoodsName
- tmp["commission"] = zhios_third_party_utils.Float64ToStr(float64(v.PromotionRate) / 10)
- tmp["coupon_start_time"] = "0"
- tmp["coupon_end_time"] = "0"
- if v.CouponStartTime > 0 {
- tmp["coupon_start_time"] = zhios_third_party_utils.IntToStr(v.CouponStartTime)
- }
- if v.CouponEndTime > 0 {
- tmp["coupon_end_time"] = zhios_third_party_utils.IntToStr(v.CouponEndTime)
- }
- tmp["coupon_price"] = zhios_third_party_utils.Float64ToStr(float64(v.CouponDiscount) / 100)
- tmp["shop_name"] = v.MallName
- tmp["mall_id"] = zhios_third_party_utils.IntToStr(v.MallId)
- tmp["min_normal_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinNormalPrice) / 100)
- tmp["min_group_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinGroupPrice) / 100)
- //销量处理
- tmp["goods_sales"] = v.SalesTip
- if strings.Contains(tmp["goods_sales"], "万+") {
- tmp["goods_sales"] = strings.ReplaceAll(tmp["goods_sales"], "万+", "")
- tmp["goods_sales"] = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(tmp["goods_sales"]) * 10000))
- }
- if strings.Contains(tmp["goods_sales"], "万") {
- tmp["goods_sales"] = strings.ReplaceAll(tmp["goods_sales"], "万", "")
- tmp["goods_sales"] = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(tmp["goods_sales"]) * 10000))
- }
- tmp["goods_img"] = v.GoodsImageUrl
- tmp["goods_min_img"] = v.GoodsThumbnailUrl
- tmp["goods_desc"] = v.GoodsDesc
- tmp["goods_sign"] = v.GoodsSign
- data = append(data, tmp)
- }
- return data
- }
- func GetGoodsDetail(keyArr map[string]string, param map[string]interface{}) map[string]interface{} {
- send, _ := Send(keyArr, "pdd.ddk.oauth.goods.detail", param)
- var res cps_pdd.GoodsDetail
- json.Unmarshal([]byte(send), &res)
- data := make(map[string]interface{})
- for _, v := range res.GoodsDetailResponse.GoodsDetails {
- tmp := make(map[string]interface{})
- tmp["gid"] = zhios_third_party_utils.Int64ToStr(v.GoodsId)
- tmp["goods_title"] = v.GoodsName
- tmp["commission"] = zhios_third_party_utils.Float64ToStr(float64(v.PromotionRate) / 10)
- tmp["coupon_start_time"] = "0"
- tmp["coupon_end_time"] = "0"
- if v.CouponStartTime > 0 {
- tmp["coupon_start_time"] = zhios_third_party_utils.IntToStr(v.CouponStartTime)
- }
- if v.CouponEndTime > 0 {
- tmp["coupon_end_time"] = zhios_third_party_utils.IntToStr(v.CouponEndTime)
- }
- tmp["coupon_price"] = zhios_third_party_utils.Float64ToStr(float64(v.CouponDiscount) / 100)
- tmp["shop_name"] = v.MallName
- tmp["mall_id"] = zhios_third_party_utils.IntToStr(v.MallId)
- tmp["min_normal_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinNormalPrice) / 100)
- tmp["min_group_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinGroupPrice) / 100)
- //销量处理
- tmp["goods_sales"] = v.SalesTip
- if strings.Contains(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万+") {
- tmp["goods_sales"] = strings.ReplaceAll(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万+", "")
- tmp["goods_sales"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(zhios_third_party_utils.AnyToString(tmp["goods_sales"])) * 10000)
- }
- if strings.Contains(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万") {
- tmp["goods_sales"] = strings.ReplaceAll(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万", "")
- tmp["goods_sales"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(zhios_third_party_utils.AnyToString(tmp["goods_sales"])) * 10000)
- }
- tmp["goods_img"] = v.GoodsImageUrl
- tmp["goods_min_img"] = v.GoodsThumbnailUrl
- tmp["goods_desc"] = v.GoodsDesc
- tmp["goods_sign"] = v.GoodsSign
- if len(v.GoodsGalleryUrls) > 0 {
- tmp["goods_img_list"] = v.GoodsGalleryUrls
- }
- data = tmp
- }
- return data
- }
|