|
@@ -1069,7 +1069,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)
|
|
|
+ SocializeSummaryAddOrUpdate(tx, v, in.SendId, 0, messageId, isCustomerServiceAccess, nowTime, false)
|
|
|
}
|
|
|
for _, vv := range groupUser {
|
|
|
if !isWithdrawByMyself {
|
|
@@ -1077,7 +1077,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)
|
|
|
+ SocializeSummaryAddOrUpdate(tx, v, 0, vv, messageId, isCustomerServiceAccess, nowTime, false)
|
|
|
}
|
|
|
}
|
|
|
MessageMailBoxAdd(tx, fieids, args)
|
|
@@ -1096,12 +1096,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)
|
|
|
+ SocializeSummaryAddOrUpdate(tx, 0, in.SendId, v, messageId, isCustomerServiceAccess, nowTime, true)
|
|
|
}
|
|
|
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)
|
|
|
+ SocializeSummaryAddOrUpdate(tx, 0, v, in.SendId, messageId, isCustomerServiceAccess, nowTime, false)
|
|
|
}
|
|
|
}
|
|
|
MessageMailBoxAdd(tx, fieids, args)
|
|
@@ -1156,7 +1156,8 @@ func GetUserByGroupId(tx *sql.Tx, groupId, sendId int64) []int64 {
|
|
|
// 最后一次聊天存储
|
|
|
// 1v1是双方的
|
|
|
// 群聊是发送人和其他人的
|
|
|
-func SocializeSummaryAddOrUpdate(tx *sql.Tx, groupId, myPositionId, yourPositionId, messageId int64, isCustomerServiceAccess int, timestamp string) bool {
|
|
|
+//send :true发送人 false接收人 用于取分1对1 身份
|
|
|
+func SocializeSummaryAddOrUpdate(tx *sql.Tx, groupId, myPositionId, yourPositionId, messageId int64, isCustomerServiceAccess int, timestamp string, send bool) bool {
|
|
|
//判断是否存在
|
|
|
if groupId > 0 {
|
|
|
isSend := myPositionId != 0
|
|
@@ -1207,25 +1208,32 @@ func SocializeSummaryAddOrUpdate(tx *sql.Tx, groupId, myPositionId, yourPosition
|
|
|
ok_my := true
|
|
|
ok_your := true
|
|
|
//发送方
|
|
|
- if IC.BaseMysql.CountBySql(fmt.Sprintf(`select count(1) from %s where my_position_id =? and your_position_id =?`, util.SOCIALIZE_SUMMARY), myPositionId, yourPositionId) > 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 { //存在更新
|
|
|
+ updateMap := map[string]interface{}{
|
|
|
+ "message_id": messageId,
|
|
|
+ "timestamp": timestamp,
|
|
|
+ }
|
|
|
+ if !send {
|
|
|
+ updateMap["unread"] = gconv.Int((*r)[0]["unread"]) + 1
|
|
|
+ }
|
|
|
ok_my = IC.BaseMysql.UpdateByTx(tx, util.SOCIALIZE_SUMMARY, map[string]interface{}{
|
|
|
"my_position_id": myPositionId,
|
|
|
"your_position_id": yourPositionId,
|
|
|
- }, map[string]interface{}{
|
|
|
- "message_id": messageId,
|
|
|
- "timestamp": timestamp,
|
|
|
- })
|
|
|
+ }, updateMap)
|
|
|
} else {
|
|
|
//新增
|
|
|
- ok_my = IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_SUMMARY, map[string]interface{}{
|
|
|
+ saveMap := map[string]interface{}{
|
|
|
"my_position_id": myPositionId,
|
|
|
"your_position_id": yourPositionId,
|
|
|
"message_id": messageId,
|
|
|
"timestamp": timestamp,
|
|
|
"unread": 0,
|
|
|
"customer_service_access": isCustomerServiceAccess,
|
|
|
- }) > 0
|
|
|
+ }
|
|
|
+ if !send {
|
|
|
+ saveMap["unread"] = 1
|
|
|
+ }
|
|
|
+ ok_my = IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_SUMMARY, saveMap) > 0
|
|
|
}
|
|
|
return ok_my && ok_your
|
|
|
}
|