<?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.openhis.financial.mapper.PaymentRecDetailMapper">

    <select id="getListByReconciliationIds"
            resultType="com.openhis.financial.model.PaymentRecDetailAccountResult">
        SELECT
        T1.ID,
        T1.predecessor_id,
        T1.reconciliation_id,
        T1.target_enum,
        T1.account_id,
        T1.account_code,
        T1.pay_enum,
        T1.pay_level_enum,
        T1.amount,
        T1.return_amount,
        T1.charge_amount,
        T1.pay_trans_no,
        T1.pay_trans_text,
        T1.pay_trans_date,
        T1.before_balance,
        T1.after_balance,
        T1.result_enum,
        --id,
        T2.status_enum,
        T2.billing_status_enum,
        T2.type_code,
        T2.NO,
        T2.NAME,
        T2.patient_id,
        T2.encounter_id,
        T2.balance_amount,
        T2.yb_area_no,
        T2.contract_no,
        T2.limit_account,
        T2.encounter_flag
        FROM
        fin_payment_rec_detail T1
        LEFT JOIN adm_account T2 ON T1.account_id = T2."id"
        AND T2.delete_flag = '0'
        WHERE
        T1.reconciliation_id IN
        <foreach collection="paymentIdList" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        AND T1.delete_flag = '0'
        AND T1.pay_enum NOT IN (310201,8,1,2,3,4,5,6,7,9,510100,340100,390100,390200,610100,640100,390400,620100,360100,999900,390300,9999981,360300)
        AND T1.delete_flag = '0';
    </select>
</mapper>