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

121 line
3.9 KiB

  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. DetailImgList: v.GoodsDetailPictures,
  27. SourceType: zhios_third_party_utils.IntToStr(v.SourceType),
  28. GoodsPrice: v.VipPrice,
  29. GoodsCostPrice: v.MarketPrice,
  30. Commission: v.Commission,
  31. CommissionRate: v.CommissionRate,
  32. Discount: v.Discount,
  33. YhqPrice: v.CouponInfo.Fav,
  34. CouponPrice: v.CouponInfo.Fav,
  35. }
  36. if zhios_third_party_utils.StrToFloat64(tmp.YhqPrice) == 0 {
  37. tmp.YhqPrice = v.ExclusiveCoupon.Fav
  38. tmp.CouponPrice = v.ExclusiveCoupon.Fav
  39. }
  40. list = append(list, tmp)
  41. }
  42. return list
  43. }
  44. // 联盟在推商品列表
  45. func GoodsListWithOauth(serviceParam map[string]string, param string) []wph.WphGoods {
  46. post, _ := SendPost("com.vip.adp.api.open.service.UnionGoodsService", "goodsListWithOauth", serviceParam, param)
  47. var goods = make([]wph.OfficialGoods, 0)
  48. json.Unmarshal([]byte(gjson.Get(post, "result.goodsInfoList").String()), &goods)
  49. list := make([]wph.WphGoods, 0)
  50. for _, v := range goods {
  51. gid := v.GoodsId
  52. if v.AdCode != "" {
  53. gid = v.GoodsId + "adCode" + v.AdCode
  54. }
  55. tmp := wph.WphGoods{
  56. Gid: gid,
  57. AdCode: v.AdCode,
  58. GoodsTitle: v.GoodsName,
  59. GoodsDesc: v.GoodsDesc,
  60. GoodsImg: v.GoodsMainPicture,
  61. ImgList: v.GoodsCarouselPictures,
  62. DetailImgList: v.GoodsDetailPictures,
  63. SourceType: zhios_third_party_utils.IntToStr(v.SourceType),
  64. GoodsPrice: v.VipPrice,
  65. GoodsCostPrice: v.MarketPrice,
  66. Commission: v.Commission,
  67. CommissionRate: v.CommissionRate,
  68. Discount: v.Discount,
  69. YhqPrice: v.CouponInfo.Fav,
  70. CouponPrice: v.CouponInfo.Fav,
  71. }
  72. if zhios_third_party_utils.StrToFloat64(tmp.YhqPrice) == 0 {
  73. tmp.YhqPrice = v.ExclusiveCoupon.Fav
  74. tmp.CouponPrice = v.ExclusiveCoupon.Fav
  75. }
  76. list = append(list, tmp)
  77. }
  78. return list
  79. }
  80. func GetByGoodsIdsWithOauth(serviceParam map[string]string, param string) []wph.WphGoods {
  81. post, _ := SendPost("com.vip.adp.api.open.service.UnionGoodsService", "getByGoodsIdsWithOauth", serviceParam, param)
  82. var goods = make([]wph.OfficialGoods, 0)
  83. json.Unmarshal([]byte(gjson.Get(post, "result").String()), &goods)
  84. list := make([]wph.WphGoods, 0)
  85. for _, v := range goods {
  86. gid := v.GoodsId
  87. if v.AdCode != "" {
  88. gid = v.GoodsId + "adCode" + v.AdCode
  89. }
  90. tmp := wph.WphGoods{
  91. Gid: gid,
  92. AdCode: v.AdCode,
  93. GoodsTitle: v.GoodsName,
  94. GoodsDesc: v.GoodsDesc,
  95. GoodsImg: v.GoodsMainPicture,
  96. ImgList: v.GoodsCarouselPictures,
  97. DetailImgList: v.GoodsDetailPictures,
  98. SourceType: zhios_third_party_utils.IntToStr(v.SourceType),
  99. GoodsPrice: v.VipPrice,
  100. GoodsCostPrice: v.MarketPrice,
  101. Commission: v.Commission,
  102. CommissionRate: v.CommissionRate,
  103. Discount: v.Discount,
  104. YhqPrice: v.CouponInfo.Fav,
  105. CouponPrice: v.CouponInfo.Fav,
  106. }
  107. if zhios_third_party_utils.StrToFloat64(tmp.YhqPrice) == 0 {
  108. tmp.YhqPrice = v.ExclusiveCoupon.Fav
  109. tmp.CouponPrice = v.ExclusiveCoupon.Fav
  110. }
  111. list = append(list, tmp)
  112. }
  113. return list
  114. }