第三方api接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 regels
1.1 KiB

  1. package express_select
  2. import (
  3. zhios_third_party_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils"
  4. "encoding/json"
  5. "errors"
  6. "github.com/tidwall/gjson"
  7. )
  8. func Send(appcode string, param map[string]string) (*ExpressData, error) {
  9. url := "https://jmexpresv2.market.alicloudapi.com/express/query-v2"
  10. headers := map[string]string{
  11. "Authorization": "APPCODE " + appcode,
  12. }
  13. post, err := zhios_third_party_utils.CurlPost(url, param, headers)
  14. if err != nil {
  15. return nil, err
  16. }
  17. if gjson.Get(string(post), "code").Int() != 200 {
  18. return nil, errors.New(gjson.Get(string(post), "msg").String())
  19. }
  20. data := gjson.Get(string(post), "data").String()
  21. var res ExpressData
  22. json.Unmarshal([]byte(data), &res)
  23. LogisticsStatus := map[string]string{
  24. "WAIT_ACCEPT": "待揽收",
  25. "ACCEPT": "已揽收",
  26. "TRANSPORT": "运输中",
  27. "DELIVERING": "派件中",
  28. "AGENT_SIGN": "已代签收",
  29. "SIGN": "已签收",
  30. "FAILED": "包裹异常",
  31. }
  32. for k, v := range res.LogisticsTraceDetails {
  33. res.LogisticsTraceDetails[k].LogisticsStatusDesc = LogisticsStatus[v.LogisticsStatus]
  34. }
  35. return &res, nil
  36. }