Browse Source

用户列表修改

WH01243 3 years ago
parent
commit
7a6af2981e
1 changed files with 6 additions and 2 deletions
  1. 6 2
      service/message_mail_box.go

+ 6 - 2
service/message_mail_box.go

@@ -36,7 +36,6 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 	v := make([]interface{}, 0)
 	sqlStr := ""
 	if in.UserType == 2 {
-
 		//用户最后一次信息查询
 		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 = Mysql.SelectBySql(userSql, in.NewUserId)
@@ -46,7 +45,7 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 		data = Mysql.SelectBySql(customerSql, in.NewUserId)
 		customerMessageId := Inhandle(data)
 		//用户的列表
-		sqlStr = "SELECT IF ( b.nickname = '', REPLACE(b.phone,SUBSTR(b.phone,4,4),'****'), 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  '剑鱼标讯' AS name,    b.ent_id AS id,  e.title,'' 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  WHERE  a.id IN (  " + customerMessageId + " )  ORDER BY create_time DESC"
+		sqlStr = "SELECT IF ( b.nickname = '', REPLACE(b.phone,SUBSTR(b.phone,4,4),'****'), 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)
 	} else {
 		phoneSql := ""
@@ -353,6 +352,11 @@ func (b MessaggeService) CloseChatSession(in *messagecenter.CloseSessionReq) (er
 
 //in数据处理
 func Inhandle(data *[]map[string]interface{}) (messId string) {
+	messId = "''"
+	if len(*data) == 0 {
+		messId = "''"
+		return
+	}
 	for k, m := range *data {
 		if k > 0 {
 			messId += `,`