bugfix:移动医保对账

This commit is contained in:
Yuan
2025-12-23 09:24:28 +08:00
parent f084043a4b
commit ae385398fc
13 changed files with 502 additions and 9 deletions

View File

@@ -41,7 +41,6 @@
from bankbill_history
where C_JYRQ = #{trade_date}
and (is_inpatient is null or is_inpatient = '0') <!-- 排除住院订单(终端号10091548和10091549) -->
and (bill_table_name is null or bill_table_name != '微信医保账单') <!-- 排除微信医保账单 -->
</select>
<insert id="saveOriginalData" parameterType="java.util.List">
insert into bankbills_original (

View File

@@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.saye.hospitalgd.mapper.FinancialReconciliation.MobileYbReconciliationMapper">
<!-- 银行侧汇总:微信医保账单 -->
<select id="sumBankMobileYb" parameterType="HashMap" resultType="HashMap">
SELECT
CAST(IFNULL(SUM(CAST(MEDFEE_SUMAMT AS DECIMAL(19,2))),0) AS DECIMAL(19,2)) AS bank_medfee,
CAST(IFNULL(SUM(CAST(ACCT_PAY AS DECIMAL(19,2))),0) AS DECIMAL(19,2)) AS bank_acct_pay,
CAST(IFNULL(SUM(CAST(FUND_PAY_SUMAMT AS DECIMAL(19,2))),0) AS DECIMAL(19,2)) AS bank_fund_pay
FROM bankbill_history
<where>
<if test="trade_date!=null and trade_date!=''">
AND C_JYRQ = #{trade_date}
</if>
AND (
bill_table_name = '微信医保账单'
OR bill_table_name = '微信移动医保账单'
OR bill_table_name LIKE '%医保%'
OR bill_table_name IS NULL
)
</where>
</select>
<!-- HIS 侧汇总HisOperCode='yb'(微信移动医保) -->
<select id="sumHisMobileYb" parameterType="HashMap" resultType="HashMap">
SELECT
CAST(IFNULL(SUM(CAST(MEDFEE_SUMAMT AS DECIMAL(19,2))),0) AS DECIMAL(19,2)) AS his_medfee,
CAST(IFNULL(SUM(CAST(ACCT_PAY AS DECIMAL(19,2))),0) AS DECIMAL(19,2)) AS his_acct_pay,
CAST(IFNULL(SUM(CAST(FUND_PAY_SUMAMT AS DECIMAL(19,2))),0) AS DECIMAL(19,2)) AS his_fund_pay
FROM hisbill_history
<where>
<if test="trade_date!=null and trade_date!=''">
AND trade_date = #{trade_date}
</if>
AND HisOperCode = 'yb'
</where>
</select>
<!-- 结果表mobile_yb_reconciliation_result -->
<insert id="insertResult" parameterType="HashMap">
INSERT INTO mobile_yb_reconciliation_result
(id, trade_date,
bank_medfee, bank_acct_pay, bank_fund_pay,
his_medfee, his_acct_pay, his_fund_pay,
diff_medfee, diff_acct_pay, diff_fund_pay,
stmt_rslt, stmt_rslt_dscr, create_time, modify_time)
VALUES
(#{id}, #{trade_date},
#{bank_medfee}, #{bank_acct_pay}, #{bank_fund_pay},
#{his_medfee}, #{his_acct_pay}, #{his_fund_pay},
#{diff_medfee}, #{diff_acct_pay}, #{diff_fund_pay},
#{stmt_rslt}, #{stmt_rslt_dscr}, now(), now())
</insert>
<delete id="deleteResultByDate" parameterType="HashMap">
DELETE FROM mobile_yb_reconciliation_result
WHERE trade_date = #{trade_date}
</delete>
<select id="findResultByDate" parameterType="HashMap" resultType="HashMap">
SELECT *
FROM mobile_yb_reconciliation_result
WHERE trade_date = #{trade_date}
LIMIT 1
</select>
</mapper>

View File

@@ -69,8 +69,9 @@
<if test="endTime != null and endTime != ''">
AND trade_date &lt;= #{endTime}
</if>
AND LOWER(HisOperCode) = 'wx'
AND LOWER(HisOperCode) in ('wx' , 'yb')
AND TradingStatus = '1'
AND PayType in ('2','1')
</where>
UNION ALL
SELECT '支付宝支付' AS PAY_NAME,
@@ -92,8 +93,9 @@
<if test="endTime != null and endTime != ''">
AND trade_date &lt;= #{endTime}
</if>
AND LOWER(HisOperCode) = 'wx'
AND LOWER(HisOperCode) in ('wx' , 'yb')
AND TradingStatus = '2'
AND PayType in ('2','1')
</where>
UNION ALL
SELECT '合计' AS PAY_NAME,
@@ -107,8 +109,9 @@
<if test="endTime != null and endTime != ''">
AND trade_date &lt;= #{endTime}
</if>
AND LOWER(HisOperCode) = 'wx'
AND LOWER(HisOperCode) in ('wx' , 'yb')
AND TradingStatus IN ('1','2')
AND PayType in ('2','1')
</where>
</select>

View File

@@ -82,7 +82,6 @@
and b.C_JYRQ &lt;= #{endTime}
and a.PayMethod != '2' -- 排除不参与对账的记录
and (b.is_inpatient is null or b.is_inpatient = '0') -- 排除住院订单
and (b.bill_table_name is null or b.bill_table_name != '微信医保账单') -- 排除微信医保账单
<if test="prepayment_code != null and prepayment_code != ''">
and a.PayType != #{prepayment_code}
</if>
@@ -140,7 +139,7 @@
</if>
) a
inner join
(select * from bankbill_history where C_JYRQ = #{trade_date} and (is_inpatient is null or is_inpatient = '0') and (bill_table_name is null or bill_table_name != '微信医保账单')) b -- 排除住院订单与微信医保账单
(select * from bankbill_history where C_JYRQ = #{trade_date} and (is_inpatient is null or is_inpatient = '0')) b -- 排除住院订单
on a.PlatformTransId = b.C_SHDDH and a.TradingStatus = b.C_JYLX and ROUND(CAST(a.Amount AS DECIMAL(18,2)), 2) = ROUND(CAST(b.C_JYJE AS DECIMAL(18,2)), 2)
</insert>
@@ -186,7 +185,7 @@
</if>
) a
left join
(select * from bankbill_history where C_JYRQ = #{trade_date} and (is_inpatient is null or is_inpatient = '0') and (bill_table_name is null or bill_table_name != '微信医保账单')) b -- 排除住院订单与微信医保账单
(select * from bankbill_history where C_JYRQ = #{trade_date} and (is_inpatient is null or is_inpatient = '0')) b -- 排除住院订单
on a.PlatformTransId = b.C_SHDDH and a.TradingStatus = b.C_JYLX and ROUND(CAST(a.Amount AS DECIMAL(18,2)), 2) = ROUND(CAST(b.C_JYJE AS DECIMAL(18,2)), 2)
where b.C_SHDDH is null
</insert>
@@ -237,13 +236,11 @@
select * from bankbill_history
where C_JYRQ = #{trade_date}
and (is_inpatient is null or is_inpatient = '0')
and (bill_table_name is null or bill_table_name != '微信医保账单')
and C_SHDDH in (
select C_SHDDH
from bankbill_history
where C_JYRQ = #{trade_date}
and (is_inpatient is null or is_inpatient = '0')
and (bill_table_name is null or bill_table_name != '微信医保账单')
group by C_SHDDH
having ROUND(SUM(CAST(C_JYJE AS DECIMAL(18,2))), 2) != 0
)