|
@@ -47,7 +47,7 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
data = util.Mysql.SelectBySql(customerSql, in.NewUserId)
|
|
data = util.Mysql.SelectBySql(customerSql, in.NewUserId)
|
|
customerMessageId := util.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"
|
|
|
|
|
|
+ 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.own_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)
|
|
v = append(v, in.NewUserId, in.NewUserId, in.NewUserId, in.NewUserId, in.NewUserId)
|
|
} else {
|
|
} else {
|
|
phoneSql := ""
|
|
phoneSql := ""
|
|
@@ -63,18 +63,17 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
endTimeSql = " and DATE_FORMAT(c.create_time,'%Y-%m-%d') <= '" + in.EndTime + "' "
|
|
endTimeSql = " and DATE_FORMAT(c.create_time,'%Y-%m-%d') <= '" + in.EndTime + "' "
|
|
}
|
|
}
|
|
//先获取每个用户最后聊天记录
|
|
//先获取每个用户最后聊天记录
|
|
- userSql := " 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_type = 1 AND d.customer_service_id = ? and ( c.type = 4 OR c.type = 5 or c.type=6 or c.type=7 ) AND d.customer_service_id !=0 " + startTimeSql + endTimeSql + " GROUP BY ( CASE WHEN c.send_user_type =2 THEN CONCAT( c.send_user_id ) WHEN c.send_user_type =1 THEN CONCAT( c.receive_user_id ) END ) "
|
|
|
|
|
|
+ userSql := " SELECT MAX( c.id ) as messageId FROM socialize_message_mailbox c LEFT JOIN socialize_chat_session d ON c.own_type=1 and c.own_id=d.id WHERE c.own_type = 1 AND d.customer_service_id = ? and ( c.type = 4 OR c.type = 5 or c.type=6 or c.type=7 ) AND d.customer_service_id !=0 " + startTimeSql + endTimeSql + " GROUP BY ( CASE WHEN c.send_user_type =2 THEN CONCAT( c.send_user_id ) WHEN c.send_user_type =1 THEN CONCAT( c.receive_user_id ) END ) "
|
|
v = append(v, in.EntUserId)
|
|
v = append(v, in.EntUserId)
|
|
log.Println(userSql, v)
|
|
log.Println(userSql, v)
|
|
data = util.Mysql.SelectBySql(userSql, v...)
|
|
data = util.Mysql.SelectBySql(userSql, v...)
|
|
if data != nil {
|
|
if data != nil {
|
|
customerMessageId := util.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 or h.type=6 or h.type=7 ) AND h.own_type = 1 AND h.own_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"
|
|
|
|
|
|
+ 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 left join socialize_chat_session i ON a.own_type = 1 AND a.own_id = i.id WHERE h.own_type = 1 AND i.id=f.id AND h.isread = 0 ) AS number FROM socialize_message_mailbox a LEFT JOIN base_user b ON a.own_type=2 and b.id = a.own_id LEFT JOIN socialize_message e ON e.id = a.messag_id LEFT JOIN socialize_chat_session f ON a.own_type=1 and a.own_id=f.id WHERE a.id IN (" + customerMessageId + ")" + phoneSql + " ORDER BY a.create_time DESC"
|
|
fmt.Println(in.EntUserId)
|
|
fmt.Println(in.EntUserId)
|
|
v = make([]interface{}, 0)
|
|
v = make([]interface{}, 0)
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
if sqlStr != "" {
|
|
if sqlStr != "" {
|
|
fmt.Println(sqlStr, v)
|
|
fmt.Println(sqlStr, v)
|
|
@@ -82,9 +81,10 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
}
|
|
}
|
|
return
|
|
return
|
|
}
|
|
}
|
|
-func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool, errorMsg string, content string, messageId int64) {
|
|
|
|
|
|
+func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool, errorMsg string, content string, messageId, nowInt int64) {
|
|
//先插入信息表
|
|
//先插入信息表
|
|
//判断会话标识是否属于本人
|
|
//判断会话标识是否属于本人
|
|
|
|
+ nowForm := time.Now().Local()
|
|
if in.ItemType != 2 {
|
|
if in.ItemType != 2 {
|
|
userId := int64(0)
|
|
userId := int64(0)
|
|
sessionId := int64(0)
|
|
sessionId := int64(0)
|
|
@@ -114,10 +114,10 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
|
|
//查找会话信息
|
|
//查找会话信息
|
|
chatJson := util.Mysql.FindOne("socialize_chat_session", map[string]interface{}{"id": sessionId}, "user_id", "")
|
|
chatJson := util.Mysql.FindOne("socialize_chat_session", map[string]interface{}{"id": sessionId}, "user_id", "")
|
|
if chatJson == nil {
|
|
if chatJson == nil {
|
|
- return false, "会话标识不存在", "", 0
|
|
|
|
|
|
+ return false, "会话标识不存在", "", 0, nowForm.Unix()
|
|
} else {
|
|
} else {
|
|
if userId != quitl.Int64All((*chatJson)["user_id"]) {
|
|
if userId != quitl.Int64All((*chatJson)["user_id"]) {
|
|
- return false, "会话标识不属于此用户", "", 0
|
|
|
|
|
|
+ return false, "会话标识不属于此用户", "", 0, nowForm.Unix()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -130,7 +130,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
|
|
"item": in.ItemType,
|
|
"item": in.ItemType,
|
|
"type": in.Type,
|
|
"type": in.Type,
|
|
"link": in.Link,
|
|
"link": in.Link,
|
|
- "create_time": time.Now().Local().Format(util.Date_Full_Layout),
|
|
|
|
|
|
+ "create_time": nowForm.Format(util.Date_Full_Layout),
|
|
"create_person": in.SendId,
|
|
"create_person": in.SendId,
|
|
}
|
|
}
|
|
ok := util.Mysql.InsertByTx(tx, "socialize_message", message)
|
|
ok := util.Mysql.InsertByTx(tx, "socialize_message", message)
|
|
@@ -141,7 +141,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
|
|
"appid": in.Appid,
|
|
"appid": in.Appid,
|
|
"messag_id": ok,
|
|
"messag_id": ok,
|
|
"type": in.ItemType,
|
|
"type": in.ItemType,
|
|
- "create_time": time.Now().Local().Format(util.Date_Full_Layout),
|
|
|
|
|
|
+ "create_time": nowForm.Format(util.Date_Full_Layout),
|
|
"isread": 0,
|
|
"isread": 0,
|
|
"send_isdel": 0,
|
|
"send_isdel": 0,
|
|
"receive_isdel": 0,
|
|
"receive_isdel": 0,
|
|
@@ -153,8 +153,8 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
|
|
"appid": in.Appid,
|
|
"appid": in.Appid,
|
|
"messag_id": ok,
|
|
"messag_id": ok,
|
|
"type": in.ItemType,
|
|
"type": in.ItemType,
|
|
- "create_time": time.Now().Local().Format(util.Date_Full_Layout),
|
|
|
|
- "read_time": time.Now().Local().Format(util.Date_Full_Layout),
|
|
|
|
|
|
+ "create_time": nowForm.Format(util.Date_Full_Layout),
|
|
|
|
+ "read_time": nowForm.Format(util.Date_Full_Layout),
|
|
"isread": 1,
|
|
"isread": 1,
|
|
"send_isdel": 0,
|
|
"send_isdel": 0,
|
|
"receive_isdel": 0,
|
|
"receive_isdel": 0,
|
|
@@ -168,7 +168,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
|
|
messageMailBox["own_id"] = in.NewUserId
|
|
messageMailBox["own_id"] = in.NewUserId
|
|
messageMailBox["send_user_id"] = in.ReceiveId
|
|
messageMailBox["send_user_id"] = in.ReceiveId
|
|
messageMailBox["receive_user_id"] = in.NewUserId
|
|
messageMailBox["receive_user_id"] = in.NewUserId
|
|
- } else {
|
|
|
|
|
|
+ } else if in.OwnType == 2 {
|
|
//客服接受系统信息
|
|
//客服接受系统信息
|
|
messageMailBox["own_type"] = 1
|
|
messageMailBox["own_type"] = 1
|
|
messageMailBox["send_user_type"] = 2
|
|
messageMailBox["send_user_type"] = 2
|
|
@@ -176,10 +176,19 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
|
|
messageMailBox["own_id"] = in.SendId
|
|
messageMailBox["own_id"] = in.SendId
|
|
messageMailBox["send_user_id"] = in.ReceiveId
|
|
messageMailBox["send_user_id"] = in.ReceiveId
|
|
messageMailBox["receive_user_id"] = in.SendId
|
|
messageMailBox["receive_user_id"] = in.SendId
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ //客服接受系统信息
|
|
|
|
+ messageMailBox["own_type"] = 1
|
|
|
|
+ messageMailBox["send_user_type"] = 2
|
|
|
|
+ messageMailBox["receive_user_type"] = 1
|
|
|
|
+ messageMailBox["own_id"] = in.ReceiveId
|
|
|
|
+ messageMailBox["send_user_id"] = in.NewUserId
|
|
|
|
+ messageMailBox["receive_user_id"] = in.ReceiveId
|
|
}
|
|
}
|
|
if in.ItemType == 4 {
|
|
if in.ItemType == 4 {
|
|
messageMailBox["isread"] = 1
|
|
messageMailBox["isread"] = 1
|
|
- messageMailBox["read_time"] = time.Now().Format(util.Date_Full_Layout)
|
|
|
|
|
|
+ messageMailBox["read_time"] = nowForm.Format(util.Date_Full_Layout)
|
|
}
|
|
}
|
|
receiveOk = util.Mysql.InsertByTx(tx, "socialize_message_mailbox", messageMailBox)
|
|
receiveOk = util.Mysql.InsertByTx(tx, "socialize_message_mailbox", messageMailBox)
|
|
return ok > 1 && receiveOk > 1
|
|
return ok > 1 && receiveOk > 1
|
|
@@ -206,7 +215,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
|
|
messageMailBox["receive_user_id"] = in.NewUserId
|
|
messageMailBox["receive_user_id"] = in.NewUserId
|
|
messageMailBox["own_id"] = in.NewUserId
|
|
messageMailBox["own_id"] = in.NewUserId
|
|
messageMailBox["isread"] = 1
|
|
messageMailBox["isread"] = 1
|
|
- messageMailBox["read_time"] = time.Now().Format(util.Date_Full_Layout)
|
|
|
|
|
|
+ messageMailBox["read_time"] = nowForm.Format(util.Date_Full_Layout)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -222,8 +231,8 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
|
|
"appid": in.Appid,
|
|
"appid": in.Appid,
|
|
"messag_id": ok,
|
|
"messag_id": ok,
|
|
"type": in.ItemType,
|
|
"type": in.ItemType,
|
|
- "create_time": time.Now().Local().Format(util.Date_Full_Layout),
|
|
|
|
- "read_time": time.Now().Local().Format(util.Date_Full_Layout),
|
|
|
|
|
|
+ "create_time": nowForm.Format(util.Date_Full_Layout),
|
|
|
|
+ "read_time": nowForm.Format(util.Date_Full_Layout),
|
|
"isread": 1,
|
|
"isread": 1,
|
|
"send_isdel": 0,
|
|
"send_isdel": 0,
|
|
"receive_isdel": 0,
|
|
"receive_isdel": 0,
|
|
@@ -263,12 +272,10 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
|
|
receiveOk = util.Mysql.InsertByTx(tx, "socialize_message_mailbox", messageMailBox)
|
|
receiveOk = util.Mysql.InsertByTx(tx, "socialize_message_mailbox", messageMailBox)
|
|
return ok > 1 && receiveOk > 1
|
|
return ok > 1 && receiveOk > 1
|
|
})
|
|
})
|
|
- return fool, "", in.Content, messageId
|
|
|
|
-
|
|
|
|
|
|
+ return fool, "", in.Content, messageId, nowForm.Unix()
|
|
}
|
|
}
|
|
-func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) (*[]map[string]interface{}, int64) {
|
|
|
|
|
|
+func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string]interface{} {
|
|
sqlStr := ""
|
|
sqlStr := ""
|
|
- countSql := ""
|
|
|
|
lastStr := " "
|
|
lastStr := " "
|
|
if in.LastId > 0 {
|
|
if in.LastId > 0 {
|
|
if in.Sort == "asc" {
|
|
if in.Sort == "asc" {
|
|
@@ -280,26 +287,21 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) (*[]map[strin
|
|
switch in.MsgType {
|
|
switch in.MsgType {
|
|
case 2: //点对点聊天
|
|
case 2: //点对点聊天
|
|
sqlStr = "SELECT a.messag_id as messageId,b.* ,if(a.own_id = a.send_user_id,1,2) as fool FROM socialize_message_mailbox a LEFT JOIN socialize_message b on a.messag_id=b.id left join base_user c on c.id=a.send_user_id left join base_user d on d.id=a.receive_user_id where a.own_id= " + quitl.InterfaceToStr(in.NewUserId) + " and ((a.send_user_id= " + quitl.InterfaceToStr(in.NewUserId) + " and a.receive_user_id= " + quitl.InterfaceToStr(in.SendId) + ") or (a.send_user_id= " + quitl.InterfaceToStr(in.SendId) + " and a.receive_user_id= " + quitl.InterfaceToStr(in.NewUserId) + ")) and a.type=2 " + lastStr + " ORDER BY a.create_time desc ,a.id asc limit 0 , " + quitl.InterfaceToStr(in.PageSize)
|
|
sqlStr = "SELECT a.messag_id as messageId,b.* ,if(a.own_id = a.send_user_id,1,2) as fool FROM socialize_message_mailbox a LEFT JOIN socialize_message b on a.messag_id=b.id left join base_user c on c.id=a.send_user_id left join base_user d on d.id=a.receive_user_id where a.own_id= " + quitl.InterfaceToStr(in.NewUserId) + " and ((a.send_user_id= " + quitl.InterfaceToStr(in.NewUserId) + " and a.receive_user_id= " + quitl.InterfaceToStr(in.SendId) + ") or (a.send_user_id= " + quitl.InterfaceToStr(in.SendId) + " and a.receive_user_id= " + quitl.InterfaceToStr(in.NewUserId) + ")) and a.type=2 " + lastStr + " ORDER BY a.create_time desc ,a.id asc limit 0 , " + quitl.InterfaceToStr(in.PageSize)
|
|
- countSql = "SELECT count(b.id) FROM socialize_message_mailbox a LEFT JOIN socialize_message b on a.messag_id=b.id left join base_user c on c.id=a.send_user_id left join base_user d on d.id=a.receive_user_id where a.own_id=" + quitl.InterfaceToStr(in.NewUserId) + " and ((a.send_user_id=" + quitl.InterfaceToStr(in.NewUserId) + " and a.receive_user_id=" + quitl.InterfaceToStr(in.SendId) + ") or (a.send_user_id=" + quitl.InterfaceToStr(in.SendId) + " and a.receive_user_id=" + quitl.InterfaceToStr(in.NewUserId) + ")) and a.type=2 " + lastStr
|
|
|
|
break
|
|
break
|
|
case 4, 5, 6, 7: //客服聊天
|
|
case 4, 5, 6, 7: //客服聊天
|
|
if in.UserType == 1 {
|
|
if in.UserType == 1 {
|
|
//客服聊天记录查看
|
|
//客服聊天记录查看
|
|
- sqlStr = "SELECT a.messag_id as messageId,b.*, IF ( a.own_id = a.send_user_id, 1, 2 ) AS fool, a.send_user_type, a.type AS itemType, d.nickname AS robotName, d.headimage AS robotImg, c.customer_service_name AS setName , c.user_id FROM socialize_message_mailbox a LEFT JOIN socialize_message b ON a.messag_id = b.id LEFT JOIN socialize_chat_session c ON IF ( a.send_user_type = 1, c.id = a.send_user_id, c.id = a.receive_user_id ) AND c.ent_id = " + quitl.InterfaceToStr(in.EntId) + " AND c.user_id = " + quitl.InterfaceToStr(in.SendId) + " LEFT JOIN socialize_tenant_robot d ON c.ent_id = d.ent_id WHERE a.own_type = 1 AND (a.type = 5 or a.type=4 or a.type=6 or a.type=7) AND c.ent_id = " + quitl.InterfaceToStr(in.EntId) + " AND c.user_id = " + quitl.InterfaceToStr(in.SendId) + lastStr + " ORDER BY a.create_time desc ,a.id asc limit 0 , " + quitl.InterfaceToStr(in.PageSize)
|
|
|
|
- countSql = "SELECT count(b.id) FROM socialize_message_mailbox a LEFT JOIN socialize_message b ON a.messag_id = b.id LEFT JOIN socialize_chat_session c ON IF ( a.send_user_type = 1, c.id = a.send_user_id, c.id = a.receive_user_id ) AND c.ent_id = " + quitl.InterfaceToStr(in.EntId) + " AND c.user_id = " + quitl.InterfaceToStr(in.SendId) + " LEFT JOIN socialize_tenant_robot d ON c.ent_id = d.ent_id WHERE a.own_type = 1 AND (a.type = 5 or a.type=4 or a.type = 5 or a.type=6 or a.type=7) AND c.ent_id = " + quitl.InterfaceToStr(in.EntId) + " AND c.user_id = " + quitl.InterfaceToStr(in.SendId) + "" + lastStr
|
|
|
|
|
|
+ sqlStr = "SELECT a.messag_id as messageId,b.*, IF ( a.own_id = a.send_user_id, 1, 2 ) AS fool, a.send_user_type, a.type AS itemType, '' AS robotName, '' AS robotImg, c.customer_service_name AS setName , c.user_id FROM socialize_message_mailbox a LEFT JOIN socialize_message b ON a.messag_id = b.id LEFT JOIN socialize_chat_session c ON a.own_type = 1 and a.own_id=c.id WHERE a.own_type = 1 AND (a.type = 5 or a.type=4 or a.type=6 or a.type=7) AND c.ent_id = " + quitl.InterfaceToStr(in.EntId) + " AND c.user_id = " + quitl.InterfaceToStr(in.SendId) + lastStr + " ORDER BY a.create_time desc ,a.id asc limit 0 , " + quitl.InterfaceToStr(in.PageSize)
|
|
} else {
|
|
} else {
|
|
//用户聊天记录查看
|
|
//用户聊天记录查看
|
|
sqlStr = "SELECT a.messag_id as messageId, b.*, IF ( a.own_id = a.send_user_id, 1, 2 ) AS fool , a.send_user_type, a.type as itemType, d.nickname as robotName, d.headimage as robotImg, c.customer_service_name as setName FROM socialize_message_mailbox a LEFT JOIN socialize_message b ON a.messag_id = b.id LEFT JOIN socialize_chat_session c ON IF ( a.send_user_type = 1, c.id = a.send_user_id, c.id = a.receive_user_id ) and c.ent_id =" + quitl.InterfaceToStr(in.SendId) + " AND c.user_id = " + quitl.InterfaceToStr(in.NewUserId) + " left join socialize_tenant_robot d on c.ent_id=d.ent_id WHERE a.own_type = 2 AND a.own_id = " + quitl.InterfaceToStr(in.NewUserId) + " and c.ent_id =" + quitl.InterfaceToStr(in.SendId) + " AND c.user_id = " + quitl.InterfaceToStr(in.NewUserId) + " AND ( a.type = 4 OR a.type = 5 or a.type=6 or a.type=7) " + lastStr + " ORDER BY a.create_time desc ,a.id asc limit 0 , " + quitl.InterfaceToStr(in.PageSize)
|
|
sqlStr = "SELECT a.messag_id as messageId, b.*, IF ( a.own_id = a.send_user_id, 1, 2 ) AS fool , a.send_user_type, a.type as itemType, d.nickname as robotName, d.headimage as robotImg, c.customer_service_name as setName FROM socialize_message_mailbox a LEFT JOIN socialize_message b ON a.messag_id = b.id LEFT JOIN socialize_chat_session c ON IF ( a.send_user_type = 1, c.id = a.send_user_id, c.id = a.receive_user_id ) and c.ent_id =" + quitl.InterfaceToStr(in.SendId) + " AND c.user_id = " + quitl.InterfaceToStr(in.NewUserId) + " left join socialize_tenant_robot d on c.ent_id=d.ent_id WHERE a.own_type = 2 AND a.own_id = " + quitl.InterfaceToStr(in.NewUserId) + " and c.ent_id =" + quitl.InterfaceToStr(in.SendId) + " AND c.user_id = " + quitl.InterfaceToStr(in.NewUserId) + " AND ( a.type = 4 OR a.type = 5 or a.type=6 or a.type=7) " + lastStr + " ORDER BY a.create_time desc ,a.id asc limit 0 , " + quitl.InterfaceToStr(in.PageSize)
|
|
- countSql = "SELECT count(a.id) FROM socialize_message_mailbox a LEFT JOIN socialize_message b ON a.messag_id = b.id LEFT JOIN socialize_chat_session c ON IF ( a.send_user_type = 1, c.id = a.send_user_id, c.id = a.receive_user_id ) and c.ent_id = " + quitl.InterfaceToStr(in.SendId) + " AND c.user_id = " + quitl.InterfaceToStr(in.NewUserId) + " left join socialize_tenant_robot d on c.ent_id=d.ent_id WHERE a.own_type = 2 AND a.own_id =" + quitl.InterfaceToStr(in.NewUserId) + " AND ( a.type = 4 OR a.type = 5 or a.type=6 or a.type=7) and c.ent_id = " + quitl.InterfaceToStr(in.SendId) + " AND c.user_id = " + quitl.InterfaceToStr(in.NewUserId) + "" + lastStr
|
|
|
|
}
|
|
}
|
|
break
|
|
break
|
|
}
|
|
}
|
|
log.Println(sqlStr)
|
|
log.Println(sqlStr)
|
|
- log.Println(countSql)
|
|
|
|
data := util.Mysql.SelectBySql(sqlStr)
|
|
data := util.Mysql.SelectBySql(sqlStr)
|
|
- count := util.Mysql.CountBySql(countSql)
|
|
|
|
//自己头像处理
|
|
//自己头像处理
|
|
- if in.UserType == 2 && count > 0 {
|
|
|
|
|
|
+ if in.UserType == 2 {
|
|
userData := util.Mysql.FindOne("base_user", map[string]interface{}{"id": in.NewUserId}, "headimg", "")
|
|
userData := util.Mysql.FindOne("base_user", map[string]interface{}{"id": in.NewUserId}, "headimg", "")
|
|
if userData != nil {
|
|
if userData != nil {
|
|
for key := range *data {
|
|
for key := range *data {
|
|
@@ -332,7 +334,7 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) (*[]map[strin
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}()
|
|
}()
|
|
- return data, count
|
|
|
|
|
|
+ return data
|
|
}
|
|
}
|
|
func (b MessaggeService) CreateChatSession(in *messagecenter.ChatSessionReq) (fool bool, sessionId int64) {
|
|
func (b MessaggeService) CreateChatSession(in *messagecenter.ChatSessionReq) (fool bool, sessionId int64) {
|
|
fool = util.Mysql.ExecTx("会话新建", func(tx *sql.Tx) bool {
|
|
fool = util.Mysql.ExecTx("会话新建", func(tx *sql.Tx) bool {
|