- dada result can not be think is map[string]interface{}.
This commit is contained in:
@@ -47,10 +47,15 @@ type DadaResult struct {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Code int `json:"code"`
|
Code int `json:"code"`
|
||||||
Msg string `json:"msg"`
|
Msg string `json:"msg"`
|
||||||
Result map[string]interface{} `json:"result"`
|
Result interface{} `json:"result"`
|
||||||
ErrorCode int `json:"errorCode"`
|
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 {
|
func NewDadaAPI(appKey, appSecret, sourceId, callbackURL string, isProd bool) *DadaAPI {
|
||||||
api := &DadaAPI{
|
api := &DadaAPI{
|
||||||
appKey: appKey,
|
appKey: appKey,
|
||||||
@@ -126,7 +131,7 @@ func (d *DadaAPI) AccessDada(action string, params map[string]interface{}) (retV
|
|||||||
}
|
}
|
||||||
|
|
||||||
if code == DadaCodeSuccess {
|
if code == DadaCodeSuccess {
|
||||||
retVal.Result = jsonResult1["result"].(map[string]interface{})
|
retVal.Result = jsonResult1["result"]
|
||||||
return common.PAErrorLevelSuccess, nil
|
return common.PAErrorLevelSuccess, nil
|
||||||
}
|
}
|
||||||
baseapi.SugarLogger.Debug(jsonResult1)
|
baseapi.SugarLogger.Debug(jsonResult1)
|
||||||
@@ -139,3 +144,21 @@ func (d *DadaAPI) AccessDada(action string, params map[string]interface{}) (retV
|
|||||||
|
|
||||||
return retVal, err
|
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"`
|
ReceiverAddress string `json:"receiver_address"`
|
||||||
ReceiverLat float64 `json:"receiver_lat"`
|
ReceiverLat float64 `json:"receiver_lat"`
|
||||||
ReceiverLng float64 `json:"receiver_lng"`
|
ReceiverLng float64 `json:"receiver_lng"`
|
||||||
|
ReceiverPhone string `json:"receiver_phone"`
|
||||||
|
ReceiverTel string `json:"receiver_tel"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateOrderResponse struct {
|
type CreateOrderResponse struct {
|
||||||
@@ -33,7 +35,7 @@ func (d *DadaAPI) QueryOrderInfo(orderId string) (retVal map[string]interface{},
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return result.Result, nil
|
return result.Result.(map[string]interface{}), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func map2CreateOrderResponse(mapData map[string]interface{}) *CreateOrderResponse {
|
func map2CreateOrderResponse(mapData map[string]interface{}) *CreateOrderResponse {
|
||||||
@@ -65,7 +67,7 @@ func (d *DadaAPI) operateOrder(action string, orderInfo *OperateOrderRequiredPar
|
|||||||
return nil, err
|
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) {
|
func (d *DadaAPI) AddOrder(orderInfo *OperateOrderRequiredParams, addParams map[string]interface{}) (retVal *CreateOrderResponse, err error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user