diff --git a/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointPlugInsBase.cs b/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointPlugInsBase.cs index 474d2ac..c490c70 100644 --- a/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointPlugInsBase.cs +++ b/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointPlugInsBase.cs @@ -83,5 +83,31 @@ namespace Shentun.Peis.PlugIns.WebAppoints { throw new NotImplementedException(); } + + + /// + /// 获取预约记录,包含收费项目 体检退费时用 + /// + /// + /// + /// + public virtual async Task> GerAppointPatientRegisterWithAsbitemListAsync(AppointPatientRegisterIdsInputDto input) + { + throw new NotImplementedException(); + + } + + + /// + /// 体检系统申请退款 + /// + /// + /// + /// + public virtual async Task CreateWeChatOrderRefundAsync(CreateWeChatOrderRefundInputDto input) + { + throw new NotImplementedException(); + + } } } diff --git a/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs b/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs index 26e69e0..fed45ed 100644 --- a/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs +++ b/src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs @@ -32,6 +32,8 @@ namespace Shentun.Peis.PlugIns.WebAppoints private string _webPeisGetAppointRegisterAsbitemListByIdUrl; private string _webPeisGetByPatientRegisterIdUrl; private string _webPeisGetAppointStatisticsReportUrl; + private string _webPeisGerAppointPatientRegisterWithAsbitemListUrl; + private string _webPeisCreateWeChatOrderRefundUrl; private Guid _medicalCenterId; public WebAppointWebPeisPlugIns(Guid thirdInterfaceId) : base(thirdInterfaceId) { @@ -51,6 +53,8 @@ namespace Shentun.Peis.PlugIns.WebAppoints _webPeisGetAppointRegisterAsbitemListByIdUrl = InterfaceConfig.GetSection("Interface").GetSection("GetAppointRegisterAsbitemListByIdUrl").Value; _webPeisGetByPatientRegisterIdUrl = InterfaceConfig.GetSection("Interface").GetSection("GetByPatientRegisterIdUrl").Value; _webPeisGetAppointStatisticsReportUrl = InterfaceConfig.GetSection("Interface").GetSection("GetAppointStatisticsReportUrl").Value; + _webPeisGerAppointPatientRegisterWithAsbitemListUrl = InterfaceConfig.GetSection("Interface").GetSection("GerAppointPatientRegisterWithAsbitemListUrl").Value; + _webPeisCreateWeChatOrderRefundUrl = InterfaceConfig.GetSection("Interface").GetSection("CreateWeChatOrderRefundUrl").Value; } /// /// 获取预约人员列表 @@ -168,6 +172,33 @@ namespace Shentun.Peis.PlugIns.WebAppoints return appointStatisticsReportListDto; } + + /// + /// 获取预约记录,包含收费项目 体检退费时用 + /// + /// + /// + /// + public override async Task> GerAppointPatientRegisterWithAsbitemListAsync(AppointPatientRegisterIdsInputDto input) + { + var appointPatientRegisterWithAsbitemListDto = await CallWePeisAppServiceAsync> + (_webPeisGerAppointPatientRegisterWithAsbitemListUrl, input); + return appointPatientRegisterWithAsbitemListDto; + } + + /// + /// 体检系统申请退款 + /// + /// + /// + /// + public override async Task CreateWeChatOrderRefundAsync(CreateWeChatOrderRefundInputDto input) + { + await CallWePeisAppServiceAsync + (_webPeisCreateWeChatOrderRefundUrl, input); + } + public async virtual Task> LoginWebPeisAsync() { if (string.IsNullOrWhiteSpace(_webPeisUser)) diff --git a/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterIdsInputDto.cs b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterIdsInputDto.cs new file mode 100644 index 0000000..683d751 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterIdsInputDto.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.AppointPatientRegisters +{ + public class AppointPatientRegisterIdsInputDto + { + /// + /// 预约id集合 + /// + public List AppointPatientRegisterIds { get; set; } = new List(); + } +} diff --git a/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/CreateWeChatOrderRefundInputDto.cs b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/CreateWeChatOrderRefundInputDto.cs new file mode 100644 index 0000000..97cdc28 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/CreateWeChatOrderRefundInputDto.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.AppointPatientRegisters +{ + public class CreateWeChatOrderRefundInputDto + { + /// + /// 预约ID + /// + public Guid AppointPatientRegisterId { get; set; } + + /// + /// 退款金额 元 + /// + public decimal RefundMoney { get; set; } + } +} diff --git a/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListDto.cs b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListDto.cs new file mode 100644 index 0000000..f9fb140 --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListDto.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.AppointPatientRegisters +{ + public class GerAppointPatientRegisterWithAsbitemListDto + { + /// + /// 预约id + /// + public Guid AppointPatientRegisterId { get; set; } + + /// + /// 收费状态 0-未收费 1-已收费 2-已退费 + /// + public char ChargeFlag { get; set; } + + /// + /// 预约日期 + /// + public string AppointDate { get; set; } + + /// + /// 预约项目 + /// + public List AppointRegisterAsbitemDetail { get; set; } = new List(); + } + + + public class GerAppointPatientRegisterWithAsbitemListChargeAsbitemDto + { + /// + /// 主键 + /// + public Guid AppointRegisterAsbitemId { get; set; } + /// + /// 组合项目ID + /// + public Guid AsbitemId { get; set; } + /// + /// 组合项目名称 + /// + public string AsbitemName { 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.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListInputDto.cs b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListInputDto.cs new file mode 100644 index 0000000..f578a3d --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListInputDto.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.AppointPatientRegisters +{ + public class GerAppointPatientRegisterWithAsbitemListInputDto + { + /// + /// 姓名 + /// + public string PatientName { get; set; } + + /// + /// 档案号 + /// + public string PatientNo { get; set; } + + /// + /// 条码号 + /// + public string PatientRegisterNo { get; set; } + + /// + /// 身份证号 + /// + public string IdNo { get; set; } + + /// + /// 日期类型(1、登记日期 2、体检日期 ) 默认登记日期 + /// + public char DateType { get; set; } = '1'; + + /// + /// 开始日期 + /// + public string StartDate { get; set; } + + /// + /// 结束日期 + /// + public string EndDate { get; set; } + + } +} diff --git a/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListWithPatientReigsterDto.cs b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListWithPatientReigsterDto.cs new file mode 100644 index 0000000..b74c2ad --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListWithPatientReigsterDto.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.AppointPatientRegisters +{ + public class GerAppointPatientRegisterWithAsbitemListWithPatientReigsterDto : GerAppointPatientRegisterWithAsbitemListDto + { + + /// + /// 条码号 + /// + public string PatientRegisterNo { get; set; } + + /// + /// 档案号 + /// + public string PatientNo { get; set; } + + /// + /// 姓名 + /// + public string PatientName { get; set; } + /// + /// 性别 + /// + public string SexName { get; set; } + + /// + /// 年龄 + /// + public short? Age { get; set; } + + /// + /// 身份证号 + /// + public string IdNo { get; set; } + + /// + /// 电话 + /// + public string Telephone { get; set; } + /// + /// 手机号 + /// + public string MobileTelephone { get; set; } + + } +} diff --git a/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/UpdateAppointPatientAsbitemStatusInputDto.cs b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/UpdateAppointPatientAsbitemStatusInputDto.cs new file mode 100644 index 0000000..75dbf4c --- /dev/null +++ b/src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/UpdateAppointPatientAsbitemStatusInputDto.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Shentun.Peis.AppointPatientRegisters +{ + public class UpdateAppointPatientAsbitemStatusInputDto + { + /// + /// 预约id + /// + public Guid AppointPatientRegisterId { get; set; } + + /// + /// 收费项目状态 + /// + public List ChargeAsbitemDetail { get; set; } = new List(); + + } + + public class UpdateAppointPatientAsbitemStatusInputDetailDto + { + public Guid AsbitemId { get; set; } + + public char IsCharge { get; set; } + } +} diff --git a/src/Shentun.Peis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs b/src/Shentun.Peis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs index 387d74a..8124e78 100644 --- a/src/Shentun.Peis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs +++ b/src/Shentun.Peis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs @@ -1,8 +1,11 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; +using NPOI.Util; using NUglify.JavaScript.Syntax; using Shentun.Peis.AppointRegisterAsbitems; +using Shentun.Peis.Asbitems; +using Shentun.Peis.CustomerOrgs; using Shentun.Peis.CustomerReports; using Shentun.Peis.Enums; using Shentun.Peis.Models; @@ -17,6 +20,7 @@ using System.Text; using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Repositories; namespace Shentun.Peis.AppointPatientRegisters @@ -27,14 +31,25 @@ namespace Shentun.Peis.AppointPatientRegisters { private readonly IRepository _thirdInterfaceRepository; private readonly IRepository _patientRegisterRepository; + private readonly IRepository _patientRepository; + private readonly IRepository _registerCheckRepository; + private readonly IRepository _registerCheckAsbitemRepository; + private readonly CacheService _cacheService; public AppointPatientRegisterAppService( IRepository thirdInterfaceRepository, - IRepository patientRegisterRepository - ) + IRepository patientRegisterRepository, + IRepository patientRepository, + IRepository registerCheckRepository, + IRepository registerCheckAsbitemRepository, + CacheService cacheService) { _thirdInterfaceRepository = thirdInterfaceRepository; _patientRegisterRepository = patientRegisterRepository; + _patientRepository = patientRepository; + _registerCheckRepository = registerCheckRepository; + _registerCheckAsbitemRepository = registerCheckAsbitemRepository; + _cacheService = cacheService; } /// /// 获取网上预约数据 @@ -161,6 +176,154 @@ namespace Shentun.Peis.AppointPatientRegisters } + + + + /// + /// 获取预约记录,包含收费项目 体检退费时用 + /// + /// + /// + [HttpPost("api/app/AppointPatientRegister/GerAppointPatientRegisterWithAsbitemList")] + public async Task> GerAppointPatientRegisterWithAsbitemListAsync(GerAppointPatientRegisterWithAsbitemListInputDto input) + { + + List entListDto = new List(); + + var thirdInterface = await _thirdInterfaceRepository.FirstOrDefaultAsync(f => f.ThirdInterfaceType == ThirdInterfaceTypeFlag.WebAppoint); + + if (thirdInterface == null) + { + throw new UserFriendlyException("该接口未找到"); + } + + if (thirdInterface.IsActive != 'Y') + { + throw new UserFriendlyException("该接口已禁用"); + } + + #region 从体检里面查询 + + var query = from patientRegister in await _patientRegisterRepository.GetQueryableAsync() + join patient in await _patientRepository.GetQueryableAsync() on patientRegister.PatientId equals patient.Id + join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId + join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckAsbitem.RegisterCheckId + where !string.IsNullOrWhiteSpace(patientRegister.AppointPatientRegisterId) + && registerCheckAsbitem.IsCharge == 'Y' + && registerCheckAsbitem.ChargeSourceFlag == '1' + select new + { + patientRegister, + patient + }; + if (!string.IsNullOrEmpty(input.PatientNo)) + query = query.Where(m => m.patientRegister.Patient.PatientNo == input.PatientNo); + if (!string.IsNullOrEmpty(input.IdNo)) + query = query.Where(m => m.patientRegister.Patient.IdNo == input.IdNo); + if (!string.IsNullOrEmpty(input.PatientName)) + query = query.Where(m => m.patientRegister.PatientName == input.PatientName); + + if (!string.IsNullOrEmpty(input.PatientRegisterNo)) + query = query.Where(m => m.patientRegister.PatientRegisterNo == input.PatientRegisterNo); + + + if (!string.IsNullOrEmpty(input.StartDate) && !string.IsNullOrEmpty(input.EndDate)) + { + if (input.DateType == '1') + { + query = query.Where(m => m.patientRegister.CreationTime >= Convert.ToDateTime(input.StartDate) && + m.patientRegister.CreationTime < Convert.ToDateTime(input.EndDate).AddDays(1)); + } + else if (input.DateType == '2') + { + query = query.Where(m => m.patientRegister.MedicalStartDate >= Convert.ToDateTime(input.StartDate) && + m.patientRegister.MedicalStartDate < Convert.ToDateTime(input.EndDate).AddDays(1)); + } + + } + + var patientRegisterList = query.ToList(); + + //获取符合条件的预约ID + var appointPatientRegisterIds = patientRegisterList.Select(s => s.patientRegister.AppointPatientRegisterId).Distinct().ToList(); + + + #endregion + + + if (!appointPatientRegisterIds.Any()) + return entListDto; + + object[] objects = [appointPatientRegisterIds]; + var parmValue = thirdInterface.ParmValue; + var configurationBuilder = new ConfigurationBuilder() + .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); + var config = configurationBuilder.Build(); + var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value; + var className = config.GetSection("Interface").GetSection("ClassName").Value; + + var pluginsOut = await Utilities.ReflectionHelper.InvokeAsync>(assemblyName, + className, [thirdInterface.Id], "GerAppointPatientRegisterWithAsbitemListAsync", objects); + foreach (var plugin in pluginsOut) + { + var entDto = ObjectMapper.Map(plugin); + + var patientRegisterEnt = patientRegisterList.FirstOrDefault(f => f.patientRegister.AppointPatientRegisterId == entDto.AppointPatientRegisterId.ToString()); + if (patientRegisterEnt != null) + { + entDto.PatientRegisterNo = patientRegisterEnt.patientRegister.PatientRegisterNo; + entDto.PatientNo = patientRegisterEnt.patient.PatientNo; + entDto.PatientName = patientRegisterEnt.patientRegister.PatientName; + entDto.SexName = await _cacheService.GetSexNameAsync(patientRegisterEnt.patientRegister.SexId); + entDto.Age = patientRegisterEnt.patientRegister.Age; + entDto.IdNo = patientRegisterEnt.patient.IdNo; + entDto.Telephone = patientRegisterEnt.patient.Telephone; + entDto.MobileTelephone = patientRegisterEnt.patient.MobileTelephone; + } + + entListDto.Add(entDto); + } + + return entListDto; + + } + + + + /// + /// 体检系统申请退款 + /// + /// + /// + [HttpPost("api/app/AppointPatientRegister/CreateWeChatOrderRefund")] + public async Task CreateWeChatOrderRefundAsync(CreateWeChatOrderRefundInputDto input) + { + + var thirdInterface = await _thirdInterfaceRepository.FirstOrDefaultAsync(f => f.ThirdInterfaceType == ThirdInterfaceTypeFlag.WebAppoint); + + if (thirdInterface == null) + { + throw new UserFriendlyException("该接口未找到"); + } + + if (thirdInterface.IsActive != 'Y') + { + throw new UserFriendlyException("该接口已禁用"); + } + + object[] objects = [input]; + var parmValue = thirdInterface.ParmValue; + var configurationBuilder = new ConfigurationBuilder() + .AddJsonStream(new MemoryStream(System.Text.Encoding.UTF8.GetBytes(parmValue))); + var config = configurationBuilder.Build(); + var assemblyName = config.GetSection("Interface").GetSection("AssemblyName").Value; + var className = config.GetSection("Interface").GetSection("ClassName").Value; + + await Utilities.ReflectionHelper.InvokeAsync(assemblyName, + className, [thirdInterface.Id], "CreateWeChatOrderRefundAsync", objects); + } + + #region 提供给小程序的接口 /// @@ -180,6 +343,36 @@ namespace Shentun.Peis.AppointPatientRegisters return isRegister; } + + /// + /// 小程序退款成功后,更新体检系统项目收费状态 + /// + /// + [HttpPost("api/app/AppointPatientRegister/UpdateAppointPatientAsbitemStatus")] + public async Task UpdateAppointPatientAsbitemStatusAsync(UpdateAppointPatientAsbitemStatusInputDto input) + { + var registerCheckAsbitemList = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync() + join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId + join registerCheckAsbitem in await _registerCheckAsbitemRepository.GetQueryableAsync() on registerCheck.Id equals registerCheckAsbitem.RegisterCheckId + where patientRegister.AppointPatientRegisterId == input.AppointPatientRegisterId.ToString() + select registerCheckAsbitem) + .ToList(); + + if (registerCheckAsbitemList.Any()) + { + foreach (var registerCheckAsbitem in registerCheckAsbitemList) + { + var inputPara = input.ChargeAsbitemDetail.FirstOrDefault(f => f.AsbitemId == registerCheckAsbitem.AsbitemId); + if (inputPara != null) + { + registerCheckAsbitem.IsCharge=inputPara.IsCharge; + } + } + + await _registerCheckAsbitemRepository.UpdateManyAsync(registerCheckAsbitemList); + } + } + #endregion } } diff --git a/src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs b/src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs index 9eee7e4..7424901 100644 --- a/src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs +++ b/src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs @@ -1,5 +1,6 @@ using AutoMapper; using AutoMapper.Internal.Mappers; +using Shentun.Peis.AppointPatientRegisters; using Shentun.Peis.AsbitemDetails; using Shentun.Peis.AsbitemGuides; using Shentun.Peis.Asbitems; @@ -612,5 +613,9 @@ public class PeisApplicationAutoMapperProfile : Profile CreateMap(); CreateMap(); + + //ȡԤԼ + CreateMap(); + } } diff --git a/src/Shentun.Peis.Application/SmallProgramCharges/SmallProgramChargeAppService.cs b/src/Shentun.Peis.Application/SmallProgramCharges/SmallProgramChargeAppService.cs new file mode 100644 index 0000000..ef08a67 --- /dev/null +++ b/src/Shentun.Peis.Application/SmallProgramCharges/SmallProgramChargeAppService.cs @@ -0,0 +1,51 @@ +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using Shentun.Peis.Models; +using Shentun.Peis.PatientRegisters; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Repositories; + +namespace Shentun.Peis.SmallProgramCharges +{ + /// + /// 小程序收费 + /// + [ApiExplorerSettings(GroupName = "Work")] + [Authorize] + public class SmallProgramChargeAppService : ApplicationService + { + private readonly IRepository _patientRegisterRepository; + private readonly IRepository _registerCheckRepository; + private readonly IRepository _registerCheckAsbitemRepository; + + public SmallProgramChargeAppService( + IRepository patientRegisterRepository, + IRepository registerCheckRepository, + IRepository registerCheckAsbitemRepository + ) + { + _patientRegisterRepository = patientRegisterRepository; + _registerCheckRepository = registerCheckRepository; + _registerCheckAsbitemRepository = registerCheckAsbitemRepository; + } + + + /// + /// 获取小程序收费过的人员 + /// + /// + [HttpPost("api/app/SmallProgramCharge/GetChargePatientRegisterList")] + public async Task> GetChargePatientRegisterListAsync(PatientRegisterChargeRequestDto input) + { + + } + + + } +}