<?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.tofly.feesapi.bjgl.mapper.YhBjflZbMapper">
    <resultMap id="yhBjflZbMap" type="com.tofly.feesapi.bjgl.entity.YhBjflZb">
        <id property="id" column="ID"/>
        <result property="yhbh" column="YHBH"/>
        <result property="cbkh" column="CBKH"/>
        <result property="typeId" column="TYPE_ID"/>
        <result property="jsfs" column="JSFS"/>
        <result property="isdisabled" column="ISDISABLED"/>
        <result property="czry" column="CZRY"/>
        <result property="czsj" column="CZSJ"/>
        <result property="czryxm" column="CZRYXM"/>
    </resultMap>
    <select id="getMaxid" resultType="java.lang.String">
        select max(id) + 1
        from yh_bjfl_zb
    </select>

    <select id="getPage" resultType="com.tofly.feesapi.bjgl.entity.vo.YhBjflZbSelect">
        select a.id,a.yhbh,a.cbkh,a.type_id typeId,a.jsfs,a.isdisabled,a.czry,a.czryxm,a.czsj,
        c.yhxm,c.yhdz,c.lxdh,
        count(b.id) fbsl
        from yh_bjfl_zb a
        left join yh_bjfl_fb b on a.id=b.zb_id
        left join yh_khjbxx c on a.yhbh=c.yhbh
        <where>
            <if test="filter.searchText!=null and filter.searchText != ''">
                AND ( a.yhbh like '%${filter.searchText}%'
                OR c.yhxm like '%${filter.searchText}%'
                OR c.yhdz like '%${filter.searchText}%'
                OR c.lxdh like '%${filter.searchText}%')
            </if>
            <if test="filter.yhbh != null and filter.yhbh != ''">
                and a.yhbh = #{filter.yhbh}
            </if>
            <if test="filter.typeId != null and filter.typeId != ''">
                and a.type_id = #{filter.typeId}
            </if>
        </where>
        group by a.id,a.yhbh,a.cbkh,a.type_id,a.jsfs,a.isdisabled,a.czry,a.czryxm,a.czsj,
        c.yhxm,c.yhdz,c.lxdh
    </select>
</mapper>
