|
@@ -114,7 +114,7 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
|
data = util.Mysql.SelectBySql(userSql, in.NewUserId)
|
|
|
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 "
|
|
|
+ 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.type=6 or c.type=7 ) 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 := util.Inhandle(data)
|
|
|
//用户的列表
|
|
@@ -135,14 +135,14 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
|
}</span>
|
|
|
|
|
|
//先获取每个用户最后聊天记录
|
|
|
- <span class="cov8" title="1">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 ) 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 ) "
|
|
|
+ <span class="cov8" title="1">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 ) "
|
|
|
v = append(v, in.EntUserId)
|
|
|
log.Println(userSql, v)
|
|
|
data = util.Mysql.SelectBySql(userSql, v...)
|
|
|
if data != nil </span><span class="cov8" title="1">{
|
|
|
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"
|
|
|
+ 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 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)
|
|
|
v = make([]interface{}, 0)
|
|
|
}</span>
|
|
@@ -348,7 +348,7 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) (*[]map[strin
|
|
|
if in.UserType == 1 </span><span class="cov8" title="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 ) LEFT JOIN socialize_tenant_robot d ON c.ent_id = d.ent_id WHERE a.own_type = 1 AND c.ent_id = " + quitl.InterfaceToStr(in.EntId) + " AND c.user_id = " + quitl.InterfaceToStr(in.SendId) + " AND (a.type = 5 or a.type=4 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(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 ) LEFT JOIN socialize_tenant_robot d ON c.ent_id = d.ent_id WHERE a.own_type = 1 AND c.ent_id = " + quitl.InterfaceToStr(in.EntId) + " AND c.user_id = " + quitl.InterfaceToStr(in.SendId) + " AND (a.type = 5 or a.type=4 or a.type = 5 or a.type=4 or a.type=6 or a.type=7) " + lastStr
|
|
|
+ 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 ) LEFT JOIN socialize_tenant_robot d ON c.ent_id = d.ent_id WHERE a.own_type = 1 AND c.ent_id = " + quitl.InterfaceToStr(in.EntId) + " AND c.user_id = " + quitl.InterfaceToStr(in.SendId) + " AND (a.type = 5 or a.type=4 or a.type = 5 or a.type=6 or a.type=7) " + lastStr
|
|
|
}</span> else<span class="cov8" title="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 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 ) left join socialize_tenant_robot d on c.ent_id=d.ent_id WHERE a.own_type = 2 AND c.ent_id = " + quitl.InterfaceToStr(in.SendId) + " AND a.own_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)
|