package service import ( "fmt" . "gitdxz.51daxuetong.cn/go_dev/jjl-tools/tinodeService/dao" "strconv" ) type Topics struct { Id int PageNum int PageSize int CompanyId int SkillGroups string GroupId int Uid string StartTime string EndTime string Name string Content string Quality int FirstReplyInterval int //查询会话记录 Topic string Sid string CreateTime string MsgNum int ChannelId int CategoryId int IsReply int } //获取会话详细记录 func (tp *Topics) GetMessageList() (mesList []Messages, err error) { mesDao := MessageDao{} //获取总条数 mesList, err = mesDao.GetMessagesList(tp.Topic, tp.Sid, tp.CreateTime, tp.PageSize) return } //获取会话开始时间, 结束时间 func (tp *Topics) GetChatRecordStartEndTime() map[string]interface{} { chatDao := ChatRecordDao{} chatList, err := chatDao.GetGroupByChatRecordLists(tp.Topic, tp.Sid) if err != nil { fmt.Println("数据为空或获取会话信息错误, topic:", tp.Topic, ", sid:", tp.Sid, ", err=", err) } insDao := InspectionDao{} list := make(map[string]interface{}) endDes := map[string]string{ "1": "客服结束", "2": "用户结束", "3": "用户超时自动关闭", "4": "客服异常关闭", "5": "用户异常关闭", } for _, v := range chatList { //判断 v.SID 是否数字, 默认是用户发送的 - 2, 如果是全数组则是客服发送的 - 1 call_start_type := 2 if _, err := strconv.ParseFloat(v.SID, 64); err == nil { call_start_type = 1 } vUser,_ := strconv.ParseInt(v.USER_ID, 10, 64) vVistor,_ := strconv.ParseInt(v.VISITOR_ID, 10, 64) customer, _ := insDao.GetUserFromRedis(1, vUser) user, _ := insDao.GetUserFromRedis(2, vVistor) cInfo := map[string]interface{}{ "call_start_time": v.CREATE_TIME, "call_end_time": v.CallEndTime, "call_end_type": v.CallEndType, "call_end_des": endDes[v.CallEndType], "call_start_type": call_start_type, "customer_nickname": customer.Realname, //客服昵称 "user_nickname": user.Realname, //用户昵称 } list[v.SID] = cInfo } return list }