sfps
This commit is contained in:
@@ -40,6 +40,10 @@ type RiderRecall struct {
|
|||||||
OrderStatus int `json:"order_status"` //22-配送员撤单
|
OrderStatus int `json:"order_status"` //22-配送员撤单
|
||||||
StatusDesc string `json:"status_desc"` //状态描述
|
StatusDesc string `json:"status_desc"` //状态描述
|
||||||
PushTime int `json:"push_time"` //状态变更时间
|
PushTime int `json:"push_time"` //状态变更时间
|
||||||
|
//OperatorName string `json:"operator_name"` //配送员姓名
|
||||||
|
//OperatorPhone string `json:"operator_phone"` //配送员电话
|
||||||
|
//RiderLng string `json:"rider_lng"` //配送员位置经度
|
||||||
|
//RiderLat string `json:"rider_lat"` //配送员位置纬度
|
||||||
}
|
}
|
||||||
|
|
||||||
// OrderComplete 订单完成回调
|
// OrderComplete 订单完成回调
|
||||||
@@ -110,19 +114,53 @@ func Err2CallbackResponse(err error) *CallbackResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRiderStatusCallback 配送状态更改回调
|
// GetCallbackUrlIndex 配送状态更改回调
|
||||||
func (a *API) GetRiderStatusCallback(request *http.Request) (riderStatus *RiderStatus, response *CallbackResponse) {
|
func (a *API) GetCallbackUrlIndex(request *http.Request) (map[string]interface{}, *CallbackResponse) {
|
||||||
data, err := ioutil.ReadAll(request.Body)
|
data, err := ioutil.ReadAll(request.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
response = &CallbackResponse{ErrorCode: -1}
|
return nil, CallbackResponseErr(false)
|
||||||
return nil, response
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = json.Unmarshal(data, &riderStatus); err != nil {
|
var (
|
||||||
response = &CallbackResponse{ErrorCode: -1}
|
urlIndex = ""
|
||||||
return nil, response
|
temp = map[string]interface{}{}
|
||||||
|
)
|
||||||
|
if err = json.Unmarshal(data, &temp); err == nil {
|
||||||
|
urlIndex = temp["url_index"].(string)
|
||||||
|
fmt.Println(urlIndex)
|
||||||
}
|
}
|
||||||
return riderStatus, SuccessResponse
|
|
||||||
|
result := make(map[string]interface{}, 0)
|
||||||
|
|
||||||
|
switch urlIndex {
|
||||||
|
case UrlIndexRiderStatus:
|
||||||
|
retVal := RiderStatus{}
|
||||||
|
if err = json.Unmarshal(data, &retVal); err != nil {
|
||||||
|
return nil, CallbackResponseErr(false)
|
||||||
|
}
|
||||||
|
result[UrlIndexRiderStatus] = retVal
|
||||||
|
case UrlIndexRiderRecall:
|
||||||
|
retVal := RiderRecall{}
|
||||||
|
if err := json.Unmarshal(data, &retVal); err != nil {
|
||||||
|
return nil, CallbackResponseErr(false)
|
||||||
|
}
|
||||||
|
result[UrlIndexRiderRecall] = retVal
|
||||||
|
case UrlIndexOrderComplete:
|
||||||
|
retVal := OrderComplete{}
|
||||||
|
if err = json.Unmarshal(data, &retVal); err != nil {
|
||||||
|
return nil, CallbackResponseErr(false)
|
||||||
|
}
|
||||||
|
result[UrlIndexOrderComplete] = retVal
|
||||||
|
case UrlIndexSFCancel:
|
||||||
|
retVal := SFCancel{}
|
||||||
|
if err = json.Unmarshal(data, &retVal); err != nil {
|
||||||
|
return nil, CallbackResponseErr(false)
|
||||||
|
}
|
||||||
|
result[UrlIndexSFCancel] = retVal
|
||||||
|
default:
|
||||||
|
return nil, CallbackResponseErr(false)
|
||||||
|
}
|
||||||
|
return result, SuccessResponse
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRiderExceptionCallback 订单异常回调
|
// GetRiderExceptionCallback 订单异常回调
|
||||||
|
|||||||
@@ -96,3 +96,10 @@ func (a *API) HttpPostJson(url string, data interface{}) *Response {
|
|||||||
|
|
||||||
return &result
|
return &result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CallbackResponseErr(param bool) (callbackResponse *CallbackResponse) {
|
||||||
|
if param {
|
||||||
|
return &CallbackResponse{ErrorCode: FailCode, ErrorMsg: FailMsg}
|
||||||
|
}
|
||||||
|
return &CallbackResponse{ErrorCode: SuccessCode, ErrorMsg: SuccessMsg}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user