public ContentResult coachplayer(PlayerCoachQueryRequest request) { request.MemberId = UserContext.WebUserContext.Id; var data = _playerCoachService.Coach_PlayerList(request); var res = new ResultDto <CoachPlayerResponse> { page = request.PageIndex, total = request.Total, records = request.Records, rows = data }; return(Content(res.Serialize())); }
//学生下的教练列表 public List <PlayerCoachResponse> Player_CoachList(PlayerCoachQueryRequest request) { List <PlayerCoachResponse> list = new List <PlayerCoachResponse>(); try { var sql = @"select * from ( select a.*, b.completepinyin CoachName,b.code CoachCode from t_player_coach a inner join t_member_coach b on a.toMemberId=b.memberId where a.isdelete=0 and a.isCoach=0 and a.isPositive=1 and a.memberId=@MemberId union all select a.*, b.completepinyin CoachName,b.code CoachCode from t_player_coach a inner join t_member_coach b on a.memberId=b.memberId where a.isdelete=0 and a.isCoach=1 and a.isPositive=0 and a.toMemberId=@MemberId ) a order by a.createtime desc "; int totalCount = 0; list = _dbContext.Page <PlayerCoachResponse>(sql, out totalCount, request.PageIndex, request.PageSize, request); request.Records = totalCount; if (list != null && list.Count > 0) { foreach (var item in list) { if (item.MemberId == request.MemberId) { item.Flag = true; } } } } catch (Exception ex) { LogUtils.LogError("PlayerCoachService.Player_CoachList", ex); } return(list); }
//教练下的学生列表 public List <CoachPlayerResponse> Coach_PlayerList(PlayerCoachQueryRequest request) { List <CoachPlayerResponse> list = new List <CoachPlayerResponse>(); try { var sql = @"select * from ( select a.*,b.completepinyin PlayerPinYinName,b.completename PlayerName,b.code PlayerCode,c.PlayerPoints from t_player_coach a inner join t_member_player b on a.MemberId=b.memberId inner join t_member_points c on a.memberId=c.memberId where a.isdelete=0 and a.isCoach=0 and a.isPositive=1 and a.toMemberId=@MemberId union all select a.*,b.completepinyin PlayerPinYinName,b.completename PlayerName,b.code PlayerCode,c.PlayerPoints from t_player_coach a inner join t_member_player b on a.ToMemberId=b.memberId inner join t_member_points c on a.memberId=c.memberId where a.isdelete=0 and a.isCoach=1 and a.isPositive=0 and a.memberId=@MemberId ) a order by a.createTime desc "; int totalCount = 0; list = _dbContext.Page <CoachPlayerResponse>(sql, out totalCount, request.PageIndex, request.PageSize, request); request.Records = totalCount; if (list != null && list.Count > 0) { foreach (var item in list) { if (item.MemberId == request.MemberId) { item.Flag = true; } if (item.PlayerCoachStatus == PlayerCoachStatusEm.意) { var playerId = item.Flag ? item.ToMemberId : item.MemberId; //参与比赛次数 item.Times = _dbContext.ExecuteScalar($"select count(distinct(eventGroupId)) from t_event_cycling_match_playerresult where playerId={playerId}").ToObjInt(); //指教期间获胜次数 StringBuilder sb = new StringBuilder(); if (item.EndDate.IsEmpty()) { sb.Append($" and c.starteventdate>={item.StartDate} "); } else { sb.Append($" and c.starteventdate>={item.StartDate} and c.endeventdate<={item.EndDate}"); } item.WinTimes = _dbContext.ExecuteScalar($@"select (select count(a.id) Count from t_event_cycling_match_playerresult a inner join t_event_cycling_match_teamresult b on a.eventId = b.eventId and a.eventGroupId = b.eventGroupId and a.cyclingMatchId = b.cyclingMatchId and a.groupNum = b.groupNum inner join t_event c on a.eventId=c.id where a.playerId = {playerId} and b.isWin = 1 {sb.ToString()}) + (select count(a.id) Count from t_event_knockout_match_teamresult a left join t_event_player_signup b on a.groupNum=b.groupNum and a.eventGroupId=b.eventGroupId and a.eventId=a.eventId inner join t_event c on a.eventId=c.id where b.memberId ={playerId} and a.isWin = 1 {sb.ToString()}) as Count").ToObjInt(); } } } } catch (Exception ex) { LogUtils.LogError("PlayerCoachService.Coach_PlayerList", ex); } return(list); }