Browse Source

退款

master
wxd 11 months ago
parent
commit
d4672d492b
  1. 5
      Shentun.Sms.Client/CreateSmsTaskDto.cs
  2. 35
      Shentun.Sms.Client/SmsClientHelper.cs
  3. 2
      Shentun.WebPeis.Plugins/AppQueueRegisterPlugIns.cs
  4. 11
      src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/CreateWeChatOrderRefundDto.cs
  5. 5
      src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListDto.cs
  6. 55
      src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/GetAppointPatientRegisterListDto.cs
  7. 46
      src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/GetAppointPatientRegisterListInputDto.cs
  8. 159
      src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs
  9. 41
      src/Shentun.WebPeis.Domain/CacheService.cs
  10. 9
      src/Shentun.WebPeis.HttpApi.Host/appsettings.json

5
Shentun.Sms.Client/CreateSmsTaskDto.cs

@ -85,6 +85,11 @@ namespace Shentun.Sms.Client
/// </summary>
public string? SenderName { get; set; }
/// <summary>
/// 短信模板ID
/// </summary>
public string TemplateId { get; set; }
}
}

35
Shentun.Sms.Client/SmsClientHelper.cs

@ -48,7 +48,7 @@ namespace Shentun.Sms.Client
throw new Exception("手机号长度必须为11位");
}
if(string.IsNullOrWhiteSpace(createSmsTaskDto.PersonId))
if (string.IsNullOrWhiteSpace(createSmsTaskDto.PersonId))
{
throw new Exception("人员ID不能为空");
@ -90,10 +90,39 @@ namespace Shentun.Sms.Client
{
throw new Exception("解析校验短信类别ID错误");
}
smsDto.SmsTypeId = verifySmsTypeId;
await CreateSmsTask(smsDto);
}
public async static Task CreateAppointSmsTask(CreateSmsTaskDto smsDto)
{
var appointSmsTypeIdStr = _appConfig.GetSection("Sms")
.GetSection("AppointSmsTypeId").Value;
if (!Guid.TryParse(appointSmsTypeIdStr, out var appointSmsTypeId))
{
throw new Exception("解析预约成功短信类别ID错误");
}
var smsAppIdStr = _appConfig.GetSection("Sms")
.GetSection("SmsAppId").Value;
if (!Guid.TryParse(smsAppIdStr, out var smsAppId))
{
throw new Exception("解析短信应用ID错误");
}
string appointTemplateId = _appConfig.GetSection("Sms")
.GetSection("AppointTemplateId").Value;
smsDto.SmsAppId = smsAppId;
smsDto.SmsTypeId = appointSmsTypeId;
smsDto.TemplateId = appointTemplateId;
var result = await CallAppServiceAsync<CreateSmsTaskDto, object>(_createSmsTaskUrl, smsDto);
}
public async static Task<TOut> CallAppServiceAsync<TInput, TOut>(string url, TInput data, string method = "post")
{
if (string.IsNullOrWhiteSpace(_baseAddress))
@ -141,7 +170,7 @@ namespace Shentun.Sms.Client
}
result = await response.Content.ReadAsStringAsync();
var resultDto = System.Text.Json.JsonSerializer.Deserialize<SmsWebApiOutDto<TOut>>(result,jsonOptions);
var resultDto = System.Text.Json.JsonSerializer.Deserialize<SmsWebApiOutDto<TOut>>(result, jsonOptions);
if (resultDto.Code == -1)
{
throw new Exception($"调用WebApi失败,返回-1,消息:" + resultDto.Message);

2
Shentun.WebPeis.Plugins/AppQueueRegisterPlugIns.cs

@ -91,7 +91,7 @@ namespace Shentun.WebPeis.Plugins
/// <returns></returns>
public async Task UpdateAppointPatientAsbitemStatusAsync(UpdateAppointPatientAsbitemStatusInputDto input)
{
await CallAppServiceAsync<UpdateAppointPatientAsbitemStatusInputDto, Task>(_appUpdateAppointPatientAsbitemStatusUrl,
await CallAppServiceAsync<UpdateAppointPatientAsbitemStatusInputDto, bool>(_appUpdateAppointPatientAsbitemStatusUrl,
input);
}

11
src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/CreateWeChatOrderRefundDto.cs

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.WebPeis.AppointPatientRegisters
{
public class CreateWeChatOrderRefundDto
{
}
}

5
src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/GerAppointPatientRegisterWithAsbitemListDto.cs

@ -21,6 +21,11 @@ namespace Shentun.WebPeis.AppointPatientRegisters
/// </summary>
public string AppointDate { get; set; }
/// <summary>
/// 收费合计金额
/// </summary>
public decimal ChargeSumMoney { get; set; }
/// <summary>
/// 预约项目
/// </summary>

55
src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/GetAppointPatientRegisterListDto.cs

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.WebPeis.AppointPatientRegisters
{
public class GetAppointPatientRegisterListDto
{
/// <summary>
/// 姓名
/// </summary>
public string PatientName { get; set; }
/// <summary>
/// 手机号
/// </summary>
public string PhoneNumber { get; set; }
/// <summary>
/// 身份证号码
/// </summary>
public string IdNo { get; set; }
/// <summary>
/// 预约日期
/// </summary>
public string AppointDate { get; set; }
/// <summary>
/// 套餐名称
/// </summary>
public string MedicalPackageName { get; set; }
/// <summary>
/// 分组名称
/// </summary>
public string CustomerOrgGroupName { get; set; }
/// <summary>
/// 单位名称
/// </summary>
public string CustomerOrgName { get; set; }
/// <summary>
/// 部门名称
/// </summary>
public string DepartmentName { get; set; }
/// <summary>
/// 收费状态 0-未收费 1-已收费 2-已退费
/// </summary>
public string ChargeFlagName { get; set; }
}
}

46
src/Shentun.WebPeis.Application.Contracts/AppointPatientRegisters/GetAppointPatientRegisterListInputDto.cs

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.WebPeis.AppointPatientRegisters
{
public class GetAppointPatientRegisterListInputDto
{
/// <summary>
/// 姓名
/// </summary>
public string PatientName { get; set; }
/// <summary>
/// 手机号
/// </summary>
public string PhoneNumber { get; set; }
/// <summary>
/// 身份证号码
/// </summary>
public string IdNo { get; set; }
/// <summary>
/// 人员类别 0-所有 1-个人 2-单位 默认0
/// </summary>
public char PersonType { get; set; } = '0';
/// <summary>
/// 预约开始日期
/// </summary>
public string AppointStartDate { get; set; }
/// <summary>
/// 预约结束日期
/// </summary>
public string AppointEndDate { get; set; }
/// <summary>
/// 收费状态 0-未收费 1-已收费 2-已退费
/// </summary>
public char? ChargeFlag { get; set; }
}
}

159
src/Shentun.WebPeis.Application/AppointPatientRegisters/AppointPatientRegisterAppService.cs

@ -1,7 +1,10 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApplicationParts;
using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Configuration;
using NPOI.Util;
using Shentun.Sms.Client;
using Shentun.WebPeis.AppointRegisterAsbitems;
using Shentun.WebPeis.AppointScheduleTimes;
using Shentun.WebPeis.CustomerOrgs;
@ -84,6 +87,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters
private readonly IRepository<WeChatOrderRefund> _weChatOrderRefundRepository;
private readonly IConfiguration _configuration;
private readonly IWechatTenpayClientFactory _wechatTenpayClientFactory;
public AppointPatientRegisterAppService(IRepository<AppointPatientRegister> repository,
CacheService cacheService,
IRepository<ItemType> itemTypeRepository,
@ -125,7 +130,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters
IRepository<WeChatOrder> weChatOrderRepository,
IRepository<WeChatOrderRefund> weChatOrderRefundRepository,
IConfiguration configuration,
IWechatTenpayClientFactory wechatTenpayClientFactory)
IWechatTenpayClientFactory wechatTenpayClientFactory
)
{
_repository = repository;
_cacheService = cacheService;
@ -201,12 +207,22 @@ namespace Shentun.WebPeis.AppointPatientRegisters
entity.MedicalCenterId = medicalCenterId;
entity = await _appointPatientRegisterManager.CreateAsync(entity);
await _repository.InsertAsync(entity);
await _repository.InsertAsync(entity, true);
//修改预约数量
await _appointScheduleTimeManager.UpdateAppointNumberAsync(input.AppointDate);
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;
}
@ -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 提供给体检系统调用
@ -1432,13 +1573,16 @@ namespace Shentun.WebPeis.AppointPatientRegisters
join appointRegisterAsbitem in await _appointRegisterAsbitemRepository.GetQueryableAsync()
on appointPatientRegister.AppointPatientRegisterId equals appointRegisterAsbitem.AppointPatientRegisterId
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
&& input.AppointPatientRegisterIds.Contains(appointPatientRegister.AppointPatientRegisterId)
&& weChatOrder.Status == "SUCCESS"
select new
{
appointPatientRegister,
appointRegisterAsbitem,
asbitem
asbitem,
weChatOrder
}).ToList();
@ -1449,6 +1593,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters
AppointPatientRegisterId = s.Key.AppointPatientRegisterId,
ChargeFlag = s.Key.ChargeFlag,
AppointDate = DataHelper.ConversionDateShortToString(s.Key.AppointDate),
ChargeSumMoney = Convert.ToDecimal(s.FirstOrDefault().weChatOrder.OrderMoney) / 100,
AppointRegisterAsbitemDetail = s.Select(ss => new GerAppointPatientRegisterWithAsbitemListChargeAsbitemDto
{
Amount = ss.appointRegisterAsbitem.Amount,
@ -1463,7 +1608,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters
}).ToList();
return entListDto;
}
@ -1476,7 +1621,7 @@ namespace Shentun.WebPeis.AppointPatientRegisters
/// <returns></returns>
[AllowAnonymous]
[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
@ -1546,6 +1691,8 @@ namespace Shentun.WebPeis.AppointPatientRegisters
{
throw new UserFriendlyException("预约Id不正确");
}
return new CreateWeChatOrderRefundDto();
}
#endregion

41
src/Shentun.WebPeis.Domain/CacheService.cs

@ -3,6 +3,7 @@ using Microsoft.Extensions.Caching.Distributed;
using Microsoft.Extensions.Caching.Memory;
using Shentun.WebPeis.Enums;
using Shentun.WebPeis.Models;
using Shentun.WebPeis.SysParmValues;
using System;
using System.Collections.Generic;
using System.Linq;
@ -33,11 +34,11 @@ namespace Shentun.WebPeis
private readonly IRepository<Sex> _sexRepository;
private readonly IRepository<ForSex> _forSexRepository;
private readonly IRepository<Asbitem> _asbitemRepository;
private readonly IRepository<ItemType> _itemTypeRepository;
private readonly IRepository<CustomerOrg> _customerOrgRepository;
private readonly IRepository<MaritalStatus> _maritalStatusRepository;
private readonly IDistributedCache<string, string> _customerOrgDisplayModeCache;
public CacheService(
IDistributedCache<IdentityUser, Guid> userCache,
IMemoryCache customerOrgCache,
@ -47,9 +48,9 @@ namespace Shentun.WebPeis
IMemoryCache asbitemCache,
IMemoryCache itemTypeCache,
IDistributedCache<MaritalStatus, char> maritalStatusCache,
IRepository<Sex> sexRepository,
IDistributedCache<ForSex, char> forSexCache,
IRepository<ForSex> forSexRepository,
IRepository<Asbitem> asbitemRepository,
@ -57,7 +58,8 @@ namespace Shentun.WebPeis
IRepository<Nation> nationRepository,
IRepository<CustomerOrg> customerOrgRepository,
IRepository<MaritalStatus> maritalStatusRepository,
IDistributedCache<string, Guid> customerOrgTopNameCache)
IDistributedCache<string, Guid> customerOrgTopNameCache,
IDistributedCache<string, string> customerOrgDisplayModeCache)
{
_userCache = userCache;
_userRepository = userRepository;
@ -85,6 +87,7 @@ namespace Shentun.WebPeis
_maritalStatusRepository = maritalStatusRepository;
_customerOrgTopNameCache = customerOrgTopNameCache;
_customerOrgDisplayModeCache = customerOrgDisplayModeCache;
}
private async Task<IdentityUser> GetUserAsync(Guid id)
@ -162,7 +165,7 @@ namespace Shentun.WebPeis
return entity.MaritalStatusName;
}
public async Task<Asbitem> GetAsbitemAsync(Guid id)
{
@ -234,7 +237,7 @@ namespace Shentun.WebPeis
_customerOrgCache.Set(id, entity);
//entity = (CustomerOrg)_customerOrgCache.Get(id);
}
return entity;
}
@ -248,18 +251,32 @@ namespace Shentun.WebPeis
return entity.CustomerOrgName;
}
/// <summary>
/// 获取单位,部门往上推一级
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<CustomerOrg> GetTopCustomerOrgAsync(Guid id)
{
var entity = (CustomerOrg)_customerOrgCache.Get(id);
if(entity == null)
var entity = (CustomerOrg)_customerOrgCache.Get(id);
if (entity == null)
{
entity = await _customerOrgRepository.GetAsync(o => o.CustomerOrgId == id);
_customerOrgCache.Set(id, entity);
}
if (entity.ParentId != null && entity.ParentId != Guid.Empty)
{
entity = await GetTopCustomerOrgAsync((Guid)entity.ParentId);
Guid parentId = (Guid)entity.ParentId;
entity = (CustomerOrg)_customerOrgCache.Get(parentId);
if (entity == null)
{
entity = await _customerOrgRepository.GetAsync(o => o.CustomerOrgId == parentId);
_customerOrgCache.Set(parentId, entity);
}
}
return entity;
}
@ -294,7 +311,7 @@ namespace Shentun.WebPeis
_customerOrgCache.Set(id, entity);
}
if (entity.CustomerOrgId == GuidFlag.PersonCustomerOrgId)
{
return entity.CustomerOrgName;

9
src/Shentun.WebPeis.HttpApi.Host/appsettings.json

@ -48,14 +48,17 @@
}
],
"Sms": {
"BaseAddress": "http://62.156.10.86:44382",
"BaseAddress": "http://192.168.2.181:44383",
"CreateSmsTaskUrl": "api/app/SmsTask/Create",
"User": "admin",
"Password": "888888",
"VerifySmsTypeId": "3a12e09d-438a-1d08-d4f0-712aef13708d",
"VerifySmsValidTime": "1",
"VerifySmsValidTime": "2",
"IsTemplateTime": "N",
"SmsAppId": "3a12e09f-8534-ec43-8c46-e61af0964ab6"
"SmsAppId": "3a12e09f-8534-ec43-8c46-e61af0964ab6",
"IsAppointEnabled": "Y",
"AppointSmsTypeId": "3a167084-3d06-ab95-a9ab-1dffc961b9ac",
"AppointTemplateId": "2316290"
},
"Redis": {
"IsEnabled": "true",

Loading…
Cancel
Save