This commit is contained in:
邹宗楠
2025-02-10 15:55:29 +08:00
parent 4bcb684bee
commit 07850d895e
6 changed files with 67 additions and 15 deletions

View File

@@ -218,7 +218,7 @@ func (a *API) CheckCallbackValidation(cmd string, params url.Values) (callbackRe
return nil
}
func (a *API) GetCallbackMsg(request *http.Request) (msg *CallbackMsg, callbackResponse *CallbackResponse) {
func (a *API) GetCallbackMsg(request *http.Request, runModel string) (msg *CallbackMsg, callbackResponse *CallbackResponse) {
err := request.ParseForm()
if err == nil {
params := make(url.Values)
@@ -228,9 +228,12 @@ func (a *API) GetCallbackMsg(request *http.Request) (msg *CallbackMsg, callbackR
}
msg = new(CallbackMsg)
msg.Cmd = GetCmd(request)
if callbackResponse = a.CheckCallbackValidation(msg.Cmd, params); callbackResponse != nil {
return nil, callbackResponse
if runModel == "prod" {
if callbackResponse = a.CheckCallbackValidation(msg.Cmd, params); callbackResponse != nil {
return nil, callbackResponse
}
}
if callbackResponse = a.unmarshalData(msg.Cmd, []byte(params.Get("body")), &msg.Body); callbackResponse != nil {
return nil, callbackResponse
}

View File

@@ -31,3 +31,52 @@ func TestPictureUpload(t *testing.T) {
t.Log(utils.Format4Output(result, false))
}
}
//
//func TestEbaiSend(t *testing.T) {
// obj := map[string]interface{}{
// "ticket": "32F4FD45-3981-4092-98B7-94AEC67AC458",
// "encrypt": "",
// "sign": "417580BA8AED5C891F7629F5B37899E2",
// "cmd": "order.create",
// "source": "34665",
// "body": map[string]interface{}{
// "order_id": "4061626013391868494",
// "platform_shop_id": "1257061574",
// },
// "version": "3",
// "timestamp": 1739110519,
// }
// msgBody, _ := json.Marshal(obj["body"])
// obj["body"] = string(msgBody)
//
// EBaiMsgPush2FruitsOrPet("jxpet", obj)
//}
//
//func EBaiMsgPush2FruitsOrPet(serverType string, msg map[string]interface{}) *CallbackResponse {
// cl := http.Client{}
// var request *http.Request
// var err error
// switch serverType {
// case "":
// request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/ebai/msg", strings.NewReader(utils.Map2URLValues(msg).Encode()))
// case "jxpet":
// request, err = http.NewRequest(http.MethodPost, "http://localhost:8080/ebai/msg", strings.NewReader(utils.Map2URLValues(msg).Encode()))
// }
// if err != nil {
// return api.Err2CallbackResponse("status.push", err, nil)
// }
//
// request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
// request.Header.Set("accept", "application/json, text/plain, */*")
// resp, err := cl.Do(request)
// if err != nil {
// return api.Err2CallbackResponse("status.push", err, nil)
// }
// defer resp.Body.Close()
// byteData, _ := ioutil.ReadAll(resp.Body)
// result := CallbackResponse{}
// json.Unmarshal(byteData, &result)
//
// return &result
//}