<?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.YhBjflFbMapper">

    <resultMap id="yhBjflFbMap" type="com.tofly.feesapi.bjgl.entity.YhBjflFb">
        <id property="id" column="ID"/>
        <result property="zbId" column="ZB_ID"/>
        <result property="zbYhbh" column="ZB_YHBH"/>
        <result property="zbCbkh" column="ZB_CBKH"/>
        <result property="yhbh" column="YHBH"/>
        <result property="cbkh" column="CBKH"/>
        <result property="typeId" column="TYPE_ID"/>
    </resultMap>

    <select id="getMaxid" resultType="java.lang.String">
        select max(id) + 1
        from yh_bjfl_fb
    </select>

    <select id="getPage" resultType="com.tofly.feesapi.bjgl.entity.vo.YhBjflFbSelect">
        select a.id,
        a.zb_id zbId,
        a.zb_yhbh zbYhbh,
        a.zb_cbkh zbCbkh,
        a.yhbh,
        a.cbkh,
        a.type_id typeId,
        fb.yhxm as yhxm,
        fb.yhdz as yhdz,
        fb.lxdh as lxdh,
        zb.yhxm as zbYhxm,
        zb.yhdz as zbYhdz,
        zb.lxdh as zbLxdh
        from yh_bjfl_fb a
        left join yh_khjbxx fb on a.yhbh = fb.yhbh
        left join yh_khjbxx zb on a.zb_yhbh = zb.yhbh
        <where>
            <if test="filter.searchText != null and filter.searchText != ''">
                and (
                fb.yhbh like '%${filter.searchText}%'
                or fb.yhxm like '%${filter.searchText}%'
                or fb.yhdz like '%${filter.searchText}%'
                or fb.lxdh like '%${filter.searchText}%'
                or zb.yhbh like '%${filter.searchText}%'
                or zb.yhxm like '%${filter.searchText}%'
                or zb.yhdz like '%${filter.searchText}%'
                or zb.lxdh like '%${filter.searchText}%'
                )
            </if>
            <if test="filter.yhbh != null and filter.yhbh != ''">
                and fb.yhbh = #{filter.yhbh}
            </if>
            <if test="filter.typeId != null and filter.typeId != ''">
                and a.type_id = #{filter.typeId}
            </if>
            <if test="filter.zbId != null and filter.zbId != ''">
                and a.zb_id = #{filter.zbId}
            </if>
        </where>
    </select>

</mapper>
