第三方api接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

goods.go 6.2 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. package pdd_union
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md/cps_pdd"
  4. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  5. "encoding/json"
  6. "strings"
  7. )
  8. func GetRecommendGoods(keyArr map[string]string, param map[string]interface{}) []map[string]string {
  9. send, _ := Send(keyArr, "pdd.ddk.oauth.goods.recommend.get", param)
  10. var res cps_pdd.RecommendGoods
  11. json.Unmarshal([]byte(send), &res)
  12. data := make([]map[string]string, 0)
  13. for _, v := range res.GoodsBasicDetailResponse.List {
  14. tmp := make(map[string]string)
  15. tmp["gid"] = v.GoodsSign
  16. tmp["goods_title"] = v.GoodsName
  17. tmp["commission"] = zhios_third_party_utils.Float64ToStr(float64(v.PromotionRate) / 10)
  18. tmp["coupon_start_time"] = "0"
  19. tmp["coupon_end_time"] = "0"
  20. if v.CouponStartTime > 0 {
  21. tmp["coupon_start_time"] = zhios_third_party_utils.IntToStr(v.CouponStartTime)
  22. }
  23. if v.CouponEndTime > 0 {
  24. tmp["coupon_end_time"] = zhios_third_party_utils.IntToStr(v.CouponEndTime)
  25. }
  26. tmp["coupon_price"] = zhios_third_party_utils.Float64ToStr(float64(v.CouponDiscount) / 100)
  27. tmp["shop_name"] = v.MallName
  28. tmp["mall_id"] = zhios_third_party_utils.IntToStr(v.MallId)
  29. tmp["min_normal_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinNormalPrice) / 100)
  30. tmp["min_group_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinGroupPrice) / 100)
  31. //销量处理
  32. tmp["goods_sales"] = v.SalesTip
  33. if strings.Contains(tmp["goods_sales"], "万+") {
  34. tmp["goods_sales"] = strings.ReplaceAll(tmp["goods_sales"], "万+", "")
  35. tmp["goods_sales"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(tmp["goods_sales"]) * 10000)
  36. }
  37. if strings.Contains(tmp["goods_sales"], "万") {
  38. tmp["goods_sales"] = strings.ReplaceAll(tmp["goods_sales"], "万", "")
  39. tmp["goods_sales"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(tmp["goods_sales"]) * 10000)
  40. }
  41. tmp["goods_img"] = v.GoodsImageUrl
  42. tmp["goods_min_img"] = v.GoodsThumbnailUrl
  43. tmp["goods_desc"] = v.GoodsDesc
  44. tmp["goods_sign"] = v.GoodsSign
  45. data = append(data, tmp)
  46. }
  47. return data
  48. }
  49. func GetSearchGoods(keyArr map[string]string, param map[string]interface{}) []map[string]string {
  50. send, _ := Send(keyArr, "pdd.ddk.oauth.goods.search", param)
  51. var res cps_pdd.SearchGoods
  52. json.Unmarshal([]byte(send), &res)
  53. data := make([]map[string]string, 0)
  54. for _, v := range res.GoodsSearchResponse.GoodsList {
  55. tmp := make(map[string]string)
  56. tmp["gid"] = v.GoodsSign
  57. tmp["goods_title"] = v.GoodsName
  58. tmp["commission"] = zhios_third_party_utils.Float64ToStr(float64(v.PromotionRate) / 10)
  59. tmp["coupon_start_time"] = "0"
  60. tmp["coupon_end_time"] = "0"
  61. if v.CouponStartTime > 0 {
  62. tmp["coupon_start_time"] = zhios_third_party_utils.IntToStr(v.CouponStartTime)
  63. }
  64. if v.CouponEndTime > 0 {
  65. tmp["coupon_end_time"] = zhios_third_party_utils.IntToStr(v.CouponEndTime)
  66. }
  67. tmp["coupon_price"] = zhios_third_party_utils.Float64ToStr(float64(v.CouponDiscount) / 100)
  68. tmp["shop_name"] = v.MallName
  69. tmp["mall_id"] = zhios_third_party_utils.IntToStr(v.MallId)
  70. tmp["min_normal_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinNormalPrice) / 100)
  71. tmp["min_group_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinGroupPrice) / 100)
  72. //销量处理
  73. tmp["goods_sales"] = v.SalesTip
  74. if strings.Contains(tmp["goods_sales"], "万+") {
  75. tmp["goods_sales"] = strings.ReplaceAll(tmp["goods_sales"], "万+", "")
  76. tmp["goods_sales"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(tmp["goods_sales"]) * 10000)
  77. }
  78. if strings.Contains(tmp["goods_sales"], "万") {
  79. tmp["goods_sales"] = strings.ReplaceAll(tmp["goods_sales"], "万", "")
  80. tmp["goods_sales"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(tmp["goods_sales"]) * 10000)
  81. }
  82. tmp["goods_img"] = v.GoodsImageUrl
  83. tmp["goods_min_img"] = v.GoodsThumbnailUrl
  84. tmp["goods_desc"] = v.GoodsDesc
  85. tmp["goods_sign"] = v.GoodsSign
  86. data = append(data, tmp)
  87. }
  88. return data
  89. }
  90. func GetGoodsDetail(keyArr map[string]string, param map[string]interface{}) map[string]interface{} {
  91. send, _ := Send(keyArr, "pdd.ddk.oauth.goods.detail", param)
  92. var res cps_pdd.GoodsDetail
  93. json.Unmarshal([]byte(send), &res)
  94. data := make(map[string]interface{})
  95. for _, v := range res.GoodsDetailResponse.GoodsDetails {
  96. tmp := make(map[string]interface{})
  97. tmp["gid"] = v.GoodsSign
  98. tmp["goods_title"] = v.GoodsName
  99. tmp["commission"] = zhios_third_party_utils.Float64ToStr(float64(v.PromotionRate) / 10)
  100. tmp["coupon_start_time"] = "0"
  101. tmp["coupon_end_time"] = "0"
  102. if v.CouponStartTime > 0 {
  103. tmp["coupon_start_time"] = zhios_third_party_utils.IntToStr(v.CouponStartTime)
  104. }
  105. if v.CouponEndTime > 0 {
  106. tmp["coupon_end_time"] = zhios_third_party_utils.IntToStr(v.CouponEndTime)
  107. }
  108. tmp["coupon_price"] = zhios_third_party_utils.Float64ToStr(float64(v.CouponDiscount) / 100)
  109. tmp["shop_name"] = v.MallName
  110. tmp["mall_id"] = zhios_third_party_utils.IntToStr(v.MallId)
  111. tmp["min_normal_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinNormalPrice) / 100)
  112. tmp["min_group_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinGroupPrice) / 100)
  113. //销量处理
  114. tmp["goods_sales"] = v.SalesTip
  115. if strings.Contains(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万+") {
  116. tmp["goods_sales"] = strings.ReplaceAll(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万+", "")
  117. tmp["goods_sales"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(zhios_third_party_utils.AnyToString(tmp["goods_sales"])) * 10000)
  118. }
  119. if strings.Contains(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万") {
  120. tmp["goods_sales"] = strings.ReplaceAll(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万", "")
  121. tmp["goods_sales"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(zhios_third_party_utils.AnyToString(tmp["goods_sales"])) * 10000)
  122. }
  123. tmp["goods_img"] = v.GoodsImageUrl
  124. tmp["goods_min_img"] = v.GoodsThumbnailUrl
  125. tmp["goods_desc"] = v.GoodsDesc
  126. tmp["goods_sign"] = v.GoodsSign
  127. if len(v.GoodsThumbnailUrl) > 0 {
  128. tmp["goods_img_list"] = v.GoodsThumbnailUrl
  129. }
  130. data = tmp
  131. }
  132. return data
  133. }