- dada result can not be think is map[string]interface{}.
This commit is contained in:
@@ -44,11 +44,16 @@ type DadaAPI struct {
|
||||
}
|
||||
|
||||
type DadaResult struct {
|
||||
Status string `json:"status"`
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Result map[string]interface{} `json:"result"`
|
||||
ErrorCode int `json:"errorCode"`
|
||||
Status string `json:"status"`
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Result interface{} `json:"result"`
|
||||
ErrorCode int `json:"errorCode"`
|
||||
}
|
||||
|
||||
type DadaCity struct {
|
||||
CityName string `json:"cityName"`
|
||||
CityCode string `json:"cityCode"`
|
||||
}
|
||||
|
||||
func NewDadaAPI(appKey, appSecret, sourceId, callbackURL string, isProd bool) *DadaAPI {
|
||||
@@ -126,7 +131,7 @@ func (d *DadaAPI) AccessDada(action string, params map[string]interface{}) (retV
|
||||
}
|
||||
|
||||
if code == DadaCodeSuccess {
|
||||
retVal.Result = jsonResult1["result"].(map[string]interface{})
|
||||
retVal.Result = jsonResult1["result"]
|
||||
return common.PAErrorLevelSuccess, nil
|
||||
}
|
||||
baseapi.SugarLogger.Debug(jsonResult1)
|
||||
@@ -139,3 +144,21 @@ func (d *DadaAPI) AccessDada(action string, params map[string]interface{}) (retV
|
||||
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
func (d *DadaAPI) GetCities() (retVal []DadaCity, err error) {
|
||||
result, err := d.AccessDada("api/cityCode/list", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cites := result.Result.([]interface{})
|
||||
for _, v := range cites {
|
||||
v2 := v.(map[string]interface{})
|
||||
city := DadaCity{
|
||||
CityName: v2["cityName"].(string),
|
||||
CityCode: v2["cityCode"].(string),
|
||||
}
|
||||
retVal = append(retVal, city)
|
||||
}
|
||||
return retVal, nil
|
||||
}
|
||||
|
||||
@@ -15,6 +15,8 @@ type OperateOrderRequiredParams struct {
|
||||
ReceiverAddress string `json:"receiver_address"`
|
||||
ReceiverLat float64 `json:"receiver_lat"`
|
||||
ReceiverLng float64 `json:"receiver_lng"`
|
||||
ReceiverPhone string `json:"receiver_phone"`
|
||||
ReceiverTel string `json:"receiver_tel"`
|
||||
}
|
||||
|
||||
type CreateOrderResponse struct {
|
||||
@@ -33,7 +35,7 @@ func (d *DadaAPI) QueryOrderInfo(orderId string) (retVal map[string]interface{},
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result.Result, nil
|
||||
return result.Result.(map[string]interface{}), nil
|
||||
}
|
||||
|
||||
func map2CreateOrderResponse(mapData map[string]interface{}) *CreateOrderResponse {
|
||||
@@ -65,7 +67,7 @@ func (d *DadaAPI) operateOrder(action string, orderInfo *OperateOrderRequiredPar
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return map2CreateOrderResponse(result.Result), nil
|
||||
return map2CreateOrderResponse(result.Result.(map[string]interface{})), nil
|
||||
}
|
||||
|
||||
func (d *DadaAPI) AddOrder(orderInfo *OperateOrderRequiredParams, addParams map[string]interface{}) (retVal *CreateOrderResponse, err error) {
|
||||
|
||||
Reference in New Issue
Block a user