<?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="org.dromara.zjk.mapper.ZjkSettlementVoucherMapper">

    <resultMap id="BaseResultMap" type="org.dromara.zjk.domain.ZjkSettlementVoucher">
            <id property="id" column="ID" jdbcType="VARCHAR"/>
            <result property="voucherCode" column="voucher_code" jdbcType="VARCHAR"/>
            <result property="productId" column="product_id" jdbcType="BIGINT"/>
            <result property="expertId" column="expert_id" jdbcType="BIGINT"/>
            <result property="money" column="money" jdbcType="NUMERIC"/>
            <result property="settleNo" column="settle_no" jdbcType="VARCHAR"/>
            <result property="syncStatus" column="sync_status" jdbcType="SMALLINT"/>
            <result property="createDept" column="create_dept" jdbcType="VARCHAR"/>
            <result property="tenantId" column="tenant_id" jdbcType="VARCHAR"/>
            <result property="createBy" column="CREATE_BY" jdbcType="BIGINT"/>
            <result property="createTime" column="CREATE_TIME" jdbcType="TIMESTAMP"/>
            <result property="updateBy" column="UPDATE_BY" jdbcType="BIGINT"/>
            <result property="updateTime" column="UPDATE_TIME" jdbcType="TIMESTAMP"/>
    </resultMap>

    <sql id="Base_Column_List">
        ID,voucher_code,product_id,
        expert_id,money,settle_no,
        sync_status,create_dept,tenant_id,
        CREATE_BY,CREATE_TIME,UPDATE_BY,
        UPDATE_TIME
    </sql>
    <select id="queryPageList" resultType="org.dromara.zjk.domain.vo.ZjkSettlementVoucherVO">
        select zsv.id, zsv.voucher_code, zsv.money, zsv.settle_no, zsv.sync_status, ze.expert_name, zp.product_name
        from zjk_settlement_voucher zsv
                 LEFT JOIN zjk_expert ze on zsv.expert_id = ze.expert_id
                 LEFT JOIN zjk_product zp on zsv.product_id = zp."id"
        <where>
            <if test="bo.voucherCode != null and bo.voucherCode != ''">
                and zsv.voucher_code like '%' || #{bo.voucherCode} || '%'
            </if>
            <if test="bo.settleNo != null and bo.settleNo != ''">
                and zsv.settle_no like '%' || #{bo.settleNo} || '%'
            </if>
        </where>
    </select>
</mapper>
