Documentation ¶
Index ¶
- Constants
- Variables
- type CallbackData
- type CallbackRequestData
- type CallbackRequestDataDetail
- type CallbackResp
- type Coordinates
- type DetailState
- type Express
- func (express *Express) AnalyticalTrackPushData(data string) (*TrackSubPushRequest, error)
- func (express *Express) Provide(ctx context.Context) interface{}
- func (express *Express) Query(response *QueryResponse) (*QueryResponse, error)
- func (express *Express) QueryByShipperCode(req *QueryRequest) (*QueryResponse, error)
- func (express *Express) TrackSubscription(req *TrackSubscriptionRequest) (*TrackSubscriptionResponse, error)
- func (express *Express) TrackSubscriptionResponse(status bool, reason string) *TrackSubPushResponse
- func (express *Express) Verify(reqData, sign string) error
- type IExpress
- type MapPushTrackData
- type MapTrackData
- type MapTrackSubPushRequest
- type Option
- type Options
- type PreCoordinates
- type PushTrackData
- type QueryExpressRequest
- type QueryExpressResponse
- type QueryRequest
- type QueryResponse
- type Receiver
- type Request
- type RequestData
- type Sender
- type ShipperCode
- type Traces
- type TrackData
- type TrackDataTrace
- type TrackSubPushRequest
- type TrackSubPushResponse
- type TrackSubscriptionRequest
- type TrackSubscriptionResponse
Constants ¶
const ( HTKY ShipperCode = "HTKY" // 百世快递 ZTO = "ZTO" // 中通 STO = "STO" // 申通 YTO = "YTO" // 圆通 YD = "YD" // 韵达 YZPY = "YZPY" // 邮政快递包裹 EMS = "EMS" // EMS SF = "SF" // 顺丰 JD = "JD" // 京东快递 UC = "UC" // 优速快递 DBL = "DBL" // 德邦快递 JTSD = "JTSD" // 极兔快递 ZYE = "ZYE" // 众邮快递 ZJS = "ZJS" // 宅急送 FWX = "FWX" // 丰网速运 )
const ( NoTrackInfo DetailState = 0 // 暂无轨迹信息 Picked = 1 // 已揽收 OnTheWay = 2 // 在途中 ArriveCity = 201 // 到达派件城市 ArriveTransitCenter = 204 // 到达转运中心 ArrivePoint = 205 // 到达派件网点 SendingPoint = 206 // 寄件网点发件 Dispatching = 202 // 派件中 PlacedCabinet = 211 // 已放入快递柜或驿站 Received = 3 // 已签收 NormalReceived = 301 // 正常签收 AbnormalReceived = 302 // 派件异常后最终签收 BehalfReceived = 304 // 代收签收 ParcelLockerReceived = 311 // 快递柜或驿站签收 Abnormal = 4 // 问题件 NoShippingInfo = 401 // 发货无信息 ExpirationNotSigned = 402 // 超时未签收 UpdatedExpiration = 403 // 超时未更新 Rejected = 404 // 拒收(退件) DeliveryAnomaly = 405 // 派件异常 ReturnReceipt = 406 // 退货签收 ReturnNotReceived = 407 // 退货未签收 PickupOverdue = 412 // 快递柜或驿站超时未取 Intercepted = 413 // 单号已拦截 Damaged = 414 // 破损 CustomerCancelled = 415 // 客户取消发货 UnableContact = 416 // 无法联系 DeliveryDelay = 417 // 配送延迟 TakenOut = 418 // 快件取出 Redeliver = 419 // 重新派送 ReceivedAddrNotDetailed = 420 // 收货地址不详细 RecipientPhoneIncorrect = 421 // 收件人电话错误 MisroutedParcel = 422 // 错分件 OutZone = 423 // 超区件 Forwarded = 5 // 转寄 CustomsClearance = 6 // 清关 WaitCustomsClearance = 601 // 待清关 InCustomsClearance = 602 // 清关中 ClearedCustoms = 603 // 已清关 CustomsClearanceException = 604 // 清关异常 AwaitingPickup = 10 // 待揽件 )
Variables ¶
var ExStateMap = map[DetailState]string{ NoTrackInfo: " 暂无轨迹信息", Picked: " 已揽收", OnTheWay: " 在途中", ArriveCity: " 到达派件城市", ArriveTransitCenter: " 到达转运中心", ArrivePoint: " 到达派件网点", SendingPoint: " 寄件网点发件", Dispatching: " 派件中", PlacedCabinet: " 已放入快递柜或驿站", Received: " 已签收", NormalReceived: " 正常签收", AbnormalReceived: " 派件异常后最终签收", BehalfReceived: " 代收签收", ParcelLockerReceived: " 快递柜或驿站签收", Abnormal: " 问题件", NoShippingInfo: " 发货无信息", ExpirationNotSigned: " 超时未签收", UpdatedExpiration: " 超时未更新", Rejected: " 拒收(退件)", DeliveryAnomaly: " 派件异常", ReturnReceipt: " 退货签收", ReturnNotReceived: " 退货未签收", PickupOverdue: " 快递柜或驿站超时未取", Intercepted: " 单号已拦截", Damaged: " 破损", CustomerCancelled: " 客户取消发货", UnableContact: " 无法联系", DeliveryDelay: " 配送延迟", TakenOut: " 快件取出", Redeliver: " 重新派送", ReceivedAddrNotDetailed: " 收货地址不详细", RecipientPhoneIncorrect: " 收件人电话错误", MisroutedParcel: " 错分件", OutZone: " 超区件", Forwarded: " 转寄", CustomsClearance: " 清关", WaitCustomsClearance: " 待清关", InCustomsClearance: " 清关中", ClearedCustoms: " 已清关", CustomsClearanceException: " 清关异常", AwaitingPickup: " 待揽件", }
ExStateMap 快递状态码对应的描述
Functions ¶
This section is empty.
Types ¶
type CallbackData ¶
type CallbackData struct { CallbackRequestData DataSign string `json:"data_sign"` RequestType string `json:"request_type"` }
type CallbackRequestData ¶
type CallbackRequestData struct { PushTime string `json:"push_time"` EBusinessID string `json:"e_business_id"` CallbackRequestDataDetail Count string `json:"count"` }
type CallbackRequestDataDetail ¶
type CallbackRequestDataDetail struct { StateEx string `json:"state_ex"` LogisticCode string `json:"logistic_code"` ShipperCode string `json:"shipper_code"` Traces []*Traces State string `json:"state"` NextCity string `json:"next_city"` OrderCode string `json:"order_code"` EBusinessID string `json:"e_business_id"` Success bool `json:"success"` Location string `json:"location"` }
type CallbackResp ¶
type Coordinates ¶
type Coordinates struct { Location string `json:"Location,omitempty"` // 当前城市 LatAndLng string `json:"LatAndLng,omitempty"` // 当前城市经纬度 }
Coordinates 轨迹推送(地图)经纬度
type DetailState ¶
type DetailState int
DetailState 快递细分状态 https://www.yuque.com/kdnjishuzhichi/weubcu/cti4czvp8hnatgue
type Express ¶
type Express struct {
Options *Options
}
func (*Express) AnalyticalTrackPushData ¶
func (express *Express) AnalyticalTrackPushData(data string) (*TrackSubPushRequest, error)
AnalyticalTrackPushData 解析轨迹推送数据 https://www.yuque.com/kdnjishuzhichi/dfcrg1/tx5q8r#JRGGr
func (*Express) Query ¶
func (express *Express) Query(response *QueryResponse) (*QueryResponse, error)
Query 即时查询(增值版) https://www.yuque.com/kdnjishuzhichi/dfcrg1/yv7zgv#JRGGr 通过运单号查询,不需要传 ShipperCode,但是需要传 LogisticCode,即运单号。并且按次数计费。
func (*Express) QueryByShipperCode ¶
func (express *Express) QueryByShipperCode(req *QueryRequest) (*QueryResponse, error)
QueryByShipperCode 即时查询(增值版) https://www.yuque.com/kdnjishuzhichi/dfcrg1/yv7zgv#JRGGr 通过快递公司编码查询,需要传 ShipperCode,LogisticCode。并且按单计费。
func (*Express) TrackSubscription ¶
func (express *Express) TrackSubscription(req *TrackSubscriptionRequest) (*TrackSubscriptionResponse, error)
TrackSubscription 轨迹订阅(增值版) https://www.yuque.com/kdnjishuzhichi/dfcrg1/qkzowx#TYqFA
func (*Express) TrackSubscriptionResponse ¶
func (express *Express) TrackSubscriptionResponse(status bool, reason string) *TrackSubPushResponse
TrackSubscriptionResponse 轨迹订阅推送请求响应 https://www.yuque.com/kdnjishuzhichi/dfcrg1/qkzowx#TYqFA
type IExpress ¶
type IExpress interface { QueryByShipperCode(req *QueryRequest) (*QueryResponse, error) // 即时查询 Query(response *QueryResponse) (*QueryResponse, error) // 快递查询 TrackSubscription(req *TrackSubscriptionRequest) (*TrackSubscriptionResponse, error) // 轨迹订阅 TrackSubscriptionResponse(status bool, reason string) *TrackSubPushResponse // 轨迹订阅推送请求响应 AnalyticalTrackPushData(data string) (*TrackSubPushRequest, error) // 解析轨迹推送数据 Verify(reqData, sign string) error // 验证推送数据 }
type MapPushTrackData ¶
type MapPushTrackData struct { EBusinessID string `json:"EBusinessID"` // 用户ID PushTime string `json:"PushTime"` // 推送时间 Data []*MapTrackData `json:"Data"` // 轨迹数据集合 Count string `json:"Count"` // 轨迹个数 }
MapPushTrackData 轨迹(地图)推送数据
type MapTrackData ¶
type MapTrackData struct { TrackData // 轨迹地图推送数据字段 ReceiverCityLatAndLng string `json:"ReceiverCityLatAndLng"` // 收件人城市经纬度 SenderCityLatAndLng string `json:"SenderCityLatAndLng"` // 寄件人城市经纬度 Coordinates *Coordinates `json:"Coordinates,omitempty"` // 当前城市经纬度 PreCoordinates *PreCoordinates `json:"PreCoordinates,omitempty"` // 预设路径经纬度 RouteMapUrl string `json:"RouteMapUrl,omitempty"` // 轨迹地图URL }
type MapTrackSubPushRequest ¶
type MapTrackSubPushRequest struct { RequestData *MapPushTrackData `json:"RequestData"` // 请求参数 DataSign string `json:"DataSign"` // 数据签名 RequestType string `json:"RequestType"` // 请求类型 }
MapTrackSubPushRequest 轨迹订阅(地图)推送请求参数
type Option ¶
type Option func(o *Options)
func WithAppKey ¶
func WithBaseURL ¶
func WithDataType ¶
func WithEBusinessID ¶
func WithRequestType ¶
type PreCoordinates ¶
type PreCoordinates struct { Location string `json:"Location,omitempty"` // 预设路径经过城市 LatAndLng string `json:"LatAndLng,omitempty"` // 预设路径城市经纬度 }
PreCoordinates 轨迹推送(地图)预设路径经纬度
type PushTrackData ¶
type PushTrackData struct { EBusinessID string `json:"EBusinessID"` // 用户ID PushTime string `json:"PushTime"` // 推送时间 Data []*TrackData `json:"Data"` // 轨迹数据集合 Count string `json:"Count"` // 轨迹个数 }
PushTrackData 轨迹推送数据
type QueryExpressRequest ¶
type QueryExpressRequest struct { RequestData EBusinessID string `json:"e_business_id"` RequestType string `json:"request_type"` DataType string `json:"data_type"` DataSign string `json:"data_sign"` }
type QueryExpressResponse ¶
type QueryExpressResponse struct { EBusinessID string `json:"e_business_id"` ShipperCode string `json:"shipper_code"` Success bool `json:"success"` LogisticCode string `json:"logistic_code"` State string `json:"state"` StateEx string `json:"state_ex"` Location string `json:"location"` Traces []*Traces `json:"traces"` Raw string `json:"raw"` }
type QueryRequest ¶
type QueryRequest struct { CustomerName *string `json:"CustomerName,omitempty"` // 顺丰必填 需要寄件人/收件人的手机号后四位 ShipperCode *ShipperCode `json:"ShipperCode"` // 快递公司编码 LogisticCode *string `json:"LogisticCode"` // 快递单号 Sort *int `json:"Sort,omitempty"` // 排序方式:0-升序(默认),1-降序 OrderCode *string `json:"OrderCode,omitempty"` // 订单编号 }
QueryRequest 快递鸟查询单号请求参数 参考文档:https://www.yuque.com/kdnjishuzhichi/dfcrg1/yv7zgv
type QueryResponse ¶
type QueryResponse struct { EBusinessID string `json:"EBusinessID"` // 用户ID ShipperCode string `json:"ShipperCode"` // 快递公司编码 LogisticCode string `json:"LogisticCode"` // 快递单号 Success bool `json:"Success"` // 成功与否 true/false Reason string `json:"Reason"` // 失败原因 State string `json:"State"` // 物流状态 0-暂无轨迹信息,1-已揽收,2-在途中,3-签收,4-问题件,5-转寄,6-清关 StateEx DetailState `json:"StateEx"` // 物流状态的细分状态 Location string `json:"Location"` // 快递当前城市 Traces []*Traces `json:"Traces"` // 物流轨迹 OrderCode string `json:"OrderCode,omitempty"` // 订单编号 Callback string `json:"Callback,omitempty"` // 用户自定义回传字段 Station string `json:"Station,omitempty"` // 派件网点的名称 StationTel string `json:"StationTel,omitempty"` // 派件网点的电话 StationAdd string `json:"StationAdd,omitempty"` // 派件网点的地址 DeliveryMan string `json:"DeliveryMan,omitempty"` // 派件员姓名 DeliveryManTel string `json:"DeliveryManTel,omitempty"` // 派件员电话 NextCity string `json:"NextCity,omitempty"` // 下一站城市 }
QueryResponse 快递鸟查询单号响应参数
type Receiver ¶
type Receiver struct { Company string `json:"Company"` // 收件人公司 Name string `json:"Title"` // 收件人 Tel string `json:"Tel"` // 收件人电话 Mobile string `json:"Mobile"` // 收件人手机 与电话号码二选一 ProvinceName string `json:"ProvinceName"` // 收件人省份 CityName string `json:"CityName"` // 收件人城市 ExpAreaName string `json:"ExpAreaName"` // 收件人区域 Address string `json:"Address"` // 收件人详细地址 }
Receiver 收件人信息
type Request ¶
type Request struct { Data interface{} `json:"-"` // 请求原始参数 RequestData string `json:"RequestData"` // 请求内容需进行URL(utf-8)编码。请求内容JSON格式,须和DataType一致。 EBusinessID string `json:"EBusinessID"` // 用户ID DataType string `json:"DataType"` // 请求、返回数据类型:2-json(固定为2); DataSign string `json:"DataSign"` // 数据内容签名:把(请求内容(未编码)+ApiKey)进行MD5加密,然后Base64编码,最后进行URL(utf-8)编码 RequestType string `json:"RequestType"` // 请求指令类型:1002-轨迹即时查询 }
func (*Request) ToUrlValues ¶
type RequestData ¶
type Sender ¶
type Sender struct { Company string `json:"Company"` // 寄件人公司 Name string `json:"Title"` // 寄件人 Tel string `json:"Tel"` // 寄件人电话 Mobile string `json:"Mobile"` // 寄件人手机 与电话号码二选一 ProvinceName string `json:"ProvinceName"` // 寄件人省份 CityName string `json:"CityName"` // 寄件人城市 ExpAreaName string `json:"ExpAreaName"` // 寄件人区域 Address string `json:"Address"` // 寄件人详细地址 }
Sender 寄件人信息
type ShipperCode ¶
type ShipperCode string
ShipperCode 快递公司编码,支持常用快递公司,具体参考快递鸟官网 https://www.yuque.com/kdnjishuzhichi/dfcrg1/mza2ln
type Traces ¶
type Traces struct { AcceptTime string `json:"AcceptTime"` // 轨迹发生事件 AcceptStation string `json:"AcceptStation"` // 轨迹描述 Location string `json:"Location"` // 轨迹发生城市 Action DetailState `json:"Action"` // 轨迹操作 通 StateEx 字段 Remark string `json:"Remark"` // 备注 }
Traces 快递轨迹
type TrackData ¶
type TrackData struct { // 基础数据字段 EBusinessID string `json:"EBusinessID"` // 用户ID ShipperCode string `json:"ShipperCode"` // 快递公司编码 LogisticCode string `json:"LogisticCode"` // 快递单号 Success bool `json:"Success"` // 成功与否 Reason string `json:"Reason,omitempty"` // 失败原因 OrderCode string `json:"OrderCode,omitempty"` // 订单编号 State string `json:"State"` // 物流状态 StateEx string `json:"StateEx"` // 物流状态的细分状态 Location string `json:"Location,omitempty"` // 快递当前城市 Callback string `json:"Callback,omitempty"` // 用户自定义回传字段 Traces []*TrackDataTrace `json:"Traces"` // 物流轨迹 Station string `json:"Station,omitempty"` // 派件网点的名称 StationTel string `json:"StationTel,omitempty"` // 派件网点的电话 StationAdd string `json:"StationAdd,omitempty"` // 派件网点的地址 DeliveryManTel string `json:"DeliveryManTel,omitempty"` // 派件员电话 DeliveryMan string `json:"DeliveryMan,omitempty"` // 派件员姓名 NextCity string `json:"NextCity,omitempty"` // 下一站城市 }
TrackData 轨迹数据集合
type TrackDataTrace ¶
type TrackDataTrace struct { AcceptTime string `json:"AcceptTime"` // 轨迹发生时间 AcceptStation string `json:"AcceptStation"` // 轨迹描述 Location string `json:"Location,omitempty"` // 轨迹发生城市 Action DetailState `json:"Action"` // 轨迹操作 Remark string `json:"Remark,omitempty"` // 备注 }
TrackDataTrace 轨迹数据
type TrackSubPushRequest ¶
type TrackSubPushRequest struct { RawRequestData string `json:"-"` // 原始数据 RequestData *PushTrackData `json:"RequestData"` // 请求参数 DataSign string `json:"DataSign"` // 数据签名 RequestType string `json:"RequestType"` // 请求类型 }
TrackSubPushRequest 轨迹订阅推送请求参数
type TrackSubPushResponse ¶
type TrackSubPushResponse struct { EBusinessID string `json:"EBusinessID"` // 用户ID UpdateTime string `json:"UpdateTime"` // 更新时间 Success bool `json:"Success"` // 成功与否 true/false Reason string `json:"Reason,omitempty"` // 失败原因 }
TrackSubPushResponse 轨迹订阅推送响应参数 https://www.yuque.com/kdnjishuzhichi/dfcrg1/meiubz#o8ytn
type TrackSubscriptionRequest ¶
type TrackSubscriptionRequest struct { ShipperCode ShipperCode `json:"ShipperCode"` // 快递公司编码 LogisticCode string `json:"LogisticCode"` // 快递单号 CustomerName string `json:"CustomerName,omitempty"` // 顺丰必填 需要寄件人/收件人的手机号后四位 Sort int `json:"Sort,omitempty"` // 排序方式:0-升序(默认),1-降序 OrderCode string `json:"OrderCode,omitempty"` // 订单编号 Callback string `json:"Callback,omitempty"` // 用户自定义回传字段 Receiver *Receiver `json:"Receiver,omitempty"` // 收件人信息 Sender *Sender `json:"Sender,omitempty"` // 寄件人信息 IsSendMessage bool `json:"IsSendMessage,omitempty"` // 是否订阅短信通知 0-不需要,1-需要 }
TrackSubscriptionRequest 轨迹订阅请求参数 参考文档: https://www.yuque.com/kdnjishuzhichi/dfcrg1/qkzowx