This commit is contained in:
邹宗楠
2025-02-11 16:09:19 +08:00
parent e44b58c86b
commit 9015ff2cfa
2 changed files with 11 additions and 9 deletions

View File

@@ -2,6 +2,7 @@ package controllers
import (
"encoding/json"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"io/ioutil"
@@ -36,9 +37,9 @@ func (c *UuPtController) UuWaybillCallback() {
} else {
switch web.BConfig.RunMode {
case model.ServerTypeVegetable:
callbackResponse = c.UuPtPush2FruitsOrPet(model.ServerTypeFruits, data)
callbackResponse = c.UuPtPush2FruitsOrPet(model.ServerTypeFruits, map[string]interface{}{"data": data})
case model.ServerTypeFruits:
callbackResponse = c.UuPtPush2FruitsOrPet(model.ServerTypePet, data)
callbackResponse = c.UuPtPush2FruitsOrPet(model.ServerTypePet, map[string]interface{}{"data": data})
case model.ServerTypePet:
return
}
@@ -51,15 +52,15 @@ func (c *UuPtController) UuWaybillCallback() {
}
}
func (c *UuPtController) UuPtPush2FruitsOrPet(serverType string, msg string) *uuptapi.CallbackResponse {
func (c *UuPtController) UuPtPush2FruitsOrPet(serverType string, msg map[string]interface{}) *uuptapi.CallbackResponse {
cl := http.Client{}
var request *http.Request
var err error
switch serverType {
case model.ServerTypeFruits:
request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/uuPt/uuWaybillCallback", strings.NewReader(msg))
request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/uuPt/uuWaybillCallback", strings.NewReader(utils.Map2URLValues(msg).Encode()))
case model.ServerTypePet:
request, err = http.NewRequest(http.MethodPost, "http://callback-gblm.jxc4.com/uuPt/uuWaybillCallback", strings.NewReader(msg))
request, err = http.NewRequest(http.MethodPost, "http://callback-gblm.jxc4.com/uuPt/uuWaybillCallback", strings.NewReader(utils.Map2URLValues(msg).Encode()))
}
if err != nil {
return uuptapi.Err2CallbackResponse(err)