|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using JetBrains.Annotations; |
|
|
|
using Castle.Components.DictionaryAdapter.Xml; |
|
|
|
using JetBrains.Annotations; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
@ -15,6 +16,7 @@ using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using TencentCloud.Faceid.V20180301.Models; |
|
|
|
using TencentCloud.Mrs.V20200910.Models; |
|
|
|
using TencentCloud.Teo.V20220901.Models; |
|
|
|
using Volo.Abp.Application.Services; |
|
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
using Volo.Abp.Identity; |
|
|
|
@ -563,7 +565,7 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
PatientNo = s.PatientNo, |
|
|
|
SexName = s.SexName, |
|
|
|
StandardPrice = DataHelper.DecimalRetainDecimals(s.f.StandardPrice * s.f.Amount, 2), |
|
|
|
Discount = s.f.StandardPrice * s.f.Amount ==0 ? "0%": Math.Floor((s.b.ChargePrice * s.b.Amount) / (s.f.StandardPrice * s.f.Amount)) + "%" |
|
|
|
Discount = s.f.StandardPrice * s.f.Amount == 0 ? "0%" : Math.Floor((s.b.ChargePrice * s.b.Amount) / (s.f.StandardPrice * s.f.Amount)) + "%" |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
return patientRegisterGroup; |
|
|
|
@ -579,53 +581,80 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
[HttpPost("api/app/charge-report/get-Personal-Fee-Details-report-in-fee-summary")] |
|
|
|
public async Task<GetPersonalFeeDetailsReportInFeeSummaryDto> GetPersonalFeeDetailsReportInFeeSummaryAsync(GetPersonalFeeDetailsReportInFeeSummaryRequestDto input) |
|
|
|
{ |
|
|
|
#region 替换
|
|
|
|
//var query = from a in await _patientRegisterRepository.GetQueryableAsync()
|
|
|
|
// join b in await _patientRepository.GetQueryableAsync() on a.PatientId equals b.Id into bb
|
|
|
|
// from ab in bb.DefaultIfEmpty()
|
|
|
|
// join c in await _sexRepository.GetQueryableAsync() on a.SexId equals c.Id into cc
|
|
|
|
// from ac in cc.DefaultIfEmpty()
|
|
|
|
// join d in (await _registerAsbitemRepository.GetQueryableAsync()).Where(m => m.IsCharge == 'Y')
|
|
|
|
// .GroupBy(g => g.PatientRegisterId)
|
|
|
|
// .Select(s => new
|
|
|
|
// {
|
|
|
|
// PatientRegisterId = s.Key,
|
|
|
|
// AsbitemChargeMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.ChargePrice * ss.Amount), 2)
|
|
|
|
// }) on a.Id equals d.PatientRegisterId
|
|
|
|
// join e in await _chargeRepository.GetQueryableAsync() on a.Id equals e.PatientRegisterId
|
|
|
|
// join f in await _chargePayRepository.GetQueryableAsync() on e.Id equals f.ChargeId
|
|
|
|
// join g in await _payModeRepository.GetQueryableAsync() on f.PayModeId equals g.Id into gg
|
|
|
|
// from ag in gg.DefaultIfEmpty()
|
|
|
|
// join h in await _userRepository.GetQueryableAsync() on e.CreatorId equals h.Id into hh
|
|
|
|
// from ah in hh.DefaultIfEmpty()
|
|
|
|
// where a.CustomerOrgId == GuidFlag.PersonCustomerOrgId
|
|
|
|
// select new
|
|
|
|
// {
|
|
|
|
// a,
|
|
|
|
// e,
|
|
|
|
// f,
|
|
|
|
// PatientName = a.PatientName,
|
|
|
|
// Age = a.Age,
|
|
|
|
// PatientNo = ab != null ? ab.PatientNo : "",
|
|
|
|
// SexName = ac != null ? ac.DisplayName : "",
|
|
|
|
// AsbitemChargeMoney = d.AsbitemChargeMoney,
|
|
|
|
// BookKeepingName = ah != null ? ah.UserName : "",
|
|
|
|
// PayModeName = ag != null ? ag.DisplayName : ""
|
|
|
|
// };
|
|
|
|
|
|
|
|
var query = from a in await _patientRegisterRepository.GetQueryableAsync() |
|
|
|
join b in await _patientRepository.GetQueryableAsync() on a.PatientId equals b.Id into bb |
|
|
|
from ab in bb.DefaultIfEmpty() |
|
|
|
join c in await _sexRepository.GetQueryableAsync() on a.SexId equals c.Id into cc |
|
|
|
from ac in cc.DefaultIfEmpty() |
|
|
|
join d in (await _registerAsbitemRepository.GetQueryableAsync()).Where(m => m.IsCharge == 'Y') |
|
|
|
.GroupBy(g => g.PatientRegisterId) |
|
|
|
.Select(s => new |
|
|
|
{ |
|
|
|
PatientRegisterId = s.Key, |
|
|
|
AsbitemChargeMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.ChargePrice * ss.Amount), 2) |
|
|
|
}) on a.Id equals d.PatientRegisterId |
|
|
|
join e in await _chargeRepository.GetQueryableAsync() on a.Id equals e.PatientRegisterId |
|
|
|
join f in await _chargePayRepository.GetQueryableAsync() on e.Id equals f.ChargeId |
|
|
|
join g in await _payModeRepository.GetQueryableAsync() on f.PayModeId equals g.Id into gg |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var query = from a in (await _chargeRepository.GetQueryableAsync()).Include(x => x.ChargePays).ThenInclude(x => x.PayMode) |
|
|
|
join b in await _chargeAsbitemRepository.GetQueryableAsync() on a.Id equals b.ChargeId |
|
|
|
join c in await _registerAsbitemRepository.GetQueryableAsync() on new { PatientRegisterId = a.PatientRegisterId, AsbitemId = b.AsbitemId } |
|
|
|
equals new { PatientRegisterId = c.PatientRegisterId, AsbitemId = c.AsbitemId } |
|
|
|
join d in await _patientRegisterRepository.GetQueryableAsync() on a.PatientRegisterId equals d.Id |
|
|
|
join e in await _patientRepository.GetQueryableAsync() on d.PatientId equals e.Id into ee |
|
|
|
from ae in ee.DefaultIfEmpty() |
|
|
|
join f in await _sexRepository.GetQueryableAsync() on d.SexId equals f.Id into ff |
|
|
|
from af in ff.DefaultIfEmpty() |
|
|
|
join g in await _userRepository.GetQueryableAsync() on a.CreatorId equals g.Id into gg |
|
|
|
from ag in gg.DefaultIfEmpty() |
|
|
|
join h in await _userRepository.GetQueryableAsync() on e.CreatorId equals h.Id into hh |
|
|
|
from ah in hh.DefaultIfEmpty() |
|
|
|
where a.CustomerOrgGroupId == GuidFlag.PersonCustomerOrgId |
|
|
|
where d.CustomerOrgId == GuidFlag.PersonCustomerOrgId |
|
|
|
select new |
|
|
|
{ |
|
|
|
a, |
|
|
|
e, |
|
|
|
f, |
|
|
|
PatientName = a.PatientName, |
|
|
|
Age = a.Age, |
|
|
|
PatientNo = ab != null ? ab.PatientNo : "", |
|
|
|
SexName = ac != null ? ac.DisplayName : "", |
|
|
|
AsbitemChargeMoney = d.AsbitemChargeMoney, |
|
|
|
BookKeepingName = ah != null ? ah.UserName : "", |
|
|
|
PayModeName = ag != null ? ag.DisplayName : "" |
|
|
|
b, |
|
|
|
c, |
|
|
|
PatientName = d.PatientName, |
|
|
|
Age = d.Age, |
|
|
|
PatientNo = ae != null ? ae.PatientNo : "", |
|
|
|
SexName = af != null ? af.DisplayName : "", |
|
|
|
BookKeepingName = ag != null ? ag.UserName : "" |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var ggg = query.ToQueryString(); |
|
|
|
|
|
|
|
|
|
|
|
if (input.UserIds.Any()) |
|
|
|
{ |
|
|
|
query = query.Where(m => input.UserIds.Contains(m.e.CreatorId.Value)); |
|
|
|
query = query.Where(m => input.UserIds.Contains(m.a.CreatorId.Value)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.StartDate) && !string.IsNullOrWhiteSpace(input.EndDate)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.e.CreationTime >= Convert.ToDateTime(input.StartDate) |
|
|
|
&& m.e.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
|
|
|
query = query.Where(m => m.a.CreationTime >= Convert.ToDateTime(input.StartDate) |
|
|
|
&& m.a.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.PatientName)) |
|
|
|
@ -639,26 +668,27 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var ggggg = query.ToList(); |
|
|
|
|
|
|
|
var personalFeeDetailsReportInFeeSummary_Details = query.GroupBy(g => g.e.Id).Select(s => new GetPersonalFeeDetailsReportInFeeSummary_Detail |
|
|
|
var sqlstr = query.ToQueryString(); |
|
|
|
|
|
|
|
var personalFeeDetailsReportInFeeSummary_Details = query.GroupBy(g => g.b.ChargeId).Select(s => new GetPersonalFeeDetailsReportInFeeSummary_Detail |
|
|
|
{ |
|
|
|
Age = s.FirstOrDefault().Age, |
|
|
|
BookKeepingName = s.FirstOrDefault().BookKeepingName, |
|
|
|
BookkeepingTiem = s.FirstOrDefault().e.CreationTime.ToString("yyyy-MM-dd HH:mm"), |
|
|
|
ChargeFlagName = s.FirstOrDefault().e.ChargeFlag == ChargeFlag.Charge ? "收费" : "退费", |
|
|
|
ChargeMoney = s.FirstOrDefault().AsbitemChargeMoney, |
|
|
|
BookkeepingTiem = s.FirstOrDefault().a.CreationTime.ToString("yyyy-MM-dd HH:mm"), |
|
|
|
ChargeFlagName = s.FirstOrDefault().a.ChargeFlag == ChargeFlag.Charge ? "收费" : "退费", |
|
|
|
PatientName = s.FirstOrDefault().PatientName, |
|
|
|
PatientNo = s.FirstOrDefault().PatientNo, |
|
|
|
ReceivedChargeMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.f.ChargeMoney), 2), |
|
|
|
SexName = s.FirstOrDefault().SexName, |
|
|
|
DiscountMoney = s.FirstOrDefault().AsbitemChargeMoney - DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.f.ChargeMoney), 2), |
|
|
|
PayModes = s.Select(ss => new GetPersonalFeeDetailsReportInFeeSummary_PayMode |
|
|
|
ChargeMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.c.ChargePrice * ss.c.Amount), 2), |
|
|
|
ReceivedChargeMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.b.ChargePrice * ss.b.Amount), 2), |
|
|
|
DiscountMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.c.ChargePrice * ss.c.Amount), 2) - DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.b.ChargePrice * ss.b.Amount), 2), |
|
|
|
PayModes = s.FirstOrDefault().a.ChargePays.Select(ss => new GetPersonalFeeDetailsReportInFeeSummary_PayMode |
|
|
|
{ |
|
|
|
PayModeName = ss.PayModeName, |
|
|
|
ReceivedChargeMoney = ss.f.ChargeMoney |
|
|
|
PayModeName = ss.PayMode.DisplayName, |
|
|
|
ReceivedChargeMoney = ss.ChargeMoney |
|
|
|
}).ToList() |
|
|
|
}).ToList(); |
|
|
|
}).OrderBy(o => o.PatientName).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
decimal sumChargeMoney = personalFeeDetailsReportInFeeSummary_Details.Any() ? DataHelper.DecimalRetainDecimals(personalFeeDetailsReportInFeeSummary_Details.Sum(s => s.ChargeMoney), 2) : 0; |
|
|
|
|