From d1458eaa3d141dc70f4e43c4f3061bc36ce99c6d Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Tue, 28 May 2024 18:38:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=BC=E5=A4=9A=E5=A4=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- express_select/api.go | 38 ++++++++++++++++++++++++++++++++++++++ express_select/select.go | 22 ++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 express_select/api.go create mode 100644 express_select/select.go diff --git a/express_select/api.go b/express_select/api.go new file mode 100644 index 0000000..591b4aa --- /dev/null +++ b/express_select/api.go @@ -0,0 +1,38 @@ +package express_select + +import ( + zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils" + "encoding/json" + "errors" + "github.com/tidwall/gjson" +) + +func Send(appcode string, param map[string]string) (*ExpressData, error) { + url := "https://jmexpresv2.market.alicloudapi.com/express/query-v2" + headers := map[string]string{ + "Authorization": "APPCODE " + appcode, + } + post, err := zhios_third_party_utils.CurlPost(url, param, headers) + if err != nil { + return nil, err + } + if gjson.Get(string(post), "code").Int() != 200 { + return nil, errors.New(gjson.Get(string(post), "msg").String()) + } + data := gjson.Get(string(post), "data").String() + var res ExpressData + json.Unmarshal([]byte(data), &res) + LogisticsStatus := map[string]string{ + "WAIT_ACCEPT": "待揽收", + "ACCEPT": "已揽收", + "TRANSPORT": "运输中", + "DELIVERING": "派件中", + "AGENT_SIGN": "已代签收", + "SIGN": "已签收", + "FAILED": "包裹异常", + } + for k, v := range res.LogisticsTraceDetails { + res.LogisticsTraceDetails[k].LogisticsStatusDesc = LogisticsStatus[v.LogisticsStatus] + } + return &res, nil +} diff --git a/express_select/select.go b/express_select/select.go new file mode 100644 index 0000000..4e43279 --- /dev/null +++ b/express_select/select.go @@ -0,0 +1,22 @@ +package express_select + +type ExpressData struct { + ExpressCode string `json:"expressCode"` + ExpressCompanyName string `json:"expressCompanyName"` + ExpressCompanyLogo string `json:"expressCompanyLogo"` + Number string `json:"number"` + LogisticsStatus string `json:"logisticsStatus"` + LogisticsStatusDesc string `json:"logisticsStatusDesc"` + TheLastMessage string `json:"theLastMessage"` + TheLastTime string `json:"theLastTime"` + TakeTime string `json:"takeTime"` + LogisticsTraceDetails []struct { + AreaCode string `json:"areaCode"` + AreaName string `json:"areaName"` + SubLogisticsStatus string `json:"subLogisticsStatus"` + Time int64 `json:"time"` + LogisticsStatus string `json:"logisticsStatus"` + LogisticsStatusDesc string `json:"logisticsStatusDesc"` + Desc string `json:"desc"` + } `json:"logisticsTraceDetails"` +}