<?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.order.mapper.BizArchiveInputDetailMapper">

    <resultMap type="cn.ezhizao.project.business.order.domain.BizArchiveInputDetail" id="BizArchiveInputDetailResult">
        <id column="id" property="id"/>
    </resultMap>


    <select id="getList" parameterType="BizArchiveInputDetail" resultMap="BizArchiveInputDetailResult">
        SELECT t1.*, t2.name as task_type_name, t2.pay_address,t3.dict_label as regionName,t4.dict_label as fictionAddress
        FROM biz_archive_input_detail t1
        left join biz_task_type t2 on t2.id = t1.task_type_id
        left join sys_dict_data t3 on t1.belong_region = t3.dict_code
        left join sys_dict_data t4 on t1.fiction_address_id = t4.dict_code
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            t1.deleted = 0
            <if test="companyId != null ">AND t1.company_id = #{companyId}</if>
            <if test="contractId != null ">AND t1.contract_id = #{contractId}</if>
            <if test="serviceNum != null ">AND t1.service_num = #{serviceNum}</if>
            <if test="price != null ">AND t1.price = #{price}</if>
            <if test="amount != null ">AND t1.amount = #{amount}</if>
        </trim>
    </select>
    <select id="getDetail" parameterType="BizArchiveInputDetail" resultMap="BizArchiveInputDetailResult">
        SELECT *
        FROM biz_archive_input_detail
        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
            deleted = 0
            <if test="contractId != null ">AND contract_id = #{contractId}</if>
            <if test="taskTypeId != null ">AND task_type_id = #{taskTypeId}</if>
            <if test="fromId  !=  null ">AND from_id = #{fromId}</if>
            <if test="companyId  !=  null ">AND company_id = #{companyId}</if>
        </trim>

    </select>
    <delete id="physicalDelete">
        DELETE FROM biz_archive_input_detail
        <where>
            <if test="id != null">
                AND  id = #{id}
            </if>
            <if test="contractId != null">
                AND  contract_id = #{contractId}
            </if>
            <if test="tenantId != null">
                AND  tenant_id = #{tenantId}
            </if>
            <if test="companyId != null ">
                AND company_id = #{companyId}
            </if>
        </where>
    </delete>
</mapper>
