Browse Source

Merge branch 'dev/v1.2.6_zxl' of SocialPlatform/messageCenter into feature/v1.2.6

duxin 2 years ago
parent
commit
892b9470c6
1 changed files with 21 additions and 15 deletions
  1. 21 15
      service/message_mail_box.go

+ 21 - 15
service/message_mail_box.go

@@ -1070,7 +1070,7 @@ func (this *MessaggeService) Chat(in *messagecenter.MessageEntity) (fool bool, e
 				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, false)
+					SocializeSummaryAddOrUpdate(tx, v, in.SendId, 0, messageId, isCustomerServiceAccess, nowTime, false, in.ItemType)
 				}
 				for _, vv := range groupUser {
 					if !isWithdrawByMyself {
@@ -1078,7 +1078,7 @@ func (this *MessaggeService) Chat(in *messagecenter.MessageEntity) (fool bool, e
 						//接收人其他用户
 						args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, vv, 2, 2, vv, nowTime, v, 0)
 						//最后一次聊天
-						SocializeSummaryAddOrUpdate(tx, v, 0, vv, messageId, isCustomerServiceAccess, nowTime, false)
+						SocializeSummaryAddOrUpdate(tx, v, 0, vv, messageId, isCustomerServiceAccess, nowTime, false, in.ItemType)
 					}
 				}
 				MessageMailBoxAdd(tx, fieids, args)
@@ -1097,12 +1097,12 @@ func (this *MessaggeService) Chat(in *messagecenter.MessageEntity) (fool bool, e
 				if !isWithdrawByOthers {
 					args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, v, 2, 2, in.SendId, nowTime, 1)
 					//最后一次聊天
-					SocializeSummaryAddOrUpdate(tx, 0, in.SendId, v, messageId, isCustomerServiceAccess, nowTime, true)
+					SocializeSummaryAddOrUpdate(tx, 0, in.SendId, v, messageId, isCustomerServiceAccess, nowTime, true, in.ItemType)
 				}
 				if !isWithdrawByMyself {
 					args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, v, 2, 2, v, nowTime, 0)
 					//最后一次聊天
-					SocializeSummaryAddOrUpdate(tx, 0, v, in.SendId, messageId, isCustomerServiceAccess, nowTime, false)
+					SocializeSummaryAddOrUpdate(tx, 0, v, in.SendId, messageId, isCustomerServiceAccess, nowTime, false, in.ItemType)
 				}
 			}
 			MessageMailBoxAdd(tx, fieids, args)
@@ -1158,7 +1158,7 @@ func GetUserByGroupId(tx *sql.Tx, groupId, sendId int64) []int64 {
 // 1v1是双方的
 // 群聊是发送人和其他人的
 // send :true发送人 false接收人 用于取分1对1 身份
-func SocializeSummaryAddOrUpdate(tx *sql.Tx, groupId, myPositionId, yourPositionId, messageId int64, isCustomerServiceAccess int, timestamp string, send bool) bool {
+func SocializeSummaryAddOrUpdate(tx *sql.Tx, groupId, myPositionId, yourPositionId, messageId int64, isCustomerServiceAccess int, timestamp string, send bool, itemType int64) bool {
 	//判断是否存在
 	if groupId > 0 {
 		isSend := myPositionId != 0
@@ -1184,24 +1184,30 @@ func SocializeSummaryAddOrUpdate(tx *sql.Tx, groupId, myPositionId, yourPosition
 			}
 		} else {
 			if r := IC.BaseMysql.SelectBySql(fmt.Sprintf(`select unread from %s where chat_group_id =? and my_position_id =?`, util.SOCIALIZE_SUMMARY), groupId, yourPositionId); r != nil && len(*r) > 0 {
+				updateMap := map[string]interface{}{
+					"message_id": messageId,
+					"timestamp":  timestamp,
+				}
+				if itemType != 6 {
+					updateMap["unread"] = gconv.Int((*r)[0]["unread"]) + 1
+				}
 				//存在更新
 				return IC.BaseMysql.UpdateByTx(tx, util.SOCIALIZE_SUMMARY, map[string]interface{}{
 					"chat_group_id":  groupId,
 					"my_position_id": yourPositionId,
-				}, map[string]interface{}{
-					"message_id": messageId,
-					"timestamp":  timestamp,
-					"unread":     gconv.Int((*r)[0]["unread"]) + 1,
-				})
+				}, updateMap)
 			} else {
 				//新增
-				return IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_SUMMARY, map[string]interface{}{
+				saveMap := map[string]interface{}{
 					"chat_group_id":  groupId,
 					"my_position_id": yourPositionId,
 					"message_id":     messageId,
 					"timestamp":      timestamp,
-					"unread":         1,
-				}) > 0
+				}
+				if itemType != 6 {
+					saveMap["unread"] = 1
+				}
+				return IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_SUMMARY, saveMap) > 0
 			}
 		}
 	} else {
@@ -1214,7 +1220,7 @@ func SocializeSummaryAddOrUpdate(tx *sql.Tx, groupId, myPositionId, yourPosition
 					"message_id": messageId,
 					"timestamp":  timestamp,
 				}
-				if !send {
+				if !send && itemType != 6 {
 					updateMap["unread"] = gconv.Int((*r)[0]["unread"]) + 1
 				}
 				ok_my = IC.BaseMysql.UpdateByTx(tx, util.SOCIALIZE_SUMMARY, map[string]interface{}{
@@ -1231,7 +1237,7 @@ func SocializeSummaryAddOrUpdate(tx *sql.Tx, groupId, myPositionId, yourPosition
 					"unread":                  0,
 					"customer_service_access": isCustomerServiceAccess,
 				}
-				if !send {
+				if !send && itemType != 6 {
 					saveMap["unread"] = 1
 				}
 				ok_my = IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_SUMMARY, saveMap) > 0