This commit is contained in:
邹宗楠
2025-01-06 14:34:52 +08:00
parent e802a3eebc
commit c73357624e
6 changed files with 57 additions and 34 deletions

View File

@@ -1,13 +1,12 @@
package controllers
import (
"fmt"
"git.rosy.net.cn/baseapi/platformapi/dingdingapi"
"encoding/json"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils/ddmsg"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/globals"
"io/ioutil"
"net/http"
"strings"
@@ -36,7 +35,7 @@ func (c *EbaiController) Msg() {
case model.ServerTypeFruits:
callbackResponse = c.EBaiMsgPush2FruitsOrPet(model.ServerTypePet, utils.Struct2Map(obj, "", false))
case model.ServerTypePet:
ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "47B1E94E8D2411EFB666525400E86DC0", "饿了么菜市推果园,果园退超市未找到门店", fmt.Sprintf("cmd:%s,storeId:%s", obj.Cmd, vendorStoreId))
//ddmsg.SendUserMessage(dingdingapi.MsgTyeText, "47B1E94E8D2411EFB666525400E86DC0", "饿了么菜市推果园,果园退超市未找到门店", fmt.Sprintf("饿了么菜市推果园cmd:%s,storeId:%s", obj.Cmd, vendorStoreId))
callbackResponse = api.EbaiAPI.Err2CallbackResponse(ebaiapi.GetCmd(c.Ctx.Request), nil, nil) // api.EbaiAPI.Err2CallbackResponse(ebaiapi.GetCmd(c.Ctx.Request), fmt.Errorf("饿了么菜市推果园,果园退超市未找到门店cmd:%s,storeId:%s", obj.Cmd, vendorStoreId), nil)
return
}
@@ -64,17 +63,23 @@ func (c *EbaiController) EBaiMsgPush2FruitsOrPet(serverType string, msg map[stri
switch serverType {
case model.ServerTypeFruits:
request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/ebai/msg", strings.NewReader(utils.Map2URLValues(msg).Encode()))
if err != nil {
return api.EbaiAPI.Err2CallbackResponse(ebaiapi.GetCmd(c.Ctx.Request), err, nil)
}
case model.ServerTypePet:
request, err = http.NewRequest(http.MethodPost, "http://callback-gblm.jxc4.com/mtps/status", strings.NewReader(utils.Map2URLValues(msg).Encode()))
if err != nil {
return api.EbaiAPI.Err2CallbackResponse(ebaiapi.GetCmd(c.Ctx.Request), err, nil)
}
}
if err != nil {
return api.EbaiAPI.Err2CallbackResponse(ebaiapi.GetCmd(c.Ctx.Request), err, nil)
}
request.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
_, err = cl.Do(request)
return api.EbaiAPI.Err2CallbackResponse(ebaiapi.GetCmd(c.Ctx.Request), 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.EbaiAPI.Err2CallbackResponse(ebaiapi.GetCmd(c.Ctx.Request), err, nil)
}
defer resp.Body.Close()
byteData, _ := ioutil.ReadAll(resp.Body)
result := ebaiapi.CallbackResponse{}
json.Unmarshal(byteData, &result)
return &result
}