im
This commit is contained in:
@@ -3,11 +3,10 @@ package ebaiapi
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -20,6 +19,11 @@ const (
|
||||
CmdShopMsgPush = "shop.msg.push"
|
||||
CmdShopBindMsg = "shop.bind.msg"
|
||||
CmdShopUnbindMsg = "shop.unbind.msg"
|
||||
|
||||
//IM消息回调通知
|
||||
CmdImMessageSendEvent = "im.message.send.event" //用户/骑手消息通知
|
||||
CmdImMessageReadEvent = "im.message.read.event" //用户/骑手已读通知
|
||||
|
||||
)
|
||||
|
||||
type CallbackResponse struct {
|
||||
@@ -85,6 +89,55 @@ type CBUserCancelInfo struct {
|
||||
CancelType int `json:"cancel_type"`
|
||||
}
|
||||
|
||||
//temp IM 用户/骑手消息通知
|
||||
type TempSent struct {
|
||||
SubBizType string `json:"subBizType"` //业务子类型,枚举值:SEND_MESSAGE-发送消息
|
||||
BizType string `json:"bizType"` //业务类型,枚举值:IM-消息
|
||||
PayLoad struct {
|
||||
SenderID string `json:"senderId"` //角色+随机数字串;角色:10(用户)、20(骑手)、30(商家)、32(连锁账号登录)
|
||||
ReceiverIDs []string `json:"receiverIds"` //角色+随机数字串;角色:10(用户)、20(骑手)、30(商家)、32(连锁账号登录)
|
||||
CreateTime int64 `json:"createTime"` //时间戳
|
||||
GroupID string `json:"groupId"` //会话id
|
||||
MsgID string `json:"msgId"` //消息ID
|
||||
ContentType int `json:"contentType"` //消息类型,枚举值:1-普通文本
|
||||
} `json:"payload"`
|
||||
PlatformShopID string `json:"platformShopId"` //平台门店ID
|
||||
}
|
||||
|
||||
//IM 用户/骑手消息通知
|
||||
type ImMessageSend struct {
|
||||
SubBizType string `json:"subBizType"` //业务子类型,枚举值:SEND_MESSAGE-发送消息
|
||||
BizType string `json:"bizType"` //业务类型,枚举值:IM-消息
|
||||
PayLoad PayLoad `json:"payLoad"`
|
||||
PlatformShopID string `json:"platformShopId"` //平台门店ID
|
||||
}
|
||||
type PayLoad struct {
|
||||
SenderID string `json:"senderId"` //角色+随机数字串;角色:10(用户)、20(骑手)、30(商家)、32(连锁账号登录)
|
||||
ReceiverIDs []string `json:"receiverIds"` //角色+随机数字串;角色:10(用户)、20(骑手)、30(商家)、32(连锁账号登录)
|
||||
CreateTime int64 `json:"createTime"` //时间戳
|
||||
GroupID string `json:"groupId"` //会话id
|
||||
MsgID string `json:"msgId"` //消息ID
|
||||
ContentType int `json:"contentType"` //消息类型,枚举值:1-普通文本
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
//ContentType =1-普通文本,8-@消息
|
||||
type Content struct {
|
||||
Text string `json:"text"`
|
||||
}
|
||||
|
||||
//IM 用户/骑手已读通知
|
||||
type ImMessageRead struct {
|
||||
PlatformShopID string `json:"platformShopId"` //平台门店ID
|
||||
BizType string `json:"bizType"` //业务类型,枚举值:IM-消息
|
||||
SubBizType string `json:"subBizType"` //业务子类型,枚举值:READ_MESSAGE-读取消息
|
||||
PayLoad struct {
|
||||
MsgIDs string `json:"msgIds"` //消息ID 列表
|
||||
CID string `json:"cid"` //会话id
|
||||
UID string `json:"uid"` //已读操作人
|
||||
} `json:"payLoad"`
|
||||
}
|
||||
|
||||
func (a *API) Err2CallbackResponse(cmd string, err error, data interface{}) *CallbackResponse {
|
||||
response := &CallbackResponse{
|
||||
Cmd: "resp." + cmd,
|
||||
@@ -168,6 +221,10 @@ func (a *API) GetCallbackMsg(request *http.Request) (msg *CallbackMsg, callbackR
|
||||
case CmdOrderUserCancel:
|
||||
var userCancelData CBUserCancelInfo
|
||||
tmpObj = &userCancelData
|
||||
case CmdImMessageSendEvent:
|
||||
tmpObj = &ImMessageSend{}
|
||||
case CmdImMessageReadEvent:
|
||||
tmpObj = &ImMessageRead{}
|
||||
}
|
||||
if tmpObj != nil {
|
||||
if utils.Map2StructByJson(msg.Body, tmpObj, true) == nil {
|
||||
|
||||
Reference in New Issue
Block a user