第三方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 2.4 KiB

1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. }