zhangxinlei1996 2 лет назад
Родитель
Сommit
7aa7dc5933

+ 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

@@ -45,15 +45,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

@@ -40,15 +40,16 @@ type MessageEntity {
 	GroupIds    []int64 `json:"groupIds,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"

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

@@ -1,31 +0,0 @@
-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 EntPersonsListLogic struct {
-	ctx    context.Context
-	svcCtx *svc.ServiceContext
-	logx.Logger
-}
-
-func NewEntPersonsListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *EntPersonsListLogic {
-	return &EntPersonsListLogic{
-		ctx:    ctx,
-		svcCtx: svcCtx,
-		Logger: logx.WithContext(ctx),
-	}
-}
-
-// 通讯录 -企业人员列表
-func (l *EntPersonsListLogic) EntPersonsList(in *messagecenter.EntPersonsListReq) (*messagecenter.EntPersonListResp, error) {
-	// todo: add your logic here and delete this line
-	ChatGroup.EntPersonsList(in)
-	return &messagecenter.EntPersonListResp{}, 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
 }

+ 0 - 6
rpc/messagecenter/internal/server/messagecenterserver.go

@@ -118,12 +118,6 @@ func (s *MessageCenterServer) GroupNoticeGet(ctx context.Context, in *messagecen
 	return l.GroupNoticeGet(in)
 }
 
-// 通讯录 -企业人员列表
-func (s *MessageCenterServer) EntPersonsList(ctx context.Context, in *messagecenter.EntPersonsListReq) (*messagecenter.EntPersonListResp, error) {
-	l := logic.NewEntPersonsListLogic(ctx, s.svcCtx)
-	return l.EntPersonsList(in)
-}
-
 // 用户撤回消息
 func (s *MessageCenterServer) WithdrawMessage(ctx context.Context, in *messagecenter.ReadWithdrawReq) (*messagecenter.CurrencyResp, error) {
 	l := logic.NewWithdrawMessageLogic(ctx, s.svcCtx)

+ 1 - 26
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;
@@ -226,30 +227,6 @@ message  GroupNotice{
   string content = 1;
   string  groupNoticeId = 2;
 }
-//企业人员列表、拉人进群列表
-message EntPersonsListReq{
-  string name =1;
-  int64 entId = 2;
-  int64 GroupId = 3;
-}
-message PersonInfo{
-  int64 id = 1;
-  string personName = 2;
-  string phone = 3;
-  string email = 4;
-  int64 positionId = 5;
-}
-message departmentsInfo{
-  int64 id = 1;
-  string departmentName = 2;
-  repeated PersonInfo persons = 3;//部门下的人
-}
-message EntPersonListResp{
-  int64         error_code = 1; //响应代码
-  string        error_msg = 2; //响应消息
-  repeated departmentsInfo data = 3; //返回数据
-  string entName = 4;
-}
 
 message ConversationReq {
   int64     newUserId = 4;  //用户标识
@@ -306,8 +283,6 @@ service messageCenter {
   rpc GroupNoticeUpdate(GroupNoticeUpdateReq)returns(CommonReq);
   //群任务详情
   rpc GroupNoticeGet(ChatGroupPersonReq)returns(GroupNoticeGetResp);
-  //通讯录 -企业人员列表
-  rpc EntPersonsList(EntPersonsListReq) returns(EntPersonListResp);
   //用户撤回消息
   rpc WithdrawMessage(ReadWithdrawReq)returns(CurrencyResp);
   // 用户评价回复

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

@@ -44,8 +44,6 @@ type (
 		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)
 		//  用户评价回复
@@ -163,12 +161,6 @@ func (m *defaultMessageCenter) GroupNoticeGet(ctx context.Context, in *ChatGroup
 	return client.GroupNoticeGet(ctx, in, opts...)
 }
 
-// 通讯录 -企业人员列表
-func (m *defaultMessageCenter) EntPersonsList(ctx context.Context, in *EntPersonsListReq, opts ...grpc.CallOption) (*EntPersonListResp, error) {
-	client := NewMessageCenterClient(m.cli.Conn())
-	return client.EntPersonsList(ctx, in, opts...)
-}
-
 // 用户撤回消息
 func (m *defaultMessageCenter) WithdrawMessage(ctx context.Context, in *ReadWithdrawReq, opts ...grpc.CallOption) (*CurrencyResp, error) {
 	client := NewMessageCenterClient(m.cli.Conn())

Разница между файлами не показана из-за своего большого размера
+ 370 - 674
rpc/messagecenter/messagecenter/messagecenter.pb.go


+ 0 - 38
rpc/messagecenter/messagecenter/messagecenter_grpc.pb.go

@@ -54,8 +54,6 @@ type MessageCenterClient interface {
 	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)
 	// 用户评价回复
@@ -218,15 +216,6 @@ func (c *messageCenterClient) GroupNoticeGet(ctx context.Context, in *ChatGroupP
 	return out, nil
 }
 
-func (c *messageCenterClient) EntPersonsList(ctx context.Context, in *EntPersonsListReq, opts ...grpc.CallOption) (*EntPersonListResp, error) {
-	out := new(EntPersonListResp)
-	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/EntPersonsList", in, out, opts...)
-	if err != nil {
-		return nil, err
-	}
-	return out, nil
-}
-
 func (c *messageCenterClient) WithdrawMessage(ctx context.Context, in *ReadWithdrawReq, opts ...grpc.CallOption) (*CurrencyResp, error) {
 	out := new(CurrencyResp)
 	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/WithdrawMessage", in, out, opts...)
@@ -299,8 +288,6 @@ type MessageCenterServer interface {
 	GroupNoticeUpdate(context.Context, *GroupNoticeUpdateReq) (*CommonReq, error)
 	//群任务详情
 	GroupNoticeGet(context.Context, *ChatGroupPersonReq) (*GroupNoticeGetResp, error)
-	//通讯录 -企业人员列表
-	EntPersonsList(context.Context, *EntPersonsListReq) (*EntPersonListResp, error)
 	//用户撤回消息
 	WithdrawMessage(context.Context, *ReadWithdrawReq) (*CurrencyResp, error)
 	// 用户评价回复
@@ -364,9 +351,6 @@ func (UnimplementedMessageCenterServer) GroupNoticeUpdate(context.Context, *Grou
 func (UnimplementedMessageCenterServer) GroupNoticeGet(context.Context, *ChatGroupPersonReq) (*GroupNoticeGetResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GroupNoticeGet not implemented")
 }
-func (UnimplementedMessageCenterServer) EntPersonsList(context.Context, *EntPersonsListReq) (*EntPersonListResp, error) {
-	return nil, status.Errorf(codes.Unimplemented, "method EntPersonsList not implemented")
-}
 func (UnimplementedMessageCenterServer) WithdrawMessage(context.Context, *ReadWithdrawReq) (*CurrencyResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method WithdrawMessage not implemented")
 }
@@ -680,24 +664,6 @@ func _MessageCenter_GroupNoticeGet_Handler(srv interface{}, ctx context.Context,
 	return interceptor(ctx, in, info, handler)
 }
 
-func _MessageCenter_EntPersonsList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
-	in := new(EntPersonsListReq)
-	if err := dec(in); err != nil {
-		return nil, err
-	}
-	if interceptor == nil {
-		return srv.(MessageCenterServer).EntPersonsList(ctx, in)
-	}
-	info := &grpc.UnaryServerInfo{
-		Server:     srv,
-		FullMethod: "/messagecenter.messageCenter/EntPersonsList",
-	}
-	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
-		return srv.(MessageCenterServer).EntPersonsList(ctx, req.(*EntPersonsListReq))
-	}
-	return interceptor(ctx, in, info, handler)
-}
-
 func _MessageCenter_WithdrawMessage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
 	in := new(ReadWithdrawReq)
 	if err := dec(in); err != nil {
@@ -841,10 +807,6 @@ var MessageCenter_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "GroupNoticeGet",
 			Handler:    _MessageCenter_GroupNoticeGet_Handler,
 		},
-		{
-			MethodName: "EntPersonsList",
-			Handler:    _MessageCenter_EntPersonsList_Handler,
-		},
 		{
 			MethodName: "WithdrawMessage",
 			Handler:    _MessageCenter_WithdrawMessage_Handler,

+ 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
 }
 
 //用户名换取职位标识(测试)

+ 0 - 59
service/ent_address_book.go

@@ -1,59 +0,0 @@
-package service
-
-import (
-	"app.yhyue.com/moapp/jybase/go-xweb/log"
-	IC "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/init"
-	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
-)
-
-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 " +
-			"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 
-			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) 
-			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`
-	}
-	data := IC.MainMysql.SelectBySql(sql, param.EntId)
-	if data != nil && len(*data) > 0 {
-		for _, v := range *data {
-			log.Println(v)
-			//id := cm.IntAll(v["id"])
-
-			/*user := map[string]interface{}{
-				"user_id":  cm.IntAll(v["user_id"]),
-				"power":    user_power,
-				"username": cm.ObjToString(v["user_name"]),
-				"phone":    cm.ObjToString(v["user_phone"]),
-				"role":     cm.ObjToString(v["role"]),
-			}
-			//log.Println("权限:", user_power)
-
-			list = append(list, map[string]interface{}{
-				"id":    id,
-				"pid":   cm.IntAll(v["pid"]),
-				"name":  cm.ObjToString(v["name"]),
-				"users": []map[string]interface{}{user},
-			})*/
-		}
-	}
-
-	//log.Println(checkedArr)
-	/*this.ServeJson(Result{Data: M{
-		"entname":     this.GetSession("entName"),
-		"checked":     checked,
-		"quota":       VarEntInfo.GetById(entId).Quota,
-		"mystaff":     Mysql.Count(Entniche_user, map[string]interface{}{"ent_id": entId}),
-		"list":        list,
-		"checkedList": checkedArr,
-	}})*/
-}

+ 0 - 34
service/ent_address_book_test.go

@@ -1,34 +0,0 @@
-package service
-
-import (
-	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
-	"testing"
-)
-
-func TestChatGroupService_EntPersonsList(t *testing.T) {
-	type args struct {
-		param *messagecenter.EntPersonsListReq
-	}
-	tests := []struct {
-		name string
-		args args
-	}{
-		// TODO: Add test cases.
-		{
-			name: "企业列表",
-			args: args{
-				&messagecenter.EntPersonsListReq{
-					EntId:   14929,
-					Name:    "",
-					GroupId: 0,
-				},
-			},
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name, func(t *testing.T) {
-			b := ChatGroupService{}
-			b.EntPersonsList(tt.args.param)
-		})
-	}
-}

+ 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

Некоторые файлы не были показаны из-за большого количества измененных файлов