<?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.ruoyi.ibs.list.mapper.DwBGridCmpmCorpcustClaimRptMapper">


    <select id="selectResultList" resultType="DwBGridCmpmCorpcustClaimResultRpt">
        select id,outlet_id,outlet_name,branch_id,branch_name,manager_id,manager_name,base_claim_cust_cnt,base_claim_acct_cnt,base_dep_bal,
               base_dep_avg,base_dfgz_cnt,base_qyhl_prod_cnt,base_dkdj_prod_cnt,report_claim_cust_cnt,report_claim_acct_cnt,report_dep_bal,
               report_dep_avg,report_dfgz_cnt,report_qyhl_prod_cnt,report_dkdj_prod_cnt,data_date
        from dwb_grid_cmpm_corpcust_claim_result_rpt
        <where>
            <if test="role != null and role == 'outlet'"> and d.outlet_id = #{deptId} </if>
            <if test="role != null and role == 'branch'"> and d.branch_id = #{deptId} </if>
            <if test="role != null and role in {'head', 'ops', 'public', 'private'}">
                and (left(outlet_id, 3) = left(#{deptId}, 3) or left(branch_id, 3) = left(#{deptId}, 3))
            </if>
        </where>
        order by id
    </select>

    <select id="selectDetailList" resultType="DwBGridCmpmCorpcustClaimDetailRpt">
        select id,outlet_id,outlet_name,branch_id,branch_name,manager_id,manager_name,cust_id,cust_name,cust_idc,cust_isn,base_claim_acct_cnt,
               base_dep_bal,base_dep_avg,base_dfgz_flag,base_qyhl_prod_cnt,base_dkdj_prod_cnt,report_claim_acct_cnt,report_dep_bal,report_dep_avg,
               report_dfgz_flag,report_qyhl_prod_cnt,report_dkdj_prod_cnt,data_date
        from dwb_grid_cmpm_corpcust_claim_detail_rpt
        <where>
            <if test="role != null and role == 'outlet'"> and d.outlet_id = #{deptId} </if>
            <if test="role != null and role == 'branch'"> and d.branch_id = #{deptId} </if>
            <if test="role != null and role in {'head', 'ops', 'public', 'private'}">
                and (left(outlet_id, 3) = left(#{deptId}, 3) or left(branch_id, 3) = left(#{deptId}, 3))
            </if>
        </where>
        order by id
    </select>

</mapper>