Selaa lähdekoodia

Merge branch 'dev/v1.0.2_dx' of SocialPlatform/messageCenter into feature/v1.0.2

wangkaiyue 2 vuotta sitten
vanhempi
commit
bc5bb412ef

+ 2 - 2
api/messagecenter/internal/types/types.go

@@ -88,9 +88,9 @@ type ReadStateReq struct {
 
 type ReadWithdrawReq struct {
 	MessageId string `json:"messageId"`
-	EntUserId string `json:"entUserId"`
 	Appid     string `header:"appid"`
-	NewUserId string `json:"newUserId"`
+	NewUserId int64  `header:"newUserId,optional"`
+	EntUserId int64  `header:"entUserId,optional"`
 	UserType  int64  `json:"userType"`
 }
 

+ 2 - 2
api/messagecenter/messagecenter.api

@@ -78,9 +78,9 @@ type ReadStateReq {
 
 type ReadWithdrawReq {
 	MessageId string `json:"messageId"`
-	EntUserId string `json:"entUserId"`
 	Appid     string `header:"appid"`
-	NewUserId string `json:"newUserId"`
+	NewUserId int64  `header:"newUserId,optional"`
+	EntUserId int64  `header:"entUserId,optional"`
 	UserType  int64  `json:"userType"`
 }
 

+ 7 - 7
rpc/messagecenter/internal/server/messagecenterserver.go

@@ -22,37 +22,37 @@ func NewMessageCenterServer(svcCtx *svc.ServiceContext) *MessageCenterServer {
 	}
 }
 
-// 查询数量
+//  查询数量
 func (s *MessageCenterServer) Count(ctx context.Context, in *messagecenter.CountReq) (*messagecenter.CountResp, error) {
 	l := logic.NewCountLogic(ctx, s.svcCtx)
 	return l.Count(in)
 }
 
-// 用户列表查询
+//  用户列表查询
 func (s *MessageCenterServer) UserList(ctx context.Context, in *messagecenter.UserReq) (*messagecenter.UserResp, error) {
 	l := logic.NewUserListLogic(ctx, s.svcCtx)
 	return l.UserList(in)
 }
 
-// 聊天内容查询
+//  聊天内容查询
 func (s *MessageCenterServer) FindMessage(ctx context.Context, in *messagecenter.MessageReq) (*messagecenter.MessageResp, error) {
 	l := logic.NewFindMessageLogic(ctx, s.svcCtx)
 	return l.FindMessage(in)
 }
 
-// 聊天保存
+//  聊天保存
 func (s *MessageCenterServer) SaveMessage(ctx context.Context, in *messagecenter.MessageEntity) (*messagecenter.SaveMessageResp, error) {
 	l := logic.NewSaveMessageLogic(ctx, s.svcCtx)
 	return l.SaveMessage(in)
 }
 
-// 会话创建
+//  会话创建
 func (s *MessageCenterServer) CreateChatSession(ctx context.Context, in *messagecenter.ChatSessionReq) (*messagecenter.ChatSessionResp, error) {
 	l := logic.NewCreateChatSessionLogic(ctx, s.svcCtx)
 	return l.CreateChatSession(in)
 }
 
-// 会话关闭
+//  会话关闭
 func (s *MessageCenterServer) CloseChatSession(ctx context.Context, in *messagecenter.CloseSessionReq) (*messagecenter.ChatSessionResp, error) {
 	l := logic.NewCloseChatSessionLogic(ctx, s.svcCtx)
 	return l.CloseChatSession(in)
@@ -76,7 +76,7 @@ func (s *MessageCenterServer) WithdrawMessage(ctx context.Context, in *messagece
 	return l.WithdrawMessage(in)
 }
 
-// 用户评价回复
+//  用户评价回复
 func (s *MessageCenterServer) AppraiseMessage(ctx context.Context, in *messagecenter.AppraiseReq) (*messagecenter.CurrencyResp, error) {
 	l := logic.NewAppraiseMessageLogic(ctx, s.svcCtx)
 	return l.AppraiseMessage(in)

+ 4 - 4
rpc/messagecenter/messagecenter.proto

@@ -122,11 +122,11 @@ message ReadStateReq {
 }
 
 message ReadWithdrawReq {
-  string         messageId = 1;
-  string        entUserId = 2;
+  string        messageId = 1;
+  int64         entUserId = 2;
   string        appid=3;
-  string newUserId = 4;
-  int64     userType=6;      //用户类型:2用户1客服
+  int64         newUserId = 4;
+  int64         userType=6;      //用户类型:2用户1客服
 }
 
 message AppraiseReq {

+ 8 - 8
rpc/messagecenter/messagecenter/messagecenter.pb.go

@@ -1276,9 +1276,9 @@ type ReadWithdrawReq struct {
 	unknownFields protoimpl.UnknownFields
 
 	MessageId string `protobuf:"bytes,1,opt,name=messageId,proto3" json:"messageId,omitempty"`
-	EntUserId string `protobuf:"bytes,2,opt,name=entUserId,proto3" json:"entUserId,omitempty"`
+	EntUserId int64  `protobuf:"varint,2,opt,name=entUserId,proto3" json:"entUserId,omitempty"`
 	Appid     string `protobuf:"bytes,3,opt,name=appid,proto3" json:"appid,omitempty"`
-	NewUserId string `protobuf:"bytes,4,opt,name=newUserId,proto3" json:"newUserId,omitempty"`
+	NewUserId int64  `protobuf:"varint,4,opt,name=newUserId,proto3" json:"newUserId,omitempty"`
 	UserType  int64  `protobuf:"varint,6,opt,name=userType,proto3" json:"userType,omitempty"` //用户类型:2用户1客服
 }
 
@@ -1321,11 +1321,11 @@ func (x *ReadWithdrawReq) GetMessageId() string {
 	return ""
 }
 
-func (x *ReadWithdrawReq) GetEntUserId() string {
+func (x *ReadWithdrawReq) GetEntUserId() int64 {
 	if x != nil {
 		return x.EntUserId
 	}
-	return ""
+	return 0
 }
 
 func (x *ReadWithdrawReq) GetAppid() string {
@@ -1335,11 +1335,11 @@ func (x *ReadWithdrawReq) GetAppid() string {
 	return ""
 }
 
-func (x *ReadWithdrawReq) GetNewUserId() string {
+func (x *ReadWithdrawReq) GetNewUserId() int64 {
 	if x != nil {
 		return x.NewUserId
 	}
-	return ""
+	return 0
 }
 
 func (x *ReadWithdrawReq) GetUserType() int64 {
@@ -1654,10 +1654,10 @@ var file_messagecenter_proto_rawDesc = []byte{
 	0x71, 0x12, 0x1c, 0x0a, 0x09, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x64, 0x18, 0x01,
 	0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x64, 0x12,
 	0x1c, 0x0a, 0x09, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01,
-	0x28, 0x09, 0x52, 0x09, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a,
+	0x28, 0x03, 0x52, 0x09, 0x65, 0x6e, 0x74, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a,
 	0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70,
 	0x70, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x6e, 0x65, 0x77, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64,
-	0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6e, 0x65, 0x77, 0x55, 0x73, 0x65, 0x72, 0x49,
+	0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6e, 0x65, 0x77, 0x55, 0x73, 0x65, 0x72, 0x49,
 	0x64, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x18, 0x06, 0x20,
 	0x01, 0x28, 0x03, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x54, 0x79, 0x70, 0x65, 0x22, 0x7b, 0x0a,
 	0x0b, 0x41, 0x70, 0x70, 0x72, 0x61, 0x69, 0x73, 0x65, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05,

+ 20 - 3
service/message_mail_box.go

@@ -682,8 +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 := encrypt.SE.Decode4Hex(in.NewUserId)
-	entUserId := encrypt.SE.Decode4Hex(in.EntUserId)
+	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失败")
@@ -698,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(newUserId), in.UserType, quitl.Int64All(entUserId), true)
+		//消息撤回 更新对方私信
+		in.UserType = quitl.Int64All(quitl.If(in.UserType == 1, 2, 1))
+		b.Count(newUserId, in.UserType, entUserId, true)
 	}
 	return m
 }
@@ -732,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
+}