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

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. package haodanku
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md"
  4. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/taobao"
  5. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  6. "encoding/json"
  7. "fmt"
  8. "github.com/tidwall/gjson"
  9. "strings"
  10. )
  11. func HaodankuFriendsCircleItems(params map[string]string) []map[string]string {
  12. var goods = make([]map[string]string, 0)
  13. reqNew, err := SendReqNew("http://v3.api.haodanku.com/friends_circle_items", params)
  14. if err != nil {
  15. return goods
  16. }
  17. data := gjson.Get(string(reqNew), "data").String()
  18. if data == "" {
  19. return goods
  20. }
  21. var oldGoods []md.HaodankuFriendsCircleItems
  22. json.Unmarshal([]byte(data), &oldGoods)
  23. for _, v := range oldGoods {
  24. v.Comment.CopyContent = strings.ReplaceAll(v.Comment.CopyContent, "<br>", "\r\n")
  25. var tmp = map[string]string{
  26. "img_list": zhios_third_party_utils.SerializeStr(v.Image),
  27. "gid": v.Items.Itemid,
  28. "title": v.Items.Itemshorttitle,
  29. "img": v.Items.Itempic,
  30. "sales": "",
  31. "price": v.Items.Itemendprice,
  32. "cost_price": v.Items.Itemprice,
  33. "coupon": v.Items.Couponmoney,
  34. "commission_rate": v.Items.Tkrates,
  35. "commission": v.Items.Tkmoney,
  36. "pvd": "taobao",
  37. "share_content": v.Comment.CopyContent,
  38. }
  39. goods = append(goods, tmp)
  40. }
  41. return goods
  42. }
  43. func HaodankuSelectedItem(params map[string]string) []map[string]string {
  44. var goods = make([]map[string]string, 0)
  45. reqNew, err := SendReqNew("http://v2.api.haodanku.com/selected_item", params)
  46. if err != nil {
  47. return goods
  48. }
  49. data := gjson.Get(string(reqNew), "data").String()
  50. if data == "" {
  51. return goods
  52. }
  53. var oldGoods []md.HaodankuSelectedItem
  54. json.Unmarshal([]byte(data), &oldGoods)
  55. for _, v := range oldGoods {
  56. content := v.CopyContent
  57. content = strings.ReplaceAll(content, "&lt;br&gt;", "\r\n")
  58. img := ""
  59. if len(v.Itempic) > 0 {
  60. img = v.Itempic[0]
  61. }
  62. var tmp = map[string]string{
  63. "gid": v.Itemid,
  64. "title": v.Title,
  65. "img": img,
  66. "sales": "",
  67. "price": v.Itemendprice,
  68. "cost_price": v.Itemprice,
  69. "coupon": v.Couponmoney,
  70. "commission_rate": v.Tkrates,
  71. "commission": zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(v.Itemendprice) * (zhios_third_party_utils.StrToFloat64(v.Tkrates) / 100)),
  72. "pvd": "taobao",
  73. "share_content": content,
  74. }
  75. goods = append(goods, tmp)
  76. }
  77. return goods
  78. }
  79. func HaodankuTikTok(params map[string]string) []map[string]string {
  80. var goods = make([]map[string]string, 0)
  81. reqNew, err := SendReqNew("https://v3.api.haodanku.com/dy_rankitem_list", params)
  82. if err != nil {
  83. return goods
  84. }
  85. data := gjson.Get(string(reqNew), "data").String()
  86. if data == "" {
  87. return goods
  88. }
  89. var oldGoods []md.HaodankuTikTok
  90. json.Unmarshal([]byte(data), &oldGoods)
  91. for _, v := range oldGoods {
  92. var tmp = map[string]string{
  93. "gid": v.ProductID,
  94. "title": v.Itemshorttitle,
  95. "img": v.Itempic,
  96. "sales": "",
  97. "price": v.Itemendprice,
  98. "cost_price": v.Itemprice,
  99. "coupon": "",
  100. "commission_rate": zhios_third_party_utils.AnyToString(v.Dyrates),
  101. "commission": zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(v.Itemendprice) * (zhios_third_party_utils.AnyToFloat64(v.Dyrates) / 100)),
  102. "pvd": md.PVD_TIKTOK,
  103. "share_content": "",
  104. }
  105. goods = append(goods, tmp)
  106. }
  107. return goods
  108. }
  109. func HaodankuTaobaoRankList(params map[string]string) []map[string]string {
  110. var goods = make([]map[string]string, 0)
  111. reqNew, err := SendReqNew("http://v2.api.haodanku.com/sales_list", params)
  112. if err != nil {
  113. return goods
  114. }
  115. data := gjson.Get(string(reqNew), "data").String()
  116. if data == "" {
  117. return goods
  118. }
  119. var oldGoods []md.HDKGoodsTaobaoRankList
  120. json.Unmarshal([]byte(data), &oldGoods)
  121. for _, v := range oldGoods {
  122. var tmp = map[string]string{
  123. "gid": v.Itemid,
  124. "title": v.Itemtitle,
  125. "img": v.Itempic,
  126. "sales": "",
  127. "price": v.Itemendprice,
  128. "cost_price": v.Itemprice,
  129. "coupon": v.Couponmoney,
  130. "commission_rate": zhios_third_party_utils.AnyToString(v.Tkrates),
  131. "commission": zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(v.Itemendprice) * (zhios_third_party_utils.AnyToFloat64(v.Tkrates) / 100)),
  132. "pvd": "taobao",
  133. "share_content": "",
  134. }
  135. goods = append(goods, tmp)
  136. }
  137. return goods
  138. }
  139. // 好单库详情接口
  140. func HaodankuDetail(Id string) (res *taobao.Material, err error) {
  141. params := map[string]string{
  142. "version": "v2.0.0",
  143. "itemid": Id,
  144. }
  145. resp, err := SendReq("http://v2.api.haodanku.com/item_detail", params)
  146. if err != nil {
  147. return nil, err
  148. }
  149. var featuredList struct {
  150. Data md.HDKDetailStruct `json:"data"`
  151. }
  152. zhios_third_party_utils.Unserialize(resp, &featuredList)
  153. var imgs = strings.Split(featuredList.Data.TaobaoImage, ",")
  154. var Shoptype int
  155. if featuredList.Data.Shoptype == "B" {
  156. Shoptype = 1
  157. } else {
  158. Shoptype = 0
  159. }
  160. if strings.Contains(featuredList.Data.Itempic, "http") == false {
  161. featuredList.Data.Itempic = fmt.Sprintf("https:%s", featuredList.Data.Itempic)
  162. }
  163. var data = taobao.Material{
  164. CommissionRate: zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(featuredList.Data.Tkrates) * 100),
  165. ItemDescription: featuredList.Data.Itemdesc,
  166. ItemID: featuredList.Data.Itemid,
  167. Nick: featuredList.Data.Shopname,
  168. PictURL: featuredList.Data.Itempic,
  169. SellerID: featuredList.Data.UserId,
  170. ShopTitle: featuredList.Data.Sellernick,
  171. Title: featuredList.Data.Itemtitle,
  172. TkTotalSales: featuredList.Data.Itemsale,
  173. Volume: zhios_third_party_utils.StrToInt(featuredList.Data.Itemsale),
  174. ZkFinalPrice: zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(featuredList.Data.Itemendprice) + zhios_third_party_utils.StrToFloat64(featuredList.Data.Couponmoney)),
  175. ReservePrice: featuredList.Data.Itemprice,
  176. CouponAmount: featuredList.Data.Couponmoney,
  177. CouponEndTime: featuredList.Data.Couponendtime,
  178. CouponStartTime: featuredList.Data.Couponstarttime,
  179. ActivityId: featuredList.Data.Activityid,
  180. UserType: Shoptype,
  181. }
  182. data.SmallImages = struct {
  183. String []string `json:"string"`
  184. }(struct{ String []string }{String: imgs})
  185. res = &data
  186. return res, nil
  187. }