第三方api接口
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

191 lignes
7.8 KiB

  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]interface{} {
  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]interface{}, 0)
  13. for _, v := range res.GoodsBasicDetailResponse.List {
  14. if v.GoodsName == "" {
  15. continue
  16. }
  17. tmp := make(map[string]interface{})
  18. tmp["gid"] = zhios_third_party_utils.Int64ToStr(v.GoodsId)
  19. tmp["goods_title"] = v.GoodsName
  20. tmp["commission"] = float64(v.PromotionRate) / 10
  21. tmp["coupon_start_time"] = 0
  22. tmp["coupon_end_time"] = 0
  23. if v.CouponStartTime > 0 {
  24. tmp["coupon_start_time"] = v.CouponStartTime
  25. }
  26. if v.CouponEndTime > 0 {
  27. tmp["coupon_end_time"] = v.CouponEndTime
  28. }
  29. tmp["coupon_price"] = float64(v.CouponDiscount) / 100
  30. tmp["shop_name"] = v.MallName
  31. tmp["mall_id"] = v.MallId
  32. tmp["min_normal_price"] = float64(v.MinNormalPrice) / 100
  33. tmp["min_group_price"] = float64(v.MinGroupPrice) / 100
  34. //销量处理
  35. goodsSale := v.SalesTip
  36. if strings.Contains(goodsSale, "万+") {
  37. goodsSale = strings.ReplaceAll(goodsSale, "万+", "")
  38. goodsSale = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(goodsSale) * 10000))
  39. }
  40. if strings.Contains(goodsSale, "万") {
  41. goodsSale = strings.ReplaceAll(goodsSale, "万", "")
  42. goodsSale = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(goodsSale) * 10000))
  43. }
  44. tmp["goods_sales"] = goodsSale
  45. tmp["goods_img"] = v.GoodsImageUrl
  46. tmp["goods_min_img"] = v.GoodsThumbnailUrl
  47. tmp["goods_desc"] = v.GoodsDesc
  48. tmp["goods_sign"] = v.GoodsSign
  49. data = append(data, tmp)
  50. }
  51. return data
  52. }
  53. func GetSearchGoods(keyArr map[string]string, param map[string]interface{}) []map[string]interface{} {
  54. send, _ := Send(keyArr, "pdd.ddk.oauth.goods.search", param)
  55. var res cps_pdd.SearchGoods
  56. json.Unmarshal([]byte(send), &res)
  57. data := make([]map[string]interface{}, 0)
  58. for _, v := range res.GoodsSearchResponse.GoodsList {
  59. if v.GoodsName == "" {
  60. continue
  61. }
  62. tmp := make(map[string]interface{})
  63. tmp["gid"] = zhios_third_party_utils.Int64ToStr(v.GoodsId)
  64. tmp["goods_title"] = v.GoodsName
  65. tmp["commission"] = float64(v.PromotionRate) / 10
  66. tmp["coupon_start_time"] = 0
  67. tmp["coupon_end_time"] = 0
  68. if v.CouponStartTime > 0 {
  69. tmp["coupon_start_time"] = v.CouponStartTime
  70. }
  71. if v.CouponEndTime > 0 {
  72. tmp["coupon_end_time"] = v.CouponEndTime
  73. }
  74. tmp["coupon_price"] = float64(v.CouponDiscount) / 100
  75. tmp["shop_name"] = v.MallName
  76. tmp["mall_id"] = v.MallId
  77. tmp["min_normal_price"] = float64(v.MinNormalPrice) / 100
  78. tmp["min_group_price"] = float64(v.MinGroupPrice) / 100
  79. //销量处理
  80. goodsSale := v.SalesTip
  81. if strings.Contains(goodsSale, "万+") {
  82. goodsSale = strings.ReplaceAll(goodsSale, "万+", "")
  83. goodsSale = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(goodsSale) * 10000))
  84. }
  85. if strings.Contains(goodsSale, "万") {
  86. goodsSale = strings.ReplaceAll(goodsSale, "万", "")
  87. goodsSale = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(goodsSale) * 10000))
  88. }
  89. tmp["goods_sales"] = goodsSale
  90. tmp["goods_img"] = v.GoodsImageUrl
  91. tmp["goods_min_img"] = v.GoodsThumbnailUrl
  92. tmp["goods_desc"] = v.GoodsDesc
  93. tmp["goods_sign"] = v.GoodsSign
  94. data = append(data, tmp)
  95. }
  96. return data
  97. }
  98. func GetSearchGoodsDetail(keyArr map[string]string, param map[string]interface{}) []map[string]string {
  99. send, _ := Send(keyArr, "pdd.ddk.oauth.goods.search", param)
  100. var res cps_pdd.SearchGoods
  101. json.Unmarshal([]byte(send), &res)
  102. data := make([]map[string]string, 0)
  103. for _, v := range res.GoodsSearchResponse.GoodsList {
  104. if v.GoodsName == "" {
  105. continue
  106. }
  107. tmp := make(map[string]string)
  108. tmp["gid"] = zhios_third_party_utils.Int64ToStr(v.GoodsId)
  109. tmp["goods_title"] = v.GoodsName
  110. tmp["commission"] = zhios_third_party_utils.Float64ToStr(float64(v.PromotionRate) / 10)
  111. tmp["coupon_start_time"] = "0"
  112. tmp["coupon_end_time"] = "0"
  113. if v.CouponStartTime > 0 {
  114. tmp["coupon_start_time"] = zhios_third_party_utils.IntToStr(v.CouponStartTime)
  115. }
  116. if v.CouponEndTime > 0 {
  117. tmp["coupon_end_time"] = zhios_third_party_utils.IntToStr(v.CouponEndTime)
  118. }
  119. tmp["coupon_price"] = zhios_third_party_utils.Float64ToStr(float64(v.CouponDiscount) / 100)
  120. tmp["shop_name"] = v.MallName
  121. tmp["mall_id"] = zhios_third_party_utils.IntToStr(v.MallId)
  122. tmp["min_normal_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinNormalPrice) / 100)
  123. tmp["min_group_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinGroupPrice) / 100)
  124. //销量处理
  125. tmp["goods_sales"] = v.SalesTip
  126. if strings.Contains(tmp["goods_sales"], "万+") {
  127. tmp["goods_sales"] = strings.ReplaceAll(tmp["goods_sales"], "万+", "")
  128. tmp["goods_sales"] = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(tmp["goods_sales"]) * 10000))
  129. }
  130. if strings.Contains(tmp["goods_sales"], "万") {
  131. tmp["goods_sales"] = strings.ReplaceAll(tmp["goods_sales"], "万", "")
  132. tmp["goods_sales"] = zhios_third_party_utils.IntToStr(int(zhios_third_party_utils.StrToFloat64(tmp["goods_sales"]) * 10000))
  133. }
  134. tmp["goods_img"] = v.GoodsImageUrl
  135. tmp["goods_min_img"] = v.GoodsThumbnailUrl
  136. tmp["goods_desc"] = v.GoodsDesc
  137. tmp["goods_sign"] = v.GoodsSign
  138. data = append(data, tmp)
  139. }
  140. return data
  141. }
  142. func GetGoodsDetail(keyArr map[string]string, param map[string]interface{}) map[string]interface{} {
  143. send, _ := Send(keyArr, "pdd.ddk.oauth.goods.detail", param)
  144. var res cps_pdd.GoodsDetail
  145. json.Unmarshal([]byte(send), &res)
  146. data := make(map[string]interface{})
  147. for _, v := range res.GoodsDetailResponse.GoodsDetails {
  148. tmp := make(map[string]interface{})
  149. tmp["gid"] = zhios_third_party_utils.Int64ToStr(v.GoodsId)
  150. tmp["goods_title"] = v.GoodsName
  151. tmp["commission"] = zhios_third_party_utils.Float64ToStr(float64(v.PromotionRate) / 10)
  152. tmp["coupon_start_time"] = "0"
  153. tmp["coupon_end_time"] = "0"
  154. if v.CouponStartTime > 0 {
  155. tmp["coupon_start_time"] = zhios_third_party_utils.IntToStr(v.CouponStartTime)
  156. }
  157. if v.CouponEndTime > 0 {
  158. tmp["coupon_end_time"] = zhios_third_party_utils.IntToStr(v.CouponEndTime)
  159. }
  160. tmp["coupon_price"] = zhios_third_party_utils.Float64ToStr(float64(v.CouponDiscount) / 100)
  161. tmp["shop_name"] = v.MallName
  162. tmp["mall_id"] = zhios_third_party_utils.IntToStr(v.MallId)
  163. tmp["min_normal_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinNormalPrice) / 100)
  164. tmp["min_group_price"] = zhios_third_party_utils.Float64ToStr(float64(v.MinGroupPrice) / 100)
  165. //销量处理
  166. tmp["goods_sales"] = v.SalesTip
  167. if strings.Contains(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万+") {
  168. tmp["goods_sales"] = strings.ReplaceAll(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万+", "")
  169. tmp["goods_sales"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(zhios_third_party_utils.AnyToString(tmp["goods_sales"])) * 10000)
  170. }
  171. if strings.Contains(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万") {
  172. tmp["goods_sales"] = strings.ReplaceAll(zhios_third_party_utils.AnyToString(tmp["goods_sales"]), "万", "")
  173. tmp["goods_sales"] = zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(zhios_third_party_utils.AnyToString(tmp["goods_sales"])) * 10000)
  174. }
  175. tmp["goods_img"] = v.GoodsImageUrl
  176. tmp["goods_min_img"] = v.GoodsThumbnailUrl
  177. tmp["goods_desc"] = v.GoodsDesc
  178. tmp["goods_sign"] = v.GoodsSign
  179. if len(v.GoodsGalleryUrls) > 0 {
  180. tmp["goods_img_list"] = v.GoodsGalleryUrls
  181. }
  182. data = tmp
  183. }
  184. return data
  185. }