<?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="cn.ezhizao.project.business.deduct.mapper.BizDeductMapper">

    <resultMap type="cn.ezhizao.project.business.deduct.domain.BizDeduct" id="BizDeductResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizDeduct" resultMap="BizDeductResult">
        SELECT t1.*, t4.form_no, t2.account_name signing_subject, t3.account_name as contact_company FROM biz_deduct t1 left join biz_tenant t2 on t2.id = t1.tenant_id left join biz_tenant t3 on t3.id = t1.from_tenant_id
        left join biz_entrust_order t4 on t4.id = t1.entrust_order_id
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            t1.deleted = 0
            <if test="id != null  and id != ''"> AND t1.id = #{id}</if>
            <if test="entrustOrderId != null and entrustOrderId != ''"> AND t1.entrust_order_id = #{entrustOrderId}</if>
            <if test="tenantId != null "> AND (t1.tenant_id = #{tenantId} or t1.from_tenant_id = #{tenantId})</if>
            <if test="description != null  and description != ''"> AND t1.description = #{description}</if>
            <if test="deductDate != null "> AND t1.deduct_date = #{deductDate}</if>
            <if test="amount != null "> AND t1. = #{amount}</if>
            <if test="status != null "> AND t1.status = #{status}</if>
        </trim>
    </select>

    <delete id="physicalDelete">
        DELETE FROM biz_deduct
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            <if test="id != null">
                id = #{id} AND
            </if>
       <!-- 删除条件为其他外键可以在这里加 -->
        </trim>
    </delete>
</mapper>
