|
@@ -181,7 +181,7 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
%s
|
|
%s
|
|
) a ORDER BY a.timestamp DESC LIMIT %d,%d`, allSql, (startNum-1)*pageSize, pageSize)
|
|
) a ORDER BY a.timestamp DESC LIMIT %d,%d`, allSql, (startNum-1)*pageSize, pageSize)
|
|
} else {
|
|
} else {
|
|
- var timeSql, phoneSql, filtrationSql string
|
|
|
|
|
|
+ var timeSql, phoneSql, filtrationSql, isTouristSql string
|
|
if in.StartTime != "" {
|
|
if in.StartTime != "" {
|
|
timeSql += fmt.Sprintf(" AND a.timestamp >= '%s 00:00:00'", in.StartTime)
|
|
timeSql += fmt.Sprintf(" AND a.timestamp >= '%s 00:00:00'", in.StartTime)
|
|
}
|
|
}
|
|
@@ -191,6 +191,10 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
if in.Phone != "" && in.IsTourist != int64(2) {
|
|
if in.Phone != "" && in.IsTourist != int64(2) {
|
|
phoneSql = " AND b.phone like '%" + in.Phone + "%'"
|
|
phoneSql = " AND b.phone like '%" + in.Phone + "%'"
|
|
}
|
|
}
|
|
|
|
+ if in.IsTourist == 1 || in.IsTourist == 2 {
|
|
|
|
+ isTouristSql = " AND b.is_tourist = " + fmt.Sprintf("%d", in.IsTourist)
|
|
|
|
+ }
|
|
|
|
+
|
|
if in.FiltrationId != "" {
|
|
if in.FiltrationId != "" {
|
|
var ids []string
|
|
var ids []string
|
|
for _, v := range strings.Split(in.FiltrationId, ",") {
|
|
for _, v := range strings.Split(in.FiltrationId, ",") {
|
|
@@ -198,7 +202,6 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
}
|
|
}
|
|
filtrationSql += fmt.Sprintf(" AND b.id not in (%s)", strings.Join(ids, ","))
|
|
filtrationSql += fmt.Sprintf(" AND b.id not 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,
|
|
@@ -211,8 +214,7 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
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 %s %s)`, in.EntId, timeSql, phoneSql, filtrationSql)
|
|
|
|
- // 人工接入 非游客
|
|
|
|
|
|
+ %s %s %s %s)`, in.EntId, timeSql, phoneSql, filtrationSql, isTouristSql)
|
|
serviceSql := fmt.Sprintf(`(SELECT
|
|
serviceSql := fmt.Sprintf(`(SELECT
|
|
a.user_id,
|
|
a.user_id,
|
|
c.message_id,
|
|
c.message_id,
|
|
@@ -224,64 +226,17 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
|
|
0 as userType
|
|
0 as userType
|
|
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 %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,
|
|
|
|
- strings.ReplaceAll(timeSql, "a.", "c."))
|
|
|
|
- // 非人工介入 游客
|
|
|
|
- aiTouristSql := fmt.Sprintf(`(SELECT
|
|
|
|
- a.user_id,
|
|
|
|
- a.message_id,
|
|
|
|
- a.timestamp,
|
|
|
|
- b.nickname,
|
|
|
|
- 0 as unread,
|
|
|
|
- b.head_img as headimg,
|
|
|
|
- "" as phone,
|
|
|
|
- 0 as userType
|
|
|
|
- FROM
|
|
|
|
- socialize_summary a
|
|
|
|
- INNER JOIN socialize_tourist 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)
|
|
|
|
- // 人工介入游客
|
|
|
|
- serviceTouristSql := fmt.Sprintf(`(SELECT
|
|
|
|
- a.user_id,
|
|
|
|
- c.message_id,
|
|
|
|
- c.timestamp,
|
|
|
|
- b.nickname,
|
|
|
|
- a.unread,
|
|
|
|
- b.head_img as headimg,
|
|
|
|
- "" as phone,
|
|
|
|
- 0 as userType
|
|
|
|
- FROM
|
|
|
|
- socialize_customer_service_user a
|
|
|
|
- INNER JOIN socialize_tourist b ON ( a.customer_service_id = %d AND a.user_id = b.id %s %s)
|
|
|
|
|
|
+ INNER JOIN base_user b ON ( a.customer_service_id = %d AND a.user_id = b.id %s %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."))
|
|
|
|
|
|
+ strings.ReplaceAll(timeSql, "a.", "c."), isTouristSql)
|
|
var restrictionSql string
|
|
var restrictionSql string
|
|
switch in.IsArtificial {
|
|
switch in.IsArtificial {
|
|
case 1:
|
|
case 1:
|
|
- if in.IsTourist == int64(2) { // 人工且游客
|
|
|
|
- restrictionSql = serviceTouristSql
|
|
|
|
- } else if in.IsTourist == int64(1) { // 人工非游客
|
|
|
|
- restrictionSql = serviceSql
|
|
|
|
- } else { // 人工 (包含游客和非游客)
|
|
|
|
- restrictionSql = serviceSql + " UNION ALL" + serviceTouristSql
|
|
|
|
- }
|
|
|
|
|
|
+ restrictionSql = serviceSql
|
|
case 2:
|
|
case 2:
|
|
- if in.IsTourist == int64(2) { // ai且游客
|
|
|
|
- restrictionSql = aiTouristSql
|
|
|
|
- } else if in.IsTourist == int64(1) { // ai非游客
|
|
|
|
- restrictionSql = aiSql
|
|
|
|
- } else { // ai (包含游客和非游客)
|
|
|
|
- restrictionSql = aiSql + " UNION ALL" + aiTouristSql
|
|
|
|
- }
|
|
|
|
|
|
+ restrictionSql = aiSql
|
|
default:
|
|
default:
|
|
- if in.IsTourist == int64(2) { // 游客
|
|
|
|
- restrictionSql = aiTouristSql + " UNION ALL " + serviceTouristSql
|
|
|
|
- } else if in.IsTourist == int64(1) { // 非游客
|
|
|
|
- restrictionSql = aiSql + " UNION ALL " + serviceSql
|
|
|
|
- } else { // 无筛选
|
|
|
|
- restrictionSql = aiSql + " UNION ALL " + serviceSql + " UNION ALL " + aiTouristSql + " UNION ALL " + serviceTouristSql
|
|
|
|
- }
|
|
|
|
|
|
+ restrictionSql = aiSql + " UNION ALL " + serviceSql
|
|
}
|
|
}
|
|
|
|
|
|
if in.Page <= 0 {
|
|
if in.Page <= 0 {
|