12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- package sf
- import (
- "encoding/json"
- "fmt"
- "testing"
- )
- var (
- SF *Client
- )
- func init() {
- SF = NewClient("BZDLLCCSJO4F", "eaUwFnYDoUV2QKgV8j3VxrArDK55PGF7", "", true)
- }
- //func TestF查询(t *testing.T) {
- // id := []string{"SF1697391386502"}
- // dd, err := SF.F快递查询(id)
- // if err != nil {
- // fmt.Println(err.Error())
- // return
- // }
- // fmt.Println(dd)
- //
- //}
- func TestOrder(t *testing.T) {
- order := SFOrder{
- IsReturnRoutelabel: 1,
- CargoDetails: []CargoDetail{
- {Name: "苹果手机"},
- },
- ContactInfoList: []ContactInfo{
- {ContactType: ContactTypeSender, Address: "贵州省贵阳市观山湖区金融城C座", Contact: "张三丰", Mobile: "17888888888", Country: "CN"},
- {ContactType: ContactTypeConsignee, Address: "贵州省贵阳市观山湖区金融城D座", Contact: "郭襄阳", Mobile: "18963828829", Country: "CN"},
- },
- Language: "zh-CN",
- OrderId: "SF1697391386502",
- ExpressTypeId: 1,
- PayMethod: 1,
- }
- //json.Unmarshal([]byte(body), &order)
- res, err := SF.Send(EXP_RECE_CREATE_ORDER, &order)
- if err != nil {
- fmt.Println("err:", err.Error())
- return
- }
- fmt.Println("res:", res)
- }
- var (
- db = `{"apiErrorMsg":"","apiResponseID":"000186644AFEBA3F9365AD375264A03F","apiResultCode":"A1000","apiResultData":"{\"success\":true,\"errorCode\":\"S0000\",\"errorMsg\":null,\"msgData\":{\"orderId\":\"SF192961670303744\",\"originCode\":\"719\",\"destCode\":\"710\",\"filterResult\":2,\"remark\":\"\",\"url\":null,\"paymentLink\":null,\"isUpstairs\":null,\"isSpecialWarehouseService\":null,\"mappingMark\":null,\"agentMailno\":null,\"returnExtraInfoList\":null,\"waybillNoInfoList\":[{\"waybillType\":1,\"waybillNo\":\"SF7444463102821\",\"boxNo\":null,\"length\":null,\"width\":null,\"height\":null,\"weight\":null,\"volume\":null}],\"routeLabelInfo\":[{\"code\":\"1000\",\"routeLabelData\":{\"waybillNo\":\"SF7444463102821\",\"sourceTransferCode\":\"719\",\"sourceCityCode\":\"719\",\"sourceDeptCode\":\"719\",\"sourceTeamCode\":\"\",\"destCityCode\":\"710\",\"destDeptCode\":\"710BF\",\"destDeptCodeMapping\":\"\",\"destTeamCode\":\"001\",\"destTeamCodeMapping\":\"\",\"destTransferCode\":\"710\",\"destRouteLabel\":\"710BF-011\",\"proName\":\"\",\"cargoTypeCode\":\"T6\",\"limitTypeCode\":\"T6\",\"expressTypeCode\":\"B1\",\"codingMapping\":\"S47\",\"codingMappingOut\":\"\",\"xbFlag\":\"0\",\"printFlag\":\"000000000\",\"twoDimensionCode\":\"MMM={'k1':'710','k2':'710BF','k3':'001','k4':'T4','k5':'SF7444463102821','k6':'A','k7':'dd297476'}\",\"proCode\":\"T 标快\",\"printIcon\":\"00010000\",\"abFlag\":\"A\",\"destPortCode\":\"\",\"destCountry\":\"\",\"destPostCode\":\"\",\"goodsValueTotal\":\"\",\"currencySymbol\":\"\",\"cusBatch\":\"\",\"goodsNumber\":\"\",\"errMsg\":\"\",\"checkCode\":\"dd297476\",\"proIcon\":\"\",\"fileIcon\":\"\",\"fbaIcon\":\"\",\"icsmIcon\":\"\",\"destGisDeptCode\":\"710BF\",\"newIcon\":null,\"sendAreaCode\":null,\"destinationStationCode\":null,\"sxLabelDestCode\":null,\"sxDestTransferCode\":null,\"sxCompany\":null,\"newAbFlag\":null,\"destAddrKeyWord\":\"\",\"rongType\":null,\"waybillIconList\":null},\"message\":\"SF7444463102821:\"}],\"contactInfoList\":null,\"sendStartTm\":null,\"customerRights\":null,\"expressTypeId\":null}}"}`
- )
- func TestF解析(t *testing.T) {
- res := new(Response)
- if err := json.Unmarshal([]byte(db), res); err != nil {
- fmt.Println("err:", err.Error())
- return
- }
- fmt.Println("数据是:", res.ApiResultData)
- rdata := new(OrderResponse)
- if err := json.Unmarshal([]byte(res.ApiResultData), rdata); err != nil {
- fmt.Println("err:", err.Error())
- return
- }
- fmt.Printf("数据是:%+v", rdata)
- }
|