소스 검색

Merge branch 'dev/v1.2.11_fu' of SocialPlatform/messageCenter into feature/v1.2.11

fuwencai 11 달 전
부모
커밋
f73a78803e
1개의 변경된 파일11개의 추가작업 그리고 56개의 파일을 삭제
  1. 11 56
      service/message_mail_box.go

+ 11 - 56
service/message_mail_box.go

@@ -181,7 +181,7 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 						%s
 					) a ORDER BY a.timestamp DESC LIMIT %d,%d`, allSql, (startNum-1)*pageSize, pageSize)
 	} else {
-		var timeSql, phoneSql, filtrationSql string
+		var timeSql, phoneSql, filtrationSql, isTouristSql string
 		if 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) {
 			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 != "" {
 			var ids []string
 			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, ","))
 		}
-		// 非人工接入 非游客
 		aiSql := fmt.Sprintf(`(SELECT
 		   				a.user_id,
 		   				a.message_id,
@@ -211,8 +214,7 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 	   				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 %s %s)`, in.EntId, timeSql, phoneSql, filtrationSql)
-		// 人工接入 非游客
+		   				%s %s %s %s)`, in.EntId, timeSql, phoneSql, filtrationSql, isTouristSql)
 		serviceSql := fmt.Sprintf(`(SELECT
 		   				a.user_id,
 		   				c.message_id,
@@ -224,64 +226,17 @@ func (b MessaggeService) UserList(in *messagecenter.UserReq) (data *[]map[string
 						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,
-			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,
-			strings.ReplaceAll(timeSql, "a.", "c."))
+			strings.ReplaceAll(timeSql, "a.", "c."), isTouristSql)
 		var restrictionSql string
 		switch in.IsArtificial {
 		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:
-			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:
-			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 {