<?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.jeeplus.modules.workreimbursement.dao.ReimbursementVATTaxDao">
    
	<sql id="ReimbursementVATTaxColumns">
		a.id AS "id",
		a.invoice_code AS "invoiceCode",
		a.invoice_number AS "invoiceNumber",
		a.tax_amount AS "taxAmount",
		a.work_reimbursement_id AS "workReimbursement.id",
		a.create_by AS "createBy.id",
		a.create_date AS "createDate",
		a.update_by AS "updateBy.id",
		a.update_date AS "updateDate",
		a.remarks AS "remarks",
		a.del_flag AS "delFlag",
		a.money AS "money",
		a.sum_money AS "sumMoney"
	</sql>
	
	<sql id="ReimbursementVATTaxJoins">
	</sql>
	
    
	<select id="get" resultType="ReimbursementVATTax" >
		SELECT 
			<include refid="ReimbursementVATTaxColumns"/>
		FROM reimbursement_vat_tax a
		<include refid="ReimbursementVATTaxJoins"/>
		WHERE a.id = #{id}
	</select>
	
	<select id="findList" resultType="ReimbursementVATTax" >
		SELECT 
			<include refid="ReimbursementVATTaxColumns"/>
		FROM reimbursement_vat_tax a
		<include refid="ReimbursementVATTaxJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
			<if test="workReimbursement != null and workReimbursement != ''">
				AND a.work_reimbursement_id = #{workReimbursement.id}
			</if>
		</where>
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.create_date ASC
			</otherwise>
		</choose>
	</select>
	
	<select id="findAllList" resultType="ReimbursementVATTax" >
		SELECT 
			<include refid="ReimbursementVATTaxColumns"/>
		FROM reimbursement_vat_tax a
		<include refid="ReimbursementVATTaxJoins"/>
		<where>
			a.del_flag = #{DEL_FLAG_NORMAL}
		</where>		
		<choose>
			<when test="page !=null and page.orderBy != null and page.orderBy != ''">
				ORDER BY ${page.orderBy}
			</when>
			<otherwise>
				ORDER BY a.create_date ASC
			</otherwise>
		</choose>
	</select>
	
	<insert id="insert">
		INSERT INTO reimbursement_vat_tax(
			id,
			invoice_code,
			invoice_number,
			tax_amount,
			work_reimbursement_id,
			create_by,
			create_date,
			update_by,
			update_date,
			remarks,
			del_flag,
			money,
			sum_money
		) VALUES (
			#{id},
			#{invoiceCode},
			#{invoiceNumber},
			#{taxAmount},
			#{workReimbursement.id},
			#{createBy.id},
			#{createDate},
			#{updateBy.id},
			#{updateDate},
			#{remarks},
			#{delFlag},
			#{money},
			#{sumMoney}
		)
	</insert>
	
	<update id="update">
		UPDATE reimbursement_vat_tax SET 	
			invoice_code = #{invoiceCode},
			invoice_number = #{invoiceNumber},
			tax_amount = #{taxAmount},
			work_reimbursement_id = #{workReimbursement.id},
			update_by = #{updateBy.id},
			update_date = #{updateDate},
			remarks = #{remarks},
			money = #{money},
			sum_money = #{sumMoney}
		WHERE id = #{id}
	</update>
	
	
	<!--物理删除-->
	<update id="delete">
		DELETE FROM reimbursement_vat_tax
		<choose>
			<when test="id !=null and id != ''">
				WHERE id = #{id}
			</when>
			<otherwise>
				WHERE work_reimbursement_id = #{workReimbursement.id}
			</otherwise>
		</choose>
	</update>
	
	<!--逻辑删除-->
	<update id="deleteByLogic">
		UPDATE reimbursement_vat_tax SET 
			del_flag = #{DEL_FLAG_DELETE}
		<choose>
			<when test="id !=null and id != ''">
				WHERE id = #{id}
			</when>
			<otherwise>
				WHERE work_reimbursement_id = #{workReimbursement.id}
			</otherwise>
		</choose>
	</update>
	
	
	<!-- 根据实体名称和字段名称和字段值获取唯一记录 -->
	<select id="findUniqueByProperty" resultType="ReimbursementVATTax" statementType="STATEMENT">
		select * FROM reimbursement_vat_tax  where ${propertyName} = '${value}'
	</select>
	
</mapper>