1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package itao
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type addressItao struct {
}
var Address = addressItao{}
type AddressDivisionReq struct {
Province string `json:"prov,omitempty"`
City string `json:"city,omitempty"`
Area string `json:"distinct,omitempty"`
Town string `json:"town,omitempty"`
Page int `json:"pageIndex"`
Size int `json:"pageSize"`
}
type AddressDivisionRes struct {
Result struct {
Result struct {
Divisions []struct {
DivisionId int `json:"divisionId"`
DivisionLeaf bool `json:"divisionLeaf"`
DivisionToken string `json:"divisionToken"`
Level int `json:"level"`
Names struct {
EN string `json:"EN"`
CN string `json:"CN"`
} `json:"names"`
} `json:"divisions"`
PageIndex int `json:"pageIndex"`
PageSize int `json:"pageSize"`
ParentToken string `json:"parentToken"`
TotalCount int `json:"totalCount"`
TotalPage int `json:"totalPage"`
} `json:"result"`
Success bool `json:"success"`
ErrMsg string `json:"errMsg"`
ErrCode string `json:"errCode"`
} `json:"result"`
}
//Division 行政区划
func (s addressItao) Division(ctx context.Context, req AddressDivisionReq) (res *AddressDivisionRes, err error) {
method := "com.alibaba.c2m/ltao.delivery.queryDivision"
result, err := server.Post(ctx, method, g.Map{
"param": req,
})
_ = gjson.New(result).Scan(&res)
return
}
type AddressParseReq struct {
Province string `json:"prov"`
City string `json:"city"`
Detail string `json:"addressDetail"`
}
type AddressParseRes struct {
Result struct {
Result struct {
City string `json:"city"`
CityId int `json:"cityId"`
District string `json:"district"`
DistrictId int `json:"districtId"`
Prov string `json:"prov"`
ProvId int `json:"provId"`
Town string `json:"town"`
TownId int `json:"townId"`
} `json:"result"`
Success bool `json:"success"`
} `json:"result"`
}
//Parse 地址解析
// 省、市必传
func (s addressItao) Parse(ctx context.Context, req AddressParseReq) (res *AddressParseRes, err error) {
method := "com.alibaba.c2m/ltao.delivery.validate"
result, err := server.Post(ctx, method, g.Map{
"param": req,
})
_ = gjson.New(result).Scan(&res)
return
}