Browse Source

Merge branch 'dev/v1.2.6_rjj' of SocialPlatform/messageCenter into feature/v1.2.6

王浩 2 years ago
parent
commit
7a28470581

+ 10 - 9
api/messagecenter/internal/logic/findmessagelogic.go

@@ -28,15 +28,16 @@ func NewFindMessageLogic(ctx context.Context, svcCtx *svc.ServiceContext) *FindM
 func (l *FindMessageLogic) FindMessage(req *types.MessageReq) (*types.CommonRes, error) {
 	// todo: add your logic here and delete this line
 	resp, err := l.svcCtx.Message.FindMessage(l.ctx, &messagecenter.MessageReq{
-		UserType:  req.UserType,
-		MsgType:   req.MsgType,
-		SendId:    quitl.Int64All(encrypt.SE.Decode4Hex(req.SendId)),
-		LastId:    quitl.Int64All(encrypt.SE.Decode4Hex(req.LastId)),
-		EntId:     req.EntId,
-		PageSize:  req.PageSize,
-		EntUserId: req.EntUserId,
-		NewUserId: req.NewUserId,
-		Sort:      req.Sort,
+		UserType:    req.UserType,
+		MsgType:     req.MsgType,
+		SendId:      quitl.Int64All(encrypt.SE.Decode4Hex(req.SendId)),
+		LastId:      quitl.Int64All(encrypt.SE.Decode4Hex(req.LastId)),
+		EntId:       req.EntId,
+		PageSize:    req.PageSize,
+		EntUserId:   req.EntUserId,
+		NewUserId:   req.NewUserId,
+		Sort:        req.Sort,
+		ChatGroupId: req.ChatGroupId,
 	})
 	if err != nil {
 		return nil, err

+ 10 - 9
api/messagecenter/internal/types/types.go

@@ -43,15 +43,16 @@ type MessageEntity struct {
 }
 
 type MessageReq struct {
-	MsgType   int64  `json:"msgType"`
-	UserType  int64  `json:"userType"`
-	SendId    string `json:"sendId,optional"`
-	LastId    string `json:"lastId,optional"`
-	PageSize  int64  `json:"pageSize"`
-	NewUserId int64  `header:"newUserId"`
-	EntUserId int64  `header:"entUserId,optional"`
-	EntId     int64  `header:"entId,optional"`
-	Sort      string `json:"sort,optional"`
+	MsgType     int64  `json:"msgType"`
+	UserType    int64  `json:"userType"`
+	SendId      string `json:"sendId,optional"`
+	LastId      string `json:"lastId,optional"`
+	PageSize    int64  `json:"pageSize"`
+	NewUserId   int64  `header:"newUserId"`
+	EntUserId   int64  `header:"entUserId,optional"`
+	EntId       int64  `header:"entId,optional"`
+	Sort        string `json:"sort,optional"`
+	ChatGroupId int64  `json:"chatGroupId,optional"`
 }
 
 type CommonRes struct {

+ 10 - 9
api/messagecenter/messagecenter.api

@@ -38,15 +38,16 @@ type MessageEntity {
 	ReceiveId string `json:"receiveId,optional"`
 }
 type MessageReq {
-	MsgType   int64  `json:"msgType"`
-	UserType  int64  `json:"userType"`
-	SendId    string `json:"sendId,optional"`
-	LastId    string `json:"lastId,optional"`
-	PageSize  int64  `json:"pageSize"`
-	NewUserId int64  `header:"newUserId"`
-	EntUserId int64  `header:"entUserId,optional"`
-	EntId     int64  `header:"entId,optional"`
-	Sort      string `json:"sort,optional"`
+	MsgType     int64  `json:"msgType"`
+	UserType    int64  `json:"userType"`
+	SendId      string `json:"sendId,optional"`
+	LastId      string `json:"lastId,optional"`
+	PageSize    int64  `json:"pageSize"`
+	NewUserId   int64  `header:"newUserId"`
+	EntUserId   int64  `header:"entUserId,optional"`
+	EntId       int64  `header:"entId,optional"`
+	Sort        string `json:"sort,optional"`
+	ChatGroupId int64  `json:"chatGroupId,optional"`
 }
 
 type CommonRes {

+ 1 - 0
entity/util.go

@@ -22,6 +22,7 @@ const (
 	SOCIALIZE_CHAT_GROUP        = "socialize_chat_group"
 	SOCIALIZE_CHAT_GROUP_NOTICE = "socialize_chat_group_notice"
 	SOCIALIZE_CHAT_GROUP_PERSON = "socialize_chat_group_person"
+	BASE_POSITION               = "base_position"
 	User_message_list           = "user_message_list"
 	//mainMysql
 	ENTNICHE_USER = "entniche_user"

+ 31 - 0
rpc/messagecenter/internal/logic/groupchatlogic.go

@@ -0,0 +1,31 @@
+package logic
+
+import (
+	"context"
+
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/internal/svc"
+	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type GroupChatLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewGroupChatLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GroupChatLogic {
+	return &GroupChatLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+//  群聊
+func (l *GroupChatLogic) GroupChat(in *messagecenter.MessageSaveReq) (*messagecenter.CommonReq, error) {
+	// todo: add your logic here and delete this line
+
+	return &messagecenter.CommonReq{}, nil
+}

+ 0 - 1
rpc/messagecenter/internal/logic/groupnameupdatelogic.go

@@ -30,6 +30,5 @@ func (l *GroupNameUpdateLogic) GroupNameUpdate(in *messagecenter.GroupNameUpdate
 	return &messagecenter.CommonReq{
 		ErrorCode: 0,
 		Status:    status,
-		ErrorMsg:  msg,
 	}, nil
 }

+ 14 - 8
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)
@@ -130,14 +130,20 @@ 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)
 }
 
-// 客服列表查询
+//  客服列表查询
 func (s *MessageCenterServer) ConversationList(ctx context.Context, in *messagecenter.ConversationReq) (*messagecenter.UserResp, error) {
 	l := logic.NewConversationListLogic(ctx, s.svcCtx)
 	return l.ConversationList(in)
 }
+
+//  群聊
+func (s *MessageCenterServer) GroupChat(ctx context.Context, in *messagecenter.MessageSaveReq) (*messagecenter.CommonReq, error) {
+	l := logic.NewGroupChatLogic(ctx, s.svcCtx)
+	return l.GroupChat(in)
+}

+ 2 - 0
rpc/messagecenter/messagecenter.proto

@@ -58,6 +58,7 @@ message MessageReq {
   int64         entId = 8;
   int64         customerEntId = 9;
   string        sort = 10;
+  int64         chatGroupId = 11;
 }
 message MessageResp {
   int64         count = 1;
@@ -241,6 +242,7 @@ message departmentsInfo{
   int64 id = 1;
   string departmentName = 2;
   repeated PersonInfo persons = 3;//部门下的人
+  departmentsInfo childDepartment = 4;//部门下子部门
 }
 message EntPersonListResp{
   int64         error_code = 1; //响应代码

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

@@ -52,6 +52,8 @@ type (
 		AppraiseMessage(ctx context.Context, in *AppraiseReq, opts ...grpc.CallOption) (*CurrencyResp, error)
 		//  客服列表查询
 		ConversationList(ctx context.Context, in *ConversationReq, opts ...grpc.CallOption) (*UserResp, error)
+		//  群聊
+		GroupChat(ctx context.Context, in *MessageSaveReq, opts ...grpc.CallOption) (*CommonReq, error)
 	}
 
 	defaultMessageCenter struct {
@@ -65,37 +67,37 @@ func NewMessageCenter(cli zrpc.Client) MessageCenter {
 	}
 }
 
-// 查询数量
+//  查询数量
 func (m *defaultMessageCenter) Count(ctx context.Context, in *CountReq, opts ...grpc.CallOption) (*CountResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.Count(ctx, in, opts...)
 }
 
-// 用户列表查询
+//  用户列表查询
 func (m *defaultMessageCenter) UserList(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.UserList(ctx, in, opts...)
 }
 
-// 聊天内容查询
+//  聊天内容查询
 func (m *defaultMessageCenter) FindMessage(ctx context.Context, in *MessageReq, opts ...grpc.CallOption) (*MessageResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.FindMessage(ctx, in, opts...)
 }
 
-// 聊天保存
+//  聊天保存
 func (m *defaultMessageCenter) SaveMessage(ctx context.Context, in *MessageEntity, opts ...grpc.CallOption) (*SaveMessageResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.SaveMessage(ctx, in, opts...)
 }
 
-// 会话创建
+//  会话创建
 func (m *defaultMessageCenter) CreateChatSession(ctx context.Context, in *ChatSessionReq, opts ...grpc.CallOption) (*ChatSessionResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.CreateChatSession(ctx, in, opts...)
 }
 
-// 会话关闭
+//  会话关闭
 func (m *defaultMessageCenter) CloseChatSession(ctx context.Context, in *CloseSessionReq, opts ...grpc.CallOption) (*ChatSessionResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.CloseChatSession(ctx, in, opts...)
@@ -173,14 +175,20 @@ func (m *defaultMessageCenter) WithdrawMessage(ctx context.Context, in *ReadWith
 	return client.WithdrawMessage(ctx, in, opts...)
 }
 
-// 用户评价回复
+//  用户评价回复
 func (m *defaultMessageCenter) AppraiseMessage(ctx context.Context, in *AppraiseReq, opts ...grpc.CallOption) (*CurrencyResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.AppraiseMessage(ctx, in, opts...)
 }
 
-// 客服列表查询
+//  客服列表查询
 func (m *defaultMessageCenter) ConversationList(ctx context.Context, in *ConversationReq, opts ...grpc.CallOption) (*UserResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())
 	return client.ConversationList(ctx, in, opts...)
 }
+
+//  群聊
+func (m *defaultMessageCenter) GroupChat(ctx context.Context, in *MessageSaveReq, opts ...grpc.CallOption) (*CommonReq, error) {
+	client := NewMessageCenterClient(m.cli.Conn())
+	return client.GroupChat(ctx, in, opts...)
+}

File diff suppressed because it is too large
+ 585 - 417
rpc/messagecenter/messagecenter/messagecenter.pb.go


+ 62 - 24
rpc/messagecenter/messagecenter/messagecenter_grpc.pb.go

@@ -34,34 +34,36 @@ type MessageCenterClient interface {
 	CreateChatSession(ctx context.Context, in *ChatSessionReq, opts ...grpc.CallOption) (*ChatSessionResp, error)
 	// 会话关闭
 	CloseChatSession(ctx context.Context, in *CloseSessionReq, opts ...grpc.CallOption) (*ChatSessionResp, error)
-	// 创建会话并且保存信息
+	//创建会话并且保存信息
 	SaveAutoReplyMsg(ctx context.Context, in *SaveAutoReplyReq, opts ...grpc.CallOption) (*MessageResp, error)
-	// 根据消息修改已读状态
+	//根据消息修改已读状态
 	UpdateReadById(ctx context.Context, in *ReadStateReq, opts ...grpc.CallOption) (*CurrencyResp, error)
-	// 群组列表查询
+	//群组列表查询
 	ChatGroupList(ctx context.Context, in *ChatGroupListReq, opts ...grpc.CallOption) (*ChatGroupListResp, error)
-	// 群组新增
+	//群组新增
 	ChatGroupAdd(ctx context.Context, in *ChatGroupAddReq, opts ...grpc.CallOption) (*CommonReq, error)
-	// 群组成员查询
+	//群组成员查询
 	ChatGroupPerson(ctx context.Context, in *ChatGroupPersonReq, opts ...grpc.CallOption) (*ChatGroupPersonResp, error)
-	// 加入群组
+	//加入群组
 	ChatGroupJoin(ctx context.Context, in *ChatGroupJoinReq, opts ...grpc.CallOption) (*CommonReq, error)
-	// 群组名称修改
+	//群组名称修改
 	GroupNameUpdate(ctx context.Context, in *GroupNameUpdateReq, opts ...grpc.CallOption) (*CommonReq, error)
-	// 群任务新增
+	//群任务新增
 	GroupNoticeAdd(ctx context.Context, in *GroupNoticeAddReq, opts ...grpc.CallOption) (*CommonReq, error)
-	// 群任务编辑
+	//群任务编辑
 	GroupNoticeUpdate(ctx context.Context, in *GroupNoticeUpdateReq, opts ...grpc.CallOption) (*CommonReq, error)
-	// 群任务详情
+	//群任务详情
 	GroupNoticeGet(ctx context.Context, in *ChatGroupPersonReq, opts ...grpc.CallOption) (*GroupNoticeGetResp, error)
-	// 通讯录 -企业人员列表
+	//通讯录 -企业人员列表
 	EntPersonsList(ctx context.Context, in *EntPersonsListReq, opts ...grpc.CallOption) (*EntPersonListResp, error)
-	// 用户撤回消息
+	//用户撤回消息
 	WithdrawMessage(ctx context.Context, in *ReadWithdrawReq, opts ...grpc.CallOption) (*CurrencyResp, error)
 	// 用户评价回复
 	AppraiseMessage(ctx context.Context, in *AppraiseReq, opts ...grpc.CallOption) (*CurrencyResp, error)
 	// 客服列表查询
 	ConversationList(ctx context.Context, in *ConversationReq, opts ...grpc.CallOption) (*UserResp, error)
+	// 群聊
+	GroupChat(ctx context.Context, in *MessageSaveReq, opts ...grpc.CallOption) (*CommonReq, error)
 }
 
 type messageCenterClient struct {
@@ -252,6 +254,15 @@ func (c *messageCenterClient) ConversationList(ctx context.Context, in *Conversa
 	return out, nil
 }
 
+func (c *messageCenterClient) GroupChat(ctx context.Context, in *MessageSaveReq, opts ...grpc.CallOption) (*CommonReq, error) {
+	out := new(CommonReq)
+	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/GroupChat", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // MessageCenterServer is the server API for MessageCenter service.
 // All implementations must embed UnimplementedMessageCenterServer
 // for forward compatibility
@@ -268,34 +279,36 @@ type MessageCenterServer interface {
 	CreateChatSession(context.Context, *ChatSessionReq) (*ChatSessionResp, error)
 	// 会话关闭
 	CloseChatSession(context.Context, *CloseSessionReq) (*ChatSessionResp, error)
-	// 创建会话并且保存信息
+	//创建会话并且保存信息
 	SaveAutoReplyMsg(context.Context, *SaveAutoReplyReq) (*MessageResp, error)
-	// 根据消息修改已读状态
+	//根据消息修改已读状态
 	UpdateReadById(context.Context, *ReadStateReq) (*CurrencyResp, error)
-	// 群组列表查询
+	//群组列表查询
 	ChatGroupList(context.Context, *ChatGroupListReq) (*ChatGroupListResp, error)
-	// 群组新增
+	//群组新增
 	ChatGroupAdd(context.Context, *ChatGroupAddReq) (*CommonReq, error)
-	// 群组成员查询
+	//群组成员查询
 	ChatGroupPerson(context.Context, *ChatGroupPersonReq) (*ChatGroupPersonResp, error)
-	// 加入群组
+	//加入群组
 	ChatGroupJoin(context.Context, *ChatGroupJoinReq) (*CommonReq, error)
-	// 群组名称修改
+	//群组名称修改
 	GroupNameUpdate(context.Context, *GroupNameUpdateReq) (*CommonReq, error)
-	// 群任务新增
+	//群任务新增
 	GroupNoticeAdd(context.Context, *GroupNoticeAddReq) (*CommonReq, error)
-	// 群任务编辑
+	//群任务编辑
 	GroupNoticeUpdate(context.Context, *GroupNoticeUpdateReq) (*CommonReq, error)
-	// 群任务详情
+	//群任务详情
 	GroupNoticeGet(context.Context, *ChatGroupPersonReq) (*GroupNoticeGetResp, error)
-	// 通讯录 -企业人员列表
+	//通讯录 -企业人员列表
 	EntPersonsList(context.Context, *EntPersonsListReq) (*EntPersonListResp, error)
-	// 用户撤回消息
+	//用户撤回消息
 	WithdrawMessage(context.Context, *ReadWithdrawReq) (*CurrencyResp, error)
 	// 用户评价回复
 	AppraiseMessage(context.Context, *AppraiseReq) (*CurrencyResp, error)
 	// 客服列表查询
 	ConversationList(context.Context, *ConversationReq) (*UserResp, error)
+	// 群聊
+	GroupChat(context.Context, *MessageSaveReq) (*CommonReq, error)
 	mustEmbedUnimplementedMessageCenterServer()
 }
 
@@ -363,6 +376,9 @@ func (UnimplementedMessageCenterServer) AppraiseMessage(context.Context, *Apprai
 func (UnimplementedMessageCenterServer) ConversationList(context.Context, *ConversationReq) (*UserResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method ConversationList not implemented")
 }
+func (UnimplementedMessageCenterServer) GroupChat(context.Context, *MessageSaveReq) (*CommonReq, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method GroupChat not implemented")
+}
 func (UnimplementedMessageCenterServer) mustEmbedUnimplementedMessageCenterServer() {}
 
 // UnsafeMessageCenterServer may be embedded to opt out of forward compatibility for this service.
@@ -736,6 +752,24 @@ func _MessageCenter_ConversationList_Handler(srv interface{}, ctx context.Contex
 	return interceptor(ctx, in, info, handler)
 }
 
+func _MessageCenter_GroupChat_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(MessageSaveReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(MessageCenterServer).GroupChat(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/messagecenter.messageCenter/GroupChat",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(MessageCenterServer).GroupChat(ctx, req.(*MessageSaveReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // MessageCenter_ServiceDesc is the grpc.ServiceDesc for MessageCenter service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -823,6 +857,10 @@ var MessageCenter_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "ConversationList",
 			Handler:    _MessageCenter_ConversationList_Handler,
 		},
+		{
+			MethodName: "GroupChat",
+			Handler:    _MessageCenter_GroupChat_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "messagecenter.proto",

+ 12 - 3
service/chat_group.go

@@ -57,7 +57,7 @@ func (b ChatGroupService) ChatGroupAdd(entId, positionId int64, userIdArr []int6
 //群组成员查询
 func (b ChatGroupService) ChatGroupPerson(chatGroupId int64, entId int64, appid string) map[string][]map[string]interface{} {
 	//先查询企业下的人
-	personMap, _ := EntPerson(entId, false)
+	personMap, _, _ := EntPerson(entId, false)
 	//用户下员工查询
 	personData := map[string][]map[string]interface{}{}
 	personList := IC.BaseMysql.SelectBySql("select DISTINCT  a.position_id,a.isgroup_admin,a.iscommon_admin,d.contact as phone   from socialize_chat_group_person  a left JOIN   base_position b on  a.position_id=b.id left join  base_account c  on  c.id=b.account_id  LEFT JOIN base_person d on  c.person_id=d.id where  a.chat_group_id=? and a.status=1 ", chatGroupId)
@@ -184,9 +184,10 @@ func (b ChatGroupService) GroupNoticeGet(chatGroupId int64, appid string) map[st
 }
 
 //企业用户查询
-func EntPerson(entId int64, isAll bool) (map[string]string, map[string]string) {
+func EntPerson(entId int64, isAll bool) (map[string]string, map[string]string, map[int]string) {
 	phoneData := map[string]string{}
 	nameData := map[string]string{}
+	positionData := map[int]string{}
 	//在职人员查询
 	personList := IC.MainMysql.Find(util.ENTNICHE_USER, map[string]interface{}{
 		"ent_Id": entId,
@@ -209,8 +210,16 @@ func EntPerson(entId int64, isAll bool) (map[string]string, map[string]string) {
 				nameData[common.InterfaceToStr(v["name"])] = common.InterfaceToStr(v["phone"])
 			}
 		}
+		//查询企业人员职位
+		positionList := IC.BaseMysql.SelectBySql("SELECT a.phone,b.id FROM base_user a LEFT JOIN base_position b ON a.id = b.user_id WHERE b.ent_id = ?", entId)
+		if positionList != nil && len(*positionList) > 0 {
+			for _, v := range *positionList {
+				positionData[common.IntAll(v["positionId"])] = phoneData[common.ObjToString(v["phone"])]
+			}
+		}
 	}
-	return phoneData, nameData
+
+	return phoneData, nameData, positionData
 }
 
 //用户名换取职位标识(测试)

+ 10 - 4
service/ent_address_book.go

@@ -9,14 +9,14 @@ import (
 func (b ChatGroupService) EntPersonsList(param *messagecenter.EntPersonsListReq) {
 	var sql string
 	if param.Name != "" {
-		sql = "SELECT a.id,a.pid,a.name,c.id as user_id,c.name as user_name,c.phone as user_phone,c.power as user_power,e.name as role from entniche_department a " +
+		sql = "SELECT a.id as dept_id,a.pid,a.name as dept_name,c.id as user_id,c.name as user_name,c.phone as user_phone,c.power as user_power,c.mail,e.name as role from entniche_department a " +
 			"INNER JOIN entniche_department_user b on (a.ent_id=? and a.id=b.dept_id) " +
 			"INNER JOIN entniche_user c on (b.user_id=c.id and c.name like '%" + param.Name + "%') " +
 			"LEFT JOIN entniche_user_role d on (c.id=d.user_id) " +
 			"LEFT JOIN entniche_role e on (d.role_id=e.id) " +
 			"order by a.id,convert(c.name using gbk) COLLATE gbk_chinese_ci asc"
 	} else {
-		sql = `SELECT a.id,a.pid,a.name,c.id as user_id,c.name as user_name,c.phone as user_phone,c.power as user_power,e.name as role from entniche_department a 
+		sql = `SELECT a.id as dept_id,a.pid,a.name as dept_name,c.id as user_id,c.name as user_name,c.phone as user_phone,c.power as user_power,c.mail,e.name as role from entniche_department a 
 			INNER JOIN entniche_department_user b on (a.ent_id=? and a.id=b.dept_id) 
 			INNER JOIN entniche_user c on (b.user_id=c.id) 
 			LEFT JOIN entniche_user_role d on (c.id=d.user_id) 
@@ -28,7 +28,14 @@ func (b ChatGroupService) EntPersonsList(param *messagecenter.EntPersonsListReq)
 		for _, v := range *data {
 			log.Println(v)
 			//id := cm.IntAll(v["id"])
-
+			/*phone := cm.ObjToString(v["user_phone"])
+			//根据用户手机号查询用户职位
+			person := messagecenter.PersonInfo{
+				Id:         cm.Int64All(v["user_id"]),
+				PersonName: cm.ObjToString(v["user_name"]),
+				Phone:      cm.ObjToString(v["user_phone"]),
+				Email:      cm.ObjToString(v["mail"]),
+			}*/
 			/*user := map[string]interface{}{
 				"user_id":  cm.IntAll(v["user_id"]),
 				"power":    user_power,
@@ -37,7 +44,6 @@ func (b ChatGroupService) EntPersonsList(param *messagecenter.EntPersonsListReq)
 				"role":     cm.ObjToString(v["role"]),
 			}
 			//log.Println("权限:", user_power)
-
 			list = append(list, map[string]interface{}{
 				"id":    id,
 				"pid":   cm.IntAll(v["pid"]),

+ 65 - 20
service/message_mail_box.go

@@ -566,6 +566,7 @@ func UserSynchronousList(customerServiceId, userId, entId, messageId int64, crea
 func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string]interface{} {
 	sqlStr := ""
 	lastStr := ""
+	positionStr := ""
 	if in.LastId > 0 {
 		if in.Sort == "asc" {
 			lastStr = fmt.Sprintf("AND  a.messag_id > %d ", in.LastId)
@@ -588,7 +589,34 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 			util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_MESSAGE, util.BASE_USER, util.BASE_USER,
 			in.NewUserId, in.NewUserId, in.SendId, in.SendId, in.NewUserId, lastStr, in.PageSize)
 		break
+	case 3: //群聊天
+
+		sqlStr = fmt.Sprintf("SELECT a.messag_id AS messageId,b.*,"+
+			"IF ( a.own_id = a.send_user_id, 1, 2 ) AS fool,"+
+			"IF ( a.own_id = a.send_user_id, 0, a.send_user_id ) AS send_position_id,"+
+			"a.send_user_type,a.type AS itemType FROM %s a "+
+			"LEFT JOIN %s b ON a.messag_id = b.id "+
+			"WHERE a.own_type = 1 AND a.own_id = %d "+
+			"AND chat_group_id = %d AND a.type IN ( 3, 6 ) "+
+			"ORDER BY a.create_time desc,a.id DESC "+
+			"LIMIT 0, %d",
+			util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_MESSAGE, in.SendId,
+			in.ChatGroupId, in.PageSize)
 	case 4, 5, 6, 7: //客服聊天
+		//查询用户所有的职位id
+		sqlPosition := fmt.Sprintf("SELECT b.id FROM %s a LEFT JOIN %s b ON a.id = b.user_id "+
+			"WHERE a.phone = (SELECT a.phone FROM %s a LEFT JOIN %s b ON a.id = b.user_id "+
+			"WHERE b.id = %d)",
+			util.BASE_USER, util.BASE_POSITION, util.BASE_USER, util.BASE_POSITION, in.NewUserId)
+		positionArr := IC.BaseMysql.SelectBySql(sqlPosition)
+		for k, val := range *positionArr {
+			if k < len(*positionArr)-1 {
+				positionStr += quitl.ObjToString(val["id"]) + ","
+			} else {
+				positionStr += quitl.ObjToString(val["id"])
+			}
+		}
+
 		if in.UserType == 1 {
 			//客服聊天记录查看
 			sqlStr = fmt.Sprintf("SELECT   a.messag_id as messageId,b.*,   IF   ( a.own_id = a.send_user_id, 1, 2 ) AS fool,   a.send_user_type,   a.type AS itemType,   '' AS robotName,   '' AS robotImg,   c.customer_service_name AS setName ,   c.user_id   "+
@@ -598,11 +626,11 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 				"WHERE   a.own_type = 1 and a.iswithdraw = 0  "+
 				"AND (a.type = 5 or a.type=4 or a.type=6 or  a.type=7 or a.type=8 )   "+
 				"AND c.ent_id =   %d "+
-				"AND c.user_id =   %d  %s "+
-				"ORDER BY a.create_time desc ,a.id asc "+
+				"AND c.user_id in (%s)  %s "+
+				"ORDER BY a.create_time desc ,a.id   asc "+
 				"limit 0 ,  %d ",
 				util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_MESSAGE, util.SOCIALIZE_CHAT_SESSION,
-				in.EntId, in.SendId, lastStr, in.PageSize)
+				in.EntId, positionStr, lastStr, in.PageSize)
 		} else {
 			//用户聊天记录查看
 			sqlStr = fmt.Sprintf("SELECT a.messag_id as messageId,e.appraise as appraise, b.*,   IF ( a.own_id = a.send_user_id, 1, 2 ) AS fool ,   a.send_user_type,   a.type as  itemType,   d.nickname as  robotName,   d.headimage as  robotImg,   c.customer_service_name as  setName   "+
@@ -610,21 +638,21 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 				"LEFT JOIN %s b ON a.messag_id = b.id   "+
 				"LEFT JOIN %s c ON   IF   ( a.send_user_type = 1, a.send_user_id, a.receive_user_id ) = c.id AND  c.ent_id = %d AND c.user_id = %d "+
 				"LEFT JOIN  %s d on  c.ent_id=d.ent_id    "+
-				"LEFT JOIN %s e on  e.messag_id=b.id "+
-				"WHERE   a.own_type = 2  and a.iswithdraw = 0  "+
-				"AND a.own_id =  %d "+
+				"WHERE   a.own_type = 2    "+
+				"AND a.own_id in  (%s) "+
 				"AND  c.ent_id = %d "+
-				"AND c.user_id =  %d "+
-				"AND ( a.type = 4 OR a.type = 5 or a.type=6 or  a.type=7 or  a.type=8)  %s "+
-				"ORDER BY a.create_time  desc,a.id   asc "+
+				"AND c.user_id in  (%s) "+
+				"AND ( a.type = 4 OR a.type = 5 or a.type=6 or  a.type=7)  %s "+
+				"ORDER BY a.create_time desc ,a.id   asc "+
 				"limit 0 ,   %d ",
-				util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_MESSAGE, util.SOCIALIZE_CHAT_SESSION, in.SendId, in.NewUserId, util.SOCIALIZE_TENANT_ROBOT, util.SOCIALIZE_APPRAISE,
-				in.NewUserId, in.SendId, in.NewUserId, lastStr, in.PageSize)
+				util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_MESSAGE, util.SOCIALIZE_CHAT_SESSION, in.SendId, in.NewUserId, util.SOCIALIZE_TENANT_ROBOT,
+				positionStr, in.SendId, positionStr, lastStr, in.PageSize)
 		}
 		break
 	}
 	log.Println(sqlStr)
 	data := IC.BaseMysql.SelectBySql(sqlStr)
+	//查询非自己发送消息得发送人名字
 	//自己头像处理
 	if in.UserType == 2 {
 		userData := IC.BaseMysql.FindOne(util.BASE_USER, map[string]interface{}{"id": in.NewUserId}, "headimg", "")
@@ -635,6 +663,15 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 		}
 
 	}
+	if in.MsgType == 3 && data != nil && len(*data) > 0 {
+		_, _, positionData := EntPerson(in.EntId, true)
+		for _, v := range *data {
+			positionId := quitl.IntAll(v["send_user_id"])
+			if positionId != 0 {
+				v["userName"] = positionData[positionId]
+			}
+		}
+	}
 	go func() {
 		updateMap := map[string]interface{}{}
 		if len(*data) > 0 && data != nil {
@@ -643,34 +680,42 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 			switch in.MsgType {
 			case 2: //点对点聊天
 				updateMap = map[string]interface{}{
-					"own_type": 2,
-					"own_id":   in.NewUserId,
-					"type":     2,
-					"isread":   0,
+					"own_type":     2,
+					"own_id":       in.NewUserId,
+					"send_user_id": in.SendId,
+					"type":         2,
+					"isread":       0,
 				}
 				IC.BaseMysql.Update(util.SOCIALIZE_MESSAGE_MAILBOX, updateMap, map[string]interface{}{"isread": 1, "read_time": time.Now().Local().Format(util.Date_Full_Layout)})
 				break
-			case 4, 5:
+			case 3: //群聊天
+				sqlStr = fmt.Sprintf("UPDATE %s a  SET a.isread = 1, a.read_time = now( ) "+
+					"WHERE a.own_type = 1 "+
+					"AND a.type IN (3,6) "+
+					"AND a.isread = 0 "+
+					"AND a.own_id = %d AND a.chat_group_id = %d",
+					util.SOCIALIZE_MESSAGE_MAILBOX, in.SendId, in.ChatGroupId)
+			case 4, 5: //UserType 2用户1客服
 				sqlStr := ""
 				if in.UserType == 1 {
 					sqlStr = fmt.Sprintf("UPDATE %s a  SET a.isread = 1,    a.read_time = now( )  "+
 						"WHERE    a.own_type = 1 and a.iswithdraw = 0 "+
 						"AND a.type IN ( 4,5,6,7)  "+
 						"AND a.isread = 0    "+
-						"AND a.own_id IN ( SELECT b.id FROM %s b WHERE   b.customer_service_id=%d AND    b.user_id=%d  )",
-						util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_CHAT_SESSION, in.EntUserId, in.SendId)
+						"AND a.own_id IN ( SELECT b.id FROM %s b WHERE   b.customer_service_id=%d AND    b.user_id in (%s) )",
+						util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_CHAT_SESSION, in.EntUserId, positionStr)
 				} else {
 					sqlStr = fmt.Sprintf("UPDATE %s a  SET a.isread = 1,    a.read_time = now( )  "+
 						"WHERE    a.own_type = 2 and a.iswithdraw = 0 "+
 						"AND a.type IN ( 4,5,6,7 )  "+
 						"AND a.isread = 0    "+
-						"AND a.own_id =%d ", util.SOCIALIZE_MESSAGE_MAILBOX, in.NewUserId)
+						"AND a.own_id  in (%s) ", util.SOCIALIZE_MESSAGE_MAILBOX, positionStr)
 				}
 				IC.BaseMysql.UpdateOrDeleteBySql(sqlStr)
 				break
 			}
 			//redis缓存处理
-			b.Count(in.NewUserId, in.UserType, in.EntUserId, true)
+			//b.Count(in.NewUserId, in.UserType, in.EntUserId, true)
 		}
 	}()
 	return data

Some files were not shown because too many files changed in this diff