1
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
package mtwmapi
|
||||
|
||||
import "net/url"
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
const (
|
||||
ImStatusOpen = 1 //开启
|
||||
ImStatusClose = 0 //关闭
|
||||
|
||||
MsgSourceStore = 1 //商家
|
||||
MsgSourceUser = 2 //用户
|
||||
MsgTypeText = 1 //文字
|
||||
@@ -12,27 +18,6 @@ const (
|
||||
MsgTypeOrderCard = 5 //订单卡片
|
||||
)
|
||||
|
||||
// SingleChat 单聊信息体
|
||||
type SingleChat struct {
|
||||
AppID int `json:"app_id"` //应用标识
|
||||
AppPoiCode string `json:"app_poi_code"` //门店标识
|
||||
Cts int `json:"cts"` //消息发送时间,10位时间戳
|
||||
MsgContent string `json:"msg_content"` //消息内容
|
||||
MsgID int `json:"msg_id"` //消息id,确保消息唯一性,发送消息时,为三方的消息id,接收消息时,为美团的消息id
|
||||
MsgSource int `json:"msg_source"` //消息发送方 商家:1,用户:2
|
||||
MsgType int `json:"msg_type"` //消息类型: 文字-1; 图片-2;语音-3,注意b2c不支持语音; 商品卡片-4(发送商品卡片类型则不关注msg_content); 订单卡片-5(订单卡片类型商家只能接收消息,不支持给用户发送消息,只支持单聊)
|
||||
OpenUserID int `json:"open_user_id"` //用户id
|
||||
OrderID int `json:"order_id"` // 订单id
|
||||
AppSpuCodes string `json:"app_spu_codes"` //开放平台侧商品标识(无须加密)
|
||||
}
|
||||
|
||||
// GetConnTokenResp 获取长链接token返回参数
|
||||
type GetConnTokenResp struct {
|
||||
ConnectionToken string `json:"connectionToken"` //建立长连接的token
|
||||
UserCount int `json:"userCount"` //30分钟内,消息发送失败的用户数
|
||||
AppKey string `json:"appKey"` //建立长连接的appkey
|
||||
}
|
||||
|
||||
// ImCallbackMsg im消息回调参数
|
||||
type ImCallbackMsg struct {
|
||||
Timestamp int `json:"timestamp"` //调用接口时的时间戳,即当前时间戳(当前距离Epoch(1970年1月1日) 以秒计算的时间,即unix - timestamp),注意传输时间戳与当前北京时间前后相差不能超过10分钟
|
||||
@@ -59,14 +44,10 @@ type PushContentReq struct {
|
||||
AppSpuCodes string `json:"app_spu_codes"` //开放平台侧商品标识(无须加密)
|
||||
}
|
||||
|
||||
type PushContentResp struct {
|
||||
ResultCode int `json:"result_code"` //1-全部操作成功,查询到的数据在data字段中;2-部分成功,成功的数据存储在data字段中,失败的数据存在error_list字段中;3-全部操作失败,失败的数据存在error_list字段中;4-请求失败,一般为签名或限流问题,关注error字段中的具体描述即可
|
||||
ErrorList []ErrorList `json:"error_list"` //返回失败原因,根据失败原因判断是否重发消息
|
||||
}
|
||||
|
||||
type ErrorList struct {
|
||||
Code int `json:"code"` //错误码
|
||||
Msg string `json:"msg"` //错误描述
|
||||
type GetPoiIMStatusResp struct {
|
||||
AppPoiCode string `json:"app_poi_code"`
|
||||
AppID int `json:"app_id"`
|
||||
ImStatus int `json:"im_status"`
|
||||
}
|
||||
|
||||
// MsgSend 商家发送IM消息 https://open-shangou.meituan.com/home/docDetail/10087
|
||||
@@ -78,11 +59,23 @@ func (a *API) MsgSend(pushContent string) (interface{}, error) {
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
// GetConnectionToken 获取长连接的token https://developer.waimai.meituan.com/home/docDetail/461
|
||||
//func (a *API) GetConnectionToken() (retVal interface{}, err error) {
|
||||
// retVal, err = a.AccessAPI("wm/IM/getConnectionToken", false, nil)
|
||||
// return retVal, err
|
||||
//}
|
||||
//设置门店IM线上状态
|
||||
func (a *API) SetPoiIMOnlineStatus(appPoiCode string, onlineStatus int) error {
|
||||
_, err := a.AccessAPI("wm/IM/setPoiIMOnlineStatus", false, map[string]interface{}{
|
||||
"app_poi_code": appPoiCode,
|
||||
"online_status": onlineStatus,
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// GetPoiIMStatus 查询门店IM单聊开关状态
|
||||
func (a *API) GetPoiIMStatus(appPoiCode string) (retVal GetPoiIMStatusResp, err error) {
|
||||
resp, err := a.AccessAPI("wm/IM/getPoiIMStatus", false, map[string]interface{}{
|
||||
"app_poi_code": appPoiCode,
|
||||
})
|
||||
utils.Map2StructByJson(resp, &retVal, false)
|
||||
return retVal, err
|
||||
}
|
||||
|
||||
// MsgRead 设置消息已读 https://open-shangou.meituan.com/home/docDetail/465
|
||||
//func (a *API) MsgRead(appPoiCode string, msgID, openUserID int) error {
|
||||
|
||||
Reference in New Issue
Block a user