bugfix:对账完成

This commit is contained in:
Yuan
2025-12-07 11:46:49 +08:00
parent 3f931c2e29
commit 66620d51ae
23 changed files with 664 additions and 124 deletions

View File

@@ -26,6 +26,9 @@
<if test="payType!=null and payType!=''">
and PayType = #{payType}
</if>
<if test="bizType!=null and bizType!=''">
and BizType = #{bizType}
</if>
<if test="startTime!=null and startTime!=''">
and trade_date &gt;= #{startTime}
</if>
@@ -47,6 +50,9 @@
<if test="payType!=null and payType!=''">
and PayType = #{payType}
</if>
<if test="bizType!=null and bizType!=''">
and BizType = #{bizType}
</if>
<if test="startTime!=null and startTime!=''">
and trade_date &gt;= #{startTime}
</if>
@@ -247,16 +253,20 @@
</where>
</select>
<!-- 医保对账:按险种和清算类别分组统计(按ReceiptNO去重即HisTransId
1. 医疗总金额MEDFEE_SUMAMT统计同一收据号HisTransId下的自费总额取该收据号的ZFAmount并按组求和
2. 统筹金额FUND_PAY_SUMAMT和账户金额ACCT_PAY只统计PayType为9和10的记录按收据号合并
3. 按HisTransId去重合并统计金额 -->
<!-- 医保对账:按险种和清算类别分组统计(去重规则HisTransId + ZFAmount 都相同才视为同一记录
1. 医疗总金额MEDFEE_SUMAMT统计同一收据号HisTransId且同一自费金额ZFAmount下的金额累计统筹 + 非退款账户 + 自费
2. 统筹金额FUND_PAY_SUMAMT:累计统筹金额(不受退款影响)
3. 账户金额ACCT_PAY累计账户金额包含退款 -->
<select id="findMedicalInsuranceGroupData" parameterType="HashMap" resultType="HashMap">
select
t.insutype as INSUTYPE,
t.clr_type as CLR_TYPE,
count(distinct t.HisTransId) as FIXMEDINS_SETL_CNT,
cast(IFNULL(sum(t.ybtc),0) + IFNULL(sum(t.ybzh),0) + IFNULL(sum(t.zf),0) as decimal(19,2)) as MEDFEE_SUMAMT,
cast(
IFNULL(sum(t.ybtc),0)
+ IFNULL(sum(case when t.is_inpatient = 1 then 0 else t.ybzh_non_refund end),0)
+ IFNULL(sum(t.zf),0)
as decimal(19,2)) as MEDFEE_SUMAMT,
cast(IFNULL(sum(t.ybtc),0) as decimal(19,2)) as FUND_PAY_SUMAMT,
cast(IFNULL(sum(t.ybzh),0) as decimal(19,2)) as ACCT_PAY
from (
@@ -266,7 +276,9 @@
HisTransId,
max(cast(IFNULL(ybtcAmount,0) as decimal(19,2))) as ybtc,
max(cast(IFNULL(ybzhAmount,0) as decimal(19,2))) as ybzh,
max(cast(IFNULL(zfAmount,0) as decimal(19,2))) as zf
max(case when TradingStatus != '2' then cast(IFNULL(ybzhAmount,0) as decimal(19,2)) else 0 end) as ybzh_non_refund,
max(cast(IFNULL(zfAmount,0) as decimal(19,2))) as zf,
max(case when PayMethod = '2' then 1 else 0 end) as is_inpatient
from hisbill_history
where trade_date = #{trade_date}
and insutype is not null
@@ -275,7 +287,7 @@
and clr_type != ''
and HisTransId is not null
and HisTransId != ''
group by insutype, clr_type, HisTransId
group by insutype, clr_type, HisTransId, cast(IFNULL(zfAmount,0) as decimal(19,2))
) as t
group by t.insutype, t.clr_type
order by t.insutype, t.clr_type