Browse Source

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

王浩 2 years ago
parent
commit
7ceb486f2a

+ 1 - 0
api/messagecenter/internal/logic/userlistlogic.go

@@ -40,6 +40,7 @@ func (l *UserListLogic) UserList(req *types.UserReq) (*types.CommonRes, error) {
 		EntId:        req.EntId,
 		QueryType:    req.QueryType,
 		NameSearch:   req.NameSearch,
+		PositionId:   req.PositionId,
 	})
 	if err != nil {
 		return nil, err

+ 1 - 0
api/messagecenter/internal/types/types.go

@@ -19,6 +19,7 @@ type UserReq struct {
 	StartTime    string `json:"startTime,optional"`
 	EndTime      string `json:"endTime,optional"`
 	NewUserId    int64  `header:"newUserId"`
+	PositionId   int64  `header:"positionId,optional"`
 	EntId        int64  `header:"entId,optional"`
 	EntUserId    int64  `header:"entUserId,optional"`
 	Page         int64  `json:"page,optional"`

+ 1 - 0
api/messagecenter/messagecenter.api

@@ -16,6 +16,7 @@ type UserReq {
 	StartTime    string `json:"startTime,optional"`
 	EndTime      string `json:"endTime,optional"`
 	NewUserId    int64  `header:"newUserId"`
+	PositionId   int64  `header:"positionId,optional"`
 	EntId        int64  `header:"entId,optional"`
 	EntUserId    int64  `header:"entUserId,optional"`
 	Page         int64  `json:"page,optional"`

+ 3 - 2
rpc/messagecenter/messagecenter.proto

@@ -18,9 +18,9 @@ message UserReq {
   string    phone = 1;
   string    startTime = 2;
   string    endTime = 3;
-  int64     newUserId = 4;  //用户标识
+  int64     newUserId = 4;  //用户base_user_id
   int64     userType = 5;  //用户类型:2用户1客服
-  int64     entUserId = 6;  //企业标识
+  int64     entUserId = 6;  //客服id
   int64     page = 7;  //页
   int64     size =8; //数
   int64     isArtificial =9; //是否人工介入 1:人工介入 2:非让人工介入
@@ -28,6 +28,7 @@ message UserReq {
   int64  entId = 11;
   int64  queryType = 12;
   string  nameSearch =13;
+  int64     positionId = 14;  //用户职位id
 }
 message UserResp {
    repeated UserEntity data=1;

+ 9 - 9
rpc/messagecenter/messagecenter/messagecenter.go

@@ -65,37 +65,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...)
@@ -167,19 +167,19 @@ 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...)

+ 16 - 6
rpc/messagecenter/messagecenter/messagecenter.pb.go

@@ -1,6 +1,6 @@
 // Code generated by protoc-gen-go. DO NOT EDIT.
 // versions:
-// 	protoc-gen-go v1.28.0
+// 	protoc-gen-go v1.28.1
 // 	protoc        v3.19.4
 // source: messagecenter.proto
 
@@ -162,9 +162,9 @@ type UserReq struct {
 	Phone        string `protobuf:"bytes,1,opt,name=phone,proto3" json:"phone,omitempty"`
 	StartTime    string `protobuf:"bytes,2,opt,name=startTime,proto3" json:"startTime,omitempty"`
 	EndTime      string `protobuf:"bytes,3,opt,name=endTime,proto3" json:"endTime,omitempty"`
-	NewUserId    int64  `protobuf:"varint,4,opt,name=newUserId,proto3" json:"newUserId,omitempty"`       //用户标识
+	NewUserId    int64  `protobuf:"varint,4,opt,name=newUserId,proto3" json:"newUserId,omitempty"`       //用户base_user_id
 	UserType     int64  `protobuf:"varint,5,opt,name=userType,proto3" json:"userType,omitempty"`         //用户类型:2用户1客服
-	EntUserId    int64  `protobuf:"varint,6,opt,name=entUserId,proto3" json:"entUserId,omitempty"`       //企业标识
+	EntUserId    int64  `protobuf:"varint,6,opt,name=entUserId,proto3" json:"entUserId,omitempty"`       //客服id
 	Page         int64  `protobuf:"varint,7,opt,name=page,proto3" json:"page,omitempty"`                 //页
 	Size         int64  `protobuf:"varint,8,opt,name=size,proto3" json:"size,omitempty"`                 //数
 	IsArtificial int64  `protobuf:"varint,9,opt,name=isArtificial,proto3" json:"isArtificial,omitempty"` //是否人工介入 1:人工介入 2:非让人工介入
@@ -172,6 +172,7 @@ type UserReq struct {
 	EntId        int64  `protobuf:"varint,11,opt,name=entId,proto3" json:"entId,omitempty"`
 	QueryType    int64  `protobuf:"varint,12,opt,name=queryType,proto3" json:"queryType,omitempty"`
 	NameSearch   string `protobuf:"bytes,13,opt,name=nameSearch,proto3" json:"nameSearch,omitempty"`
+	PositionId   int64  `protobuf:"varint,14,opt,name=positionId,proto3" json:"positionId,omitempty"` //用户职位id
 }
 
 func (x *UserReq) Reset() {
@@ -297,6 +298,13 @@ func (x *UserReq) GetNameSearch() string {
 	return ""
 }
 
+func (x *UserReq) GetPositionId() int64 {
+	if x != nil {
+		return x.PositionId
+	}
+	return 0
+}
+
 type UserResp struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -2619,7 +2627,7 @@ func (x *ConversationReq) GetFiltrationId() string {
 	return ""
 }
 
-//聊天保存
+// 聊天保存
 type MessageSaveReq struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -2760,7 +2768,7 @@ var file_messagecenter_proto_rawDesc = []byte{
 	0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03,
 	0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65,
 	0x72, 0x72, 0x6f, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08,
-	0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x22, 0xf3, 0x02, 0x0a, 0x07, 0x55, 0x73, 0x65,
+	0x65, 0x72, 0x72, 0x6f, 0x72, 0x4d, 0x73, 0x67, 0x22, 0x93, 0x03, 0x0a, 0x07, 0x55, 0x73, 0x65,
 	0x72, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x18, 0x01, 0x20,
 	0x01, 0x28, 0x09, 0x52, 0x05, 0x70, 0x68, 0x6f, 0x6e, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x73, 0x74,
 	0x61, 0x72, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73,
@@ -2783,7 +2791,9 @@ var file_messagecenter_proto_rawDesc = []byte{
 	0x12, 0x1c, 0x0a, 0x09, 0x71, 0x75, 0x65, 0x72, 0x79, 0x54, 0x79, 0x70, 0x65, 0x18, 0x0c, 0x20,
 	0x01, 0x28, 0x03, 0x52, 0x09, 0x71, 0x75, 0x65, 0x72, 0x79, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e,
 	0x0a, 0x0a, 0x6e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x18, 0x0d, 0x20, 0x01,
-	0x28, 0x09, 0x52, 0x0a, 0x6e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x22, 0x8b,
+	0x28, 0x09, 0x52, 0x0a, 0x6e, 0x61, 0x6d, 0x65, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x1e,
+	0x0a, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x0e, 0x20, 0x01,
+	0x28, 0x03, 0x52, 0x0a, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x8b,
 	0x01, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d, 0x0a, 0x04, 0x64,
 	0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x6d, 0x65, 0x73, 0x73,
 	0x61, 0x67, 0x65, 0x63, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x45, 0x6e,

+ 22 - 22
rpc/messagecenter/messagecenter/messagecenter_grpc.pb.go

@@ -34,27 +34,27 @@ 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)
-	//用户撤回消息
+	// 用户撤回消息
 	WithdrawMessage(ctx context.Context, in *ReadWithdrawReq, opts ...grpc.CallOption) (*CurrencyResp, error)
 	// 用户评价回复
 	AppraiseMessage(ctx context.Context, in *AppraiseReq, opts ...grpc.CallOption) (*CurrencyResp, error)
@@ -268,27 +268,27 @@ 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)
-	//用户撤回消息
+	// 用户撤回消息
 	WithdrawMessage(context.Context, *ReadWithdrawReq) (*CurrencyResp, error)
 	// 用户评价回复
 	AppraiseMessage(context.Context, *AppraiseReq) (*CurrencyResp, error)

+ 60 - 47
service/message_mail_box.go

@@ -81,12 +81,10 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 	tm := time.Now()
 	if in.UserType == 2 {
 		var (
-			allSql, nameSql string
-			sqlArr          []string
+			allSql string
+			sqlArr []string
 		)
-		if in.NameSearch != "" {
-			nameSql = " WHERE a.name  like '%" + in.NameSearch + "%"
-		}
+
 		//一对一
 		oneSql := fmt.Sprintf(`(SELECT
 							a.your_position_id AS id,
@@ -97,12 +95,13 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 							d.type 
 							d.create_time,
 							a.unread as number,
-						    a.timestamp
+						    a.timestamp,
+							c.phone
 						FROM
 							socialize_summary a
 							INNER JOIN base_position b ON ( a.my_position_id = %d AND a.your_position_id = b.id )
 							INNER JOIN base_user c ON ( b.user_id = c.id )
-							LEFT JOIN socialize_message d ON ( a.message_id = d.id ))`, in.NewUserId)
+							LEFT JOIN socialize_message d ON ( a.message_id = d.id ))`, in.PositionId)
 		//客服列表
 		serviceSql := fmt.Sprintf(` (
 						SELECT
@@ -114,10 +113,11 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 							c.type,
 							c.create_time,
 							a.unread as number,
-							a.timestamp
+							a.timestamp,
+							"" as phone
 						FROM
 							socialize_summary a
-							INNER JOIN socialize_tenant_robot b ON ( a.user_id = %d AND a.ent_id = b.ent_id  )
+							INNER JOIN socialize_tenant_robot b ON ( a.user_id = %d AND a.ent_id = b.ent_id)
 							LEFT JOIN socialize_message c ON ( a.message_id = c.id ) 
 						) `, in.NewUserId)
 		//群列表
@@ -131,25 +131,26 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 							d.type,
 							d.create_time,
 							a.unread as number,
-							c.timestamp
+							c.timestamp,
+							"" as phone
 						FROM
 							socialize_chat_group_person a
 							INNER JOIN socialize_chat_group b ON ( a.position_id = %d AND a.chat_group_id = b.id AND b.isdismiss = 0)
 							INNER JOIN socialize_summary c ON ( b.id = c.chat_group_id )
 							LEFT JOIN socialize_message d ON ( c.message_id = d.id ) 
-						) `, in.NewUserId)
+						) `, in.PositionId)
 		switch in.QueryType {
 		case 1: //分享列表
-			allSql = strings.Join(append(sqlArr, oneSql, groupSql), " union ")
+			allSql = strings.Join(append(sqlArr, oneSql, groupSql), " UNION ALL ")
 		case 2: //历史会话列表
-			allSql = strings.Join(append(sqlArr, oneSql, groupSql, serviceSql), " union ")
+			allSql = strings.Join(append(sqlArr, oneSql, groupSql, serviceSql), " UNION ALL ")
 		}
 
 		sqlStr = fmt.Sprintf(`SELECT * FROM
 					(
 						%s
-					) a %s
-				a.ORDER BY a.timestamp DESC`, allSql, nameSql)
+					) a 
+				a.ORDER BY a.timestamp DESC`, allSql)
 	} else {
 		var timeSql, phoneSql, filtrationSql string
 		if in.StartTime != "" {
@@ -168,29 +169,33 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 			}
 			filtrationSql += fmt.Sprintf(" AND  b.id not in (%s)", strings.Join(ids, ","))
 		}
-		aiSql := fmt.Sprintf(`SELECT
+		aiSql := fmt.Sprintf(`(SELECT
 		   				a.user_id,
 		   				a.message_id,
 		   				a.timestamp,
 		   				b.nickname,
 		   				0 as unread,
-		   				b.headimg
+		   				b.headimg,
+						"" as phone,
+						0 as userType
 	   				FROM
 		   				socialize_summary a
-		   				INNER JOIN base_user b ON  (a.user_id = b.id AND a.ent_id = %d AND a.customer_service_access = 0 
+		   				INNER JOIN base_user b ON  (a.user_id = b.id AND a.ent_id = %d AND a.customer_service_access = 0)) 
 		   				%s %s %s)`, in.EntId, timeSql, phoneSql, filtrationSql)
 
-		serviceSql := fmt.Sprintf(`SELECT
+		serviceSql := fmt.Sprintf(`(SELECT
 		   				a.user_id,
 		   				c.message_id,
 		   				c.timestamp,
 		   				b.nickname,
 		   				a.unread,
-		   				b.headimg
+		   				b.headimg,
+						"" as phone,
+						0 as userType
 	   				FROM
 		   				socialize_customer_service_user a
 		   				INNER JOIN base_user b ON  ( a.customer_service_id = %d AND a.user_id = b.id %s %s)
-						INNER JOIN socialize_summary c ON ( a.ent_id = c.ent_id AND a.user_id = c.user_id %s)`, in.EntUserId, filtrationSql, phoneSql,
+						INNER JOIN socialize_summary c ON ( a.ent_id = c.ent_id AND a.user_id = c.user_id %s))`, in.EntUserId, filtrationSql, phoneSql,
 			strings.ReplaceAll(timeSql, "a.", "c."))
 		var restrictionSql string
 		switch in.IsArtificial {
@@ -209,7 +214,15 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 			in.Size = 50
 		}
 		sqlStr = fmt.Sprintf(`SELECT 
-    				a.nickname as name,
+    				(
+						CASE
+							WHEN SUBSTR( a.nickname, 1, 3 ) = 'JY_' THEN
+								CONCAT( SUBSTR( a.phone, 1, 3 ), '****', SUBSTR( a.phone, 8, 11 ) ) 
+							WHEN a.nickname = '' 
+							OR a.nickname IS NULL THEN
+								CONCAT( SUBSTR( a.phone, 1, 3 ), '****', SUBSTR( a.phone, 8, 11 ) ) ELSE a.nickname 
+						END 
+					) AS name,
     				c.content,
     				c.title,
     				c.type,
@@ -219,7 +232,9 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
     				a.timestamp,
     				a.unread as number,
     				a.user_id as id,
-    				a.headimg
+    				a.headimg,
+    				a.phone,
+    				a.userType
    				FROM
 	   				(%s) a
 				LEFT JOIN socialize_message c ON ( a.message_id = c.id )
@@ -239,11 +254,21 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 				} else {
 					dataSize = (*data)[(in.Page-1)*in.Size : in.Page*in.Size]
 				}
-				return &dataSize, count, err
+			} else {
+				phoneMap, _, _ := EntPerson(in.EntId, false)
+				for _, v := range *data {
+					if name, ok := phoneMap[quitl.InterfaceToStr(v["phone"])]; ok && quitl.IntAll(v["userType"]) == 1 {
+						v["name"] = name
+					}
+					if in.NameSearch != "" && !strings.Contains(quitl.InterfaceToStr(v["name"]), in.NameSearch) {
+						continue
+					}
+					dataSize = append(dataSize, v)
+				}
 			}
 		}
 	}
-	return
+	return &dataSize, count, err
 }
 
 // 客服会话列表
@@ -256,7 +281,7 @@ func (b MessaggeService) ConversationList(in *messagecenter.ConversationReq) (da
 			ids = append(ids, encrypt.SE.Decode4Hex(v))
 		}
 		filtrationSql := fmt.Sprintf(" AND  b.id in (%s)", strings.Join(ids, ","))
-		aiSql := fmt.Sprintf(`SELECT
+		aiSql := fmt.Sprintf(`(SELECT
 		   				a.user_id,
 		   				a.message_id,
 		   				a.timestamp,
@@ -266,9 +291,9 @@ func (b MessaggeService) ConversationList(in *messagecenter.ConversationReq) (da
 	   				FROM
 		   				socialize_summary a
 		   				INNER JOIN base_user b ON  (a.user_id = b.id AND a.ent_id = %d AND a.customer_service_access = 0 
-		   				%s )`, in.EntId, filtrationSql)
+		   				%s ))`, in.EntId, filtrationSql)
 
-		serviceSql := fmt.Sprintf(`SELECT
+		serviceSql := fmt.Sprintf(`(SELECT
 		   				a.user_id,
 		   				c.message_id,
 		   				c.timestamp,
@@ -278,7 +303,7 @@ func (b MessaggeService) ConversationList(in *messagecenter.ConversationReq) (da
 	   				FROM
 		   				socialize_customer_service_user a
 		   				INNER JOIN base_user b ON  ( a.customer_service_id = %d AND a.user_id = b.id %s)
-						INNER JOIN socialize_summary c ON ( a.ent_id = c.ent_id AND a.user_id = c.user_id)`, in.EntUserId, filtrationSql)
+						INNER JOIN socialize_summary c ON ( a.ent_id = c.ent_id AND a.user_id = c.user_id))`, in.EntUserId, filtrationSql)
 		sqlStr = aiSql + " UNION ALL " + serviceSql
 	}
 
@@ -865,12 +890,16 @@ func SynchronousInfo(sender, recipient, conversationType, messageId, userType, e
 	switch conversationType {
 	case 1: //一对一用户聊天
 		if IC.BaseMysql.Count(util.SOCIALIZE_MESSAGE, map[string]interface{}{"id": messageId, "own_id": recipient, "isread": 0}) > 0 {
-			IC.BaseMysql.SelectBySql(fmt.Sprintf("update %s set Value=CASE WHEN Value > 0 and my_position_id = %d and your_position_id = %d THEN Value-1 ELSE 0 END;", util.Socialize_summary, recipient, sender))
+			IC.BaseMysql.SelectBySql(fmt.Sprintf("update %s set unread=CASE WHEN unread > 0 and my_position_id = %d and your_position_id = %d THEN unread-1 ELSE 0 END;", util.Socialize_summary, recipient, sender))
 		}
 	case 2: //用户与客服
 		if IC.BaseMysql.Count(util.SOCIALIZE_MESSAGE, map[string]interface{}{"id": messageId, "own_id": recipient, "isread": 0}) > 0 {
 			if userType == 2 { //发送人是用户
-				IC.BaseMysql.SelectBySql(fmt.Sprintf("update %s set unread=CASE WHEN unread > 0 and user_id = %d and customer_service_id = %d and entId = %d THEN unread-1 ELSE 0 END;", util.Socialize_customer_service_user, sender, recipient, entId))
+				//接收人是会话标识 查询客服id
+				data := IC.BaseMysql.FindOne(util.SOCIALIZE_CHAT_SESSION, map[string]interface{}{"id": recipient}, "", "")
+				if data != nil && len(*data) > 0 {
+					IC.BaseMysql.SelectBySql(fmt.Sprintf("update %s set unread=CASE WHEN unread > 0 and user_id = %d and customer_service_id = %d and entId = %d THEN unread-1 ELSE 0 END;", util.Socialize_customer_service_user, sender, quitl.IntAll((*data)["customer_service_id"]), entId))
+				}
 			} else { //发送人是客服
 				IC.BaseMysql.SelectBySql(fmt.Sprintf("update %s set unread=CASE WHEN unread > 0 and user_id = %d and ent_id = %d THEN unread-1 ELSE 0 END;", util.Socialize_summary, recipient, entId))
 			}
@@ -917,22 +946,6 @@ func (b MessaggeService) AppraiseMessage(in *messagecenter.AppraiseReq) error {
 	return fmt.Errorf("评价消息异常")
 }
 
-// NewEndId 消息撤回 获取对方userid
-func NewEndId(messageId, iType int64) (newUserId, entUserId int64) {
-	data := IC.BaseMysql.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
-}
-
 // 聊天
 // 包含 1v1 ,群聊,群发
 /*