Jelajahi Sumber

fix:消息撤回更新私信修改

duxin 2 tahun lalu
induk
melakukan
06fc944157
1 mengubah file dengan 20 tambahan dan 1 penghapusan
  1. 20 1
      service/message_mail_box.go

+ 20 - 1
service/message_mail_box.go

@@ -682,6 +682,7 @@ func (b MessaggeService) UpdateReadById(in *messagecenter.ReadStateReq) bool {
 // WithdrawMessage 撤回消息
 func (b MessaggeService) WithdrawMessage(in *messagecenter.ReadWithdrawReq) bool {
 	messageId := encrypt.SE.Decode4Hex(in.MessageId)
+	newUserId, entUserId := NewEndId(quitl.Int64All(messageId), in.UserType)
 	msg := util.Mysql.FindOne(util.SOCIALIZE_MESSAGE, map[string]interface{}{"id": messageId}, "create_time", "")
 	if msg == nil || len(*msg) <= 0 {
 		log.Println("查询消息id失败")
@@ -696,7 +697,9 @@ func (b MessaggeService) WithdrawMessage(in *messagecenter.ReadWithdrawReq) bool
 	m := util.Mysql.Update(util.SOCIALIZE_MESSAGE_MAILBOX,
 		map[string]interface{}{"messag_id": messageId}, map[string]interface{}{"iswithdraw": 1, "withdraw_time": nowForm.Format(util.Date_Full_Layout)})
 	if m {
-		b.Count(quitl.Int64All(in.NewUserId), in.UserType, in.EntUserId, true)
+		//消息撤回 更新对方私信
+		in.UserType = quitl.Int64All(quitl.If(in.UserType == 1, 2, 1))
+		b.Count(newUserId, in.UserType, entUserId, true)
 	}
 	return m
 }
@@ -730,3 +733,19 @@ func (b MessaggeService) AppraiseMessage(in *messagecenter.AppraiseReq) error {
 	}
 	return fmt.Errorf("评价消息异常")
 }
+
+// NewEndId 消息撤回 获取对方userid
+func NewEndId(messageId, iType int64) (newUserId, entUserId int64) {
+	data := util.Mysql.FindOne(util.SOCIALIZE_MESSAGE_MAILBOX, map[string]interface{}{"messag_id": messageId, "own_type": iType}, "", "")
+	if data != nil && len(*data) > 0 {
+		if iType == 1 { //客服撤回消息 获取客服id与用户id
+			entUserId = quitl.Int64All((*data)["send_user_id"])
+			newUserId = quitl.Int64All((*data)["receive_user_id"])
+		} else {
+			//用户撤回消息 获取客服id与用户id
+			newUserId = quitl.Int64All((*data)["send_user_id"])
+			entUserId = quitl.Int64All((*data)["receive_user_id"])
+		}
+	}
+	return
+}