diff --git a/business/partner/delivery/sfps/waybill.go b/business/partner/delivery/sfps/waybill.go index 70bdd3760..635181dca 100644 --- a/business/partner/delivery/sfps/waybill.go +++ b/business/partner/delivery/sfps/waybill.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "fmt" + "io/ioutil" "net/http" "strings" "time" @@ -475,22 +476,26 @@ func pushCallbackToGy(urlIndex string, msg interface{}) { param = changeToRaw(urlIndex, msg) globals.SugarLogger.Debugf("sfsfsf pushCallbackToGy param=%s", utils.Format4Output(param, false)) - //b, err := json.Marshal(param) - // - //if err != nil { - // globals.SugarLogger.Debugf("pushCallbackToGy marshal err=%v", err) - //} + b, _ := json.Marshal(param) + switch urlIndex { case sfps2.UrlIndexRiderException: request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/SFPS/SfAbnormal", bufio.NewReader(strings.NewReader(utils.Map2URLValues(param).Encode()))) default: - request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/SFPS/SfOrder", strings.NewReader(utils.Map2URLValues(param).Encode())) + request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/SFPS/SfOrder", strings.NewReader(string(b))) } - globals.SugarLogger.Debugf("pushCallbackToGy request=%s,err=%v", utils.Format4Output(request, false), err) + + //检测request数据 + data, err := ioutil.ReadAll(request.Body) + temp := make(map[string]interface{}) + if err = json.Unmarshal(data, &temp); err == nil { + globals.SugarLogger.Debugf("pushCallbackToGy test reqData temp=%s,err=%v", utils.Format4Output(temp, false), err) + } + if err != nil { return } - request.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8") + request.Header.Set("Content-Type", "application/json;charset=UTF-8") client.Do(request) }