From cb46461edece1beac570b20daca5768edce3dd33 Mon Sep 17 00:00:00 2001 From: his-dev Date: Fri, 3 Apr 2026 14:08:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(#303):=20=E5=B0=86=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E9=A2=84=E7=BA=A6=E9=99=90=E5=88=B6=E4=BB=8E=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E6=93=8D=E4=BD=9C=E7=A7=BB=E8=87=B3=E9=A2=84=E7=BA=A6=E6=8C=82?= =?UTF-8?q?=E5=8F=B7=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 问题:取消预约时检查次数限制,导致用户无法取消预约 修复:将取消次数限制检查移到预约挂号时进行 变更: - bookTicket(): 添加取消次数限制检查,达到上限禁止预约 - cancelTicket(): 移除取消限制检查,允许正常取消 提示信息:"由于您在月度内累计取消预约已达X次,触发系统限制,暂时无法在线预约,请联系分诊台或咨询客服。" --- .../service/impl/TicketServiceImpl.java | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/openhis-server-new/openhis-domain/src/main/java/com/openhis/clinical/service/impl/TicketServiceImpl.java b/openhis-server-new/openhis-domain/src/main/java/com/openhis/clinical/service/impl/TicketServiceImpl.java index 01fb025e..b1ffbfbe 100644 --- a/openhis-server-new/openhis-domain/src/main/java/com/openhis/clinical/service/impl/TicketServiceImpl.java +++ b/openhis-server-new/openhis-domain/src/main/java/com/openhis/clinical/service/impl/TicketServiceImpl.java @@ -146,7 +146,25 @@ public class TicketServiceImpl extends ServiceImpl impleme logger.debug("开始执行纯净打单路线,slotId: {}, patientName: {}", slotId, dto.getPatientName()); - // 1. 直查物理大底座! + // 1. 检查患者取消预约次数限制(应在预约挂号时限制,而非取消预约时) + Integer tenantId = dto.getTenant_id(); + Long patientId = dto.getPatientId(); + if (tenantId != null && patientId != null) { + AppointmentConfig config = appointmentConfigService.getConfigByTenantId(tenantId); + if (config != null && config.getCancelAppointmentCount() != null + && config.getCancelAppointmentCount() > 0) { + // 计算当前周期的起始时间 + LocalDateTime startTime = calculatePeriodStartTime(config.getCancelAppointmentType()); + // 统计已取消次数 + long cancelledCount = orderService.countPatientCancellations(patientId, tenantId, startTime); + if (cancelledCount >= config.getCancelAppointmentCount()) { + String periodName = getPeriodName(config.getCancelAppointmentType()); + throw new RuntimeException("由于您在" + periodName + "内累计取消预约已达" + cancelledCount + "次,触发系统限制,暂时无法在线预约,请联系分诊台或咨询客服。"); + } + } + } + + // 2. 直查物理大底座! TicketSlotDTO slot = scheduleSlotMapper.selectTicketSlotById(slotId); if (slot == null) { @@ -242,26 +260,11 @@ public class TicketServiceImpl extends ServiceImpl impleme throw new RuntimeException("当前号源没有可取消的预约订单"); } - // 核心逻辑:获取订单信息并检查机构取消限制 + // 获取订单信息 Order latestOrder = orders.get(0); - Integer tenantId = latestOrder.getTenantId(); - Long patientId = latestOrder.getPatientId(); - - if (tenantId != null && patientId != null) { - AppointmentConfig config = appointmentConfigService.getConfigByTenantId(tenantId); - if (config != null && config.getCancelAppointmentCount() != null - && config.getCancelAppointmentCount() > 0) { - // 计算当前周期的起始时间 - LocalDateTime startTime = calculatePeriodStartTime(config.getCancelAppointmentType()); - // 统计已取消次数 - long cancelledCount = orderService.countPatientCancellations(patientId, tenantId, startTime); - if (cancelledCount >= config.getCancelAppointmentCount()) { - String periodName = getPeriodName(config.getCancelAppointmentType()); - throw new RuntimeException("您在" + periodName + "内已达到该机构取消预约次数上限(" + config.getCancelAppointmentCount() + "次),禁止取消"); - } - } - } + // 直接执行取消,不再检查取消限制 + // 根据需求,取消限制应在预约挂号时检查,而非取消预约时 for (Order order : orders) { orderService.cancelAppointmentOrder(order.getId(), "患者取消预约"); }