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

99 lines
3.5 KiB

  1. package taobao
  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. "xorm.io/xorm"
  6. )
  7. //TaoBaoArgs is args
  8. type TaoBaoArgs struct {
  9. Keyword string
  10. PageIndex string
  11. PageSize string
  12. Sort string
  13. StartPrice string
  14. EndPrice string
  15. IsTmall string
  16. IsCoupon string
  17. StartCommissionRate string
  18. EndCommissionRate string
  19. }
  20. func TaoBaoFeaturedList(eg *xorm.Engine, dbName, Platform string, AccTaobaoShareId int, postData map[string]string) []map[string]string {
  21. var goods = make([]map[string]string, 0)
  22. sdk, err := NewTaobaoSDK(eg, dbName, Platform, AccTaobaoShareId)
  23. if err != nil {
  24. return goods
  25. }
  26. list, err := sdk.TaoBaoFeaturedList(postData)
  27. if list != nil {
  28. for _, v := range *list {
  29. var tmp = map[string]string{
  30. "gid": zhios_third_party_utils.AnyToString(v.ItemID),
  31. "title": v.Title,
  32. "img": v.PictURL,
  33. "sales": zhios_third_party_utils.IntToStr(v.Volume),
  34. "price": zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(v.ZkFinalPrice) - float64(v.CouponAmount)),
  35. "cost_price": v.ZkFinalPrice,
  36. "coupon": zhios_third_party_utils.IntToStr(v.CouponAmount),
  37. "commission_rate": zhios_third_party_utils.AnyToString(zhios_third_party_utils.StrToFloat64(v.CommissionRate) / 100),
  38. "commission": zhios_third_party_utils.Float64ToStr((zhios_third_party_utils.StrToFloat64(v.ZkFinalPrice) - float64(v.CouponAmount)) * (zhios_third_party_utils.StrToFloat64(v.CommissionRate) / 100 / 100)),
  39. "pvd": md.PVD_TB,
  40. "share_content": "",
  41. }
  42. goods = append(goods, tmp)
  43. }
  44. }
  45. return goods
  46. }
  47. func TaoBaoSearchList(eg *xorm.Engine, dbName, Platform string, AccTaobaoShareId int, postData map[string]string) []map[string]string {
  48. var goods = make([]map[string]string, 0)
  49. sdk, err := NewTaobaoSDK(eg, dbName, Platform, AccTaobaoShareId)
  50. if err != nil {
  51. return goods
  52. }
  53. list, err := sdk.TaoBaoSearchList(postData)
  54. if list != nil {
  55. for _, v := range *list {
  56. var tmp = map[string]string{
  57. "gid": zhios_third_party_utils.AnyToString(v.ItemID),
  58. "title": v.Title,
  59. "img": v.PictURL,
  60. "sales": zhios_third_party_utils.IntToStr(v.Volume),
  61. "price": zhios_third_party_utils.Float64ToStr(zhios_third_party_utils.StrToFloat64(v.ZkFinalPrice) - zhios_third_party_utils.StrToFloat64(v.CouponAmount)),
  62. "cost_price": v.ZkFinalPrice,
  63. "coupon": v.CouponAmount,
  64. "commission_rate": zhios_third_party_utils.AnyToString(zhios_third_party_utils.StrToFloat64(v.CommissionRate) / 100),
  65. "commission": zhios_third_party_utils.Float64ToStr((zhios_third_party_utils.StrToFloat64(v.ZkFinalPrice) - zhios_third_party_utils.StrToFloat64(v.CouponAmount)) * (zhios_third_party_utils.StrToFloat64(v.CommissionRate) / 100 / 100)),
  66. "pvd": md.PVD_TB,
  67. "share_content": "",
  68. }
  69. goods = append(goods, tmp)
  70. }
  71. }
  72. return goods
  73. }
  74. // TaoBaoSearchList is return taobao search list
  75. func (t *TB) TaoBaoFeaturedList(args map[string]string) (*[]md.TBFeatureStruct, error) {
  76. list, err := t.FeaturedList(
  77. args,
  78. )
  79. if err != nil {
  80. return nil, err
  81. }
  82. return list, nil
  83. }
  84. func (t *TB) TaoBaoSearchList(args map[string]string) (*[]Material, error) {
  85. list, err := t.SearchList(
  86. args,
  87. )
  88. if err != nil {
  89. return nil, err
  90. }
  91. return list, nil
  92. }