Browse Source

小程序退款

master
wxd 11 months ago
parent
commit
e01f6ef311
  1. 26
      src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointPlugInsBase.cs
  2. 31
      src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointWebPeisPlugIns.cs
  3. 14
      src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/AppointPatientRegisterIdsInputDto.cs
  4. 19
      src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/CreateWeChatOrderRefundInputDto.cs
  5. 72
      src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListDto.cs
  6. 45
      src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListInputDto.cs
  7. 49
      src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListWithPatientReigsterDto.cs
  8. 27
      src/Shentun.Peis.Application.Contracts/AppointPatientRegisters/UpdateAppointPatientAsbitemStatusInputDto.cs
  9. 197
      src/Shentun.Peis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs
  10. 5
      src/Shentun.Peis.Application/PeisApplicationAutoMapperProfile.cs
  11. 51
      src/Shentun.Peis.Application/SmallProgramCharges/SmallProgramChargeAppService.cs

26
src/Shentun.ColumnReferencePlugIns/WebAppoints/WebAppointPlugInsBase.cs

@ -83,5 +83,31 @@ namespace Shentun.Peis.PlugIns.WebAppoints
{
throw new NotImplementedException();
}
/// <summary>
/// 获取预约记录,包含收费项目 体检退费时用
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public virtual async Task<List<GerAppointPatientRegisterWithAsbitemListDto>> GerAppointPatientRegisterWithAsbitemListAsync(AppointPatientRegisterIdsInputDto input)
{
throw new NotImplementedException();
}
/// <summary>
/// 体检系统申请退款
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public virtual async Task CreateWeChatOrderRefundAsync(CreateWeChatOrderRefundInputDto input)
{
throw new NotImplementedException();
}
}
}

31
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;
}
/// <summary>
/// 获取预约人员列表
@ -168,6 +172,33 @@ namespace Shentun.Peis.PlugIns.WebAppoints
return appointStatisticsReportListDto;
}
/// <summary>
/// 获取预约记录,包含收费项目 体检退费时用
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public override async Task<List<GerAppointPatientRegisterWithAsbitemListDto>> GerAppointPatientRegisterWithAsbitemListAsync(AppointPatientRegisterIdsInputDto input)
{
var appointPatientRegisterWithAsbitemListDto = await CallWePeisAppServiceAsync<AppointPatientRegisterIdsInputDto,
List<GerAppointPatientRegisterWithAsbitemListDto>>
(_webPeisGerAppointPatientRegisterWithAsbitemListUrl, input);
return appointPatientRegisterWithAsbitemListDto;
}
/// <summary>
/// 体检系统申请退款
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="NotImplementedException"></exception>
public override async Task CreateWeChatOrderRefundAsync(CreateWeChatOrderRefundInputDto input)
{
await CallWePeisAppServiceAsync<CreateWeChatOrderRefundInputDto, Task>
(_webPeisCreateWeChatOrderRefundUrl, input);
}
public async virtual Task<WebApiOutDto<LoginOutDataDto>> LoginWebPeisAsync()
{
if (string.IsNullOrWhiteSpace(_webPeisUser))

14
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
{
/// <summary>
/// 预约id集合
/// </summary>
public List<Guid> AppointPatientRegisterIds { get; set; } = new List<Guid>();
}
}

19
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
{
/// <summary>
/// 预约ID
/// </summary>
public Guid AppointPatientRegisterId { get; set; }
/// <summary>
/// 退款金额 元
/// </summary>
public decimal RefundMoney { get; set; }
}
}

72
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
{
/// <summary>
/// 预约id
/// </summary>
public Guid AppointPatientRegisterId { get; set; }
/// <summary>
/// 收费状态 0-未收费 1-已收费 2-已退费
/// </summary>
public char ChargeFlag { get; set; }
/// <summary>
/// 预约日期
/// </summary>
public string AppointDate { get; set; }
/// <summary>
/// 预约项目
/// </summary>
public List<GerAppointPatientRegisterWithAsbitemListChargeAsbitemDto> AppointRegisterAsbitemDetail { get; set; } = new List<GerAppointPatientRegisterWithAsbitemListChargeAsbitemDto>();
}
public class GerAppointPatientRegisterWithAsbitemListChargeAsbitemDto
{
/// <summary>
/// 主键
/// </summary>
public Guid AppointRegisterAsbitemId { get; set; }
/// <summary>
/// 组合项目ID
/// </summary>
public Guid AsbitemId { get; set; }
/// <summary>
/// 组合项目名称
/// </summary>
public string AsbitemName { get; set; }
/// <summary>
/// 标准价格
/// </summary>
public decimal StandardPrice { get; set; }
/// <summary>
/// 收费价格
/// </summary>
public decimal ChargePrice { get; set; }
/// <summary>
/// 支付类别标准
/// </summary>
public char PayTypeFlag { get; set; }
/// <summary>
/// 是否收费
/// </summary>
public char IsCharge { get; set; }
/// <summary>
/// 数量
/// </summary>
public short Amount { get; set; }
}
}

45
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
{
/// <summary>
/// 姓名
/// </summary>
public string PatientName { get; set; }
/// <summary>
/// 档案号
/// </summary>
public string PatientNo { get; set; }
/// <summary>
/// 条码号
/// </summary>
public string PatientRegisterNo { get; set; }
/// <summary>
/// 身份证号
/// </summary>
public string IdNo { get; set; }
/// <summary>
/// 日期类型(1、登记日期 2、体检日期 ) 默认登记日期
/// </summary>
public char DateType { get; set; } = '1';
/// <summary>
/// 开始日期
/// </summary>
public string StartDate { get; set; }
/// <summary>
/// 结束日期
/// </summary>
public string EndDate { get; set; }
}
}

49
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
{
/// <summary>
/// 条码号
/// </summary>
public string PatientRegisterNo { get; set; }
/// <summary>
/// 档案号
/// </summary>
public string PatientNo { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string PatientName { get; set; }
/// <summary>
/// 性别
/// </summary>
public string SexName { get; set; }
/// <summary>
/// 年龄
/// </summary>
public short? Age { get; set; }
/// <summary>
/// 身份证号
/// </summary>
public string IdNo { get; set; }
/// <summary>
/// 电话
/// </summary>
public string Telephone { get; set; }
/// <summary>
/// 手机号
/// </summary>
public string MobileTelephone { get; set; }
}
}

27
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
{
/// <summary>
/// 预约id
/// </summary>
public Guid AppointPatientRegisterId { get; set; }
/// <summary>
/// 收费项目状态
/// </summary>
public List<UpdateAppointPatientAsbitemStatusInputDetailDto> ChargeAsbitemDetail { get; set; } = new List<UpdateAppointPatientAsbitemStatusInputDetailDto>();
}
public class UpdateAppointPatientAsbitemStatusInputDetailDto
{
public Guid AsbitemId { get; set; }
public char IsCharge { get; set; }
}
}

197
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<ThirdInterface, Guid> _thirdInterfaceRepository;
private readonly IRepository<PatientRegister, Guid> _patientRegisterRepository;
private readonly IRepository<Patient, Guid> _patientRepository;
private readonly IRepository<RegisterCheck, Guid> _registerCheckRepository;
private readonly IRepository<RegisterCheckAsbitem, Guid> _registerCheckAsbitemRepository;
private readonly CacheService _cacheService;
public AppointPatientRegisterAppService(
IRepository<ThirdInterface, Guid> thirdInterfaceRepository,
IRepository<PatientRegister, Guid> patientRegisterRepository
)
IRepository<PatientRegister, Guid> patientRegisterRepository,
IRepository<Patient, Guid> patientRepository,
IRepository<RegisterCheck, Guid> registerCheckRepository,
IRepository<RegisterCheckAsbitem, Guid> registerCheckAsbitemRepository,
CacheService cacheService)
{
_thirdInterfaceRepository = thirdInterfaceRepository;
_patientRegisterRepository = patientRegisterRepository;
_patientRepository = patientRepository;
_registerCheckRepository = registerCheckRepository;
_registerCheckAsbitemRepository = registerCheckAsbitemRepository;
_cacheService = cacheService;
}
/// <summary>
/// 获取网上预约数据
@ -161,6 +176,154 @@ namespace Shentun.Peis.AppointPatientRegisters
}
/// <summary>
/// 获取预约记录,包含收费项目 体检退费时用
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/app/AppointPatientRegister/GerAppointPatientRegisterWithAsbitemList")]
public async Task<List<GerAppointPatientRegisterWithAsbitemListWithPatientReigsterDto>> GerAppointPatientRegisterWithAsbitemListAsync(GerAppointPatientRegisterWithAsbitemListInputDto input)
{
List<GerAppointPatientRegisterWithAsbitemListWithPatientReigsterDto> entListDto = new List<GerAppointPatientRegisterWithAsbitemListWithPatientReigsterDto>();
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<List<GerAppointPatientRegisterWithAsbitemListDto>>(assemblyName,
className, [thirdInterface.Id], "GerAppointPatientRegisterWithAsbitemListAsync", objects);
foreach (var plugin in pluginsOut)
{
var entDto = ObjectMapper.Map<GerAppointPatientRegisterWithAsbitemListDto, GerAppointPatientRegisterWithAsbitemListWithPatientReigsterDto>(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;
}
/// <summary>
/// 体检系统申请退款
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[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<Task>(assemblyName,
className, [thirdInterface.Id], "CreateWeChatOrderRefundAsync", objects);
}
#region 提供给小程序的接口
/// <summary>
@ -180,6 +343,36 @@ namespace Shentun.Peis.AppointPatientRegisters
return isRegister;
}
/// <summary>
/// 小程序退款成功后,更新体检系统项目收费状态
/// </summary>
/// <returns></returns>
[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
}
}

5
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<CreateThirdMedicalCenterDto, ThirdMedicalCenter>();
CreateMap<UpdateThirdMedicalCenterDto, ThirdMedicalCenter>();
//获取预约数据
CreateMap<GerAppointPatientRegisterWithAsbitemListDto, GerAppointPatientRegisterWithAsbitemListWithPatientReigsterDto>();
}
}

51
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
{
/// <summary>
/// 小程序收费
/// </summary>
[ApiExplorerSettings(GroupName = "Work")]
[Authorize]
public class SmallProgramChargeAppService : ApplicationService
{
private readonly IRepository<PatientRegister,Guid> _patientRegisterRepository;
private readonly IRepository<RegisterCheck,Guid> _registerCheckRepository;
private readonly IRepository<RegisterCheckAsbitem,Guid> _registerCheckAsbitemRepository;
public SmallProgramChargeAppService(
IRepository<PatientRegister, Guid> patientRegisterRepository,
IRepository<RegisterCheck, Guid> registerCheckRepository,
IRepository<RegisterCheckAsbitem, Guid> registerCheckAsbitemRepository
)
{
_patientRegisterRepository = patientRegisterRepository;
_registerCheckRepository = registerCheckRepository;
_registerCheckAsbitemRepository = registerCheckAsbitemRepository;
}
/// <summary>
/// 获取小程序收费过的人员
/// </summary>
/// <returns></returns>
[HttpPost("api/app/SmallProgramCharge/GetChargePatientRegisterList")]
public async Task<PagedResultDto<GetPatientRegisterChargeListDto>> GetChargePatientRegisterListAsync(PatientRegisterChargeRequestDto input)
{
}
}
}
Loading…
Cancel
Save