This commit is contained in:
richboo111
2024-01-10 11:23:08 +08:00
parent c608c2cdba
commit 935bc9f76d

View File

@@ -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)
}