61 lines
2.6 KiB
Go
61 lines
2.6 KiB
Go
package mongo_model
|
||
|
||
import "time"
|
||
|
||
// 消息方向
|
||
const (
|
||
WxMsgDirectionCustomer = "customer" // 客户发来
|
||
WxMsgDirectionSelf = "self" // 销售本人发出
|
||
WxMsgDirectionAi = "ai" // AI 发出
|
||
)
|
||
|
||
// 消息来源
|
||
const (
|
||
WxMsgSourceCallback = "callback" // 上游回调
|
||
WxMsgSourceWeb = "web" // 后台/AI 发送登记
|
||
WxMsgSourceManual = "manual" // 人工录入
|
||
)
|
||
|
||
// 消息类型
|
||
const (
|
||
WxMsgTypeText = "text"
|
||
WxMsgTypeImage = "image"
|
||
WxMsgTypeVoice = "voice"
|
||
WxMsgTypeVideo = "video"
|
||
WxMsgTypeEmoji = "emoji"
|
||
WxMsgTypeLocation = "location"
|
||
WxMsgTypeAppMsg = "app_msg"
|
||
WxMsgTypeSystem = "system"
|
||
WxMsgTypeGroupSys = "group_sys"
|
||
WxMsgTypeNameCard = "namecard"
|
||
WxMsgTypeFriendReq = "friend_req"
|
||
WxMsgTypeOther = "other"
|
||
)
|
||
|
||
// AdvicerWxMsgMongo 微信消息流水(回调接收入库 + 发送登记),是画像迭代与分析的基础数据
|
||
type AdvicerWxMsgMongo struct {
|
||
AppId string `json:"appId" bson:"appId"` // 登录实例 appId
|
||
Wxid string `json:"wxid" bson:"wxid"` // 对话方(客户/群)wxid
|
||
SelfWxid string `json:"selfWxid" bson:"selfWxid"` // 我方(销售)wxid
|
||
SenderWxid string `json:"senderWxid" bson:"senderWxid"` // 群消息真实发送人 wxid(仅群消息有值)
|
||
Direction string `json:"direction" bson:"direction"` // 方向:customer/self/ai
|
||
MsgType string `json:"msgType" bson:"msgType"` // 消息类型:text/image/voice/video/app_msg/...
|
||
Content string `json:"content" bson:"content"` // 文本内容(非文本消息存 XML 或简要描述)
|
||
MediaXml string `json:"mediaXml,omitempty" bson:"mediaXml,omitempty"` // 媒体消息原始 XML(用于下载 API,群消息未去前缀)
|
||
MsgId string `json:"msgId" bson:"msgId"` // 上游消息 ID(兼容旧记录)
|
||
NewMsgId string `json:"newMsgId" bson:"newMsgId"` // 消息唯一 ID(AppId+NewMsgId 为去重键)
|
||
Source string `json:"source" bson:"source"` // 来源:callback/web/manual
|
||
Analyzed bool `json:"analyzed" bson:"analyzed"` // 是否已参与画像迭代分析
|
||
Read bool `json:"read" bson:"read"` // 是否已读(客户发来的消息默认未读,打开会话后标记已读)
|
||
Raw string `json:"raw" bson:"raw"` // 回调原始报文
|
||
CreateAt time.Time `json:"createAt" bson:"createAt"` // 消息发生时间
|
||
}
|
||
|
||
func NewAdvicerWxMsgMongo() *AdvicerWxMsgMongo {
|
||
return &AdvicerWxMsgMongo{}
|
||
}
|
||
|
||
func (a *AdvicerWxMsgMongo) MongoTableName() string {
|
||
return "advicer_wx_msg"
|
||
}
|