第三方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.

haodanku.go 4.4 KiB

1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. package haodanku
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
  4. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  5. "encoding/json"
  6. "github.com/tidwall/gjson"
  7. "strings"
  8. )
  9. func HaodankuFriendsCircleItems(params map[string]string) []map[string]string {
  10. var goods = make([]map[string]string, 0)
  11. reqNew, err := SendReqNew("http://v3.api.haodanku.com/friends_circle_items", params)
  12. if err != nil {
  13. return goods
  14. }
  15. data := gjson.Get(string(reqNew), "data").String()
  16. if data == "" {
  17. return goods
  18. }
  19. var oldGoods []md.HaodankuFriendsCircleItems
  20. json.Unmarshal([]byte(data), &oldGoods)
  21. for _, v := range oldGoods {
  22. v.Comment.CopyContent = strings.ReplaceAll(v.Comment.CopyContent, "<br>", "\r\n")
  23. var tmp = map[string]string{
  24. "gid": v.Items.Itemid,
  25. "title": v.Items.Itemshorttitle,
  26. "img": v.Items.Itempic,
  27. "sales": "",
  28. "price": v.Items.Itemendprice,
  29. "cost_price": v.Items.Itemprice,
  30. "coupon": v.Items.Couponmoney,
  31. "commission_rate": v.Items.Tkrates,
  32. "commission": v.Items.Tkmoney,
  33. "pvd": "taobao",
  34. "share_content": v.Comment.CopyContent,
  35. }
  36. goods = append(goods, tmp)
  37. }
  38. return goods
  39. }
  40. func HaodankuSelectedItem(params map[string]string) []map[string]string {
  41. var goods = make([]map[string]string, 0)
  42. reqNew, err := SendReqNew("http://v2.api.haodanku.com/selected_item", params)
  43. if err != nil {
  44. return goods
  45. }
  46. data := gjson.Get(string(reqNew), "data").String()
  47. if data == "" {
  48. return goods
  49. }
  50. var oldGoods []md.HaodankuSelectedItem
  51. json.Unmarshal([]byte(data), &oldGoods)
  52. for _, v := range oldGoods {
  53. content := v.CopyContent
  54. content = strings.ReplaceAll(content, "&lt;br&gt;", "\r\n")
  55. img := ""
  56. if len(v.Itempic) > 0 {
  57. img = v.Itempic[0]
  58. }
  59. var tmp = map[string]string{
  60. "gid": v.Itemid,
  61. "title": v.Title,
  62. "img": img,
  63. "sales": "",
  64. "price": v.Itemendprice,
  65. "cost_price": v.Itemprice,
  66. "coupon": v.Couponmoney,
  67. "commission_rate": v.Tkrates,
  68. "commission": zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(v.Itemendprice) * (zhios_third_party_utils.StrToFloat64(v.Tkrates) / 100)),
  69. "pvd": "taobao",
  70. "share_content": content,
  71. }
  72. goods = append(goods, tmp)
  73. }
  74. return goods
  75. }
  76. func HaodankuTikTok(params map[string]string) []map[string]string {
  77. var goods = make([]map[string]string, 0)
  78. reqNew, err := SendReqNew("https://v3.api.haodanku.com/dy_rankitem_list", params)
  79. if err != nil {
  80. return goods
  81. }
  82. data := gjson.Get(string(reqNew), "data").String()
  83. if data == "" {
  84. return goods
  85. }
  86. var oldGoods []md.HaodankuTikTok
  87. json.Unmarshal([]byte(data), &oldGoods)
  88. for _, v := range oldGoods {
  89. var tmp = map[string]string{
  90. "gid": v.ProductID,
  91. "title": v.Itemshorttitle,
  92. "img": v.Itempic,
  93. "sales": "",
  94. "price": v.Itemendprice,
  95. "cost_price": v.Itemprice,
  96. "coupon": "",
  97. "commission_rate": zhios_third_party_utils.AnyToString(v.Dyrates),
  98. "commission": zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(v.Itemendprice) * (zhios_third_party_utils.AnyToFloat64(v.Dyrates) / 100)),
  99. "pvd": md.PVD_TIKTOK,
  100. "share_content": "",
  101. }
  102. goods = append(goods, tmp)
  103. }
  104. return goods
  105. }
  106. func HaodankuTaobaoRankList(params map[string]string) []map[string]string {
  107. var goods = make([]map[string]string, 0)
  108. reqNew, err := SendReqNew("http://v2.api.haodanku.com/sales_list", params)
  109. if err != nil {
  110. return goods
  111. }
  112. data := gjson.Get(string(reqNew), "data").String()
  113. if data == "" {
  114. return goods
  115. }
  116. var oldGoods []md.HDKGoodsTaobaoRankList
  117. json.Unmarshal([]byte(data), &oldGoods)
  118. for _, v := range oldGoods {
  119. var tmp = map[string]string{
  120. "gid": v.Itemid,
  121. "title": v.Itemtitle,
  122. "img": v.Itempic,
  123. "sales": "",
  124. "price": v.Itemendprice,
  125. "cost_price": v.Itemprice,
  126. "coupon": v.Couponmoney,
  127. "commission_rate": zhios_third_party_utils.AnyToString(v.Tkrates),
  128. "commission": zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(v.Itemendprice) * (zhios_third_party_utils.AnyToFloat64(v.Tkrates) / 100)),
  129. "pvd": "taobao",
  130. "share_content": "",
  131. }
  132. goods = append(goods, tmp)
  133. }
  134. return goods
  135. }