挂号退款加退款记录
This commit is contained in:
@@ -267,6 +267,17 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
|
||||
new HashSet<>(Arrays.asList("patient_name", "organization_name", "practitioner_name", "healthcare_name")),
|
||||
request);
|
||||
|
||||
// 手动处理 statusEnum 参数(用于过滤退号记录)
|
||||
String statusEnumParam = request.getParameter("statusEnum");
|
||||
if (statusEnumParam != null && !statusEnumParam.isEmpty()) {
|
||||
try {
|
||||
Integer statusEnum = Integer.parseInt(statusEnumParam);
|
||||
queryWrapper.eq("status_enum", statusEnum);
|
||||
} catch (NumberFormatException e) {
|
||||
// 忽略无效的参数值
|
||||
}
|
||||
}
|
||||
|
||||
IPage<CurrentDayEncounterDto> currentDayEncounter = outpatientRegistrationAppMapper.getCurrentDayEncounter(
|
||||
new Page<>(pageNo, pageSize), EncounterClass.AMB.getValue(), ParticipantType.ADMITTER.getCode(),
|
||||
queryWrapper, ChargeItemContext.REGISTER.getValue(), PaymentStatus.SUCCESS.getValue());
|
||||
|
||||
@@ -131,4 +131,40 @@ public class CurrentDayEncounterDto {
|
||||
*/
|
||||
private Date birthDate;
|
||||
|
||||
/**
|
||||
* 退号日期/时间
|
||||
*/
|
||||
private Date returnDate;
|
||||
|
||||
/**
|
||||
* 退号原因
|
||||
*/
|
||||
private String returnReason;
|
||||
|
||||
/**
|
||||
* 退号操作人
|
||||
*/
|
||||
private String operatorName;
|
||||
|
||||
/**
|
||||
* 退号操作工号
|
||||
*/
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
private Long operatorId;
|
||||
|
||||
/**
|
||||
* 退款金额
|
||||
*/
|
||||
private BigDecimal refundAmount;
|
||||
|
||||
/**
|
||||
* 合同编码(费用性质代码)
|
||||
*/
|
||||
private String contractNo;
|
||||
|
||||
/**
|
||||
* 退款方式(多个支付方式用逗号分隔)
|
||||
*/
|
||||
private String refundMethod;
|
||||
|
||||
}
|
||||
|
||||
@@ -597,7 +597,7 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
|
||||
// 全退
|
||||
String ybSettleIds = paymentReconciliation.getYbSettleIds();
|
||||
PaymentReconciliation unPaymentReconciliation = normalUnCharge(paymentReconciliation, PaymentRecDetails, null);
|
||||
PaymentReconciliation unPaymentReconciliation = normalUnCharge(paymentReconciliation, PaymentRecDetails, null, null);
|
||||
if (!StringUtils.isEmpty(ybSettleIds)) {
|
||||
// 医保结算信息
|
||||
List<String> ybSettleIdList = Arrays.asList(ybSettleIds.split(","));
|
||||
@@ -734,7 +734,7 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
}
|
||||
|
||||
PaymentReconciliation unPaymentReconciliation =
|
||||
normalUnCharge(paymentReconciliation, paymentRecDetails, cancelPaymentDto.getSetlId());
|
||||
normalUnCharge(paymentReconciliation, paymentRecDetails, cancelPaymentDto.getSetlId(), cancelPaymentDto.getReason());
|
||||
|
||||
return R.ok(unPaymentReconciliation);
|
||||
}
|
||||
@@ -792,10 +792,12 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
*
|
||||
* @param paymentReconciliation 付款实体
|
||||
* @param paymentRecDetails 付款详情
|
||||
* @param setlIds 医保结算ID
|
||||
* @param reason 退号/退费原因
|
||||
* @return 结果
|
||||
*/
|
||||
private PaymentReconciliation normalUnCharge(PaymentReconciliation paymentReconciliation,
|
||||
List<PaymentRecDetail> paymentRecDetails, String setlIds) {
|
||||
List<PaymentRecDetail> paymentRecDetails, String setlIds, String reason) {
|
||||
|
||||
// 获取原ID
|
||||
Long id = paymentReconciliation.getId();
|
||||
@@ -805,7 +807,8 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
.setEntererId(SecurityUtils.getLoginUser().getPractitionerId()).setBillDate(new Date())
|
||||
.setTenderedAmount(paymentReconciliation.getTenderedAmount().negate())
|
||||
.setReturnedAmount(paymentReconciliation.getReturnedAmount().negate())
|
||||
.setDisplayAmount(paymentReconciliation.getDisplayAmount().negate());
|
||||
.setDisplayAmount(paymentReconciliation.getDisplayAmount().negate())
|
||||
.setRefundReason(reason); // 保存退号/退费原因
|
||||
if (setlIds != null) {
|
||||
paymentReconciliation.setYbSettleIds(setlIds);
|
||||
}
|
||||
@@ -2232,7 +2235,7 @@ public class PaymentRecServiceImpl implements IPaymentRecService {
|
||||
}
|
||||
|
||||
// 全退
|
||||
PaymentReconciliation unPaymentReconciliation = normalUnCharge(paymentReconciliation, paymentRecDetails, null);
|
||||
PaymentReconciliation unPaymentReconciliation = normalUnCharge(paymentReconciliation, paymentRecDetails, null, null);
|
||||
|
||||
// 取医保结算数据
|
||||
String ybSettleIds = paymentReconciliation.getYbSettleIds();
|
||||
|
||||
@@ -62,7 +62,14 @@
|
||||
T9.charge_item_ids,
|
||||
T9.payment_id,
|
||||
T9.picture_url,
|
||||
T9.birth_date
|
||||
T9.birth_date,
|
||||
T9.return_date,
|
||||
T9.return_reason,
|
||||
T9.operator_name,
|
||||
T9.operator_id,
|
||||
T9.refund_amount,
|
||||
T9.contract_no,
|
||||
T9.refund_method
|
||||
from (
|
||||
SELECT T1.tenant_id AS tenant_id,
|
||||
T1.id AS encounter_id,
|
||||
@@ -84,7 +91,15 @@
|
||||
T13.charge_item_ids,
|
||||
T13.id AS payment_id,
|
||||
ai.picture_url AS picture_url,
|
||||
T8.birth_date AS birth_date
|
||||
T8.birth_date AS birth_date,
|
||||
-- 退号相关信息
|
||||
T14.bill_date AS return_date,
|
||||
T14.refund_reason AS return_reason,
|
||||
T15."name" AS operator_name,
|
||||
T14.enterer_id AS operator_id,
|
||||
ABS(T14.display_amount) AS refund_amount,
|
||||
T6.contract_no AS contract_no,
|
||||
T16.refund_method AS refund_method
|
||||
FROM adm_encounter AS T1
|
||||
LEFT JOIN adm_organization AS T2 ON T1.organization_id = T2.ID AND T2.delete_flag = '0'
|
||||
LEFT JOIN adm_healthcare_service AS T3 ON T1.service_type_id = T3.ID AND T3.delete_flag = '0'
|
||||
@@ -111,9 +126,35 @@
|
||||
LEFT JOIN fin_payment_reconciliation T13
|
||||
ON T10.id::TEXT = ANY(string_to_array(T13.charge_item_ids,','))
|
||||
AND T13.delete_flag = '0'
|
||||
AND T13.status_enum = ${paymentStatus}
|
||||
LEFT JOIN adm_invoice AS ai
|
||||
ON ai.reconciliation_id = T13.id AND ai.delete_flag = '0'
|
||||
AND T13.status_enum = ${paymentStatus}
|
||||
-- 关联退号记录(当状态为退号时,通过relation_id关联原支付记录)
|
||||
LEFT JOIN fin_payment_reconciliation T14
|
||||
ON T13.id = T14.relation_id
|
||||
AND T14.delete_flag = '0'
|
||||
AND T14.status_enum = 3
|
||||
AND T14.payment_enum = 1
|
||||
LEFT JOIN adm_practitioner AS T15 ON T15.ID = T14.enterer_id AND T15.delete_flag = '0'
|
||||
-- 关联退号支付详情,获取退款方式(聚合多个支付方式)
|
||||
LEFT JOIN (
|
||||
SELECT reconciliation_id,
|
||||
STRING_AGG(
|
||||
CASE pay_enum
|
||||
WHEN 220400 THEN '现金'
|
||||
WHEN 220100 THEN '微信'
|
||||
WHEN 220200 THEN '支付宝'
|
||||
WHEN 220300 THEN '银联'
|
||||
END,
|
||||
','
|
||||
ORDER BY pay_enum
|
||||
) AS refund_method
|
||||
FROM fin_payment_rec_detail
|
||||
WHERE delete_flag = '0'
|
||||
AND amount < 0
|
||||
AND pay_enum IN (220400, 220100, 220200, 220300)
|
||||
GROUP BY reconciliation_id
|
||||
) AS T16 ON T14.id = T16.reconciliation_id
|
||||
LEFT JOIN adm_invoice AS ai
|
||||
ON ai.reconciliation_id = T13.id AND ai.delete_flag = '0'
|
||||
WHERE T1.delete_flag = '0'
|
||||
AND T1.class_enum = #{classEnum}
|
||||
-- AND T1.create_time
|
||||
|
||||
Reference in New Issue
Block a user