第三方api接口
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

goods.go 3.6 KiB

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