diff --git a/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/CreateAppointPatientRegisterDto.cs b/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/CreateAppointPatientRegisterDto.cs index e22fb52..503c715 100644 --- a/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/CreateAppointPatientRegisterDto.cs +++ b/src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/CreateAppointPatientRegisterDto.cs @@ -5,34 +5,68 @@ using System.Text; namespace Shentun.WebPeis.AppointPatientRegisters { + /// + /// 预约 + /// public class CreateAppointPatientRegisterDto { + /// + /// 人员ID + /// public Guid PersonId { get; set; } + /// + /// 单位ID + /// public Guid CustomerOrgId { get; set; } + /// + /// 单位分组ID + /// public Guid? CustomerOrgGroupId { get; set; } + /// + /// 套餐ID + /// public Guid? MedicalPackageId { get; set; } + /// + /// 预约体检日期 + /// - public char CompleteFlag { get; set; } - - public DateTime MedicalStartDate { get; set; } + public DateTime AppointDate { get; set; } + /// + /// 备注 + /// public string? Remark { get; set; } + /// + /// 体检中心 + /// public Guid MedicalCenterId { get; set; } + /// + /// 单位登记ID + /// public Guid CustomerOrgRegisterId { get; set; } - - public string? ConcurrencyStamp { get; set; } + /// + /// 备孕标志0-无,1-备孕,2-怀孕 + /// public char PregnantFlag { get; set; } + /// + /// 身高 + /// public decimal? Height { get; set; } + /// + /// 体重 + /// public decimal? Weight { get; set; } - + /// + /// 预约组合项目 + /// public List Asbitems { get; set; } = new List(); } } diff --git a/src/Shentun.WebPeis.Application.Contracts/AppointRegisterAsbitems/CreateAppointRegisterAsbitemDto.cs b/src/Shentun.WebPeis.Application.Contracts/AppointRegisterAsbitems/CreateAppointRegisterAsbitemDto.cs index e6d2187..0963e2d 100644 --- a/src/Shentun.WebPeis.Application.Contracts/AppointRegisterAsbitems/CreateAppointRegisterAsbitemDto.cs +++ b/src/Shentun.WebPeis.Application.Contracts/AppointRegisterAsbitems/CreateAppointRegisterAsbitemDto.cs @@ -4,21 +4,23 @@ using System.Text; namespace Shentun.WebPeis.AppointRegisterAsbitems { + /// + /// 预约组合项目 + /// public class CreateAppointRegisterAsbitemDto { - public Guid AppointRegisterAsbitemId { get; set; } - + /// + /// 组合项目ID + /// public Guid AsbitemId { get; set; } - - public Guid AppointPatientRegisterId { get; set; } - - public decimal StandardPrice { get; set; } + /// + /// 实收价格 + /// public decimal ChargePrice { get; set; } - - public char PayTypeFlag { get; set; } - - public char IsCharge { get; set; } + /// + /// 数量 + /// public short Amount { get; set; } diff --git a/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs b/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs index c48aa78..6ac56ce 100644 --- a/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs +++ b/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs @@ -46,9 +46,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters var asbitems = ObjectMapper.Map, List>(input.Asbitems); entity.AppointRegisterAsbitems = asbitems; entity = await _appointPatientRegisterManager.CreateAsync(entity); - entity.AppointRegisterAsbitems = null; await _repository.InsertAsync(entity); - await _appointRegisterAsbitemRepository.InsertManyAsync(asbitems); var result = ObjectMapper.Map(entity); return result; } diff --git a/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs b/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs index 0a1f375..e989f3d 100644 --- a/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs +++ b/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs @@ -26,6 +26,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters private readonly IRepository _nationRepository; private readonly SysParmValueManager _sysParmValueManager; private readonly IRepository _primarykeyBuilderRepository; + private readonly IRepository _asbitemRepository; public AppointPatientRegisterManager(IRepository repository, IRepository identityUserRepository, IdentityUserManager identityUserManager, @@ -35,7 +36,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters IRepository customerOrgGroupRepository, IRepository medicalPackageRepository, IRepository customerOrgRepository, - IRepository customerOrgRegisterRepository + IRepository customerOrgRegisterRepository, + IRepository asbitemRepository ) { _repository = repository; @@ -48,6 +50,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters _medicalPackageRepository = medicalPackageRepository; _customerOrgRepository = customerOrgRepository; _customerOrgRegisterRepository = customerOrgRegisterRepository; + _asbitemRepository = asbitemRepository; } public async Task CreateAsync(AppointPatientRegister entity) @@ -65,8 +68,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters Check.NotNull(entity.PersonId, "人员ID"); Check.NotNull(entity.MedicalCenterId, "体检中心"); Check.NotDefaultOrNull(entity.CustomerOrgId, "单位"); - Check.NotNull(entity.MedicalStartDate, "体检日期"); - if(entity.MedicalStartDate < DateTime.Now.Date) + Check.NotNull(entity.AppointDate, "体检日期"); + if(entity.AppointDate < DateTime.Now.Date) { throw new UserFriendlyException("预约日期不能小于当前日期"); } @@ -135,20 +138,22 @@ namespace Shentun.WebPeis.AppointPatientRegisters { throw new UserFriendlyException("必须预约组合项目"); } + var asbitems = await _asbitemRepository.GetListAsync(); foreach (var appointRegisterAsbitem in entity.AppointRegisterAsbitems) { - - if(appointRegisterAsbitem.ChargePrice < 0) + var asbitem = asbitems.Where(o => o.AsbitemId == appointRegisterAsbitem.AsbitemId).Single(); + appointRegisterAsbitem.StandardPrice = asbitem.Price; + if (appointRegisterAsbitem.ChargePrice < 0) { - throw new UserFriendlyException("价格不能小于0"); + throw new UserFriendlyException($"{asbitem.AsbitemName}价格不能小于0"); } if (appointRegisterAsbitem.ChargePrice > 10000) { - throw new UserFriendlyException("价格不能大于10000"); + throw new UserFriendlyException($"{asbitem.AsbitemName}价格不能大于10000"); } if (appointRegisterAsbitem.Amount < 1) { - throw new UserFriendlyException("数量不能小于1"); + throw new UserFriendlyException($"{asbitem.AsbitemName}数量不能小于1"); } if (customerOrg.CustomerOrgId == GuidFlag.PersonCustomerOrgId) { @@ -161,9 +166,10 @@ namespace Shentun.WebPeis.AppointPatientRegisters if (appointRegisterAsbitem.PayTypeFlag != PayTypeFlag.PersonPay && appointRegisterAsbitem.PayTypeFlag != PayTypeFlag.OrgPay) { - throw new UserFriendlyException("支付类别错误"); + throw new UserFriendlyException($"{asbitem.AsbitemName}支付类别错误"); } } + appointRegisterAsbitem.IsCharge = 'N'; } } diff --git a/src/Shentun.WebPeis.Domain/Models/AppointPatientRegister.cs b/src/Shentun.WebPeis.Domain/Models/AppointPatientRegister.cs index 3dd9862..91df25e 100644 --- a/src/Shentun.WebPeis.Domain/Models/AppointPatientRegister.cs +++ b/src/Shentun.WebPeis.Domain/Models/AppointPatientRegister.cs @@ -5,6 +5,9 @@ using Volo.Abp.Domain.Entities; namespace Shentun.WebPeis.Models; +/// +/// 预约登记 +/// public partial class AppointPatientRegister: AuditedEntity, IHasConcurrencyStamp { public AppointPatientRegister() @@ -15,34 +18,67 @@ public partial class AppointPatientRegister: AuditedEntity, IHasConcurrencyStamp { AppointPatientRegisterId = id; } + /// + /// 主键 + /// public Guid AppointPatientRegisterId { get; set; } - + /// + /// 人员ID + /// public Guid PersonId { get; set; } - + /// + /// 单位ID + /// public Guid CustomerOrgId { get; set; } - + /// + /// 单位分组ID + /// public Guid? CustomerOrgGroupId { get; set; } - + /// + /// 套餐ID + /// public Guid? MedicalPackageId { get; set; } - + /// + /// 完成标志 + /// public char CompleteFlag { get; set; } - - public DateTime MedicalStartDate { get; set; } - + /// + /// 预约日期 + /// + public DateTime AppointDate { get; set; } + /// + /// 备注 + /// public string? Remark { get; set; } - + /// + /// 体检中心 + /// public Guid MedicalCenterId { get; set; } - + /// + /// 单位登记ID + /// public Guid CustomerOrgRegisterId { get; set; } public string? ConcurrencyStamp { get; set; } - + /// + /// 备孕标志 + /// public char PregnantFlag { get; set; } - + /// + /// 身高 + /// public decimal? Height { get; set; } - + /// + /// 体重 + /// public decimal? Weight { get; set; } + /// + /// 收费 + /// public virtual ICollection Charges { get; set; } = new List(); + /// + /// 预约组合项目 + /// public virtual ICollection AppointRegisterAsbitems { get; set; } = new List(); public override object?[] GetKeys() { diff --git a/src/Shentun.WebPeis.Domain/Models/AppointRegisterAsbitem.cs b/src/Shentun.WebPeis.Domain/Models/AppointRegisterAsbitem.cs index edbb321..432a5d2 100644 --- a/src/Shentun.WebPeis.Domain/Models/AppointRegisterAsbitem.cs +++ b/src/Shentun.WebPeis.Domain/Models/AppointRegisterAsbitem.cs @@ -5,22 +5,42 @@ using Volo.Abp.Domain.Entities; namespace Shentun.WebPeis.Models; +/// +/// 预约组合项目 +/// public partial class AppointRegisterAsbitem : AuditedEntity, IHasConcurrencyStamp { + /// + /// 主键 + /// public Guid AppointRegisterAsbitemId { get; set; } - + /// + /// 组合项目ID + /// public Guid AsbitemId { get; set; } - + /// + /// 预约主档ID + /// public Guid AppointPatientRegisterId { get; set; } - + /// + /// 标准价格 + /// public decimal StandardPrice { get; set; } - + /// + /// 收费价格 + /// public decimal ChargePrice { get; set; } - + /// + /// 支付类别标准 + /// public char PayTypeFlag { get; set; } - + /// + /// 是否收费 + /// public char IsCharge { get; set; } - + /// + /// 数量 + /// public short Amount { get; set; } public string? ConcurrencyStamp { get; set; } diff --git a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/AppointPatientRegisterConfigure.cs b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/AppointPatientRegisterConfigure.cs index a06c21f..6789a09 100644 --- a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/AppointPatientRegisterConfigure.cs +++ b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/AppointPatientRegisterConfigure.cs @@ -44,10 +44,10 @@ namespace Shentun.WebPeis.Configures entity.Property(e => e.LastModifierId).HasColumnName("last_modifier_id"); entity.Property(e => e.MedicalCenterId).HasColumnName("medical_center_id"); entity.Property(e => e.MedicalPackageId).HasColumnName("medical_package_id"); - entity.Property(e => e.MedicalStartDate) + entity.Property(e => e.AppointDate) .HasDefaultValueSql("date(timezone('UTC-8'::text, now()))") .HasColumnType("timestamp(6) without time zone") - .HasColumnName("medical_start_date"); + .HasColumnName("appoint_date"); entity.Property(e => e.PersonId).HasColumnName("person_id"); entity.Property(e => e.Remark) .HasMaxLength(200) diff --git a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/AppointRegisterAsbitemConfigure.cs b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/AppointRegisterAsbitemConfigure.cs index 17dc64c..ade6a5b 100644 --- a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/AppointRegisterAsbitemConfigure.cs +++ b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/AppointRegisterAsbitemConfigure.cs @@ -52,10 +52,12 @@ namespace Shentun.WebPeis.Configures .HasPrecision(10, 2) .HasColumnName("standard_price"); - entity.HasOne(d => d.AppointPatientRegister).WithMany() + entity.HasOne(d => d.AppointPatientRegister).WithMany(p => p.AppointRegisterAsbitems) .HasForeignKey(d => d.AppointPatientRegisterId) .OnDelete(DeleteBehavior.ClientSetNull) .HasConstraintName("fk_appoint_register_asbitem"); + + } } } diff --git a/test/Shentun.WebPeis.Application.Tests/AppointPatientRegisterAppServiceTest.cs b/test/Shentun.WebPeis.Application.Tests/AppointPatientRegisterAppServiceTest.cs index d39839b..f17997f 100644 --- a/test/Shentun.WebPeis.Application.Tests/AppointPatientRegisterAppServiceTest.cs +++ b/test/Shentun.WebPeis.Application.Tests/AppointPatientRegisterAppServiceTest.cs @@ -44,7 +44,7 @@ namespace Shentun.WebPeis CustomerOrgId = GuidFlag.PersonCustomerOrgId, MedicalCenterId = new Guid("150da355-dfbf-466b-9697-355836a862c4"), MedicalPackageId = null, - MedicalStartDate = DateTime.Now, + AppointDate = DateTime.Now, CustomerOrgRegisterId = GuidFlag.PersonCustomerOrgRegisterId, PregnantFlag = PregnantFlag.None, Height = 170, @@ -58,6 +58,14 @@ namespace Shentun.WebPeis ChargePrice = (decimal)30.5 } ); + entity.Asbitems.Add( + new CreateAppointRegisterAsbitemDto() + { + AsbitemId = new Guid("3a126b35-1163-6b80-6b57-7b5a7bc9e935"), + Amount = 2, + ChargePrice = (decimal)50.45 + } + ); var newEntity = await _appService.CreateAsync(entity); await unitOfWork.CompleteAsync(); }