<?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.yifu.cloud.plus.v1.yifu.salary.mapper.TSalaryTaxConfigMapper">

    <resultMap id="tSalaryTaxConfigMap" type="com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryTaxConfig">
        <id property="id" column="ID"/>
        <result property="taxableIncomeRemark" column="TAXABLE_INCOME_REMARK"/>
        <result property="withholdingRate" column="WITHHOLDING_RATE"/>
        <result property="quickDeducation" column="QUICK_DEDUCATION"/>
        <result property="minIncome" column="MIN_INCOME"/>
        <result property="maxIncome" column="MAX_INCOME"/>
        <result property="level" column="LEVEL"/>
        <result property="type" column="TYPE"/>
        <result property="startPoint" column="START_POINT"/>
    </resultMap>

	<sql id="Base_Column_List">
		ID,
        TAXABLE_INCOME_REMARK,
        WITHHOLDING_RATE,
        QUICK_DEDUCATION,
        MIN_INCOME,
        MAX_INCOME,
        LEVEL,
        TYPE,
        START_POINT
    </sql>
	<sql id="tSalaryTaxConfig_where">
		<if test="tSalaryTaxConfig != null">
			<if test="tSalaryTaxConfig.id != null and tSalaryTaxConfig.id.trim() != ''">
				AND ID = #{tSalaryTaxConfig.id}
			</if>
			<if test="tSalaryTaxConfig.taxableIncomeRemark != null and tSalaryTaxConfig.taxableIncomeRemark.trim() != ''">
				AND TAXABLE_INCOME_REMARK = #{tSalaryTaxConfig.taxableIncomeRemark}
			</if>
			<if test="tSalaryTaxConfig.withholdingRate != null">
				AND WITHHOLDING_RATE = #{tSalaryTaxConfig.withholdingRate}
			</if>
			<if test="tSalaryTaxConfig.quickDeducation != null">
				AND QUICK_DEDUCATION = #{tSalaryTaxConfig.quickDeducation}
			</if>
			<if test="tSalaryTaxConfig.minIncome != null">
				AND MIN_INCOME = #{tSalaryTaxConfig.minIncome}
			</if>
			<if test="tSalaryTaxConfig.maxIncome != null">
				AND MAX_INCOME = #{tSalaryTaxConfig.maxIncome}
			</if>
			<if test="tSalaryTaxConfig.level != null">
				AND LEVEL = #{tSalaryTaxConfig.level}
			</if>
			<if test="tSalaryTaxConfig.type != null">
				AND TYPE = #{tSalaryTaxConfig.type}
			</if>
			<if test="tSalaryTaxConfig.startPoint != null">
				AND START_POINT = #{tSalaryTaxConfig.startPoint}
			</if>
		</if>
	</sql>

    <!--tSalaryTaxConfig简单分页查询-->
    <select id="getTSalaryTaxConfigPage" resultMap="tSalaryTaxConfigMap">
        SELECT
			<include refid="Base_Column_List"/>
        FROM t_salary_tax_config
        <where>
            1=1
			<include refid="tSalaryTaxConfig_where"/>
        </where>
    </select>

    <!--tSalaryTaxConfig获取个税配置-->
    <select id="getTaxConfigByPersonList" resultMap="tSalaryTaxConfigMap">
        SELECT
			<include refid="Base_Column_List"/>
        FROM t_salary_tax_config
        <where>
            TYPE = 0
			<include refid="tSalaryTaxConfig_where"/>
        </where>
    </select>

    <!--tSalaryTaxConfig获取年终奖配置-->
    <select id="getTaxConfigByAnnualBonusList" resultMap="tSalaryTaxConfigMap">
        SELECT
			<include refid="Base_Column_List"/>
        FROM t_salary_tax_config
        <where>
            TYPE = 1
			<include refid="tSalaryTaxConfig_where"/>
        </where>
    </select>

	<!--tSalaryTaxConfig获取实发倒推配置-->
	<select id="getTaxConfigByActualList" resultMap="tSalaryTaxConfigMap">
		SELECT
		<include refid="Base_Column_List"/>
		FROM t_salary_tax_config
		<where>
			TYPE = 2
			<include refid="tSalaryTaxConfig_where"/>
		</where>
	</select>


</mapper>
