浏览代码

Merge branch 'feature/v1.2.6' into dev/v1.2.6_dx

# Conflicts:
#	api/messagecenter/internal/handler/routes.go
#	api/messagecenter/internal/types/types.go
#	api/messagecenter/messagecenter.api
#	entity/util.go
#	go.mod
#	go.sum
#	rpc/messagecenter/internal/server/messagecenterserver.go
#	rpc/messagecenter/messagecenter.proto
#	rpc/messagecenter/messagecenter/messagecenter.go
#	rpc/messagecenter/messagecenter/messagecenter.pb.go
#	rpc/messagecenter/messagecenter/messagecenter_grpc.pb.go
#	service/message_mail_box.go
duxin 2 年之前
父节点
当前提交
d39dd6d143

+ 15 - 1
api/messagecenter/internal/handler/routes.go

@@ -5,7 +5,6 @@ import (
 	"net/http"
 
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/api/messagecenter/internal/svc"
-
 	"github.com/zeromicro/go-zero/rest"
 )
 
@@ -92,6 +91,21 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/message/groupNoticeGet",
 				Handler: groupNoticeGetHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/message/withdrawMessage",
+				Handler: withdrawMessageHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/message/appraiseMessage",
+				Handler: AppraiseMessageHandler(serverCtx),
+			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/message/conversationList",
+				Handler: ConversationListHandler(serverCtx),
+			},
 		},
 	)
 }

+ 27 - 6
api/messagecenter/internal/types/types.go

@@ -14,12 +14,17 @@ type CountResp struct {
 }
 
 type UserReq struct {
-	Phone     string `json:"phone,optional"`
-	UserType  int64  `json:"userType"`
-	StartTime string `json:"startTime,optional"`
-	EndTime   string `json:"endTime,optional"`
-	NewUserId int64  `header:"newUserId"`
-	EntUserId int64  `header:"entUserId,optional"`
+	Phone        string `json:"phone,optional"`
+	UserType     int64  `json:"userType"`
+	StartTime    string `json:"startTime,optional"`
+	EndTime      string `json:"endTime,optional"`
+	NewUserId    int64  `header:"newUserId"`
+	EntId        int64  `header:"entId,optional"`
+	EntUserId    int64  `header:"entUserId,optional"`
+	Page         int64  `json:"page,optional"`
+	Size         int64  `json:"size,optional"`
+	IsArtificial int64  `json:"isArtificial,optional"`
+	FiltrationId string `json:"filtrationId,optional"`
 }
 
 type MessageEntity struct {
@@ -121,3 +126,19 @@ type GroupNoticeUpdateReq struct {
 	Content       string `json:"content"`
 	GroupNoticeId string `json:"groupNoticeId"`
 }
+
+type ReadWithdrawReq struct {
+	MessageId string `json:"messageId"`
+	Appid     string `header:"appid"`
+	NewUserId int64  `header:"newUserId,optional"`
+	EntUserId int64  `header:"entUserId,optional"`
+	UserType  int64  `json:"userType"`
+}
+
+type AppraiseMessageReq struct {
+	EntId     int64  `header:"entId,optional"`
+	AppId     string `header:"appId"`
+	NewUserId int64  `header:"newUserId"`
+	MessageId string `json:"messageId"`
+	Appraise  int64  `json:"appraise,options=-1|1"`
+}

+ 34 - 6
api/messagecenter/messagecenter.api

@@ -11,12 +11,17 @@ type CountResp {
 }
 
 type UserReq {
-	Phone     string `json:"phone,optional"`
-	UserType  int64  `json:"userType"`
-	StartTime string `json:"startTime,optional"`
-	EndTime   string `json:"endTime,optional"`
-	NewUserId int64  `header:"newUserId"`
-	EntUserId int64  `header:"entUserId,optional"`
+	Phone        string `json:"phone,optional"`
+	UserType     int64  `json:"userType"`
+	StartTime    string `json:"startTime,optional"`
+	EndTime      string `json:"endTime,optional"`
+	NewUserId    int64  `header:"newUserId"`
+	EntId        int64  `header:"entId,optional"`
+	EntUserId    int64  `header:"entUserId,optional"`
+	Page         int64  `json:"page,optional"`
+	Size         int64  `json:"size,optional"`
+	IsArtificial int64  `json:"isArtificial,optional"`
+	FiltrationId string `json:"filtrationId,optional"`
 }
 type MessageEntity {
 	OwnType   int64  `json:"ownType"`
@@ -105,6 +110,23 @@ type GroupNoticeUpdateReq {
 	Content       string `json:"content"`
 	GroupNoticeId string `json:"groupNoticeId"`
 }
+
+type ReadWithdrawReq {
+	MessageId string `json:"messageId"`
+	Appid     string `header:"appid"`
+	NewUserId int64  `header:"newUserId,optional"`
+	EntUserId int64  `header:"entUserId,optional"`
+	UserType  int64  `json:"userType"`
+}
+
+type AppraiseMessageReq {
+	EntId     int64  `header:"entId,optional"`
+	AppId     string `header:"appId"`
+	NewUserId int64  `header:"newUserId"`
+	MessageId string `json:"messageId"`
+	Appraise  int64  `json:"appraise,options=-1|1"`
+}
+
 service messagecenter-api {
 	@handler messageCount
 	post /message/messageCount (CountReq) returns (CommonRes);
@@ -138,4 +160,10 @@ service messagecenter-api {
 	post /message/groupNoticeUpdate (GroupNoticeUpdateReq) returns (CommonRes);
 	@handler groupNoticeGet
 	post /message/groupNoticeGet (ChatGroupPersonReq) returns (CommonRes);
+	@handler withdrawMessage //撤回消息
+	post /message/withdrawMessage (ReadWithdrawReq) returns (CommonRes);
+	@handler AppraiseMessage // 消息评价
+	post /message/appraiseMessage (AppraiseMessageReq) returns (CommonRes);
+	@handler ConversationList // 会话列表
+	post /message/conversationList (UserReq) returns (CommonRes);
 }

+ 68 - 2
entity/util.go

@@ -5,6 +5,8 @@ import (
 	"app.yhyue.com/moapp/jybase/redis"
 	"encoding/json"
 	"fmt"
+	"reflect"
+	"sort"
 	"strings"
 )
 
@@ -19,10 +21,12 @@ const (
 	SOCIALIZE_CHAT_GROUP        = "socialize_chat_group"
 	SOCIALIZE_CHAT_GROUP_NOTICE = "socialize_chat_group_notice"
 	SOCIALIZE_CHAT_GROUP_PERSON = "socialize_chat_group_person"
+	User_message_list           = "user_message_list"
 	//mainMysql
 	ENTNICHE_USER = "entniche_user"
 	//mongo
-	ENTNICHE_DELETE = "entniche_delete"
+	ENTNICHE_DELETE    = "entniche_delete"
+	SOCIALIZE_APPRAISE = "socialize_message_appraise"
 )
 const (
 	SUCCESS_CODE = int64(0)
@@ -37,7 +41,7 @@ func SafeConvert2String(obj interface{}) string {
 	return ""
 }
 
-//in数据处理
+// in数据处理
 func Inhandle(data *[]map[string]interface{}) (messId string) {
 	if len(*data) == 0 {
 		messId = "''"
@@ -96,3 +100,65 @@ func IntJoin(elems []int64, sep string) string {
 	}
 	return b.String()
 }
+
+// 排序 排序键必须为数字类型
+type SortBy struct {
+	Data    []map[string]interface{}
+	Sortkey string
+}
+
+func (a SortBy) Len() int { return len(a.Data) }
+
+func (a SortBy) Swap(i, j int) {
+	a.Data[i], a.Data[j] = a.Data[j], a.Data[i]
+}
+
+func (a SortBy) Less(i, j int) bool {
+	//return Float64(a.Data[i][a.Sortkey]) < Float64(a.Data[j][a.Sortkey])
+	m := a.Data[i][a.Sortkey]
+	n := a.Data[j][a.Sortkey]
+	w := reflect.ValueOf(m)
+	v := reflect.ValueOf(n)
+	switch v.Kind() {
+	case reflect.String:
+		return w.String() < v.String()
+	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
+		return w.Int() < v.Int()
+	case reflect.Float64, reflect.Float32:
+		return w.Float() < v.Float()
+	default:
+		return fmt.Sprintf("%v", w) < fmt.Sprintf("%v", v)
+	}
+}
+
+// 根据指定字符排序
+//
+//	m := []map[string]int{
+//	   {"k": 2},
+//	   {"k": 1},
+//	   {"k": 3},
+//	}
+//
+// customer.SortData(&m, "k", true)
+// ture  倒序3, 2, 1
+// fmt.Println(m)
+func SortData(data interface{}, sortkey string, reverse bool) {
+	//func SortData(data interface{}, sortkey string, reverse bool) {
+	var db []map[string]interface{}
+	err := quitl.Bind(data, &db)
+	if err != nil {
+		fmt.Println(err)
+		return
+	}
+	stb := SortBy{db, sortkey}
+	if !reverse {
+		sort.Sort(stb)
+	} else {
+		sort.Sort(sort.Reverse(stb))
+	}
+	err = quitl.Bind(stb.Data, data)
+	if err != nil {
+		fmt.Println(err)
+	}
+
+}

+ 2 - 0
go.mod

@@ -7,7 +7,9 @@ require (
 	app.yhyue.com/moapp/jypkg v0.0.0-20230407092858-0d6d33fa63d6
 	bp.jydev.jianyu360.cn/BaseService/gateway v1.3.4
 	github.com/go-sql-driver/mysql v1.7.0
+	github.com/microcosm-cc/bluemonday v1.0.23
 	github.com/zeromicro/go-zero v1.4.4
 	google.golang.org/grpc v1.53.0
 	google.golang.org/protobuf v1.28.1
+
 )

+ 20 - 4
go.sum

@@ -481,6 +481,8 @@ github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb
 github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY=
 github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48=
 github.com/aws/aws-sdk-go v1.35.20/go.mod h1:tlPOdRjfxPBpNIwqDj61rmsnA85v9jc0Ps9+muhnW+k=
+github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
+github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
 github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc=
 github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
 github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
@@ -814,6 +816,8 @@ github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+
 github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
 github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU=
 github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
+github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
+github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
 github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
 github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
 github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
@@ -1014,6 +1018,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
 github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI=
 github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
 github.com/memcachier/mc v2.0.1+incompatible/go.mod h1:7bkvFE61leUBvXz+yxsOnGBQSZpBSPIMUQSmmSHvuXc=
+github.com/microcosm-cc/bluemonday v1.0.23 h1:SMZe2IGa0NuHvnVNAZ+6B38gsTbi5e4sViiWJyDDqFY=
+github.com/microcosm-cc/bluemonday v1.0.23/go.mod h1:mN70sk7UkkF8TUr2IGBpNN0jAgStuPzlK76QuruE/z4=
 github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
 github.com/mkevac/debugcharts v0.0.0-20191222103121-ae1c48aa8615/go.mod h1:Ad7oeElCZqA1Ufj0U9/liOF4BtVepxRcTvr2ey7zTvM=
 github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c=
@@ -1417,6 +1423,7 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
 golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
 golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
+golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
 golang.org/x/net v0.0.0-20180218175443-cbe0f9307d01/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
 golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -1484,8 +1491,10 @@ golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfS
 golang.org/x/net v0.0.0-20221012135044-0b7e1fb9d458/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
 golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
 golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
-golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
 golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
+golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
+golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
+golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
 golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
 golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -1633,15 +1642,19 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
 golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.0.0-20220919091848-fb04ddd9f9c8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
-golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
 golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
+golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
+golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
 golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
 golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
 golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
 golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
-golang.org/x/term v0.4.0 h1:O7UWfv5+A2qiuulQk30kVinPoMtoIPeVaKLEgLpVkvg=
 golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
+golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
+golang.org/x/term v0.6.0 h1:clScbb1cHjoCkyRbWwBEUZ5H/tIFu5TAXIqaZD0Gcjw=
+golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
 golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
@@ -1654,8 +1667,10 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
 golang.org/x/text v0.3.8-0.20211105212822-18b340fc7af2/go.mod h1:EFNZuWvGYxIRUEX+K8UmCFwYmZjqcrnq15ZuVldZkZ0=
 golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
 golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
-golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
 golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
+golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
+golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
+golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
 golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
 golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
@@ -1741,6 +1756,7 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
 golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo=
 golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
 golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k=
+golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
 golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

+ 24 - 6
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)
@@ -123,3 +123,21 @@ func (s *MessageCenterServer) EntPersonsList(ctx context.Context, in *messagecen
 	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)
+	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)
+}

+ 57 - 19
rpc/messagecenter/messagecenter.proto

@@ -21,11 +21,17 @@ message UserReq {
   int64     newUserId = 4;  //用户标识
   int64     userType = 5;  //用户类型:2用户1客服
   int64     entUserId = 6;  //企业标识
+  int64     page = 7;  //页
+  int64     size =8; //数
+  int64     isArtificial =9; //是否人工介入 1:人工介入 2:非让人工介入
+  string    filtrationId = 10; //客服列表过滤会话中派对中用户
+  int64  entId = 11;
 }
 message UserResp {
-  repeated UserEntity data = 1;
-  int64 error_code = 2; //响应代码
-  string error_msg = 3; //响应消息
+   repeated UserEntity data=1;
+   int64 error_code = 2; //响应代码
+   string error_msg = 3; //响应消息
+  int64 count = 4; //响应代码
 }
 message UserEntity {
   string userId = 1;
@@ -35,9 +41,11 @@ message UserEntity {
   string link = 5;
   string content = 6;
   int64 userType = 7;
-  int64 create_time = 8;
-  int64 number = 9;
-  string headimg = 11;
+
+  int64 create_time= 8;
+  int64 number= 9;
+  string headimg=11;
+  bool isOnline=12;
 }
 message MessageReq {
   int64         msgType = 1;     // 消息类型 ;1:站内信消息 2:点对点消息 3:群消息 4:机器人消息 5:客服消息
@@ -70,19 +78,21 @@ message MessageEntity {
   int64         type = 4;
   string        link = 5;
   int64         create_time = 6;
-  string        appid = 7;
-  int64         itemType = 8;
-  int64         sendId = 9;
-  int64         entUserId = 10;
-  int64         newUserId = 16;
-  int64         own_type = 11;//拥有者类型;1:用户 2:会话
-  int64         fool = 12;
-  string        robotName = 13;
-  string        robotImg = 14;
-  string        setName = 15;
-  int64         receiveId = 17;
-  string        ownImg = 18;
-  string        messageId = 19;
+
+  string        appid=7;
+  int64         itemType=8;
+  int64         sendId=9;
+  int64         entUserId=10;
+  int64         newUserId=16;
+  int64         own_type =11;//拥有者类型;1:用户 2:会话
+  int64         fool=12;
+  string        robotName=13;
+  string        robotImg=14;
+  string        setName=15;
+  int64         receiveId=17;
+  string        ownImg=18;
+  string        messageId=19;
+  int64         appraise=20;
 }
 
 message ChatSessionReq {
@@ -115,6 +125,21 @@ message ReadStateReq {
   int64         newUserId = 3;
 }
 
+message ReadWithdrawReq {
+  string        messageId = 1;
+  int64         entUserId = 2;
+  string        appid=3;
+  int64         newUserId = 4;
+  int64         userType=6;      //用户类型:2用户1客服
+}
+
+message AppraiseReq {
+  string        appid=1;
+  string        messageId = 2;
+  int64         newUserId = 3;
+  int64         appraise = 4;
+}
+
 message CurrencyResp {
   int64 error_code = 2; //响应代码
   string error_msg = 1; //响应消息
@@ -158,6 +183,7 @@ message ChatGroupPersonResp{
   int64         error_code = 2; //响应代码
   string        error_msg = 3; //响应消息
 }
+
 message ChatGroupPersonList{
   repeated      ChatGroupPerson data = 1;
 }
@@ -223,6 +249,12 @@ message EntPersonListResp{
   string entName = 4;
 }
 
+message ConversationReq {
+  int64     newUserId = 4;  //用户标识
+  int64     userType=5;  //用户类型:2用户1客服
+  int64     entUserId = 6;  //企业标识
+  string    filtrationId = 10; //客服列表过滤会话中派对中用户
+}
 service messageCenter {
   // 查询数量
   rpc Count(CountReq) returns(CountResp);
@@ -258,4 +290,10 @@ service messageCenter {
   rpc GroupNoticeGet(ChatGroupPersonReq)returns(GroupNoticeGetResp);
   //通讯录 -企业人员列表
   rpc EntPersonsList(EntPersonsListReq) returns(EntPersonListResp);
+  //用户撤回消息
+  rpc WithdrawMessage(ReadWithdrawReq)returns(CurrencyResp);
+  // 用户评价回复
+  rpc AppraiseMessage(AppraiseReq) returns(CurrencyResp);
+  // 客服列表查询
+  rpc ConversationList(ConversationReq) returns(UserResp);
 }

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

@@ -1,5 +1,4 @@
-
-// Code generated by goctl. DO NOT EDIT.
+// Code generated by goctl. DO NOT EDIT!
 // Source: messagecenter.proto
 
 package messagecenter
@@ -13,17 +12,17 @@ import (
 
 type (
 	MessageCenter interface {
-		// 查询数量
+		//  查询数量
 		Count(ctx context.Context, in *CountReq, opts ...grpc.CallOption) (*CountResp, error)
-		// 用户列表查询
+		//  用户列表查询
 		UserList(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserResp, error)
-		// 聊天内容查询
+		//  聊天内容查询
 		FindMessage(ctx context.Context, in *MessageReq, opts ...grpc.CallOption) (*MessageResp, error)
-		// 聊天保存
+		//  聊天保存
 		SaveMessage(ctx context.Context, in *MessageEntity, opts ...grpc.CallOption) (*SaveMessageResp, error)
-		// 会话创建
+		//  会话创建
 		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)
@@ -47,7 +46,12 @@ type (
 		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)
 	}
 
 	defaultMessageCenter struct {
@@ -163,3 +167,20 @@ func (m *defaultMessageCenter) EntPersonsList(ctx context.Context, in *EntPerson
 	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())
+	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...)
+}

文件差异内容过多而无法显示
+ 769 - 430
rpc/messagecenter/messagecenter/messagecenter.pb.go


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

@@ -34,28 +34,34 @@ 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)
 }
 
 type messageCenterClient struct {
@@ -219,6 +225,33 @@ func (c *messageCenterClient) EntPersonsList(ctx context.Context, in *EntPersons
 	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...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *messageCenterClient) AppraiseMessage(ctx context.Context, in *AppraiseReq, opts ...grpc.CallOption) (*CurrencyResp, error) {
+	out := new(CurrencyResp)
+	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/AppraiseMessage", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
+func (c *messageCenterClient) ConversationList(ctx context.Context, in *ConversationReq, opts ...grpc.CallOption) (*UserResp, error) {
+	out := new(UserResp)
+	err := c.cc.Invoke(ctx, "/messagecenter.messageCenter/ConversationList", 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
@@ -235,28 +268,34 @@ 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)
 	mustEmbedUnimplementedMessageCenterServer()
 }
 
@@ -315,6 +354,15 @@ func (UnimplementedMessageCenterServer) GroupNoticeGet(context.Context, *ChatGro
 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")
+}
+func (UnimplementedMessageCenterServer) AppraiseMessage(context.Context, *AppraiseReq) (*CurrencyResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method AppraiseMessage not implemented")
+}
+func (UnimplementedMessageCenterServer) ConversationList(context.Context, *ConversationReq) (*UserResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method ConversationList not implemented")
+}
 func (UnimplementedMessageCenterServer) mustEmbedUnimplementedMessageCenterServer() {}
 
 // UnsafeMessageCenterServer may be embedded to opt out of forward compatibility for this service.
@@ -634,6 +682,60 @@ func _MessageCenter_EntPersonsList_Handler(srv interface{}, ctx context.Context,
 	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 {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(MessageCenterServer).WithdrawMessage(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/messagecenter.messageCenter/WithdrawMessage",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(MessageCenterServer).WithdrawMessage(ctx, req.(*ReadWithdrawReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _MessageCenter_AppraiseMessage_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(AppraiseReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(MessageCenterServer).AppraiseMessage(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/messagecenter.messageCenter/AppraiseMessage",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(MessageCenterServer).AppraiseMessage(ctx, req.(*AppraiseReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
+func _MessageCenter_ConversationList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(ConversationReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(MessageCenterServer).ConversationList(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/messagecenter.messageCenter/ConversationList",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(MessageCenterServer).ConversationList(ctx, req.(*ConversationReq))
+	}
+	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)
@@ -709,6 +811,18 @@ var MessageCenter_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "EntPersonsList",
 			Handler:    _MessageCenter_EntPersonsList_Handler,
 		},
+		{
+			MethodName: "WithdrawMessage",
+			Handler:    _MessageCenter_WithdrawMessage_Handler,
+		},
+		{
+			MethodName: "AppraiseMessage",
+			Handler:    _MessageCenter_AppraiseMessage_Handler,
+		},
+		{
+			MethodName: "ConversationList",
+			Handler:    _MessageCenter_ConversationList_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "messagecenter.proto",

+ 302 - 80
service/message_mail_box.go

@@ -2,19 +2,23 @@ package service
 
 import (
 	quitl "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/encrypt"
 	util "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/entity"
 	IC "bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/init"
 	"bp.jydev.jianyu360.cn/SocialPlatform/messageCenter/rpc/messagecenter/messagecenter"
 	"database/sql"
 	"fmt"
 	"log"
+	"strings"
+	"sync"
 	"time"
 )
 
 type MessaggeService struct{}
 
-//未读消息查询
+// 未读消息查询
 func (b MessaggeService) Count(newUserId, userType, entUserId int64, isClean bool) (count int, last map[string]interface{}, err error) {
+	log.Printf("用户id:%d,userType:%d,entUserId:%d,isClean:%v", newUserId, userType, entUserId, isClean)
 	v := make([]interface{}, 0)
 	sqlStr := ""
 	if userType == 1 {
@@ -29,7 +33,8 @@ func (b MessaggeService) Count(newUserId, userType, entUserId int64, isClean boo
 		sqlStr = fmt.Sprintf("select  count(b.id) from   %s a  "+
 			"LEFT  JOIN  %s  b ON a.id=b.own_id "+
 			"where  b.type=5 "+
-			"AND   a.customer_service_id=%d   "+
+			"AND   a.customer_service_id=%d  "+
+			"AND b.iswithdraw = 0  "+
 			"AND  b.isread=0  "+
 			"AND own_type = 1 "+
 			"order by create_time", util.SOCIALIZE_CHAT_SESSION, util.SOCIALIZE_MESSAGE_MAILBOX, entUserId)
@@ -43,7 +48,8 @@ func (b MessaggeService) Count(newUserId, userType, entUserId int64, isClean boo
 		}
 		sqlStr = fmt.Sprintf("select  count(b.id) from    %s  b "+
 			"where   b.send_user_id != %d    "+
-			"AND   b.own_id=%d  "+
+			"AND   b.own_id=%d "+
+			"AND b.iswithdraw = 0  "+
 			"AND  b.isread=0 "+
 			"AND own_type = 2 "+
 			"order by create_time", util.SOCIALIZE_MESSAGE_MAILBOX, newUserId, newUserId)
@@ -57,7 +63,8 @@ func (b MessaggeService) Count(newUserId, userType, entUserId int64, isClean boo
 	sqlStr = fmt.Sprintf("SELECT  c.* FROM %s  b   "+
 		"LEFT join %s c on  b.messag_id=c.id "+
 		"WHERE  b.send_user_id != %d   "+
-		"AND b.own_id = %d  "+
+		"AND b.own_id = %d "+
+		"AND b.iswithdraw = 0  "+
 		"AND   b.isread=0  "+
 		"AND own_type = 2  "+
 		"ORDER BY  create_time DESC   "+
@@ -81,13 +88,15 @@ func (b MessaggeService) Count(newUserId, userType, entUserId int64, isClean boo
 	return
 }
 
-//用户列表查询
-func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string]interface{}, err error) {
+// 用户列表查询
+func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string]interface{}, count int64, err error) {
 	sqlStr := ""
+	tm := time.Now()
 	if in.UserType == 2 {
 		//用户最后一次信息查询
 		userSql := fmt.Sprintf("SELECT  MAX( c.id )   as messageId  FROM  socialize_message_mailbox c "+
-			"WHERE  c.own_id = %d   "+
+			"WHERE  c.own_id = %d  "+
+			"AND c.iswithdraw = 0  "+
 			"AND c.type = 2   "+
 			"AND c.own_type = 2 "+
 			"GROUP BY  (  CASE  WHEN c.send_user_id > c.receive_user_id "+
@@ -101,6 +110,7 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 		customerSql := fmt.Sprintf("SELECT   MAX( c.id )   as messageId  FROM   %s c "+
 			"LEFT JOIN %s d ON  IF   ( c.send_user_type = 1, d.id = c.send_user_id, d.id = c.receive_user_id ) "+
 			"WHERE   c.own_id = %d  "+
+			"AND c.iswithdraw = 0 "+
 			"AND ( c.type = 4 OR c.type = 5  or c.type=6 or  c.type=7 ) "+
 			"AND c.own_type = 2 "+
 			"AND   d.user_id=c.own_id "+
@@ -109,14 +119,14 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 		customerMessageId := util.Inhandle(data)
 		//用户的列表
 		sqlStr = fmt.Sprintf("SELECT "+
-			"(  CASE        WHEN SUBSTR( b.nickname, 1, 3 ) = 'JY_' THEN    CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) )     WHEN b.nickname = '' THEN    CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) ) ELSE b.nickname    END    )"+
+			"(  CASE        WHEN SUBSTR( b.nickname, 1, 3 ) = 'JY_' THEN    CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) )     WHEN b.nickname = '' or b.nickname is null THEN    CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) ) ELSE b.nickname    END    )"+
 			"AS name, b.id, e.title, b.headimg, e.type, e.link, e.content, 2 AS userType, a.create_time, a.type AS itemType, "+
 			"( SELECT  count( h.id )  FROM  %s h  "+
 			"WHERE  h.type = 2  "+
 			"AND h.own_id = %d  "+
 			"AND h.own_type = 2  "+
 			"AND   h.send_user_id=b.id   "+
-			"AND h.isread = 0  ) AS number  FROM  %s a "+
+			"AND h.isread = 0 AND h.iswithdraw = 0  ) AS number  FROM  %s a "+
 			"LEFT JOIN  %s b ON  b.id = a.receive_user_id or  b.id = a.send_user_id  "+
 			"LEFT JOIN  %s e ON e.id = a.messag_id  "+
 			"WHERE a.id IN ( %s )  AND b.id != %d "+
@@ -145,75 +155,167 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 			util.SOCIALIZE_TENANT_ROBOT,
 			customerMessageId)
 	} else {
-		phoneSql := ""
-		if in.Phone != "" {
-			phoneSql = "AND  b.phone like '%" + in.Phone + "%'"
+		idSql := fmt.Sprintf(" (a.customer_service_id = %d OR a.customer_service_id = 0) ", in.EntUserId)
+		if in.IsArtificial == 1 {
+			idSql = fmt.Sprintf(" a.customer_service_id = %d ", in.EntUserId)
+		} else if in.IsArtificial == 2 {
+			idSql = " a.customer_service_id = 0 "
 		}
-		startTimeSql := ""
 		if in.StartTime != "" {
-			startTimeSql = "AND  DATE_FORMAT(c.create_time,'%Y-%m-%d') >= '" + in.StartTime + "' "
+			idSql += " AND  DATE_FORMAT(a.update_time,'%Y-%m-%d') >= '" + in.StartTime + "' "
 		}
-		endTimeSql := ""
 		if in.EndTime != "" {
-			endTimeSql = "AND DATE_FORMAT(c.create_time,'%Y-%m-%d') <= '" + in.EndTime + "' "
-		}
-		//先获取每个用户最后聊天记录
-		userSql := fmt.Sprintf("SELECT   MAX( c.id ) as messageId   FROM  %s c   "+
-			"LEFT JOIN %s d ON   c.own_type=1 AND  c.own_id=d.id   "+
-			"WHERE   c.own_type = 1    "+
-			"AND d.customer_service_id = %d   "+
-			"AND ( c.type = 4 OR c.type = 5 or  c.type=6 or  c.type=7 )   "+
-			"AND d.customer_service_id !=0   %s %s  "+
-			"GROUP BY   (   CASE  WHEN  c.send_user_type =2 THEN  CONCAT( c.send_user_id )   WHEN c.send_user_type =1 THEN  CONCAT( c.receive_user_id )  END  ) ",
-			util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_CHAT_SESSION,
-			in.EntUserId, startTimeSql, endTimeSql)
-		data = IC.BaseMysql.SelectBySql(userSql)
-		if data != nil {
-			customerMessageId := util.Inhandle(data)
-			//客服的用户列表
-			sqlStr = fmt.Sprintf("SELECT  "+
-				"(  CASE        WHEN SUBSTR( b.nickname, 1, 3 ) = 'JY_' THEN    CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) )     WHEN b.nickname = '' THEN    CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) ) ELSE b.nickname    END    )"+
-				" AS name,  b.id,  e.title,  b.headimg,  e.type,  e.link,  e.content,  a.create_time,  "+
-				"(  SELECT   count( h.id )   FROM   %s h   "+
-				"LEFT JOIN %s i ON h.own_type = 1 AND h.own_id = i.id     "+
-				"WHERE  h.own_type = 1  "+
-				"AND i.ent_id=f.ent_id "+
-				"AND  i.user_id=f.user_id    "+
-				"AND h.isread = 0    "+
-				"AND  i.customer_service_id= %d ) AS number "+
-				"FROM  %s a  "+
-				"LEFT JOIN %s b ON if (a.send_user_type=1 ,a.receive_user_id,a.send_user_id)=b.id  "+
-				"LEFT JOIN %s e ON e.id = a.messag_id  "+
-				"LEFT JOIN %s f ON a.own_type=1 AND  a.own_id=f.id   "+
-				"WHERE  a.id IN  ( %s) %s ORDER BY  a.create_time DESC",
-				util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_CHAT_SESSION,
-				in.EntUserId, util.SOCIALIZE_MESSAGE_MAILBOX, util.BASE_USER, util.SOCIALIZE_MESSAGE, util.SOCIALIZE_CHAT_SESSION, customerMessageId, phoneSql)
+			idSql += "AND DATE_FORMAT(a.update_time,'%Y-%m-%d') <= '" + in.EndTime + "' "
+		}
+		if in.Phone != "" {
+			idSql += " AND  b.phone like '%" + in.Phone + "%'"
+		}
+		if in.FiltrationId != "" {
+			var ids []string
+			for _, v := range strings.Split(in.FiltrationId, ",") {
+				ids = append(ids, encrypt.SE.Decode4Hex(v))
+			}
+			idSql += fmt.Sprintf(" AND  b.id not in (%s)", strings.Join(ids, ","))
+		}
+		if in.Page <= 0 {
+			in.Page = 1
 		}
+		if in.Size <= 0 || in.Size > 100 {
+			in.Size = 50
+		}
+		sqlStr = fmt.Sprintf(`SELECT(
+			 CASE
+            	WHEN SUBSTR( b.nickname, 1, 3 ) = 'JY_' THEN
+            	CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) ) 
+            	WHEN b.nickname = '' 
+            	OR b.nickname IS NULL THEN
+            	CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) ) ELSE b.nickname 
+            	END 
+            ) AS name,
+			b.id,
+			e.title,
+			b.headimg,
+			e.type,
+			e.link,
+			e.content,
+			a.update_time as create_time,
+			(
+			SELECT
+				count( h.id ) 
+			FROM
+				 %s h
+				LEFT JOIN  %s i ON h.own_id = i.id 
+			WHERE
+				h.own_type = 1 
+				AND i.ent_id = a.ent_id 
+				AND i.user_id = a.user_id 
+				AND h.isread = 0 
+				AND h.iswithdraw = 0 
+				AND i.customer_service_id = %d 
+			) AS number 
+		FROM
+			%s a
+			INNER JOIN %s b ON  a.ent_id = %d and %s 
+			AND a.user_id = b.id
+			LEFT JOIN  %s e ON e.id = a.message_id 
+	ORDER BY
+	a.update_time DESC`, util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_CHAT_SESSION, in.EntUserId, util.User_message_list, util.BASE_USER, in.EntId, idSql, util.SOCIALIZE_MESSAGE)
 	}
+	dataSize := []map[string]interface{}{}
 	if sqlStr != "" {
-		log.Println(sqlStr)
+		log.Println("查询列表sql:", sqlStr)
 		data = IC.BaseMysql.SelectBySql(sqlStr)
+		if data != nil && len(*data) > 0 {
+			count = quitl.Int64All(len(*data))
+			log.Println("查询列表耗时2:", time.Since(tm), count)
+			if in.UserType != 2 {
+				if in.Page*in.Size >= count {
+					dataSize = (*data)[(in.Page-1)*in.Size:]
+				} else {
+					dataSize = (*data)[(in.Page-1)*in.Size : in.Page*in.Size]
+				}
+				return &dataSize, count, err
+			}
+		}
 	}
 	return
 }
 
-//消息保存
+// 客服会话列表
+func (b MessaggeService) ConversationList(in *messagecenter.ConversationReq) (data *[]map[string]interface{}, count int64, err error) {
+	sqlStr := ""
+	tm := time.Now()
+	if in.UserType == 1 && in.FiltrationId != "" {
+		var ids []string
+		for _, v := range strings.Split(in.FiltrationId, ",") {
+			ids = append(ids, encrypt.SE.Decode4Hex(v))
+		}
+		idSql := fmt.Sprintf("a.customer_service_id = %d AND  b.id  in (%s) ", in.EntUserId, strings.Join(ids, ","))
+		sqlStr = fmt.Sprintf(`SELECT(
+			CASE
+            	WHEN SUBSTR( b.nickname, 1, 3 ) = 'JY_' THEN
+            	CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) ) 
+            	WHEN b.nickname = '' 
+            	OR b.nickname IS NULL THEN
+            	CONCAT( SUBSTR( b.phone, 1, 3 ), '****', SUBSTR( b.phone, 8, 11 ) ) ELSE b.nickname 
+            	END 
+            ) AS name,
+			b.id,
+			e.title,
+			b.headimg,
+			e.type,
+			e.link,
+			e.content,
+			a.update_time as create_time,
+			(
+			SELECT
+				count( h.id ) 
+			FROM
+				 %s h
+				LEFT JOIN  %s i ON h.own_id = i.id 
+			WHERE
+				h.own_type = 1 
+				AND i.ent_id = a.ent_id 
+				AND i.user_id = a.user_id 
+				AND h.isread = 0 
+				AND h.iswithdraw = 0 
+				AND i.customer_service_id = %d 
+			) AS number 
+		FROM
+			%s a
+			INNER JOIN %s b ON  %s 
+			AND a.user_id = b.id
+			LEFT JOIN  %s e ON e.id = a.message_id`,
+			util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_CHAT_SESSION, in.EntUserId, util.User_message_list, util.BASE_USER, idSql, util.SOCIALIZE_MESSAGE)
+	}
+
+	if sqlStr != "" {
+		log.Println("查询列表sql:", sqlStr)
+		data = IC.BaseMysql.SelectBySql(sqlStr)
+		log.Println("查询耗时2:", time.Since(tm), count)
+	}
+	return
+}
+
+// 消息保存
 func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool, errorMsg string, content string, messageId, nowInt int64) {
 	//先插入信息表
 	//判断会话标识是否属于本人
+	var customer_service_id, userid, entid, message_id int64
 	nowForm := time.Now().Local()
+	create_time := nowForm.Format(util.Date_Full_Layout)
 	if in.ItemType != 2 {
 		userId := int64(0)
 		sessionId := int64(0)
 		switch in.ItemType {
-		case 4, 5:
+		case 4, 5, 8:
 			if in.OwnType == 1 {
 				sessionId = in.ReceiveId
 				userId = in.NewUserId
 			} else {
 				sessionId = in.SendId
 				userId = in.ReceiveId
-				if in.ItemType == 4 {
+				if in.ItemType == 4 || in.ItemType == 8 {
 					userId = in.NewUserId
 				}
 			}
@@ -232,7 +334,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 			break
 		}
 		//查找会话信息
-		chatJson := IC.BaseMysql.FindOne(util.SOCIALIZE_CHAT_SESSION, map[string]interface{}{"id": sessionId}, "user_id", "")
+		chatJson := IC.BaseMysql.FindOne(util.SOCIALIZE_CHAT_SESSION, map[string]interface{}{"id": sessionId}, "user_id,ent_id,customer_service_id", "")
 		if chatJson == nil {
 			return false, "会话标识不存在", "", 0, nowForm.Unix()
 		} else {
@@ -240,10 +342,12 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 				return false, "会话标识不属于此用户", "", 0, nowForm.Unix()
 			}
 		}
+		customer_service_id = quitl.Int64All((*chatJson)["customer_service_id"])
+		entid = quitl.Int64All((*chatJson)["ent_id"])
+		userid = userId
 	}
 	fool = IC.BaseMysql.ExecTx("聊天信息保存", func(tx *sql.Tx) bool {
 		//先插入信息表
-		create_time := nowForm.Format(util.Date_Full_Layout)
 		userType := int64(1)
 		userId := int64(0)
 		message := map[string]interface{}{
@@ -264,7 +368,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 		}
 		ok := IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_MESSAGE, message)
 		receiveOk := int64(0)
-		messageId = ok
+		messageId, message_id = ok, ok
 		data["id"] = ok
 		//在插入邮箱表socialize_message_mailbox
 		messageMailBox := map[string]interface{}{
@@ -319,7 +423,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 			receiveOk = IC.BaseMysql.InsertByTx(tx, util.SOCIALIZE_MESSAGE_MAILBOX, messageMailBox)
 			return ok > 1 && receiveOk > 1
 		}
-		if in.ItemType == 4 || in.ItemType == 5 {
+		if in.ItemType == 4 || in.ItemType == 8 || in.ItemType == 5 {
 			//客服或者机器人聊天
 			if in.OwnType == 1 {
 				// (用户发送)客服接受
@@ -340,7 +444,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 				messageMailBox["send_user_id"] = in.SendId
 				messageMailBox["receive_user_id"] = in.ReceiveId
 				userId = in.ReceiveId
-				if in.ItemType == 4 {
+				if in.ItemType == 4 || in.ItemType == 8 {
 					messageMailBox["receive_user_id"] = in.NewUserId
 					userId = in.NewUserId
 					messageMailBox["own_id"] = in.NewUserId
@@ -372,7 +476,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 			"receive_isdel": 0,
 			"iswithdraw":    0,
 		}
-		if in.ItemType == 4 || in.ItemType == 5 {
+		if in.ItemType == 4 || in.ItemType == 8 || in.ItemType == 5 {
 			//客服或者机器人聊天
 			if in.OwnType == 1 {
 				//用户发送(用户接受)
@@ -391,7 +495,7 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 				messageMailBox["own_id"] = in.SendId
 				messageMailBox["send_user_id"] = in.SendId
 				messageMailBox["receive_user_id"] = in.ReceiveId
-				if in.ItemType == 4 {
+				if in.ItemType == 4 || in.ItemType == 8 {
 					messageMailBox["receive_user_id"] = in.NewUserId
 				}
 			}
@@ -414,10 +518,47 @@ func (b MessaggeService) SaveMessage(in *messagecenter.MessageEntity) (fool bool
 		}
 		return ok > 1 && receiveOk > 1
 	})
+	if fool && in.ItemType != 2 && in.ItemType != 3 {
+		go UserSynchronousList(customer_service_id, userid, entid, message_id, create_time)
+	}
 	return fool, "", in.Content, messageId, nowForm.Unix()
 }
 
-//历史信息查询
+var rwLock = new(sync.RWMutex)
+
+// 客服 用户聊天消息列表同步
+func UserSynchronousList(customerServiceId, userId, entId, messageId int64, createTime string) {
+	log.Printf("同步最后消息参数customerServiceId:%d,userId:%d,entId%d,messageId:%d", customerServiceId, userId, entId, messageId)
+	rwLock.Lock()
+	defer rwLock.Unlock()
+	if IC.BaseMysql.Count(util.User_message_list, map[string]interface{}{"user_id": userId, "ent_id": entId}) > 0 {
+		upData := map[string]interface{}{
+			"message_id":  messageId,
+			"update_time": createTime,
+		}
+		//判断是否机器人聊天
+		if customerServiceId > 0 && IC.BaseMysql.Count(util.User_message_list, map[string]interface{}{"user_id": userId, "ent_id": entId, "customer_service_id": 0}) > 0 {
+			//将机器人列表更新成用户
+			upData["customer_service_id"] = customerServiceId
+			//转人工 机器人聊天类型修改
+			upData["type"] = 1
+		}
+		//已于人工客服联系过 只同步最后消息
+		IC.BaseMysql.Update(util.User_message_list, map[string]interface{}{"user_id": userId, "ent_id": entId}, upData)
+		return
+	}
+	//不存在消息列表 创建
+	IC.BaseMysql.Insert(util.User_message_list, map[string]interface{}{
+		"ent_id":              entId,
+		"user_id":             userId,
+		"message_id":          messageId,
+		"update_time":         createTime,
+		"customer_service_id": customerServiceId,
+		"type":                quitl.If(customerServiceId == 0, 0, 1),
+	})
+}
+
+// 历史信息查询
 func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string]interface{} {
 	sqlStr := ""
 	lastStr := ""
@@ -435,10 +576,10 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 			"LEFT JOIN %s b on  a.messag_id=b.id  "+
 			"LEFT  JOIN  %s c on  c.id=a.send_user_id   "+
 			"LEFT JOIN  %s d on  d.id=a.receive_user_id  "+
-			"where  a.own_id=  %d "+
+			"where  a.own_id=  %d and a.iswithdraw = 0"+
 			"AND ((a.send_user_id=   %d AND   a.receive_user_id=   %d) or (a.send_user_id=  %d AND  a.receive_user_id=  %d)) "+
 			"AND  a.type=2  %s "+
-			"ORDER BY a.create_time desc ,a.id   asc "+
+			"ORDER BY a.create_time desc,a.id   asc "+
 			"limit 0 ,  %d ",
 			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)
@@ -450,29 +591,30 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 				"FROM   %s a   "+
 				"LEFT JOIN %s b ON a.messag_id = b.id   "+
 				"LEFT JOIN %s c ON   a.own_type = 1  AND  a.own_id=c.id    "+
-				"WHERE   a.own_type = 1   "+
-				"AND (a.type = 5 or a.type=4 or  a.type=6 or  a.type=7)   "+
+				"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 "+
+				"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)
 		} else {
 			//用户聊天记录查看
-			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,   d.nickname as  robotName,   d.headimage as  robotImg,   c.customer_service_name as  setName   "+
+			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   "+
 				"FROM   %s a   "+
 				"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    "+
-				"WHERE   a.own_type = 2    "+
+				"LEFT JOIN %s e on  e.messag_id=b.id "+
+				"WHERE   a.own_type = 2  and a.iswithdraw = 0  "+
 				"AND a.own_id =  %d "+
 				"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)  %s "+
-				"ORDER BY a.create_time desc ,a.id   asc "+
+				"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 "+
 				"limit 0 ,   %d ",
-				util.SOCIALIZE_MESSAGE_MAILBOX, util.SOCIALIZE_MESSAGE, util.SOCIALIZE_CHAT_SESSION, in.SendId, in.NewUserId, util.SOCIALIZE_TENANT_ROBOT,
+				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)
 		}
 		break
@@ -491,8 +633,8 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 	}
 	go func() {
 		updateMap := map[string]interface{}{}
-		//if len(*data) > 0 && data != nil {
-		if true {
+		if len(*data) > 0 && data != nil {
+			//if true {
 			//未读信息修改
 			switch in.MsgType {
 			case 2: //点对点聊天
@@ -508,14 +650,14 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 				sqlStr := ""
 				if in.UserType == 1 {
 					sqlStr = fmt.Sprintf("UPDATE %s a  SET a.isread = 1,    a.read_time = now( )  "+
-						"WHERE    a.own_type = 1  "+
+						"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)
 				} else {
 					sqlStr = fmt.Sprintf("UPDATE %s a  SET a.isread = 1,    a.read_time = now( )  "+
-						"WHERE    a.own_type = 2  "+
+						"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)
@@ -530,7 +672,7 @@ func (b MessaggeService) FindMessage(in *messagecenter.MessageReq) *[]map[string
 	return data
 }
 
-//创建会话
+// 创建会话
 func (b MessaggeService) CreateChatSession(in *messagecenter.ChatSessionReq) (fool bool, sessionId int64) {
 	fool = IC.BaseMysql.ExecTx("会话新建", func(tx *sql.Tx) bool {
 		customerserviceName := in.CustomerserviceName
@@ -566,7 +708,7 @@ func (b MessaggeService) CreateChatSession(in *messagecenter.ChatSessionReq) (fo
 	return
 }
 
-//结束会话
+// 结束会话
 func (b MessaggeService) CloseChatSession(in *messagecenter.CloseSessionReq) bool {
 	fool := IC.BaseMysql.ExecTx("关闭会话", func(tx *sql.Tx) bool {
 		updateMap := map[string]interface{}{
@@ -578,10 +720,11 @@ func (b MessaggeService) CloseChatSession(in *messagecenter.CloseSessionReq) boo
 	return fool
 }
 
-//创建会话并保存信息
+// 创建会话并保存信息
 func (b *MessaggeService) SaveAutoReplyMsg(userType, entId, entUserId, userId int64, content, appId, nowFormat string) (bool, int64) {
+	var customer_service_id, userid, entid, message_id int64
 	messageId := int64(0)
-	return IC.BaseMysql.ExecTx("保存自动回复消息", func(tx *sql.Tx) bool {
+	ok1 := IC.BaseMysql.ExecTx("保存自动回复消息", func(tx *sql.Tx) bool {
 		entUserName := ""
 		if entUserId > 0 {
 			list := IC.BaseMysql.SelectBySql(`select ? from socialize_tenant_seat where appid=? AND ent_id=? AND customer_service_id=?`, util.SOCIALIZE_CHAT_SESSION, appId, entId, entUserId)
@@ -601,11 +744,19 @@ func (b *MessaggeService) SaveAutoReplyMsg(userType, entId, entUserId, userId in
 		} else if userType == 2 {
 			ok = IC.BaseMysql.InsertBySqlByTx(tx, `insert into socialize_message_mailbox (appid,messag_id,type,send_user_id,send_user_type,receive_user_id,receive_user_type,own_id,own_type,create_time) values (?,?,?,?,?,?,?,?,?,?)`, appId, messageId, 7, sessionId, 1, userId, 2, userId, 2, nowFormat) > 0
 		}
+		message_id = messageId
 		return messageId > 0 && sessionId > 0 && ok
-	}), messageId
+	})
+	if ok1 {
+		customer_service_id = entUserId
+		userid = userId
+		entid = entId
+		go UserSynchronousList(customer_service_id, userid, entid, message_id, nowFormat)
+	}
+	return ok1, messageId
 }
 
-//修改未读状态
+// 修改未读状态
 func (b MessaggeService) UpdateReadById(in *messagecenter.ReadStateReq) bool {
 	fool := IC.BaseMysql.ExecTx("已读状态修改", func(tx *sql.Tx) bool {
 		updateMap := map[string]interface{}{
@@ -644,3 +795,74 @@ func (b MessaggeService) UpdateReadById(in *messagecenter.ReadStateReq) bool {
 	})
 	return fool
 }
+
+// WithdrawMessage 撤回消息
+func (b MessaggeService) WithdrawMessage(in *messagecenter.ReadWithdrawReq) bool {
+	messageId := encrypt.SE.Decode4Hex(in.MessageId)
+	newUserId, entUserId := NewEndId(quitl.Int64All(messageId), in.UserType)
+	msg := IC.BaseMysql.FindOne(util.SOCIALIZE_MESSAGE, map[string]interface{}{"id": messageId}, "create_time", "")
+	if msg == nil || len(*msg) <= 0 {
+		log.Println("查询消息id失败")
+		return false
+	}
+	createTime, _ := time.Parse(util.Date_Full_Layout, quitl.InterfaceToStr((*msg)["create_time"]))
+	if createTime.Unix()+60*2 < time.Now().Unix() {
+		log.Println("消息已超过2分钟,撤回失败")
+		return false
+	}
+	nowForm := time.Now().Local()
+	m := IC.BaseMysql.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 {
+		//消息撤回 更新对方私信
+		in.UserType = quitl.Int64All(quitl.If(in.UserType == 1, 2, 1))
+		b.Count(newUserId, in.UserType, entUserId, true)
+	}
+	return m
+}
+
+// AppraiseMessage 消息评价
+func (b MessaggeService) AppraiseMessage(in *messagecenter.AppraiseReq) error {
+	messageId := encrypt.SE.Decode4Hex(in.MessageId)
+	//查询此条消息是否是当前用户的
+	if IC.BaseMysql.Count(util.SOCIALIZE_MESSAGE_MAILBOX, map[string]interface{}{
+		"messag_id":         messageId,
+		"receive_user_id":   in.NewUserId,
+		"receive_user_type": 2,
+		"type":              8,
+	}) == 0 {
+		return fmt.Errorf("未查询到信息")
+	}
+	if IC.BaseMysql.Count(util.SOCIALIZE_APPRAISE, map[string]interface{}{
+		"appid":     in.Appid,
+		"messag_id": messageId,
+	}) > 0 {
+		return fmt.Errorf("请勿重复评价")
+	}
+	//插入评价
+	if IC.BaseMysql.Insert(util.SOCIALIZE_APPRAISE, map[string]interface{}{
+		"appid":       in.Appid,
+		"messag_id":   messageId,
+		"create_time": time.Now().Local().Format(util.Date_Full_Layout),
+		"appraise":    in.Appraise,
+	}) > 0 {
+		return nil
+	}
+	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
+}

部分文件因为文件数量过多而无法显示