1
This commit is contained in:
@@ -1,8 +1,19 @@
|
||||
package ebaiapi
|
||||
|
||||
import "errors"
|
||||
import (
|
||||
"errors"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
|
||||
// GetStoreIMStatus 获取门店的im状态
|
||||
const (
|
||||
IMStoreStatusOnLine = "ONLINE" // 门店im在线状态
|
||||
IMStoreStatusBusy = "BUSY" // 忙碌状态
|
||||
IMType = "IM" // 业务类型,消息默认IM
|
||||
SubIMType = "SEND_MESSAGE" // 子业务类型,发送消息。默认值:SEND_MESSAGE
|
||||
ReadIMType = "READ_MESSAGE"
|
||||
)
|
||||
|
||||
// GetStoreIMStatus 获取门店的im状态(这个应该不怎么用)
|
||||
func (a *API) GetStoreIMStatus(platformShopId string) (int, error) {
|
||||
result, err := a.AccessAPI("im.getIMStatus", map[string]interface{}{"platformShopId": platformShopId})
|
||||
if err != nil {
|
||||
@@ -14,3 +25,76 @@ func (a *API) GetStoreIMStatus(platformShopId string) (int, error) {
|
||||
|
||||
return result.Data.(map[string]interface{})["imStatus"].(int), nil
|
||||
}
|
||||
|
||||
// GetImOnlineStatus 获取门店IM线上状态
|
||||
func (a *API) GetImOnlineStatus(platformShopId string) (int, error) {
|
||||
result, err := a.AccessAPI("im.getIMOnlineStatus", map[string]interface{}{"platformShopId": platformShopId})
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if result.ErrNo != 0 {
|
||||
return 0, errors.New(result.Error)
|
||||
}
|
||||
|
||||
return result.Data.(map[string]interface{})["status"].(int), nil
|
||||
}
|
||||
|
||||
// SetImOnlineStatus 设置im线上状态 ONLINE - 在线 BUSY - 忙碌
|
||||
func (a *API) SetImOnlineStatus(platformShopId string, status string) error {
|
||||
result, err := a.AccessAPI("im.updateIMOnlineStatus", map[string]interface{}{"platformShopId": platformShopId, "status": status})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if result.ErrNo != 0 {
|
||||
return errors.New(result.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// BusinessSendMsg 门店老板发送消息
|
||||
func (a *API) BusinessSendMsg(param *BusinessSendMsgReq) error {
|
||||
result, err := a.AccessAPI("im.message", utils.Struct2MapByJson(param))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if result.ErrNo != 0 {
|
||||
return errors.New(result.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// BusinessSendMsgReq im发送消息
|
||||
type BusinessSendMsgReq struct {
|
||||
PlatformShopId string `json:"platformShopId"` // 平台门店id
|
||||
BizType string `json:"bizType"` // 业务类型,IM消息。默认值:IM
|
||||
SubBizType string `json:"subBizType"` // 子业务类型,发送消息。默认值:SEND_MESSAGE
|
||||
Payload BusinessMsgPayload `json:"payload"`
|
||||
}
|
||||
|
||||
type BusinessMsgPayload struct {
|
||||
GroupId string `json:"groupId"` // 会话ID
|
||||
MsgId string `json:"msgId"` // 消息ID
|
||||
ReceiverIds []string `json:"receiverIds"` // 接收人列表
|
||||
Content string `json:"content"` // 发送内容,格式:JSON {"text":"msg"}
|
||||
ContentType string `json:"contentType"` // 内容类型,目前只支持文本消息。枚举值: 1-普通文本
|
||||
}
|
||||
|
||||
// SettingStoreMsgRead 设置消息已读
|
||||
func (a *API) SettingStoreMsgRead(platformShopId string, msgId string) error {
|
||||
result, err := a.AccessAPI("im.message.read", map[string]interface{}{
|
||||
"platformShopId": platformShopId,
|
||||
"bizType": IMType,
|
||||
"subBizType": ReadIMType,
|
||||
"payload": map[string]string{"msgId": msgId},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if result.ErrNo != 0 {
|
||||
return errors.New(result.Error)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user