/// <summary> /// 医生列表 /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <GetDoctorPageResponseDto> GetDoctorPageAsync(GetDoctorPageRequestDto request) { var whereSql = $@"1=1 and status='{DoctorModel.StatusEnum.Approved.ToString()}'"; if (!string.IsNullOrWhiteSpace(request.Name)) { request.Name = $"{request.Name}%"; whereSql = $"{whereSql} AND user_name like @Name"; } if (!string.IsNullOrWhiteSpace(request.Phone)) { request.Phone = $"{request.Phone}%"; whereSql = $"{whereSql} AND phone like @Phone"; } if (!string.IsNullOrWhiteSpace(request.HospitalGuid)) { whereSql = $"{whereSql} AND Hospital_Guid like @HospitalGuid"; } if (!string.IsNullOrWhiteSpace(request.OfficeGuid)) { whereSql = $"{whereSql} AND Office_Guid like @OfficeGuid"; } if (request.BeginDate != null) { request.BeginDate = request.BeginDate?.Date; whereSql = $"{whereSql} AND creation_date > @BeginDate"; } if (request.EndDate != null) { request.EndDate = request.EndDate?.AddDays(1).Date; whereSql = $"{whereSql} AND creation_date < @EndDate"; } var sql = $@" SELECT * FROM( SELECT A.*, CONCAT( B.base_path, B.relative_path ) AS PortraitUrl, C.user_name , C.phone, D.count as article_qty, E.count as advisory_qty, F.count as fans_qty FROM t_doctor A LEFT JOIN t_utility_accessory B ON B.accessory_guid = A.portrait_guid LEFT JOIN t_utility_user C ON C.user_guid = A.doctor_guid LEFT JOIN (SELECT author_guid,count(1) as count FROM t_utility_article WHERE `enable`=1 GROUP BY author_guid) D ON D.author_guid = A.doctor_guid LEFT JOIN (select doctor_guid, sum(times) as count from t_doctor_consult_statistic WHERE `enable`=1 GROUP BY doctor_guid) E ON E.doctor_guid = A.doctor_guid left join (select target_guid,count(1) as count from t_consumer_collection where `enable`=1 and target_type='doctor' GROUP BY target_guid) F on F.target_guid=A.doctor_guid ) ___t WHERE {whereSql} ORDER BY creation_date desc" ; return(await MySqlHelper.QueryByPageAsync <GetDoctorPageRequestDto, GetDoctorPageResponseDto, GetDoctorPageItemDto>(sql, request)); }
public async Task <IActionResult> GetDoctorPageAsync([FromBody] GetDoctorPageRequestDto request) { var settings = Factory.GetSettings("host.json"); var presence = settings["XMPP:presence"]; var domain = settings["XMPP:domain"]; var response = await new DoctorBiz().GetDoctorPageAsync(request); ScoreBiz scoreBiz = new ScoreBiz(); var users = response.CurrentPage.Select(a => a.DoctorGuid).ToArray(); var totalPoints = await scoreBiz.GetUserPointsAsync(users); var wechatSubscriptionRecommendCounts = await new WechatSubscriptionBiz().GetWechatSubscriptionRecommendCountsAsync(WechatSubscriptionModel.EntranceEnum.Doctor, users); foreach (var item in response.CurrentPage) { item.PresenceIcon = $"{presence}?jid={item.DoctorGuid}@{domain}"; item.TotalPoints = totalPoints.FirstOrDefault(a => a.UserGuid == item.DoctorGuid)?.Variation ?? 0; item.RecommendCount = wechatSubscriptionRecommendCounts.FirstOrDefault(a => a.UserGuid == item.DoctorGuid)?.Count ?? 0; } return(Success(response)); }