1
This commit is contained in:
@@ -66,14 +66,18 @@ 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 {
|
||||
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)
|
||||
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 {
|
||||
switch beego.BConfig.RunMode {
|
||||
case model.ServerTypeFruits:
|
||||
pushIMToGyOrPet(msg, model.ServerTypePet)
|
||||
return mtwmapi.SuccessResponse
|
||||
case model.ServerTypeVegetable:
|
||||
pushIMToGyOrPet(msg, model.ServerTypeFruits)
|
||||
return mtwmapi.SuccessResponse
|
||||
}
|
||||
}
|
||||
@@ -87,18 +91,32 @@ func OnImMsg(msg *mtwmapi.ImCallbackMsg) (response *mtwmapi.CallbackResponse) {
|
||||
return mtwmapi.SuccessResponse
|
||||
}
|
||||
|
||||
func pushIMToGy(msg *mtwmapi.ImCallbackMsg) {
|
||||
cl := http.Client{}
|
||||
func pushIMToGyOrPet(msg *mtwmapi.ImCallbackMsg, serverType string) {
|
||||
var (
|
||||
cl = http.Client{}
|
||||
request = &http.Request{}
|
||||
err error
|
||||
)
|
||||
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
|
||||
|
||||
switch serverType {
|
||||
case model.ServerTypeFruits:
|
||||
request, err = http.NewRequest(http.MethodPost, "http://callback-jxgy.jxc4.com/mtwm/iMCallback", strings.NewReader(utils.Map2URLValues(params).Encode()))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
case model.ServerTypePet:
|
||||
request, err = http.NewRequest(http.MethodPost, "http://callback-jxpet.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