运营数据

This commit is contained in:
duoaohui
2026-06-06 14:32:40 +08:00
parent c6e460ad97
commit 4477132081

View File

@@ -675,8 +675,22 @@ func (s *MeetingService) JoinRoom(ctx context.Context, userID int64, code, passw
return room, participant, routerID, nil return room, participant, routerID, nil
} }
// isCloudLawRoom 判断是否为云律视频咨询房间host 为云律自动创建的用户(邮箱后缀 @cloud-law.local
// 云律房间语义是「发起人(用户)↔接单人(律师)」一对一咨询,发起人挂断即咨询结束。
func (s *MeetingService) isCloudLawRoom(ctx context.Context, hostID int64) bool {
if s.userResolver == nil || hostID <= 0 {
return false
}
users, err := s.userResolver.GetUsersByIDs(ctx, []int64{hostID})
if err != nil || len(users) == 0 {
return false
}
return strings.HasSuffix(users[0].Email, "@cloud-law.local")
}
// LeaveRoom 用户主动离会 // LeaveRoom 用户主动离会
// 若离开者为 host 且房间内还有其他活跃成员事务内转让给最早加入者若为空房关闭房间status=Ended, reason=empty_ttl // 若离开者为 host 且房间内还有其他活跃成员事务内转让给最早加入者若为空房关闭房间status=Ended, reason=empty_ttl
// 云律房间例外:发起人(host)离会即结束整场会议(见下方说明)
func (s *MeetingService) LeaveRoom(ctx context.Context, userID int64, code string) (int, error) { func (s *MeetingService) LeaveRoom(ctx context.Context, userID int64, code string) (int, error) {
funcName := "service.meeting_service.LeaveRoom" funcName := "service.meeting_service.LeaveRoom"
@@ -712,6 +726,16 @@ func (s *MeetingService) LeaveRoom(ctx context.Context, userID int64, code strin
} }
if participant.Role == constants.MeetingRoleHost && len(actives) > 0 { if participant.Role == constants.MeetingRoleHost && len(actives) > 0 {
// 云律视频咨询:发起人(host)即咨询者,挂断/离会即代表咨询结束,
// 应直接结束整场会议,而不是把主持人转让给律师让会议继续
//(否则表现为「用户已挂断、律师端会议仍在、云律 status 一直 accepted」
if s.isCloudLawRoom(ctx, room.HostID) {
if endErr := s.EndRoomForInternal(ctx, code); endErr != nil {
logs.Warn(ctx, funcName, "云律发起人离会自动结束会议失败",
zap.String("room_code", code), zap.Int64("host_id", room.HostID), zap.Error(endErr))
}
return duration, nil
}
newHost := actives[0] newHost := actives[0]
// P1-1TransferHost 内部事务已同时更新 meeting_rooms.host_id不再需要单独 UpdateHost // P1-1TransferHost 内部事务已同时更新 meeting_rooms.host_id不再需要单独 UpdateHost
if txErr := s.participantDAO.TransferHost(ctx, room.ID, userID, newHost.UserID); txErr != nil { if txErr := s.participantDAO.TransferHost(ctx, room.ID, userID, newHost.UserID); txErr != nil {