添加京东im

This commit is contained in:
邹宗楠
2025-12-10 10:56:48 +08:00
parent cbe7ee196d
commit 69b568fb73
12 changed files with 332 additions and 81 deletions

View File

@@ -3,6 +3,8 @@ package controllers
import (
"bytes"
"fmt"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/partner/im"
"io/ioutil"
"net/http"
@@ -244,6 +246,38 @@ func (c *DjswController) ApplyOrderInvoiceStatus() {
}
}
func (c *DjswController) imMsg() {
if c.Ctx.Input.Method() == http.MethodPost {
var callbackResponse *jdapi.CallbackResponse
msg, url, err := jdapi.ImChatRiskMsg(getUsefulRequest(c.Ctx))
if err != nil {
callbackResponse = jdapi.Err2CallbackResponse(err, "")
} else {
callbackResponse = jdapi.Err2CallbackResponse(im.ReadMsgFromVendor(model.VendorIDJD, url, msg), "")
}
c.Data["json"] = c.transferResponse("orderStatus", callbackResponse)
c.ServeJSON()
} else {
c.Abort("404")
}
}
// ChatRiskMsg 风控消息推送
func (c *DjswController) ChatRiskMsg() {
c.imMsg()
}
// MsChatMessageMsg 用户消息
func (c *DjswController) MsChatMessageMsg() {
c.imMsg()
}
// MsgReadAckMsg 消息已读
func (c *DjswController) MsgReadAckMsg() {
c.imMsg()
}
//免费开卡接不到回调
//func (c *DjswController) MemberCreateCard() {
// if c.Ctx.Input.Method() == http.MethodPost {