public async Task <IActionResult> GetHealthManagerConsumers([FromQuery] GetHealthManagerConsumerListRequestDto request) { var managerBiz = new HealthManagerBiz(); var response = await managerBiz.GetHealthManagerConsumers(request); return(Success(response)); }
public async Task <IActionResult> GetHealthManagerConsumers([FromQuery] GetHealthManagerConsumerListRequestDto request) { request.UserId = UserID; var managerBiz = new HealthManagerBiz(); var response = await managerBiz.GetHealthManagerConsumers(request); if (response != null) { foreach (var item in response.CurrentPage) { if (item.ReportMaxDate > item.MaxDate) { item.MaxDate = item.ReportMaxDate; } } response.CurrentPage = response.CurrentPage?.OrderByDescending(s => s.MaxDate).ThenByDescending(s => s.ManagerBindDate).ToList(); } return(Success(response)); }
/// <summary> /// 获取绑定用户列表 /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <GetHealthManagerConsumerListResponseDto> GetHealthManagerConsumers(GetHealthManagerConsumerListRequestDto request) { var sql = @"select c.consumer_guid, u.user_name, u.gender,u.phone, b.maxdate, c.manager_bind_date, e.reportmaxdate, ( IF(u.birthday IS NULL, '0', TIMESTAMPDIFF(YEAR, u.birthday, CURDATE())) ) AS age, concat(p.base_path, p.relative_path) as portrait_img from t_consumer as c inner join t_utility_user AS u on u.user_guid = c.consumer_guid LEFT JOIN (SELECT Max(a.last_updated_date) maxdate,a.user_guid FROM t_consumer_indicator a GROUP BY a.user_guid) b on c.consumer_guid=b.user_guid LEFT JOIN (SELECT Max(a.last_updated_date) reportmaxdate,a.user_guid FROM t_consumer_health_report a GROUP BY a.user_guid) e on c.consumer_guid=e.user_guid left join t_utility_accessory AS p on u.portrait_guid = p.accessory_guid where c.health_manager_guid = @UserId"; if (!string.IsNullOrWhiteSpace(request.KeyWord)) { sql = $"{sql} AND (u.user_name like @KeyWord or u.phone like @KeyWord)"; request.KeyWord = $"{request.KeyWord}%"; } return(await MySqlHelper.QueryByPageAsync <GetHealthManagerConsumerListRequestDto, GetHealthManagerConsumerListResponseDto, GetHealthManagerConsumerItem>(sql, request)); }
/// <summary> /// 查询指定健康管理师已绑定会员分页列表 /// </summary> /// <param name="requestDto"></param> /// <returns></returns> public async Task <GetHealthManagerConsumerListResponseDto> GetHealthManagerConsumers(GetHealthManagerConsumerListRequestDto requestDto) { var sql = @"select c.consumer_guid, u.user_name, u.gender,u.phone, ( IF(u.birthday IS NULL, '-', TIMESTAMPDIFF(YEAR, u.birthday, CURDATE())) ) AS age, c.manager_bind_date as bind_date from t_consumer as c inner join t_utility_user AS u on u.user_guid = c.consumer_guid where c.health_manager_guid = @ManagerGuid"; if (!string.IsNullOrEmpty(requestDto.KeyWord)) { sql = $"{sql} and (u.user_name like '%{requestDto.KeyWord}%' or u.phone like '%{requestDto.KeyWord}%')"; } if (requestDto.BindTime.HasValue) { if (requestDto.EndTime.HasValue) { requestDto.EndTime = requestDto.EndTime.Value.AddDays(1).AddSeconds(-1); } else { requestDto.EndTime = requestDto.BindTime.Value.AddDays(1).AddSeconds(-1); } sql = $"{sql} and c.manager_bind_date >= @BindTime and c.manager_bind_date <= @EndTime"; } sql = $"{sql} order by c.manager_bind_date desc"; return(await MySqlHelper.QueryByPageAsync <GetHealthManagerConsumerListRequestDto, GetHealthManagerConsumerListResponseDto, GetHealthManagerConsumerItem>(sql, requestDto)); }