瀏覽代碼

feat: 个人聊天最后一次存储

zhangxinlei1996 2 年之前
父節點
當前提交
0372e823fd
共有 1 個文件被更改,包括 3 次插入23 次删除
  1. 3 23
      service/message_mail_box.go

+ 3 - 23
service/message_mail_box.go

@@ -1060,11 +1060,13 @@ func (this *MessaggeService) Chat(in *messagecenter.MessageEntity) (fool bool, e
 			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)
+					//最后一次聊天
+					SocializeSummaryAddOrUpdate(tx, 0, in.SendId, v, messageId, isCustomerServiceAccess, nowTime)
 				}
 				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)
@@ -1190,28 +1192,6 @@ func SocializeSummaryAddOrUpdate(tx *sql.Tx, groupId, myPositionId, yourPosition
 					"customer_service_access": isCustomerServiceAccess,
 				}) > 0
 			}
-			//接收方
-			if r := IC.BaseMysql.SelectBySql(fmt.Sprintf(`select id,unread from %s where my_position_id =? and your_position_id =? limit 1`, util.SOCIALIZE_SUMMARY), yourPositionId, myPositionId); r != nil && len(*r) > 0 {
-				//存在更新
-				ok_your = IC.BaseMysql.UpdateByTx(tx, util.SOCIALIZE_SUMMARY, map[string]interface{}{
-					"my_position_id":   yourPositionId,
-					"your_position_id": myPositionId,
-				}, map[string]interface{}{
-					"message_id": messageId,
-					"timestamp":  timestamp,
-					"unread":     gconv.Int((*r)[0]["unread"]) + 1,
-				})
-			} else {
-				//新增
-				ok_your = IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_SUMMARY, map[string]interface{}{
-					"my_position_id":          yourPositionId,
-					"your_position_id":        myPositionId,
-					"message_id":              messageId,
-					"timestamp":               timestamp,
-					"unread":                  1,
-					"customer_service_access": isCustomerServiceAccess,
-				}) > 0
-			}
 			return ok_my && ok_your
 		}
 	}