|
|
@ -1,7 +1,10 @@ |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.AspNetCore.Mvc.ApplicationParts; |
|
|
using Microsoft.AspNetCore.Mvc.ApplicationParts; |
|
|
|
|
|
using Microsoft.Extensions.Caching.Distributed; |
|
|
using Microsoft.Extensions.Configuration; |
|
|
using Microsoft.Extensions.Configuration; |
|
|
|
|
|
using NPOI.Util; |
|
|
|
|
|
using Shentun.Sms.Client; |
|
|
using Shentun.WebPeis.AppointRegisterAsbitems; |
|
|
using Shentun.WebPeis.AppointRegisterAsbitems; |
|
|
using Shentun.WebPeis.AppointScheduleTimes; |
|
|
using Shentun.WebPeis.AppointScheduleTimes; |
|
|
using Shentun.WebPeis.CustomerOrgs; |
|
|
using Shentun.WebPeis.CustomerOrgs; |
|
|
@ -84,6 +87,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
private readonly IRepository<WeChatOrderRefund> _weChatOrderRefundRepository; |
|
|
private readonly IRepository<WeChatOrderRefund> _weChatOrderRefundRepository; |
|
|
private readonly IConfiguration _configuration; |
|
|
private readonly IConfiguration _configuration; |
|
|
private readonly IWechatTenpayClientFactory _wechatTenpayClientFactory; |
|
|
private readonly IWechatTenpayClientFactory _wechatTenpayClientFactory; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public AppointPatientRegisterAppService(IRepository<AppointPatientRegister> repository, |
|
|
public AppointPatientRegisterAppService(IRepository<AppointPatientRegister> repository, |
|
|
CacheService cacheService, |
|
|
CacheService cacheService, |
|
|
IRepository<ItemType> itemTypeRepository, |
|
|
IRepository<ItemType> itemTypeRepository, |
|
|
@ -125,7 +130,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
IRepository<WeChatOrder> weChatOrderRepository, |
|
|
IRepository<WeChatOrder> weChatOrderRepository, |
|
|
IRepository<WeChatOrderRefund> weChatOrderRefundRepository, |
|
|
IRepository<WeChatOrderRefund> weChatOrderRefundRepository, |
|
|
IConfiguration configuration, |
|
|
IConfiguration configuration, |
|
|
IWechatTenpayClientFactory wechatTenpayClientFactory) |
|
|
|
|
|
|
|
|
IWechatTenpayClientFactory wechatTenpayClientFactory |
|
|
|
|
|
) |
|
|
{ |
|
|
{ |
|
|
_repository = repository; |
|
|
_repository = repository; |
|
|
_cacheService = cacheService; |
|
|
_cacheService = cacheService; |
|
|
@ -201,12 +207,22 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
entity.MedicalCenterId = medicalCenterId; |
|
|
entity.MedicalCenterId = medicalCenterId; |
|
|
|
|
|
|
|
|
entity = await _appointPatientRegisterManager.CreateAsync(entity); |
|
|
entity = await _appointPatientRegisterManager.CreateAsync(entity); |
|
|
await _repository.InsertAsync(entity); |
|
|
|
|
|
|
|
|
await _repository.InsertAsync(entity, true); |
|
|
|
|
|
|
|
|
//修改预约数量
|
|
|
//修改预约数量
|
|
|
await _appointScheduleTimeManager.UpdateAppointNumberAsync(input.AppointDate); |
|
|
await _appointScheduleTimeManager.UpdateAppointNumberAsync(input.AppointDate); |
|
|
|
|
|
|
|
|
var result = ObjectMapper.Map<AppointPatientRegister, AppointPatientRegisterDto>(entity); |
|
|
var result = ObjectMapper.Map<AppointPatientRegister, AppointPatientRegisterDto>(entity); |
|
|
|
|
|
|
|
|
|
|
|
#region 推送预约成功短信
|
|
|
|
|
|
|
|
|
|
|
|
var isAppointEnabled = _configuration.GetSection("Sms:IsAppointEnabled").Value; |
|
|
|
|
|
if (isAppointEnabled == "Y") |
|
|
|
|
|
{ |
|
|
|
|
|
await PushAppointPatientRegisterSuccessSmsAsync(entity.AppointPatientRegisterId); |
|
|
|
|
|
} |
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -1147,7 +1163,132 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取预约列表,小程序后台统计
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("api/app/AppointPatientRegister/GetAppointPatientRegisterList")] |
|
|
|
|
|
public async Task<List<GetAppointPatientRegisterListDto>> GetAppointPatientRegisterListAsync(GetAppointPatientRegisterListInputDto input) |
|
|
|
|
|
{ |
|
|
|
|
|
var query = from appointPatientRegister in await _repository.GetQueryableAsync() |
|
|
|
|
|
join person in await _personRepository.GetQueryableAsync() on appointPatientRegister.PersonId equals person.PersonId |
|
|
|
|
|
join identityUser in await _identityUserRepository.GetQueryableAsync() on person.PersonId equals identityUser.Id |
|
|
|
|
|
join patientRegister in await _patientRegisterRepository.GetQueryableAsync() on appointPatientRegister.PatientRegisterId equals patientRegister.PatientRegisterId into patientRegisterTemp |
|
|
|
|
|
from patientRegisterHaveEmpty in patientRegisterTemp.DefaultIfEmpty() |
|
|
|
|
|
join patient in await _patientRepository.GetQueryableAsync() on patientRegisterHaveEmpty.PatientId equals patient.PatientId into patientTemp |
|
|
|
|
|
from patientHaveEmpty in patientTemp.DefaultIfEmpty() |
|
|
|
|
|
join medicalPackage in await _medicalPackageRepository.GetQueryableAsync() on appointPatientRegister.MedicalPackageId equals medicalPackage.MedicalPackageId into medicalPackageTemp |
|
|
|
|
|
from medicalPackageHaveEmpty in medicalPackageTemp.DefaultIfEmpty() |
|
|
|
|
|
join customerOrgGroup in await _customerOrgGroupRepository.GetQueryableAsync() on appointPatientRegister.CustomerOrgGroupId equals customerOrgGroup.CustomerOrgGroupId into customerOrgGroupTemp |
|
|
|
|
|
from customerOrgGroupHaveEmpty in customerOrgGroupTemp.DefaultIfEmpty() |
|
|
|
|
|
where appointPatientRegister.CompleteFlag != AppointPatientRegisterCompleteFlag.CancelAppoint |
|
|
|
|
|
select new |
|
|
|
|
|
{ |
|
|
|
|
|
patientName = identityUser.Name, |
|
|
|
|
|
phoneNumber = identityUser.PhoneNumber, |
|
|
|
|
|
idNo = person.IdNo, |
|
|
|
|
|
appointPatientRegister, |
|
|
|
|
|
patientRegisterHaveEmpty, |
|
|
|
|
|
patientHaveEmpty, |
|
|
|
|
|
medicalPackageName = medicalPackageHaveEmpty != null ? medicalPackageHaveEmpty.MedicalPackageName : "", |
|
|
|
|
|
customerOrgGroupName = customerOrgGroupHaveEmpty != null ? customerOrgGroupHaveEmpty.CustomerOrgGroupName : "" |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.PatientName)) |
|
|
|
|
|
{ |
|
|
|
|
|
query = query.Where(m => m.patientName == input.PatientName); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.PhoneNumber)) |
|
|
|
|
|
{ |
|
|
|
|
|
query = query.Where(m => m.phoneNumber == input.PhoneNumber); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.IdNo)) |
|
|
|
|
|
{ |
|
|
|
|
|
query = query.Where(m => m.idNo == input.IdNo); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (input.ChargeFlag != null) |
|
|
|
|
|
{ |
|
|
|
|
|
query = query.Where(m => m.appointPatientRegister.ChargeFlag == input.ChargeFlag); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (input.PersonType == '1') |
|
|
|
|
|
{ |
|
|
|
|
|
query = query.Where(m => m.patientRegisterHaveEmpty == null); |
|
|
|
|
|
} |
|
|
|
|
|
else if (input.PersonType == '2') |
|
|
|
|
|
{ |
|
|
|
|
|
query = query.Where(m => m.patientRegisterHaveEmpty != null); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.AppointStartDate) && !string.IsNullOrWhiteSpace(input.AppointEndDate)) |
|
|
|
|
|
{ |
|
|
|
|
|
query = query.Where(m => m.appointPatientRegister.AppointDate >= Convert.ToDateTime(input.AppointStartDate) && |
|
|
|
|
|
m.appointPatientRegister.AppointDate < Convert.ToDateTime(input.AppointEndDate).AddDays(1)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var entListDto = query.ToList().Select(s => new GetAppointPatientRegisterListDto |
|
|
|
|
|
{ |
|
|
|
|
|
AppointDate = DataHelper.ConversionDateShortToString(s.appointPatientRegister.AppointDate), |
|
|
|
|
|
ChargeFlagName = s.appointPatientRegister.ChargeFlag == '0' ? "未收费" : s.appointPatientRegister.ChargeFlag == '1' ? "已收费" : "已退费", |
|
|
|
|
|
IdNo = s.idNo, |
|
|
|
|
|
PatientName = s.patientName, |
|
|
|
|
|
PhoneNumber = s.phoneNumber, |
|
|
|
|
|
DepartmentName = _cacheService.GetCustomerOrgAsync(s.appointPatientRegister.CustomerOrgId).GetAwaiter().GetResult().CustomerOrgName, |
|
|
|
|
|
CustomerOrgName = _cacheService.GetTopCustomerOrgAsync(s.appointPatientRegister.CustomerOrgId).GetAwaiter().GetResult().CustomerOrgName, |
|
|
|
|
|
MedicalPackageName = s.medicalPackageName, |
|
|
|
|
|
CustomerOrgGroupName = s.customerOrgGroupName |
|
|
|
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
return entListDto; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 推送预约成功短信
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="appointPatientRegisterId"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
private async Task PushAppointPatientRegisterSuccessSmsAsync(Guid appointPatientRegisterId) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
var personEnt = (from appointPatientRegister in await _repository.GetQueryableAsync() |
|
|
|
|
|
join person in await _personRepository.GetQueryableAsync() on appointPatientRegister.PersonId equals person.PersonId |
|
|
|
|
|
join identityUser in await _identityUserRepository.GetQueryableAsync() on person.PersonId equals identityUser.Id |
|
|
|
|
|
where appointPatientRegister.AppointPatientRegisterId == appointPatientRegisterId |
|
|
|
|
|
select new |
|
|
|
|
|
{ |
|
|
|
|
|
identityUser.Name, |
|
|
|
|
|
identityUser.PhoneNumber, |
|
|
|
|
|
person.PersonId |
|
|
|
|
|
}).FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
|
|
if (personEnt != null) |
|
|
|
|
|
{ |
|
|
|
|
|
var inputDto = new CreateSmsTaskDto |
|
|
|
|
|
{ |
|
|
|
|
|
Content = "", |
|
|
|
|
|
CountryCode = "86", |
|
|
|
|
|
MobileTelephone = personEnt.PhoneNumber, |
|
|
|
|
|
PersonId = personEnt.PersonId.ToString(), |
|
|
|
|
|
PersonName = personEnt.Name, |
|
|
|
|
|
SenderId = "admin", |
|
|
|
|
|
SenderName = "体检", |
|
|
|
|
|
StopTime = "", |
|
|
|
|
|
TaskCorn = "", |
|
|
|
|
|
TaskCycleType = '0', |
|
|
|
|
|
ThirdId = personEnt.PersonId.ToString() |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
await SmsClientHelper.CreateAppointSmsTask(inputDto); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 提供给体检系统调用
|
|
|
#region 提供给体检系统调用
|
|
|
|
|
|
|
|
|
@ -1432,13 +1573,16 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
join appointRegisterAsbitem in await _appointRegisterAsbitemRepository.GetQueryableAsync() |
|
|
join appointRegisterAsbitem in await _appointRegisterAsbitemRepository.GetQueryableAsync() |
|
|
on appointPatientRegister.AppointPatientRegisterId equals appointRegisterAsbitem.AppointPatientRegisterId |
|
|
on appointPatientRegister.AppointPatientRegisterId equals appointRegisterAsbitem.AppointPatientRegisterId |
|
|
join asbitem in await _asbitemRepository.GetQueryableAsync() on appointRegisterAsbitem.AsbitemId equals asbitem.AsbitemId |
|
|
join asbitem in await _asbitemRepository.GetQueryableAsync() on appointRegisterAsbitem.AsbitemId equals asbitem.AsbitemId |
|
|
|
|
|
join weChatOrder in await _weChatOrderRepository.GetQueryableAsync() on appointPatientRegister.AppointPatientRegisterId equals weChatOrder.AppointPatientRegisterId |
|
|
where appointPatientRegister.ChargeFlag == ChargeFlag.Charge |
|
|
where appointPatientRegister.ChargeFlag == ChargeFlag.Charge |
|
|
&& input.AppointPatientRegisterIds.Contains(appointPatientRegister.AppointPatientRegisterId) |
|
|
&& input.AppointPatientRegisterIds.Contains(appointPatientRegister.AppointPatientRegisterId) |
|
|
|
|
|
&& weChatOrder.Status == "SUCCESS" |
|
|
select new |
|
|
select new |
|
|
{ |
|
|
{ |
|
|
appointPatientRegister, |
|
|
appointPatientRegister, |
|
|
appointRegisterAsbitem, |
|
|
appointRegisterAsbitem, |
|
|
asbitem |
|
|
|
|
|
|
|
|
asbitem, |
|
|
|
|
|
weChatOrder |
|
|
}).ToList(); |
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1449,6 +1593,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
AppointPatientRegisterId = s.Key.AppointPatientRegisterId, |
|
|
AppointPatientRegisterId = s.Key.AppointPatientRegisterId, |
|
|
ChargeFlag = s.Key.ChargeFlag, |
|
|
ChargeFlag = s.Key.ChargeFlag, |
|
|
AppointDate = DataHelper.ConversionDateShortToString(s.Key.AppointDate), |
|
|
AppointDate = DataHelper.ConversionDateShortToString(s.Key.AppointDate), |
|
|
|
|
|
ChargeSumMoney = Convert.ToDecimal(s.FirstOrDefault().weChatOrder.OrderMoney) / 100, |
|
|
AppointRegisterAsbitemDetail = s.Select(ss => new GerAppointPatientRegisterWithAsbitemListChargeAsbitemDto |
|
|
AppointRegisterAsbitemDetail = s.Select(ss => new GerAppointPatientRegisterWithAsbitemListChargeAsbitemDto |
|
|
{ |
|
|
{ |
|
|
Amount = ss.appointRegisterAsbitem.Amount, |
|
|
Amount = ss.appointRegisterAsbitem.Amount, |
|
|
@ -1463,7 +1608,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
}).ToList(); |
|
|
}).ToList(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return entListDto; |
|
|
return entListDto; |
|
|
} |
|
|
} |
|
|
@ -1476,7 +1621,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
[AllowAnonymous] |
|
|
[AllowAnonymous] |
|
|
[HttpPost("api/app/AppointPatientRegister/CreateWeChatOrderRefund")] |
|
|
[HttpPost("api/app/AppointPatientRegister/CreateWeChatOrderRefund")] |
|
|
public async Task CreateWeChatOrderRefundAsync(CreateWeChatOrderRefundInputDto input) |
|
|
|
|
|
|
|
|
public async Task<CreateWeChatOrderRefundDto> CreateWeChatOrderRefundAsync(CreateWeChatOrderRefundInputDto input) |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
var weChatOrderEnt = await _weChatOrderRepository.FirstOrDefaultAsync(f => f.AppointPatientRegisterId == input.AppointPatientRegisterId |
|
|
var weChatOrderEnt = await _weChatOrderRepository.FirstOrDefaultAsync(f => f.AppointPatientRegisterId == input.AppointPatientRegisterId |
|
|
@ -1546,6 +1691,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters |
|
|
{ |
|
|
{ |
|
|
throw new UserFriendlyException("预约Id不正确"); |
|
|
throw new UserFriendlyException("预约Id不正确"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return new CreateWeChatOrderRefundDto(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#endregion
|
|
|
#endregion
|
|
|
|