项目作者: iscod

项目描述 :
sf-express-go - an sf-express package library for Go(顺丰go包)
高级语言: Go
项目地址: git://github.com/iscod/sf-express-go.git
创建时间: 2020-05-21T07:39:56Z
项目社区:https://github.com/iscod/sf-express-go

开源协议:MIT License

下载


Go Sf-Express

Welcome to use sf-express-go

Installation

  1. go get -u -v github.com/IsCod/sf-express-go

Quickstart

  1. package main
  2. import (
  3. "fmt"
  4. "math/rand"
  5. sfexpress "sf-express-go"
  6. "time"
  7. )
  8. func main() {
  9. c := sfexpress.Config{CheckWord: "FBIqMkZjzxbsZgo7jTpeq7PD8CVzLT4Q", ClientCode: "NTL", Custid: "7553032834"}
  10. orderId := "SF-" + time.Now().Format("20060102150405") + string(rand.Intn(100))
  11. //order push
  12. o, err := c.Order(sfexpress.Order{
  13. OrderId: orderId,
  14. ExpressType: 1,
  15. PayMethod: 1,
  16. JCompany: "顺丰镖局",
  17. JContact: "虾哥",
  18. JTel: "15012345678",
  19. JMobile: "",
  20. JProvince: "广东省",
  21. JCity: "深圳市",
  22. JCounty: "南山区",
  23. JAddress: "福田区新洲十一街万基商务大厦26楼",
  24. DCompany: "顺丰镖局",
  25. DContact: "虾哥",
  26. DTel: "15012345678",
  27. DMobile: "",
  28. DProvince: "广东省",
  29. DCity: "深圳市",
  30. DCounty: "南山区",
  31. DAddress: "福田区新洲十一街万基商务大厦26楼",
  32. AddedService: sfexpress.AddedService{
  33. Name: "COD",
  34. Value: "1.01",
  35. },
  36. Cargo: "iphone x",
  37. })
  38. if err != nil {
  39. fmt.Printf("❌ Push: %s\n", err.Error())
  40. } else {
  41. fmt.Printf("✅ Push: orderId: %s, MailNo: %s\n", o.OrderId, o.MailNo)
  42. }
  43. //order query
  44. order, err := c.OrderQuery(sfexpress.OrderSearch{OrderId: o.OrderId, SearchType: 1})
  45. if err != nil {
  46. fmt.Printf("❌ query: %s\n", err)
  47. } else {
  48. fmt.Printf("✅ query: orderId: %s, MailNo: %s\n", order.OrderId, order.MailNo)
  49. }
  50. //order confirm&cancel
  51. oc, err := c.OrderConfirm(sfexpress.OrderConfirm{OrderId: o.OrderId, DealType: "2"})
  52. if err != nil {
  53. fmt.Printf("❌ Confirm: %s\n", err)
  54. } else {
  55. fmt.Printf("✅ Confirm: orderId: %s, ResStatus: %d\n", oc.OrderId, oc.ResStatus)
  56. }
  57. //route Query By OrderNo
  58. oro, err := c.OrderRouteService(sfexpress.RouteRequest{TrackingType: 1, TrackingNumber: o.MailNo})
  59. if err != nil {
  60. fmt.Printf("❌ RouteQueryByOrderNo: %s", err)
  61. } else {
  62. for _, i := range oro {
  63. fmt.Printf("✅ RouteQueryByOrderNo: orderId: %s, MailNo: %s, %v", i.OrderId, i.MailNo, i.Route)
  64. }
  65. }
  66. }

Development

TODO:

Contributing

License

The sf-express-go is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the SfExpress project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.