Bläddra i källkod

拼多多

master
huangjiajun 6 månader sedan
förälder
incheckning
d1458eaa3d
2 ändrade filer med 60 tillägg och 0 borttagningar
  1. +38
    -0
      express_select/api.go
  2. +22
    -0
      express_select/select.go

+ 38
- 0
express_select/api.go Visa fil

@@ -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
}

+ 22
- 0
express_select/select.go Visa fil

@@ -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"`
}

Laddar…
Avbryt
Spara