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

62 lines
2.0 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. // TaoBaoSearchList is return taobao search list
  48. func (t *TB) TaoBaoFeaturedList(args map[string]string) (*[]md.TBFeatureStruct, error) {
  49. list, err := t.FeaturedList(
  50. args,
  51. )
  52. if err != nil {
  53. return nil, err
  54. }
  55. return list, nil
  56. }