renjiaojiao пре 2 година
родитељ
комит
4d0821def0
2 измењених фајлова са 22 додато и 81 уклоњено
  1. 2 3
      .idea/workspace.xml
  2. 20 78
      service/message_mail_box.go

+ 2 - 3
.idea/workspace.xml

@@ -6,11 +6,9 @@
   <component name="ChangeListManager">
     <list default="true" id="f5220264-ecf0-4305-ada3-6105184077a7" name="Changes" comment="提交">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/rpc/messagecenter/internal/logic/savemessagelogic.go" beforeDir="false" afterPath="$PROJECT_DIR$/rpc/messagecenter/internal/logic/savemessagelogic.go" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/rpc/messagecenter/logs/access.log" beforeDir="false" afterPath="$PROJECT_DIR$/rpc/messagecenter/logs/access.log" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/rpc/messagecenter/logs/error.log" beforeDir="false" afterPath="$PROJECT_DIR$/rpc/messagecenter/logs/error.log" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/rpc/messagecenter/logs/slow.log" beforeDir="false" afterPath="$PROJECT_DIR$/rpc/messagecenter/logs/slow.log" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/rpc/messagecenter/test/message_test.go" beforeDir="false" afterPath="$PROJECT_DIR$/rpc/messagecenter/test/message_test.go" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/service/message_mail_box.go" beforeDir="false" afterPath="$PROJECT_DIR$/service/message_mail_box.go" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
@@ -201,9 +199,9 @@
       <item itemvalue="Go 构建.messageRpc_win" />
       <item itemvalue="Go 测试.bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/test 中的 Test_FindMessage (1)" />
       <item itemvalue="Go 测试.bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/test 中的 Test_test1" />
+      <item itemvalue="HTTP 请求.generated-requests | #2" />
       <item itemvalue="HTTP 请求.generated-requests | #3" />
       <item itemvalue="HTTP 请求.generated-requests | #4" />
-      <item itemvalue="HTTP 请求.generated-requests | #2" />
     </list>
     <recent_temporary>
       <list>
@@ -252,6 +250,7 @@
     <MESSAGE value="未读消息数量sql修改" />
     <MESSAGE value="未读sql修改" />
     <MESSAGE value="历史聊天记录查询" />
+    <MESSAGE value="群聊sql修改" />
     <MESSAGE value="提交" />
     <option name="LAST_COMMIT_MESSAGE" value="提交" />
   </component>

+ 20 - 78
service/message_mail_box.go

@@ -25,68 +25,10 @@ var rwLock = new(sync.RWMutex)
 // Count 未读消息查询
 func (b MessaggeService) Count(newUserId int64) (count int, last map[string]interface{}, err error) {
 	//导航右上角未读消息总量  1v1聊天+群组消息+客服消息
-	//v := make([]interface{}, 0)
-	var (
-		allSql string
-		sqlArr []string
-	)
-	//一对一
-	oneSql := fmt.Sprintf(`(SELECT
-							a.your_position_id AS id,
-							1 AS userType,
-							c.nickname AS name,
-							c.headimg,
-							d.content,
-							d.type,
-							d.create_time,
-							a.unread as number,
-						    a.timestamp
-						FROM
-							socialize_summary a
-							INNER JOIN base_position b ON ( a.my_position_id = %d AND a.unread > 0 AND a.your_position_id = b.id )
-							INNER JOIN base_user c ON ( b.user_id = c.id )
-							LEFT JOIN socialize_message d ON ( a.message_id = d.id ))`, newUserId)
-	//客服列表
-	serviceSql := fmt.Sprintf(` (
-						SELECT
-							a.ent_id AS id,
-							2 AS userType,
-							b.nickname AS name,
-							b.headimage as headimg,
-							c.content,
-							c.type,
-							c.create_time,
-							a.unread as number,
-							a.timestamp
-						FROM
-							socialize_summary a
-							INNER JOIN socialize_tenant_robot b ON ( a.user_id = %d AND a.unread > 0 AND a.ent_id = b.ent_id  )
-							LEFT JOIN socialize_message c ON ( a.message_id = c.id ) 
-						) `, newUserId)
-	//群列表
-	groupSql := fmt.Sprintf(` (
-						SELECT
-							b.id,
-							3 AS userType,
-							b.name,
-							'' AS headimg,
-							d.content,
-							d.type,
-							d.create_time,
-							a.unread as number,
-							c.timestamp
-						FROM
-							socialize_chat_group_person a
-							INNER JOIN socialize_chat_group b ON ( a.position_id = %d AND a.unread > 0 AND a.chat_group_id = b.id AND b.isdismiss = 0)
-							INNER JOIN socialize_summary c ON ( b.id = c.chat_group_id )
-							LEFT JOIN socialize_message d ON ( c.message_id = d.id ) 
-						) `, newUserId)
-
-	allSql = strings.Join(append(sqlArr, oneSql, groupSql, serviceSql), " union ")
 
-	log.Println("查询sql", allSql)
-	data := IC.BaseMysql.SelectBySql(allSql)
-	log.Println("查询数据:", data)
+	//log.Println("查询sql", allSql)
+	//data := IC.BaseMysql.SelectBySql(allSql)
+	//log.Println("查询数据:", data)
 	return
 }
 
@@ -675,8 +617,8 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 	case 3: //群聊天
 
 		sqlStr = fmt.Sprintf("SELECT a.messag_id AS messageId,b.*,"+
-			"IF ( a.own_id = a.receive_user_id, 1, 2 ) AS fool,"+
-			"IF ( a.own_id = a.receive_user_id, 0, a.receive_user_id ) AS receive_position_id,"+
+			"IF ( a.own_id = a.send_user_id, 1, 2 ) AS fool,"+
+			"IF ( a.own_id = a.send_user_id, 0, a.send_user_id ) AS send_position_id,"+
 			"a.send_user_type,a.type AS itemType FROM %s a "+
 			"LEFT JOIN %s b ON a.messag_id = b.id "+
 			"WHERE a.own_type = 2 AND a.own_id = %d "+
@@ -697,28 +639,28 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 				"WHERE   a.own_type = 1 and a.iswithdraw = 0  "+
 				"AND (a.type = 5 or a.type=4 or a.type=6 or  a.type=7 or a.type=8 )   "+
 				"AND c.ent_id =   %d "+
-				"AND c.user_id in (%s)  %s "+
-				"ORDER BY a.create_time desc ,a.id   asc "+
+				"AND c.user_id =   %d  %s "+
+				"ORDER BY a.create_time desc ,a.id asc "+
 				"limit 0 ,  %d ",
 				util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_MESSAGE, util.SOCIALIZE_CHAT_SESSION,
-				in.EntId, positionStr, lastStr, in.PageSize)
+				in.EntId, in.SendId, lastStr, in.PageSize)
 		} else {
 			//用户聊天记录查看
 			sqlStr = fmt.Sprintf("SELECT a.messag_id as messageId,e.appraise as appraise, 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   %s a   "+
 				"LEFT JOIN %s b ON a.messag_id = b.id   "+
-				"LEFT JOIN %s c ON   IF  ( a.send_user_type = 1, a.send_user_id, a.receive_user_id ) = c.id  AND c.user_id in (%s) "+
-				"LEFT JOIN  %s d on  c.ent_id=d.ent_id  "+
-				"LEFT JOIN  %s e on  b.id=e.messag_id  "+
-				"WHERE   a.own_type = 2    "+
-				"AND a.own_id in  (%s) "+
-				//"AND  c.ent_id = %d "+
-				"AND c.user_id in  (%s) "+
-				"AND ( a.type = 4 OR a.type = 5 or a.type=6 or  a.type=7)  %s "+
-				"ORDER BY a.create_time desc ,a.id   asc "+
+				"LEFT JOIN %s c ON   IF   ( a.send_user_type = 1, a.send_user_id, a.receive_user_id ) = c.id AND  c.ent_id = %d AND c.user_id = %d "+
+				"LEFT JOIN  %s d on  c.ent_id=d.ent_id    "+
+				"LEFT JOIN %s e on  e.messag_id=b.id "+
+				"WHERE   a.own_type = 2  and a.iswithdraw = 0  "+
+				"AND a.own_id =  %d "+
+				"AND  c.ent_id = %d "+
+				"AND c.user_id =  %d "+
+				"AND ( a.type = 4 OR a.type = 5 or a.type=6 or  a.type=7 or  a.type=8)  %s "+
+				"ORDER BY a.create_time  desc,a.id   asc "+
 				"limit 0 ,   %d ",
-				util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_MESSAGE, util.SOCIALIZE_CHAT_SESSION, positionStr, util.SOCIALIZE_TENANT_ROBOT,
-				util.SOCIALIZE_APPRAISE, positionStr, positionStr, lastStr, in.PageSize)
+				util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_MESSAGE, util.SOCIALIZE_CHAT_SESSION, in.SendId, in.NewUserId, util.SOCIALIZE_TENANT_ROBOT, util.SOCIALIZE_APPRAISE,
+				in.NewUserId, in.SendId, in.NewUserId, lastStr, in.PageSize)
 		}
 		break
 	}
@@ -739,7 +681,7 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 	if (in.MsgType == 3 || in.MsgType == 2) && data != nil && len(*data) > 0 {
 		_, _, positionData := EntPerson(in.EntId, true)
 		for _, v := range *data {
-			positionId := quitl.IntAll(v["receive_position_id"])
+			positionId := quitl.IntAll(v["send_position_id"])
 			if positionId != 0 {
 				v["userName"] = positionData[positionId]
 				log.Println(v["userName"], positionData[positionId])