|
|
|
@ -1,9 +1,12 @@ |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using JetBrains.Annotations; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using NPOI.SS.Formula.Functions; |
|
|
|
using Shentun.Peis.Charges; |
|
|
|
using Shentun.Peis.Enums; |
|
|
|
using Shentun.Peis.ItemTypes; |
|
|
|
using Shentun.Peis.Models; |
|
|
|
using Shentun.Peis.Patients; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
@ -14,6 +17,7 @@ using TencentCloud.Mrs.V20200910.Models; |
|
|
|
using Volo.Abp.Application.Services; |
|
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
using Volo.Abp.Identity; |
|
|
|
using Volo.Abp.OpenIddict.Applications; |
|
|
|
using Volo.Abp.Users; |
|
|
|
|
|
|
|
namespace Shentun.Peis.ChargeReports |
|
|
|
@ -40,6 +44,8 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
private readonly IRepository<CustomerOrgRegister, Guid> _customerOrgRegisterRepository; |
|
|
|
private readonly IRepository<CustomerOrg, Guid> _customerOrgRepository; |
|
|
|
private readonly IRepository<ItemType, Guid> _itemTypeRepository; |
|
|
|
private readonly IRepository<Patient, Guid> _patientRepository; |
|
|
|
private readonly IRepository<Sex> _sexRepository; |
|
|
|
private readonly ItemTypeManager _itemTypeManager; |
|
|
|
public ChargeReportAppService( |
|
|
|
IRepository<Charge, Guid> chargeRepository, |
|
|
|
@ -57,7 +63,9 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
IRepository<CustomerOrg, Guid> customerOrgRepository, |
|
|
|
IRepository<ItemType, Guid> itemTypeRepository, |
|
|
|
ItemTypeManager itemTypeManager |
|
|
|
) |
|
|
|
, |
|
|
|
IRepository<Patient, Guid> patientRepository, |
|
|
|
IRepository<Sex> sexRepository) |
|
|
|
{ |
|
|
|
_chargeRepository = chargeRepository; |
|
|
|
_chargeBackRepository = chargeBackRepository; |
|
|
|
@ -74,6 +82,8 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
_customerOrgRepository = customerOrgRepository; |
|
|
|
_itemTypeRepository = itemTypeRepository; |
|
|
|
_itemTypeManager = itemTypeManager; |
|
|
|
_patientRepository = patientRepository; |
|
|
|
_sexRepository = sexRepository; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -119,7 +129,7 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
PayModeDetails = s.GroupBy(gg => gg.b.PayModeId).Select(ss => new GetChargeAndChargeBackSummary_PayModeDetail |
|
|
|
{ |
|
|
|
PayModeName = ss.FirstOrDefault().PayModeName, |
|
|
|
Money = Math.Round(ss.Sum(sss => sss.b.ChargeMoney), 2) |
|
|
|
Money = DataHelper.DecimalRetainDecimals(ss.Sum(sss => sss.b.ChargeMoney), 2) |
|
|
|
}).ToList() |
|
|
|
}); |
|
|
|
#endregion
|
|
|
|
@ -158,7 +168,7 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
PayModeDetails = s.GroupBy(gg => gg.b.PayModeId).Select(ss => new GetChargeAndChargeBackSummary_PayModeDetail |
|
|
|
{ |
|
|
|
PayModeName = ss.FirstOrDefault().PayModeName, |
|
|
|
Money = Math.Round(ss.Sum(sss => sss.b.BackMoeny), 2) |
|
|
|
Money = DataHelper.DecimalRetainDecimals(ss.Sum(sss => sss.b.BackMoeny), 2) |
|
|
|
}).ToList() |
|
|
|
}); |
|
|
|
#endregion
|
|
|
|
@ -229,7 +239,7 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
ChargeCount = chargeQuery.GroupBy(g => g.a.Id).Count(), |
|
|
|
ChargeBackCount = chargeBackQuery.GroupBy(g => g.a.Id).Count(), |
|
|
|
ChargeDetails = chargeAndChargeBackDetails, |
|
|
|
SumTotalMoney = chargeAndChargeBackDetails.Any() ? Math.Round(chargeAndChargeBackDetails.Sum(s => s.TotalMoney), 2) : 0 |
|
|
|
SumTotalMoney = chargeAndChargeBackDetails.Any() ? DataHelper.DecimalRetainDecimals(chargeAndChargeBackDetails.Sum(s => s.TotalMoney), 2) : 0 |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
@ -280,7 +290,7 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
var chargeDetails = chargeQuery.GroupBy(g => g.ac.InvoiceItemTypeId).Select(s => new GetTollCollectorFeeReportInInvoiceType_InvoiceTypeDetail |
|
|
|
{ |
|
|
|
InvoiceTypeName = s.FirstOrDefault().InvoiceItemTypeName, |
|
|
|
InvoiceTypeMoney = Math.Round(s.Sum(ss => ss.b.Amount * ss.b.ChargePrice), 2) |
|
|
|
InvoiceTypeMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.b.Amount * ss.b.ChargePrice), 2) |
|
|
|
}).ToList(); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
@ -319,7 +329,7 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
var chargeBackDetails = chargeBackQuery.GroupBy(g => g.ad.InvoiceItemTypeId).Select(s => new GetTollCollectorFeeReportInInvoiceType_InvoiceTypeDetail |
|
|
|
{ |
|
|
|
InvoiceTypeName = s.FirstOrDefault().InvoiceItemTypeName, |
|
|
|
InvoiceTypeMoney = Math.Round(s.Sum(ss => ss.c.Amount * ss.c.ChargePrice), 2) |
|
|
|
InvoiceTypeMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.c.Amount * ss.c.ChargePrice), 2) |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
@ -329,10 +339,10 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
string chargeDate = Convert.ToDateTime(input.StartDate).ToString("yyyy年MM月dd日") + "到" + Convert.ToDateTime(input.EndDate).ToString("yyyy年MM月dd日"); |
|
|
|
|
|
|
|
//收款合计
|
|
|
|
decimal chargeTotalMoney = chargeDetails.Any() ? Math.Round(chargeDetails.Sum(s => s.InvoiceTypeMoney), 2) : 0; |
|
|
|
decimal chargeTotalMoney = chargeDetails.Any() ? DataHelper.DecimalRetainDecimals(chargeDetails.Sum(s => s.InvoiceTypeMoney), 2) : 0; |
|
|
|
|
|
|
|
//退费合计
|
|
|
|
decimal chargeBackTotalMoney = chargeBackDetails.Any() ? Math.Round(chargeBackDetails.Sum(s => s.InvoiceTypeMoney), 2) : 0; |
|
|
|
decimal chargeBackTotalMoney = chargeBackDetails.Any() ? DataHelper.DecimalRetainDecimals(chargeBackDetails.Sum(s => s.InvoiceTypeMoney), 2) : 0; |
|
|
|
|
|
|
|
var tollCollectorFeeReportInInvoiceTypeDto = new GetTollCollectorFeeReportInInvoiceTypeDto |
|
|
|
{ |
|
|
|
@ -358,10 +368,441 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 收费员收费报表 按组合项目
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/charge-report/get-toll-collector-fee-report-in-asbitem")] |
|
|
|
public async Task<List<GetTollCollectorFeeReportInAsbitemDto>> GetTollCollectorFeeReportInAsbitemAsync(GetTollCollectorFeeReportInAsbitemRequestDto input) |
|
|
|
{ |
|
|
|
var query = from a in await _chargeRepository.GetQueryableAsync() |
|
|
|
join b in await _chargeAsbitemRepository.GetQueryableAsync() on a.Id equals b.ChargeId |
|
|
|
join c in await _asbitemRepository.GetQueryableAsync() on b.AsbitemId equals c.Id into cc |
|
|
|
from ac in cc.DefaultIfEmpty() |
|
|
|
join d in await _itemTypeRepository.GetQueryableAsync() on ac.ItemTypeId equals d.Id into dd |
|
|
|
from ad in dd.DefaultIfEmpty() |
|
|
|
select new |
|
|
|
{ |
|
|
|
a, |
|
|
|
b, |
|
|
|
AsbitemName = ac != null ? ac.DisplayName : "", |
|
|
|
ItemTypeName = ad != null ? ad.DisplayName : "" |
|
|
|
}; |
|
|
|
|
|
|
|
if (input.UserIds.Any()) |
|
|
|
{ |
|
|
|
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.a.CreationTime >= Convert.ToDateTime(input.StartDate) |
|
|
|
&& m.a.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var asbitemGroup = query.GroupBy(g => g.b.AsbitemId).Select(s => new GetTollCollectorFeeReportInAsbitem_Detail |
|
|
|
{ |
|
|
|
AsbitemName = s.FirstOrDefault().AsbitemName, |
|
|
|
ChargeMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.b.ChargePrice * ss.b.Amount), 2), |
|
|
|
ItemTypeName = s.FirstOrDefault().ItemTypeName |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
var tollCollectorFeeReportInAsbitemDtos = asbitemGroup.GroupBy(g => g.ItemTypeName).Select(s => new GetTollCollectorFeeReportInAsbitemDto |
|
|
|
{ |
|
|
|
Details = s.ToList(), |
|
|
|
ItemTypeName = s.FirstOrDefault().ItemTypeName, |
|
|
|
TotalMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.ChargeMoney), 2) |
|
|
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
return tollCollectorFeeReportInAsbitemDtos; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 个人收费明细报表 按收费明细
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/charge-report/get-Personal-Fee-Details-report-in-fee-details")] |
|
|
|
public async Task<List<GetPersonalFeeDetailsReportInFeeDetailsDto>> GetPersonalFeeDetailsReportInFeeDetailsAsync(GetPersonalFeeDetailsReportInFeeDetailsRequestDto input) |
|
|
|
{ |
|
|
|
var query = from a in await _chargeRepository.GetQueryableAsync() |
|
|
|
join b in await _chargeAsbitemRepository.GetQueryableAsync() on a.Id equals b.ChargeId |
|
|
|
join c in await _patientRegisterRepository.GetQueryableAsync() on a.PatientRegisterId equals c.Id |
|
|
|
join d in await _patientRepository.GetQueryableAsync() on c.PatientId equals d.Id into dd |
|
|
|
from ad in dd.DefaultIfEmpty() |
|
|
|
join e in await _sexRepository.GetQueryableAsync() on c.SexId equals e.Id into ee |
|
|
|
from ae in ee.DefaultIfEmpty() |
|
|
|
join f in await _registerAsbitemRepository.GetQueryableAsync() on c.Id equals f.PatientRegisterId |
|
|
|
join g in await _asbitemRepository.GetQueryableAsync() on f.AsbitemId equals g.Id into gg |
|
|
|
from ag in gg.DefaultIfEmpty() |
|
|
|
join h in await _userRepository.GetQueryableAsync() on a.CreatorId equals h.Id into hh |
|
|
|
from ah in hh.DefaultIfEmpty() |
|
|
|
where c.CustomerOrgId == GuidFlag.PersonCustomerOrgId && a.ChargeFlag == ChargeFlag.Charge |
|
|
|
select new |
|
|
|
{ |
|
|
|
a, |
|
|
|
b, |
|
|
|
c, |
|
|
|
f, |
|
|
|
PatientNo = ad != null ? ad.PatientNo : "", |
|
|
|
SexName = ae != null ? ae.DisplayName : "", |
|
|
|
AsbitemName = ag != null ? ag.DisplayName : "", |
|
|
|
BookKeepingName = ah != null ? ah.UserName : "" |
|
|
|
}; |
|
|
|
|
|
|
|
if (input.UserIds.Any()) |
|
|
|
{ |
|
|
|
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.a.CreationTime >= Convert.ToDateTime(input.StartDate) |
|
|
|
&& m.a.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.PatientName)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.c.PatientName == input.PatientName); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.PatientNo)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.PatientNo == input.PatientNo); |
|
|
|
} |
|
|
|
|
|
|
|
var patientRegisterGroup = query.Select(s => new GetPersonalFeeDetailsReportInFeeDetailsDto |
|
|
|
{ |
|
|
|
Age = s.c.Age, |
|
|
|
AsbitemName = s.AsbitemName, |
|
|
|
BookKeepingName = s.BookKeepingName, |
|
|
|
BookkeepingTiem = s.a.CreationTime.ToString("yyyy-MM-dd HH:mm"), |
|
|
|
CharePrice = DataHelper.DecimalRetainDecimals(s.b.ChargePrice * s.b.Amount, 2), |
|
|
|
MedicalTimes = s.c.MedicalTimes, |
|
|
|
PatientName = s.c.PatientName, |
|
|
|
PatientNo = s.PatientNo, |
|
|
|
SexName = s.SexName, |
|
|
|
StandardPrice = DataHelper.DecimalRetainDecimals(s.f.StandardPrice * s.f.Amount, 2), |
|
|
|
Discount = Math.Floor((s.b.ChargePrice * s.b.Amount) / (s.f.StandardPrice.Value * s.f.Amount.Value)) + "%" |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
return patientRegisterGroup; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 个人收费明细报表 按退费明细
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/charge-report/get-Personal-Fee-Details-report-in-refund-details")] |
|
|
|
public async Task<List<GetPersonalFeeDetailsReportInRefundDetailsDto>> GetPersonalFeeDetailsReportInRefundDetailsAsync(GetPersonalFeeDetailsReportInRefundDetailsRequestDto input) |
|
|
|
{ |
|
|
|
var query = from a in await _chargeRepository.GetQueryableAsync() |
|
|
|
join b in await _chargeAsbitemRepository.GetQueryableAsync() on a.Id equals b.ChargeId |
|
|
|
join c in await _patientRegisterRepository.GetQueryableAsync() on a.PatientRegisterId equals c.Id |
|
|
|
join d in await _patientRepository.GetQueryableAsync() on c.PatientId equals d.Id into dd |
|
|
|
from ad in dd.DefaultIfEmpty() |
|
|
|
join e in await _sexRepository.GetQueryableAsync() on c.SexId equals e.Id into ee |
|
|
|
from ae in ee.DefaultIfEmpty() |
|
|
|
join f in await _registerAsbitemRepository.GetQueryableAsync() on c.Id equals f.PatientRegisterId |
|
|
|
join g in await _asbitemRepository.GetQueryableAsync() on f.AsbitemId equals g.Id into gg |
|
|
|
from ag in gg.DefaultIfEmpty() |
|
|
|
join h in await _userRepository.GetQueryableAsync() on a.CreatorId equals h.Id into hh |
|
|
|
from ah in hh.DefaultIfEmpty() |
|
|
|
where c.CustomerOrgId == GuidFlag.PersonCustomerOrgId && a.ChargeFlag == ChargeFlag.ChargeBack |
|
|
|
select new |
|
|
|
{ |
|
|
|
a, |
|
|
|
b, |
|
|
|
c, |
|
|
|
f, |
|
|
|
PatientNo = ad != null ? ad.PatientNo : "", |
|
|
|
SexName = ae != null ? ae.DisplayName : "", |
|
|
|
AsbitemName = ag != null ? ag.DisplayName : "", |
|
|
|
BookKeepingName = ah != null ? ah.UserName : "" |
|
|
|
}; |
|
|
|
|
|
|
|
if (input.UserIds.Any()) |
|
|
|
{ |
|
|
|
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.a.CreationTime >= Convert.ToDateTime(input.StartDate) |
|
|
|
&& m.a.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.PatientName)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.c.PatientName == input.PatientName); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.PatientNo)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.PatientNo == input.PatientNo); |
|
|
|
} |
|
|
|
|
|
|
|
var patientRegisterGroup = query.Select(s => new GetPersonalFeeDetailsReportInRefundDetailsDto |
|
|
|
{ |
|
|
|
Age = s.c.Age, |
|
|
|
AsbitemName = s.AsbitemName, |
|
|
|
BookKeepingName = s.BookKeepingName, |
|
|
|
BookkeepingTiem = s.a.CreationTime.ToString("yyyy-MM-dd HH:mm"), |
|
|
|
CharePrice = DataHelper.DecimalRetainDecimals(s.b.ChargePrice * s.b.Amount, 2), |
|
|
|
MedicalTimes = s.c.MedicalTimes, |
|
|
|
PatientName = s.c.PatientName, |
|
|
|
PatientNo = s.PatientNo, |
|
|
|
SexName = s.SexName, |
|
|
|
StandardPrice = DataHelper.DecimalRetainDecimals(s.f.StandardPrice * s.f.Amount, 2), |
|
|
|
Discount = Math.Floor((s.b.ChargePrice * s.b.Amount) / (s.f.StandardPrice.Value * s.f.Amount.Value)) + "%" |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
return patientRegisterGroup; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 个人收费明细报表 按收费汇总
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/charge-report/get-Personal-Fee-Details-report-in-fee-summary")] |
|
|
|
public async Task<GetPersonalFeeDetailsReportInFeeSummaryDto> GetPersonalFeeDetailsReportInFeeSummaryAsync(GetPersonalFeeDetailsReportInFeeSummaryRequestDto input) |
|
|
|
{ |
|
|
|
|
|
|
|
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.Value * ss.Amount.Value), 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.CustomerOrgGroupId == 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 : "" |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (input.UserIds.Any()) |
|
|
|
{ |
|
|
|
query = query.Where(m => input.UserIds.Contains(m.e.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)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.PatientName)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.PatientName == input.PatientName); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.PatientNo)) |
|
|
|
{ |
|
|
|
query = query.Where(m => m.PatientNo == input.PatientNo); |
|
|
|
} |
|
|
|
|
|
|
|
var personalFeeDetailsReportInFeeSummary_Details = query.GroupBy(g => g.e.Id).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, |
|
|
|
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 |
|
|
|
{ |
|
|
|
PayModeName = ss.PayModeName, |
|
|
|
ReceivedChargeMoney = ss.f.ChargeMoney |
|
|
|
}).ToList() |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
decimal sumChargeMoney = personalFeeDetailsReportInFeeSummary_Details.Any() ? DataHelper.DecimalRetainDecimals(personalFeeDetailsReportInFeeSummary_Details.Sum(s => s.ChargeMoney), 2) : 0; |
|
|
|
decimal sumDiscountMoney = personalFeeDetailsReportInFeeSummary_Details.Any() ? DataHelper.DecimalRetainDecimals(personalFeeDetailsReportInFeeSummary_Details.Sum(s => s.DiscountMoney), 2) : 0; |
|
|
|
decimal sumReceivedChargeMoney = personalFeeDetailsReportInFeeSummary_Details.Any() ? DataHelper.DecimalRetainDecimals(personalFeeDetailsReportInFeeSummary_Details.Sum(s => s.ReceivedChargeMoney), 2) : 0; |
|
|
|
|
|
|
|
var personalFeeDetailsReportInFeeSummaryDto = new GetPersonalFeeDetailsReportInFeeSummaryDto |
|
|
|
{ |
|
|
|
ChargeCount = personalFeeDetailsReportInFeeSummary_Details.Count, |
|
|
|
Details = personalFeeDetailsReportInFeeSummary_Details, |
|
|
|
SumChargeMoney = sumChargeMoney, |
|
|
|
SumDiscountMoney = sumDiscountMoney, |
|
|
|
SumReceivedChargeMoney = sumReceivedChargeMoney |
|
|
|
}; |
|
|
|
|
|
|
|
return personalFeeDetailsReportInFeeSummaryDto; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 收费人收费汇总报表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/charge-report/get-toll-collector-fee-summary-report")] |
|
|
|
public async Task<GetTollcollectorFeeSummaryReportDto> GetTollcollectorFeeSummaryReportAsync(GetTollcollectorFeeSummaryReportRequestDto input) |
|
|
|
{ |
|
|
|
#region 收费
|
|
|
|
var chargeQuery = from a in await _chargeRepository.GetQueryableAsync() |
|
|
|
join b in await _chargePayRepository.GetQueryableAsync() on a.Id equals b.ChargeId |
|
|
|
join d in await _userRepository.GetQueryableAsync() on a.CreatorId equals d.Id into dd |
|
|
|
from ad in dd.DefaultIfEmpty() |
|
|
|
select new |
|
|
|
{ |
|
|
|
a, |
|
|
|
b, |
|
|
|
UserName = ad != null ? ad.UserName : "" |
|
|
|
}; |
|
|
|
|
|
|
|
if (input.UserIds.Any()) |
|
|
|
{ |
|
|
|
chargeQuery = chargeQuery.Where(m => input.UserIds.Contains(m.a.CreatorId.Value)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.StartDate) && !string.IsNullOrWhiteSpace(input.EndDate)) |
|
|
|
{ |
|
|
|
chargeQuery = chargeQuery.Where(m => m.a.CreationTime >= Convert.ToDateTime(input.StartDate) |
|
|
|
&& m.a.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
|
|
|
} |
|
|
|
|
|
|
|
//收费归总
|
|
|
|
var chargeDetails = chargeQuery.GroupBy(g => g.a.CreatorId).Select(s => new GetTollcollectorFeeSummaryReport_Detail |
|
|
|
{ |
|
|
|
ChargeBackMoney = 0, |
|
|
|
ChargeMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.b.ChargeMoney), 2), |
|
|
|
ChargeName = s.FirstOrDefault().UserName, |
|
|
|
TotalMoney = 0 |
|
|
|
}).ToList(); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 退费
|
|
|
|
|
|
|
|
var chargeBackQuery = from a in await _chargeBackRepository.GetQueryableAsync() |
|
|
|
join b in await _chargeBackPayRepository.GetQueryableAsync() on a.Id equals b.ChargeBackId |
|
|
|
join d in await _userRepository.GetQueryableAsync() on a.CreatorId equals d.Id into dd |
|
|
|
from ad in dd.DefaultIfEmpty() |
|
|
|
select new |
|
|
|
{ |
|
|
|
a, |
|
|
|
b, |
|
|
|
UserName = ad != null ? ad.UserName : "" |
|
|
|
}; |
|
|
|
|
|
|
|
if (input.UserIds.Any()) |
|
|
|
{ |
|
|
|
chargeBackQuery = chargeBackQuery.Where(m => input.UserIds.Contains(m.a.CreatorId.Value)); |
|
|
|
} |
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.StartDate) && !string.IsNullOrWhiteSpace(input.EndDate)) |
|
|
|
{ |
|
|
|
chargeBackQuery = chargeBackQuery.Where(m => m.a.CreationTime >= Convert.ToDateTime(input.StartDate) |
|
|
|
&& m.a.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); |
|
|
|
} |
|
|
|
|
|
|
|
//收费归总
|
|
|
|
var chargeBackDetails = chargeBackQuery.GroupBy(g => g.a.CreatorId).Select(s => new GetTollcollectorFeeSummaryReport_Detail |
|
|
|
{ |
|
|
|
ChargeBackMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.b.BackMoeny), 2), |
|
|
|
ChargeMoney = 0, |
|
|
|
ChargeName = s.FirstOrDefault().UserName, |
|
|
|
TotalMoney = 0 |
|
|
|
}).ToList(); |
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 拼接收费数据
|
|
|
|
|
|
|
|
List<GetTollcollectorFeeSummaryReport_Detail> tollcollectorFeeSummaryReport_Detail = new List<GetTollcollectorFeeSummaryReport_Detail>(); |
|
|
|
|
|
|
|
//去重科室Id
|
|
|
|
var ChargeNameList = chargeDetails.Select(s => s.ChargeName).Union(chargeBackDetails.Select(s => s.ChargeName)); |
|
|
|
|
|
|
|
foreach (var item in ChargeNameList) |
|
|
|
{ |
|
|
|
|
|
|
|
var tempData = chargeDetails.Where(m => m.ChargeName == item).FirstOrDefault(); |
|
|
|
|
|
|
|
if (tempData != null) |
|
|
|
{ |
|
|
|
var chargeBackDetail = chargeBackDetails.Where(m => m.ChargeName == item).FirstOrDefault(); |
|
|
|
if (chargeBackDetail != null) |
|
|
|
{ |
|
|
|
tempData.ChargeBackMoney = chargeBackDetail.ChargeBackMoney; |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
tempData = chargeBackDetails.Where(m => m.ChargeName == item).FirstOrDefault(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tempData.TotalMoney = tempData.ChargeMoney - tempData.ChargeBackMoney; |
|
|
|
|
|
|
|
tollcollectorFeeSummaryReport_Detail.Add(tempData); |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
decimal sumChargeMoney = tollcollectorFeeSummaryReport_Detail.Any() ? DataHelper.DecimalRetainDecimals(tollcollectorFeeSummaryReport_Detail.Sum(s => s.ChargeMoney), 2) : 0; |
|
|
|
decimal sumChargeBackMoney = tollcollectorFeeSummaryReport_Detail.Any() ? DataHelper.DecimalRetainDecimals(tollcollectorFeeSummaryReport_Detail.Sum(s => s.ChargeBackMoney), 2) : 0; |
|
|
|
decimal sumTotalMoney = tollcollectorFeeSummaryReport_Detail.Any() ? DataHelper.DecimalRetainDecimals(tollcollectorFeeSummaryReport_Detail.Sum(s => s.TotalMoney), 2) : 0; |
|
|
|
|
|
|
|
var tollcollectorFeeSummaryReportDto = new GetTollcollectorFeeSummaryReportDto |
|
|
|
{ |
|
|
|
Details = tollcollectorFeeSummaryReport_Detail, |
|
|
|
SumChargeMoney = sumChargeMoney, |
|
|
|
SumChargeBackMoney = sumChargeBackMoney, |
|
|
|
SumTotalMoney = sumTotalMoney |
|
|
|
}; |
|
|
|
|
|
|
|
return tollcollectorFeeSummaryReportDto; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 项目收费报表
|
|
|
|
/// </summary>
|
|
|
|
@ -421,7 +862,7 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
AsbitemId = s.Key.AsbitemId, |
|
|
|
ItemTypeName = s.FirstOrDefault().ItemTypeName, |
|
|
|
AsbitemName = s.FirstOrDefault().AsbitemName, |
|
|
|
ChargeMoney = Math.Round(s.Sum(ss => ss.a.Amount.Value * ss.a.ChargePrice.Value), 2), |
|
|
|
ChargeMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.a.Amount.Value * ss.a.ChargePrice.Value), 2), |
|
|
|
ReceivedChargeMoney = 0 |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
@ -470,7 +911,7 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
AsbitemId = s.Key.AsbitemId, |
|
|
|
ItemTypeName = s.FirstOrDefault().ItemTypeName, |
|
|
|
AsbitemName = s.FirstOrDefault().AsbitemName, |
|
|
|
ReceivedChargeMoney = Math.Round(s.Sum(ss => ss.a.Amount * ss.a.ChargePrice), 2), |
|
|
|
ReceivedChargeMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.a.Amount * ss.a.ChargePrice), 2), |
|
|
|
ChargeMoney = 0 |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
@ -511,9 +952,9 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
decimal sumChargeMoney = projectFeesReport_Details.Any() ? Math.Round(projectFeesReport_Details.Sum(s => s.ChargeMoney), 2) : 0; |
|
|
|
decimal sumDiscountMoney = projectFeesReport_Details.Any() ? Math.Round(projectFeesReport_Details.Sum(s => s.DiscountMoney), 2) : 0; |
|
|
|
decimal sumReceivedChargeMoney = projectFeesReport_Details.Any() ? Math.Round(projectFeesReport_Details.Sum(s => s.ReceivedChargeMoney), 2) : 0; |
|
|
|
decimal sumChargeMoney = projectFeesReport_Details.Any() ? DataHelper.DecimalRetainDecimals(projectFeesReport_Details.Sum(s => s.ChargeMoney), 2) : 0; |
|
|
|
decimal sumDiscountMoney = projectFeesReport_Details.Any() ? DataHelper.DecimalRetainDecimals(projectFeesReport_Details.Sum(s => s.DiscountMoney), 2) : 0; |
|
|
|
decimal sumReceivedChargeMoney = projectFeesReport_Details.Any() ? DataHelper.DecimalRetainDecimals(projectFeesReport_Details.Sum(s => s.ReceivedChargeMoney), 2) : 0; |
|
|
|
|
|
|
|
|
|
|
|
var projectFeesReportDto = new GetProjectFeesReportDto |
|
|
|
@ -579,7 +1020,7 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
{ |
|
|
|
ItemTypeId = s.Key, |
|
|
|
ItemTypeName = s.FirstOrDefault().ItemTypeName, |
|
|
|
ChargeMoney = Math.Round(s.Sum(ss => ss.a.Amount.Value * ss.a.ChargePrice.Value), 2), |
|
|
|
ChargeMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.a.Amount.Value * ss.a.ChargePrice.Value), 2), |
|
|
|
ReceivedChargeMoney = 0 |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
@ -620,7 +1061,7 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
{ |
|
|
|
ItemTypeId = s.Key, |
|
|
|
ItemTypeName = s.FirstOrDefault().ItemTypeName, |
|
|
|
ReceivedChargeMoney = Math.Round(s.Sum(ss => ss.a.Amount * ss.a.ChargePrice), 2), |
|
|
|
ReceivedChargeMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.a.Amount * ss.a.ChargePrice), 2), |
|
|
|
ChargeMoney = 0 |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
@ -661,9 +1102,9 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
decimal sumChargeMoney = summaryOfDepartmentalFeesReport_Details.Any() ? Math.Round(summaryOfDepartmentalFeesReport_Details.Sum(s => s.ChargeMoney), 2) : 0; |
|
|
|
decimal sumDiscountMoney = summaryOfDepartmentalFeesReport_Details.Any() ? Math.Round(summaryOfDepartmentalFeesReport_Details.Sum(s => s.DiscountMoney), 2) : 0; |
|
|
|
decimal sumReceivedChargeMoney = summaryOfDepartmentalFeesReport_Details.Any() ? Math.Round(summaryOfDepartmentalFeesReport_Details.Sum(s => s.ReceivedChargeMoney), 2) : 0; |
|
|
|
decimal sumChargeMoney = summaryOfDepartmentalFeesReport_Details.Any() ? DataHelper.DecimalRetainDecimals(summaryOfDepartmentalFeesReport_Details.Sum(s => s.ChargeMoney), 2) : 0; |
|
|
|
decimal sumDiscountMoney = summaryOfDepartmentalFeesReport_Details.Any() ? DataHelper.DecimalRetainDecimals(summaryOfDepartmentalFeesReport_Details.Sum(s => s.DiscountMoney), 2) : 0; |
|
|
|
decimal sumReceivedChargeMoney = summaryOfDepartmentalFeesReport_Details.Any() ? DataHelper.DecimalRetainDecimals(summaryOfDepartmentalFeesReport_Details.Sum(s => s.ReceivedChargeMoney), 2) : 0; |
|
|
|
|
|
|
|
|
|
|
|
var summaryOfDepartmentalFeesReportDto = new GetSummaryOfDepartmentalFeesReportDto |
|
|
|
@ -714,7 +1155,7 @@ namespace Shentun.Peis.ChargeReports |
|
|
|
{ |
|
|
|
CustomerOrgName = s.FirstOrDefault().CustomerOrgName, |
|
|
|
SummaryCount = s.Count(), |
|
|
|
ChargeMoney = Math.Round(s.Sum(ss => ss.b.Amount.Value * ss.b.ChargePrice.Value), 2) |
|
|
|
ChargeMoney = DataHelper.DecimalRetainDecimals(s.Sum(ss => ss.b.Amount.Value * ss.b.ChargePrice.Value), 2) |
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|