diff --git a/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs b/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs index 2b6a768..ee2d1c8 100644 --- a/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs +++ b/src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs @@ -296,7 +296,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters on appointRegisterAsbitem.AsbitemId equals asbitem.AsbitemId join customerOrg in await _customerOrgRepository.GetQueryableAsync() on appointPatientRegister.CustomerOrgId equals customerOrg.CustomerOrgId - where appointPatientRegister.PersonId == input.PersonId + where appointPatientRegister.PersonId == input.PersonId && + appointPatientRegister.CompleteFlag != AppointPatientRegisterCompleteFlag.CancelAppoint orderby appointPatientRegister.AppointDate select new { diff --git a/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs b/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs index 4b2b172..ff64c9f 100644 --- a/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs +++ b/src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs @@ -178,8 +178,29 @@ namespace Shentun.WebPeis.AppointPatientRegisters throw new UserFriendlyException("单位分组项目不能取消"); } }); + + foreach(var asbitem in entity.AppointRegisterAsbitems) + { + decimal addMoney = 0; + var customerOrgGroupDetail = customerOrgGroupDetails.Where(o => o.AsbitemId == asbitem.AsbitemId).FirstOrDefault(); + if(customerOrgGroupDetail != null) + { + addMoney += customerOrgGroupDetail.Price; + } + + if(addMoney > 0) + { + var customerOrgGroup = await _customerOrgGroupRepository.GetAsync(o => o.CustomerOrgGroupId == entity.CustomerOrgGroupId); + if(addMoney > customerOrgGroup.CanAddMoney) + { + throw new UserFriendlyException($"自选的单位支付金额能超过{customerOrgGroup.CanAddMoney}元"); + } + } + } } + + var asbitems = await _asbitemRepository.GetListAsync(); foreach (var appointRegisterAsbitem in entity.AppointRegisterAsbitems) { diff --git a/src/Shentun.WebPeis.Domain/Models/CustomerOrgGroup.cs b/src/Shentun.WebPeis.Domain/Models/CustomerOrgGroup.cs index b1b2688..aba89b7 100644 --- a/src/Shentun.WebPeis.Domain/Models/CustomerOrgGroup.cs +++ b/src/Shentun.WebPeis.Domain/Models/CustomerOrgGroup.cs @@ -63,6 +63,11 @@ public partial class CustomerOrgGroup : AuditedEntity, IHasConcurrencyStamp public int DisplayOrder { get; set; } public Guid CustomerOrgRegisterId { get; set; } + /// + /// 可增加单位支付金额 + /// + + public decimal CanAddMoney { get; set; } public string? ConcurrencyStamp { get; set; } diff --git a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/CustomerOrgGroupConfigure.cs b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/CustomerOrgGroupConfigure.cs index 1c3a31e..198398e 100644 --- a/src/Shentun.WebPeis.EntityFrameworkCore/Configures/CustomerOrgGroupConfigure.cs +++ b/src/Shentun.WebPeis.EntityFrameworkCore/Configures/CustomerOrgGroupConfigure.cs @@ -69,12 +69,19 @@ namespace Shentun.WebPeis.Configures entity.Property(e => e.Price) .HasPrecision(10, 2) .HasComment("价格") - .HasColumnName("price"); + .HasColumnName("price") + .HasDefaultValueSql("0"); ; entity.Property(e => e.Remark) .HasMaxLength(100) .HasComment("备注") .HasColumnName("remark"); + entity.Property(e => e.CanAddMoney) + .HasPrecision(10, 2) + .HasColumnName("can_add_money") + .HasComment("可增加单位支付金额") + .IsRequired().HasDefaultValueSql("0"); + entity.HasOne(d => d.CustomerOrgRegister).WithMany(p => p.CustomerOrgGroups) .HasForeignKey(d => d.CustomerOrgRegisterId) .OnDelete(DeleteBehavior.ClientSetNull)