第三方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 3.8 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package wph
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/md/wph"
  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. )
  8. // 关键字查询
  9. func QueryWithOauth(serviceParam map[string]string, param string) []wph.WphGoods {
  10. post, _ := SendPost("com.vip.adp.api.open.service.UnionGoodsService", "queryWithOauth", serviceParam, param)
  11. var goods = make([]wph.OfficialGoods, 0)
  12. json.Unmarshal([]byte(gjson.Get(post, "result.goodsInfoList").String()), &goods)
  13. list := make([]wph.WphGoods, 0)
  14. for _, v := range goods {
  15. gid := v.GoodsId
  16. if v.AdCode != "" {
  17. gid = v.GoodsId + "adCode" + v.AdCode
  18. }
  19. tmp := wph.WphGoods{
  20. Gid: gid,
  21. AdCode: v.AdCode,
  22. GoodsTitle: v.GoodsName,
  23. GoodsDesc: v.GoodsDesc,
  24. GoodsImg: v.GoodsMainPicture,
  25. ImgList: v.GoodsCarouselPictures,
  26. SourceType: zhios_third_party_utils.IntToStr(v.SourceType),
  27. GoodsPrice: v.VipPrice,
  28. GoodsCostPrice: v.MarketPrice,
  29. Commission: v.Commission,
  30. CommissionRate: v.CommissionRate,
  31. Discount: v.Discount,
  32. YhqPrice: v.CouponInfo.Fav,
  33. CouponPrice: v.CouponInfo.Fav,
  34. }
  35. if zhios_third_party_utils.StrToFloat64(tmp.YhqPrice) == 0 {
  36. tmp.YhqPrice = v.ExclusiveCoupon.Fav
  37. tmp.CouponPrice = v.ExclusiveCoupon.Fav
  38. }
  39. list = append(list, tmp)
  40. }
  41. return list
  42. }
  43. // 联盟在推商品列表
  44. func GoodsListWithOauth(serviceParam map[string]string, param string) []wph.WphGoods {
  45. post, _ := SendPost("com.vip.adp.api.open.service.UnionGoodsService", "goodsListWithOauth", serviceParam, param)
  46. var goods = make([]wph.OfficialGoods, 0)
  47. json.Unmarshal([]byte(gjson.Get(post, "result.goodsInfoList").String()), &goods)
  48. list := make([]wph.WphGoods, 0)
  49. for _, v := range goods {
  50. gid := v.GoodsId
  51. if v.AdCode != "" {
  52. gid = v.GoodsId + "adCode" + v.AdCode
  53. }
  54. tmp := wph.WphGoods{
  55. Gid: gid,
  56. AdCode: v.AdCode,
  57. GoodsTitle: v.GoodsName,
  58. GoodsDesc: v.GoodsDesc,
  59. GoodsImg: v.GoodsMainPicture,
  60. ImgList: v.GoodsCarouselPictures,
  61. SourceType: zhios_third_party_utils.IntToStr(v.SourceType),
  62. GoodsPrice: v.VipPrice,
  63. GoodsCostPrice: v.MarketPrice,
  64. Commission: v.Commission,
  65. CommissionRate: v.CommissionRate,
  66. Discount: v.Discount,
  67. YhqPrice: v.CouponInfo.Fav,
  68. CouponPrice: v.CouponInfo.Fav,
  69. }
  70. if zhios_third_party_utils.StrToFloat64(tmp.YhqPrice) == 0 {
  71. tmp.YhqPrice = v.ExclusiveCoupon.Fav
  72. tmp.CouponPrice = v.ExclusiveCoupon.Fav
  73. }
  74. list = append(list, tmp)
  75. }
  76. return list
  77. }
  78. func GetByGoodsIdsWithOauth(serviceParam map[string]string, param string) []wph.WphGoods {
  79. post, _ := SendPost("com.vip.adp.api.open.service.UnionGoodsService", "getByGoodsIdsWithOauth", serviceParam, param)
  80. var goods = make([]wph.OfficialGoods, 0)
  81. json.Unmarshal([]byte(gjson.Get(post, "result").String()), &goods)
  82. list := make([]wph.WphGoods, 0)
  83. for _, v := range goods {
  84. gid := v.GoodsId
  85. if v.AdCode != "" {
  86. gid = v.GoodsId + "adCode" + v.AdCode
  87. }
  88. tmp := wph.WphGoods{
  89. Gid: gid,
  90. AdCode: v.AdCode,
  91. GoodsTitle: v.GoodsName,
  92. GoodsDesc: v.GoodsDesc,
  93. GoodsImg: v.GoodsMainPicture,
  94. ImgList: v.GoodsCarouselPictures,
  95. SourceType: zhios_third_party_utils.IntToStr(v.SourceType),
  96. GoodsPrice: v.VipPrice,
  97. GoodsCostPrice: v.MarketPrice,
  98. Commission: v.Commission,
  99. CommissionRate: v.CommissionRate,
  100. Discount: v.Discount,
  101. YhqPrice: v.CouponInfo.Fav,
  102. CouponPrice: v.CouponInfo.Fav,
  103. }
  104. if zhios_third_party_utils.StrToFloat64(tmp.YhqPrice) == 0 {
  105. tmp.YhqPrice = v.ExclusiveCoupon.Fav
  106. tmp.CouponPrice = v.ExclusiveCoupon.Fav
  107. }
  108. list = append(list, tmp)
  109. }
  110. return list
  111. }