<?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.yhgl.mapper.YhKhjbxxLogMapper">

    <resultMap id="yhKhjbxxLogMap" type="com.tofly.feesapi.yhgl.entity.YhKhjbxxLog">
        <id property="logId" column="LOG_ID"/>
        <result property="logLsh" column="LOG_LSH"/>
        <result property="logCzrybm" column="LOG_CZRYBM"/>
        <result property="logCzryxm" column="LOG_CZRYXM"/>
        <result property="logCzsj" column="LOG_CZSJ"/>
        <result property="logCzlx" column="LOG_CZLX"/>
        <result property="logCllx" column="LOG_CLLX"/>
        <result property="logBz" column="LOG_BZ"/>
        <result property="yhbh" column="YHBH"/>
        <result property="ykhbh" column="YKHBH"/>
        <result property="ssgs" column="SSGS"/>
        <result property="sscbpq" column="SSCBPQ"/>
        <result property="sscbb" column="SSCBB"/>
        <result property="sqrq" column="SQRQ"/>
        <result property="yhxm" column="YHXM"/>
        <result property="yhdz" column="YHDZ"/>
        <result property="lxdh" column="LXDH"/>
        <result property="rks" column="RKS"/>
        <result property="xb" column="XB"/>
        <result property="sj" column="SJ"/>
        <result property="zzdh" column="ZZDH"/>
        <result property="gzdw" column="GZDW"/>
        <result property="bgdh" column="BGDH"/>
        <result property="dzyx" column="DZYX"/>
        <result property="zjlb" column="ZJLB"/>
        <result property="zjhm" column="ZJHM"/>
        <result property="hzgx" column="HZGX"/>
        <result property="yhzt" column="YHZT"/>
        <result property="zsjb" column="ZSJB"/>
        <result property="jdrq" column="JDRQ"/>
        <result property="tsbz" column="TSBZ"/>
        <result property="tsrq" column="TSRQ"/>
        <result property="htqd" column="HTQD"/>
        <result property="htqdrq" column="HTQDRQ"/>
        <result property="htbh" column="HTBH"/>
        <result property="bz" column="BZ"/>
        <result property="bzGcbh" column="BZ_GCBH"/>
        <result property="bzPcxlh" column="BZ_PCXLH"/>
        <result property="czrybm" column="CZRYBM"/>
        <result property="czryxm" column="CZRYXM"/>
        <result property="czsj" column="CZSJ"/>
        <result property="psfz" column="PSFZ"/>
        <result property="pht" column="PHT"/>
        <result property="pgszz" column="PGSZZ"/>
        <result property="pfcz" column="PFCZ"/>
        <result property="pyyzz" column="PYYZZ"/>
        <result property="pyxzj" column="PYXZJ"/>
        <result property="xydj" column="XYDJ"/>
        <result property="tkhbz" column="TKHBZ"/>
        <result property="zw" column="ZW"/>
        <result property="jdrybm" column="JDRYBM"/>
        <result property="jdryxm" column="JDRYXM"/>
        <result property="jdpcxlh" column="JDPCXLH"/>
        <result property="fplx" column="FPLX"/>
        <result property="sfqz" column="SFQZ"/>
        <result property="cbryxm" column="CBRYXM"/>
        <result property="xh" column="XH"/>
        <result property="ssregion" column="SSREGION"/>
        <result property="xgrybm" column="XGRYBM"/>
        <result property="fpName" column="FP_NAME"/>
        <result property="fpNsrsbh" column="FP_NSRSBH"/>
        <result property="fpDz" column="FP_DZ"/>
        <result property="fpLxdh" column="FP_LXDH"/>
        <result property="fpBankname" column="FP_BANKNAME"/>
        <result property="fpBankcode" column="FP_BANKCODE"/>
        <result property="fpBz" column="FP_BZ"/>
        <result property="fffs" column="FFFS"/>
        <result property="jtzqljl" column="JTZQLJL"/>
        <result property="khlb" column="KHLB"/>
        <result property="pyjm" column="PYJM"/>
        <result property="yljl" column="YLJL"/>
        <result property="sbsl" column="SBSL"/>
    </resultMap>

    <select id="getLogPage" resultType="com.tofly.feesapi.yhgl.entity.YhKhjbxxLog">
        <include refid="querySql"/>
    </select>

    <sql id="querySql">
        SELECT
            a.*,
            b.cbpqmc cbpq ,
            c.cbbmc cbb
        FROM
            yh_khjbxx_log a
        LEFT JOIN
            bm_cbpq b on a.sscbpq =b.cbpqbm
        LEFT JOIN
            bm_cbb c on a.sscbb = c.cbbbm
        WHERE
            1=1
        <if test="filter.searchText != null and filter.searchText != ''">
            and (a.yhxm like '%${filter.searchText}%'
            or a.yhdz like '%${filter.searchText}%'
            or a.zjhm like '%${filter.searchText}%'
            or a.lxdh like '%${filter.searchText}%'
            or a.yhbh like '%${filter.searchText}%'
            )
        </if>
        <if test="filter.ssgs != null and filter.ssgs != ''">
            and a.ssgs=#{filter.ssgs}
        </if>
        <if test="filter.sscbpq != null and filter.sscbpq != ''">
            and a.sscbpq=#{filter.sscbpq}
        </if>
        <if test="filter.sscbb != null and filter.sscbb != ''">
            and a.sscbb=#{filter.sscbb}
        </if>
        <if test="filter.qyfzr!=null">
            and a.sscbb in(select cbbbm from bm_cbb where qyfzr=#{filter.qyfzr})
        </if>
        <if test="filter.ksrq!=null and filter.jsrq!=null">
            and a.log_czsj between to_date(#{filter.ksrq},'yyyy-MM-dd hh24:mi:ss') and
            to_date(#{filter.jsrq},'yyyy-MM-dd hh24:mi:ss')
        </if>
        <if test="filter.czry!=null and filter.czry!=''">
            and a.czrybm=#{filter.czry!=}
        </if>
    </sql>
</mapper>
