Browse Source

feat: 消息接收人调整

zhangxinlei1996 2 years ago
parent
commit
e4709ef6d1
1 changed files with 16 additions and 17 deletions
  1. 16 17
      service/message_mail_box.go

+ 16 - 17
service/message_mail_box.go

@@ -1029,15 +1029,15 @@ func (this *MessaggeService) Chat(in *messagecenter.MessageEntity) (fool bool, e
 			fieids := []string{"appid", "messag_id", "type", "send_user_id", "send_user_type", "receive_user_id", "receive_user_type", "own_type", "own_id", "create_time", "chat_group_id", "isread"}
 			for _, v := range in.GroupIds {
 				args := []interface{}{}
-				//发送人自己
-				if !isWithdrawByOthers {
-					args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, in.SendId, 2, 2, in.SendId, nowTime, v, 1)
-					//最后一次聊天
-					SocializeSummaryAddOrUpdate(tx, v, in.SendId, 0, messageId, isCustomerServiceAccess, nowTime)
-				}
-				if !isWithdrawByMyself {
-					groupUser := GetUserByGroupId(tx, v, in.SendId)
-					for _, vv := range groupUser {
+				groupUser := GetUserByGroupId(tx, v, in.SendId)
+				for _, vv := range groupUser {
+					//发送人自己
+					if !isWithdrawByOthers {
+						args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, vv, 2, 2, in.SendId, nowTime, v, 1)
+						//最后一次聊天
+						SocializeSummaryAddOrUpdate(tx, v, in.SendId, 0, messageId, isCustomerServiceAccess, nowTime)
+					}
+					if !isWithdrawByMyself {
 						log.Println("获取到群组下员工:", vv)
 						//接收人其他用户
 						args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, vv, 2, 2, vv, nowTime, v, 0)
@@ -1056,19 +1056,18 @@ func (this *MessaggeService) Chat(in *messagecenter.MessageEntity) (fool bool, e
 			}
 			fieids := []string{"appid", "messag_id", "type", "send_user_id", "send_user_type", "receive_user_id", "receive_user_type", "own_type", "own_id", "create_time", "isread"}
 			args := []interface{}{}
-			if !isWithdrawByOthers {
-				args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, in.SendId, 2, 2, in.SendId, nowTime, 1)
-			}
-			if !isWithdrawByMyself {
-				for _, v := range in.ReceiverIds {
-					args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, v, 2, 2, v, nowTime, 0)
 
+			for _, v := range in.ReceiverIds {
+				if !isWithdrawByOthers {
+					args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, v, 2, 2, in.SendId, nowTime, 1)
+				}
+				if !isWithdrawByMyself {
+					args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, v, 2, 2, v, nowTime, 0)
 					//最后一次聊天
 					SocializeSummaryAddOrUpdate(tx, 0, in.SendId, v, messageId, isCustomerServiceAccess, nowTime)
-					// SocializeSummaryAddOrUpdate(tx, 0, v, in.SendId, messageId, isCustomerServiceAccess, nowTime)
 				}
-				MessageMailBoxAdd(tx, fieids, args)
 			}
+			MessageMailBoxAdd(tx, fieids, args)
 		}
 		return true
 	})