|
@@ -1021,7 +1021,8 @@ func (b MessaggeService) AppraiseMessage(in *messagecenter.AppraiseReq) error {
|
|
|
// 聊天
|
|
|
// 包含 1v1 ,群聊,群发
|
|
|
/*
|
|
|
-入参 appid,title,content,sendid,link,item,messagetype,receiverIds,groupIds
|
|
|
+类型;1:站内信消息 2:点对点消息 3:群消息 4:机器人消息 5:客服消息 6系统信息 7:客服自动回复 8:评价 9:其它系统消息 (除客服以外的) 10:撤回(自己看到的) 11:撤回(其他人看到的)
|
|
|
+群撤回自己看到的和用户看到的不一样
|
|
|
*/
|
|
|
func (this *MessaggeService) Chat(in *messagecenter.MessageEntity) (fool bool, errorMsg string, content string, messageId, nowInt int64) {
|
|
|
now := time.Now()
|
|
@@ -1030,12 +1031,14 @@ func (this *MessaggeService) Chat(in *messagecenter.MessageEntity) (fool bool, e
|
|
|
fool = IC.BaseMysql.ExecTx("消息存储", func(tx *sql.Tx) bool {
|
|
|
isGroup := len(in.GroupIds) > 0
|
|
|
isOneToOne := len(in.ReceiverIds) > 0
|
|
|
+ isWithdrawByMyself := in.ItemType == 10
|
|
|
+ isWithdrawByOthers := in.ItemType == 11
|
|
|
createperson := strconv.Itoa(int(in.SendId))
|
|
|
messageId = MessageAdd(tx, in.Appid, in.Title, in.Content, createperson, in.Link, in.Item, in.Type)
|
|
|
//是否客服介入
|
|
|
isCustomerServiceAccess := 0
|
|
|
//除客服消息以外的系统消息
|
|
|
- if in.ItemType == 9 {
|
|
|
+ if in.ItemType == 9 || in.ItemType == 10 || in.ItemType == 11 {
|
|
|
in.ItemType = 6
|
|
|
}
|
|
|
//群聊
|
|
@@ -1047,17 +1050,23 @@ 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{}{}
|
|
|
- args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, in.SendId, 2, 2, in.SendId, nowTime, v, 1)
|
|
|
- groupUser := GetUserByGroupId(tx, v, in.SendId)
|
|
|
- for _, vv := range groupUser {
|
|
|
- log.Println("获取到群组下员工:", vv)
|
|
|
- args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, vv, 2, 2, vv, nowTime, v, 0)
|
|
|
+ //发送人自己
|
|
|
+ if !isWithdrawByOthers {
|
|
|
+ args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, in.SendId, 2, 2, in.SendId, nowTime, v, 1)
|
|
|
+ }
|
|
|
+ if !isWithdrawByMyself {
|
|
|
+ groupUser := GetUserByGroupId(tx, v, in.SendId)
|
|
|
+ for _, vv := range groupUser {
|
|
|
+ log.Println("获取到群组下员工:", vv)
|
|
|
+ //接收人其他用户
|
|
|
+ args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, vv, 2, 2, vv, nowTime, v, 0)
|
|
|
+ //最后一次聊天
|
|
|
+ SocializeSummaryAddOrUpdate(tx, v, vv, 0, messageId, isCustomerServiceAccess, nowTime)
|
|
|
+ }
|
|
|
+ //更新未读消息
|
|
|
+ GroupUserUnReadUpdate(tx, groupUser)
|
|
|
}
|
|
|
MessageMailBoxAdd(tx, fieids, args)
|
|
|
- //最后一次聊天
|
|
|
- SocializeSummaryAddOrUpdate(tx, v, 0, 0, messageId, isCustomerServiceAccess, nowTime)
|
|
|
- //更新未读消息
|
|
|
- GroupUserUnReadUpdate(tx, groupUser)
|
|
|
}
|
|
|
}
|
|
|
//1v1
|
|
@@ -1068,15 +1077,19 @@ 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{}{}
|
|
|
- args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, in.SendId, 2, 2, in.SendId, nowTime, 1)
|
|
|
- for _, v := range in.ReceiverIds {
|
|
|
- args = append(args, in.Appid, messageId, in.ItemType, in.SendId, 2, v, 2, 2, v, nowTime, 0)
|
|
|
+ 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)
|
|
|
|
|
|
- //最后一次聊天
|
|
|
- SocializeSummaryAddOrUpdate(tx, 0, in.SendId, v, messageId, isCustomerServiceAccess, nowTime)
|
|
|
- SocializeSummaryAddOrUpdate(tx, 0, v, in.SendId, messageId, isCustomerServiceAccess, nowTime)
|
|
|
+ //最后一次聊天
|
|
|
+ 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
|
|
|
})
|