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

jd.go 1.5 KiB

1 year ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package zhimeng
  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. "encoding/json"
  6. )
  7. func JdGoods(param map[string]interface{}) []map[string]string {
  8. var goods = make([]map[string]string, 0)
  9. resp, err := Send("jd", "new_getgoods", param)
  10. if err != nil {
  11. return goods
  12. }
  13. var tmp struct {
  14. Data []md.JDZhimengItem `json:"data"`
  15. }
  16. if err = json.Unmarshal(resp, &tmp); err != nil {
  17. return goods
  18. }
  19. for _, v := range tmp.Data {
  20. var tmp = map[string]string{
  21. "img_list": zhios_third_party_utils.SerializeStr(v.ImgList),
  22. "gid": v.Gid,
  23. "title": v.GoodsTitle,
  24. "img": v.GoodsImg,
  25. "sales": zhios_third_party_utils.IntToStr(v.InOrderCount),
  26. "price": zhios_third_party_utils.Float64ToStr(v.WlGoodsPrice - float64(v.CouponPrice)),
  27. "cost_price": zhios_third_party_utils.Float64ToStr(v.PcGoodsPrice),
  28. "coupon": zhios_third_party_utils.IntToStr(v.CouponPrice),
  29. "commission_rate": zhios_third_party_utils.AnyToString(v.CommissionRate),
  30. "commission": zhios_third_party_utils.Float64ToStr((v.WlGoodsPrice - float64(v.CouponPrice)) * (zhios_third_party_utils.AnyToFloat64(v.CommissionRate) / 100)),
  31. "pvd": md.PVD_JDS,
  32. "share_content": "",
  33. }
  34. goods = append(goods, tmp)
  35. }
  36. return goods
  37. }
  38. // NewZhiMengJingDongSDK is constructor
  39. func NewZhiMengJingDongSDK() *SDK {
  40. jd := &SDK{}
  41. jd.Init(md.PVD_JDS)
  42. return jd
  43. }