<?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.unis.financialSupervision.modular.bizFsSettleDataCheck.mapper.BizFsSettleDataCheckMapper">

    <select id="selectMyPage"
            resultType="com.unis.financialSupervision.modular.bizFsSettleDataCheck.vo.BizFsSettleDataCheckPageVO">


        SELECT DISTINCT
        t1.id,
        t2.org_name,
        t4.contract_number,
        t1.settlement_time,
        sum(ifnull( t5.in_detail_total_price, 0 )) inDetailTotalPrice
        FROM
        biz_fs_settle_data_check t1
        LEFT JOIN depot_qh.org_info t2 ON t1.org_id = t2.org_id
        LEFT JOIN biz_fs_settle_data_check_item t3 ON t1.id = t3.fs_settle_data_check_id
        LEFT JOIN depot_qh.business_contract t4 ON t3.contract_id = t4.id
        LEFT JOIN depot_qh.business_store_ware_detail t5 ON t5.zid = t4.id

        <where>
            t5.type = 'contract'
            <if test="orgName!=null and orgName!=''">
                and t2.org_name like concat("%",#{orgName},"%")
            </if>
        </where>

        GROUP BY
        t3.fs_settle_data_check_id
        order by t1.create_time desc

    </select>

    <select id="liquidationPage"
            resultType="com.unis.financialSupervision.modular.bizFsSettleDataCheck.vo.BizFsSettleDataCheckPageVO">

        SELECT
        t1.id,t2.org_name,t4.contract_number,t5.in_detail_total_price,t1.settlement_time,t1.clear_status
        FROM
        biz_fs_settle_data_check t1
        left join depot_qh.org_info t2 on t1.org_id=t2.org_id
        LEFT JOIN biz_fs_settle_data_check_item t3 ON t1.id = t3.fs_settle_data_check_id
        LEFT JOIN depot_qh.business_contract t4 ON t3.contract_id = t4.id
        LEFT JOIN depot_qh.business_store_ware_detail t5 ON t5.zid = t4.id
        <where>
            t5.type="contract" and t1.check_status='1'
            <if test="orgName!=null and orgName!=''">
                and t2.org_name like concat("%",#{orgName},"%")
            </if>
        </where>
        order by t1.create_time desc

    </select>

</mapper>