|
@@ -40,11 +40,11 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
|
//用户最后一次信息查询
|
|
|
userSql := "SELECT MAX( c.id ) as messageId FROM socialize_message_mailbox c WHERE c.own_id = ? AND c.type = 2 AND c.own_type = 2 GROUP BY ( CASE WHEN c.send_user_id > c.receive_user_id THEN CONCAT( c.send_user_id, c.receive_user_id ) WHEN c.send_user_id < c.receive_user_id THEN CONCAT( c.receive_user_id, c.send_user_id ) END ) "
|
|
|
data = util.Mysql.SelectBySql(userSql, in.NewUserId)
|
|
|
- userMessageId := Inhandle(data)
|
|
|
+ userMessageId := util.Inhandle(data)
|
|
|
//客服最后一次信息查询
|
|
|
customerSql := " SELECT max( c.id ) as messageId FROM socialize_message_mailbox c LEFT JOIN socialize_chat_session d ON IF ( c.send_user_type = 1, d.id = c.send_user_id, d.id = c.receive_user_id ) WHERE c.own_id = ? AND ( c.type = 4 OR c.type = 5 ) AND c.own_type = 2 and d.user_id=c.own_id GROUP BY d.ent_id "
|
|
|
data = util.Mysql.SelectBySql(customerSql, in.NewUserId)
|
|
|
- customerMessageId := Inhandle(data)
|
|
|
+ customerMessageId := util.Inhandle(data)
|
|
|
//用户的列表
|
|
|
sqlStr = "SELECT IF ( b.nickname = '', CONCAT(SUBSTR( b.phone, 1, 3 ),'****',SUBSTR( b.phone, 8, 11)), b.nickname ) AS name, b.id, e.title, b.headimg, e.type, e.link, e.content, 2 AS userType, a.create_time, a.type AS itemType, ( SELECT count( h.id ) FROM socialize_message_mailbox h WHERE h.type = 2 AND h.own_id = ? AND h.own_type = 2 AND h.receive_user_id = ? and h.send_user_id=b.id AND h.isread = 0 ) AS number FROM socialize_message_mailbox a LEFT JOIN base_user b ON b.id = a.receive_user_id or b.id = a.send_user_id LEFT JOIN socialize_message e ON e.id = a.messag_id WHERE a.id IN ( " + userMessageId + " ) AND b.id != ? UNION ALL SELECT f.nickname AS name, b.ent_id AS id, e.title,f.headimage AS headimg, e.type, e.link, e.content, 1 AS userType, a.create_time, a.type AS itemType, ( SELECT count( h.id ) FROM socialize_message_mailbox h WHERE ( h.type = 4 OR h.type = 5 ) AND h.own_id = ? AND h.own_type = 2 AND h.send_user_type = 1 and h.receive_user_id = ? AND h.isread = 0 ) AS number FROM socialize_message_mailbox a LEFT JOIN socialize_chat_session b ON IF ( a.send_user_type = 1, b.id = a.send_user_id, b.id = a.receive_user_id ) LEFT JOIN socialize_message e ON e.id = a.messag_id left join socialize_tenant_robot f on f.ent_id=b.ent_id WHERE a.id IN ( " + customerMessageId + " ) ORDER BY create_time DESC"
|
|
|
v = append(v, in.NewUserId, in.NewUserId, in.NewUserId, in.NewUserId, in.NewUserId)
|
|
@@ -68,7 +68,7 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
|
log.Println(userSql, v)
|
|
|
data = util.Mysql.SelectBySql(userSql, v...)
|
|
|
if data != nil {
|
|
|
- customerMessageId := Inhandle(data)
|
|
|
+ customerMessageId := util.Inhandle(data)
|
|
|
//客服的用户列表
|
|
|
sqlStr = "SELECT IF ( b.nickname = '', CONCAT(SUBSTR( b.phone, 1, 3 ),'****',SUBSTR( b.phone, 8, 11)), b.nickname ) AS name, b.id, e.title, b.headimg, e.type, e.link, e.content, a.create_time, ( SELECT count( h.id ) FROM socialize_message_mailbox h WHERE ( h.type = 4 OR h.type = 5 ) AND h.own_type = 1 AND IF ( h.send_user_type = 1, h.send_user_id = f.id, h.receive_user_id = f.id ) AND h.isread = 0 ) AS number FROM socialize_message_mailbox a LEFT JOIN base_user b ON IF ( a.send_user_type = 1, b.id = a.receive_user_id, b.id = a.send_user_id ) LEFT JOIN socialize_message e ON e.id = a.messag_id LEFT JOIN socialize_chat_session f ON IF ( a.send_user_type = 1, f.id = a.send_user_id, f.id = a.receive_user_id ) WHERE a.id IN (" + customerMessageId + ")" + phoneSql + " ORDER BY a.create_time DESC"
|
|
|
fmt.Println(in.EntUserId)
|
|
@@ -107,7 +107,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (errorCode
|
|
|
userId = in.NewUserId
|
|
|
} else {
|
|
|
sessionId = in.SendId
|
|
|
- userId = in.NewUserId
|
|
|
+ userId = in.ReceiveId
|
|
|
}
|
|
|
break
|
|
|
}
|
|
@@ -382,21 +382,6 @@ func (b MessaggeService) CloseChatSession(in *messagecenter.CloseSessionReq) (er
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//in数据处理
|
|
|
-func Inhandle(data *[]map[string]interface{}) (messId string) {
|
|
|
- if len(*data) == 0 {
|
|
|
- messId = "''"
|
|
|
- return
|
|
|
- }
|
|
|
- for k, m := range *data {
|
|
|
- if k > 0 {
|
|
|
- messId += `,`
|
|
|
- }
|
|
|
- messId += "'" + quitl.InterfaceToStr(m["messageId"]) + "'"
|
|
|
- }
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
func (m *MessaggeService) SaveAutoReplyMsg(userType, entId, entUserId, userId int64, content, appId, nowFormat string) bool {
|
|
|
return util.Mysql.ExecTx("保存自动回复消息", func(tx *sql.Tx) bool {
|
|
|
entUserName := ""
|