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