bugfix:对账完成
This commit is contained in:
@@ -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 >= #{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 >= #{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
|
||||
|
||||
Reference in New Issue
Block a user