|
@@ -81,12 +81,10 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
tm := time.Now()
|
|
tm := time.Now()
|
|
if in.UserType == 2 {
|
|
if in.UserType == 2 {
|
|
var (
|
|
var (
|
|
- allSql, nameSql string
|
|
|
|
- sqlArr []string
|
|
|
|
|
|
+ allSql string
|
|
|
|
+ sqlArr []string
|
|
)
|
|
)
|
|
- if in.NameSearch != "" {
|
|
|
|
- nameSql = " WHERE a.name like '%" + in.NameSearch + "%"
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
//一对一
|
|
//一对一
|
|
oneSql := fmt.Sprintf(`(SELECT
|
|
oneSql := fmt.Sprintf(`(SELECT
|
|
a.your_position_id AS id,
|
|
a.your_position_id AS id,
|
|
@@ -119,7 +117,7 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
"" as phone
|
|
"" as phone
|
|
FROM
|
|
FROM
|
|
socialize_summary a
|
|
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 )
|
|
LEFT JOIN socialize_message c ON ( a.message_id = c.id )
|
|
) `, in.NewUserId)
|
|
) `, in.NewUserId)
|
|
//群列表
|
|
//群列表
|
|
@@ -151,8 +149,8 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
sqlStr = fmt.Sprintf(`SELECT * FROM
|
|
sqlStr = fmt.Sprintf(`SELECT * FROM
|
|
(
|
|
(
|
|
%s
|
|
%s
|
|
- ) a %s
|
|
|
|
- a.ORDER BY a.timestamp DESC`, allSql, nameSql)
|
|
|
|
|
|
+ ) a
|
|
|
|
+ a.ORDER BY a.timestamp DESC`, allSql)
|
|
} else {
|
|
} else {
|
|
var timeSql, phoneSql, filtrationSql string
|
|
var timeSql, phoneSql, filtrationSql string
|
|
if in.StartTime != "" {
|
|
if in.StartTime != "" {
|
|
@@ -256,18 +254,21 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
} else {
|
|
} else {
|
|
dataSize = (*data)[(in.Page-1)*in.Size : in.Page*in.Size]
|
|
dataSize = (*data)[(in.Page-1)*in.Size : in.Page*in.Size]
|
|
}
|
|
}
|
|
- return &dataSize, count, err
|
|
|
|
} else {
|
|
} else {
|
|
phoneMap, _, _ := EntPerson(in.EntId, false)
|
|
phoneMap, _, _ := EntPerson(in.EntId, false)
|
|
for _, v := range *data {
|
|
for _, v := range *data {
|
|
if name, ok := phoneMap[quitl.InterfaceToStr(v["phone"])]; ok && quitl.IntAll(v["userType"]) == 1 {
|
|
if name, ok := phoneMap[quitl.InterfaceToStr(v["phone"])]; ok && quitl.IntAll(v["userType"]) == 1 {
|
|
v["name"] = name
|
|
v["name"] = name
|
|
}
|
|
}
|
|
|
|
+ if in.NameSearch != "" && !strings.Contains(quitl.InterfaceToStr(v["name"]), in.NameSearch) {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ dataSize = append(dataSize, v)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return
|
|
|
|
|
|
+ return &dataSize, count, err
|
|
}
|
|
}
|
|
|
|
|
|
// 客服会话列表
|
|
// 客服会话列表
|
|
@@ -280,7 +281,7 @@ func (b MessaggeService) ConversationList(in *messagecenter.ConversationReq) (da
|
|
ids = append(ids, encrypt.SE.Decode4Hex(v))
|
|
ids = append(ids, encrypt.SE.Decode4Hex(v))
|
|
}
|
|
}
|
|
filtrationSql := fmt.Sprintf(" AND b.id in (%s)", strings.Join(ids, ","))
|
|
filtrationSql := fmt.Sprintf(" AND b.id in (%s)", strings.Join(ids, ","))
|
|
- aiSql := fmt.Sprintf(`SELECT
|
|
|
|
|
|
+ aiSql := fmt.Sprintf(`(SELECT
|
|
a.user_id,
|
|
a.user_id,
|
|
a.message_id,
|
|
a.message_id,
|
|
a.timestamp,
|
|
a.timestamp,
|
|
@@ -290,9 +291,9 @@ func (b MessaggeService) ConversationList(in *messagecenter.ConversationReq) (da
|
|
FROM
|
|
FROM
|
|
socialize_summary a
|
|
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 )`, in.EntId, filtrationSql)
|
|
|
|
|
|
+ %s ))`, in.EntId, filtrationSql)
|
|
|
|
|
|
- serviceSql := fmt.Sprintf(`SELECT
|
|
|
|
|
|
+ serviceSql := fmt.Sprintf(`(SELECT
|
|
a.user_id,
|
|
a.user_id,
|
|
c.message_id,
|
|
c.message_id,
|
|
c.timestamp,
|
|
c.timestamp,
|
|
@@ -302,7 +303,7 @@ func (b MessaggeService) ConversationList(in *messagecenter.ConversationReq) (da
|
|
FROM
|
|
FROM
|
|
socialize_customer_service_user a
|
|
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 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
|
|
sqlStr = aiSql + " UNION ALL " + serviceSql
|
|
}
|
|
}
|
|
|
|
|
|
@@ -889,7 +890,7 @@ func SynchronousInfo(sender, recipient, conversationType, messageId, userType, e
|
|
switch conversationType {
|
|
switch conversationType {
|
|
case 1: //一对一用户聊天
|
|
case 1: //一对一用户聊天
|
|
if IC.BaseMysql.Count(util.SOCIALIZE_MESSAGE, map[string]interface{}{"id": messageId, "own_id": recipient, "isread": 0}) > 0 {
|
|
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: //用户与客服
|
|
case 2: //用户与客服
|
|
if IC.BaseMysql.Count(util.SOCIALIZE_MESSAGE, map[string]interface{}{"id": messageId, "own_id": recipient, "isread": 0}) > 0 {
|
|
if IC.BaseMysql.Count(util.SOCIALIZE_MESSAGE, map[string]interface{}{"id": messageId, "own_id": recipient, "isread": 0}) > 0 {
|
|
@@ -941,22 +942,6 @@ func (b MessaggeService) AppraiseMessage(in *messagecenter.AppraiseReq) error {
|
|
return fmt.Errorf("评价消息异常")
|
|
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 ,群聊,群发
|
|
// 包含 1v1 ,群聊,群发
|
|
/*
|
|
/*
|