1
This commit is contained in:
@@ -4,6 +4,9 @@ import (
|
||||
"encoding/json"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/partner/im"
|
||||
beego "github.com/astaxie/beego/server/web"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/mtwmapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||
@@ -63,13 +66,17 @@ func GetVendorAppIdFromMsg(msg *mtwmapi.CallbackMsg) string {
|
||||
// OnImMsg im消息回调
|
||||
func OnImMsg(msg *mtwmapi.ImCallbackMsg) (response *mtwmapi.CallbackResponse) {
|
||||
if str, err := json.Marshal(msg.PushContent); err == nil {
|
||||
|
||||
var PushContentReq = mtwmapi.PushContentReq{}
|
||||
if err = json.Unmarshal(str, &PushContentReq); err != nil {
|
||||
return mtwmapi.SignatureIsNotOk
|
||||
if beego.BConfig.RunMode != "jxgy" {
|
||||
var PushContentReq = mtwmapi.PushContentReq{}
|
||||
if err = json.Unmarshal(str, &PushContentReq); err != nil {
|
||||
return mtwmapi.SignatureIsNotOk
|
||||
}
|
||||
storeDetail, err2 := dao.GetStoreDetailByVendorStoreID(dao.GetDB(), PushContentReq.AppPoiCode, model.VendorIDMTWM, utils.Int2Str(PushContentReq.AppID))
|
||||
if err2 != nil || storeDetail == nil {
|
||||
pushIMToGy(msg)
|
||||
return mtwmapi.SuccessResponse
|
||||
}
|
||||
}
|
||||
globals.SugarLogger.Debugf("===========msg liulei := %s ", utils.Format4Output(&msg, false))
|
||||
globals.SugarLogger.Debugf("===========PushContentReq liulei := %s ", utils.Format4Output(&PushContentReq, false))
|
||||
|
||||
err = im.ReadMsgFromVendor(model.VendorIDMTWM, "", str)
|
||||
if err != nil {
|
||||
@@ -79,3 +86,19 @@ func OnImMsg(msg *mtwmapi.ImCallbackMsg) (response *mtwmapi.CallbackResponse) {
|
||||
}
|
||||
return mtwmapi.SuccessResponse
|
||||
}
|
||||
|
||||
func pushIMToGy(msg *mtwmapi.ImCallbackMsg) {
|
||||
cl := http.Client{}
|
||||
params := make(map[string]interface{})
|
||||
params["timestamp"] = msg.Timestamp
|
||||
params["sign"] = msg.Sig
|
||||
params["app_id"] = msg.AppID
|
||||
params["biz_type"] = msg.BizType
|
||||
params["push_content"] = msg.PushContent
|
||||
request, err := http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/mtwm/iMCallback", strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8")
|
||||
cl.Do(request)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user