<?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.goafanti.common.dao.OrgRatepayMapper" >
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.OrgRatepay" >
    <id column="id" property="id" jdbcType="VARCHAR" />
    <result column="uid" property="uid" jdbcType="VARCHAR" />
    <result column="operating_income" property="operatingIncome" jdbcType="DECIMAL" />
    <result column="management_cost" property="managementCost" jdbcType="DECIMAL" />
    <result column="operating_profit" property="operatingProfit" jdbcType="DECIMAL" />
    <result column="non_operating_income" property="nonOperatingIncome" jdbcType="DECIMAL" />
    <result column="non_taxable_income" property="nonTaxableIncome" jdbcType="DECIMAL" />
    <result column="tax_exempt_income" property="taxExemptIncome" jdbcType="DECIMAL" />
    <result column="subsidy_income" property="subsidyIncome" jdbcType="DECIMAL" />
    <result column="year" property="year" jdbcType="INTEGER" />
    <result column="gross_profit" property="grossProfit" jdbcType="DECIMAL" />
    <result column="research_cost" property="researchCost" jdbcType="DECIMAL" />
    <result column="tax_return_url" property="taxReturnUrl" jdbcType="VARCHAR" />
    <result column="deleted_sign" property="deletedSign" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, uid, operating_income, management_cost, operating_profit, non_operating_income, 
    non_taxable_income, tax_exempt_income, subsidy_income, year, gross_profit, research_cost, tax_return_url, deleted_sign
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from org_ratepay
    where id = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from org_ratepay
    where id = #{id,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.goafanti.common.model.OrgRatepay" >
    insert into org_ratepay (id, uid, operating_income, 
      management_cost, operating_profit, non_operating_income, 
      non_taxable_income, tax_exempt_income, subsidy_income, year, gross_profit, research_cost,
      tax_return_url, deleted_sign)
    values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, #{operatingIncome,jdbcType=DECIMAL}, 
      #{managementCost,jdbcType=DECIMAL}, #{operatingProfit,jdbcType=DECIMAL}, #{nonOperatingIncome,jdbcType=DECIMAL}, 
      #{nonTaxableIncome,jdbcType=DECIMAL}, #{taxExemptIncome,jdbcType=DECIMAL}, #{subsidyIncome,jdbcType=DECIMAL}, 
      #{year,jdbcType=INTEGER}, #{grossProfit,jdbcType=DECIMAL}, #{researchCost,jdbcType=DECIMAL}, 
      #{taxReturnUrl,jdbcType=VARCHAR}, #{deletedSign,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.goafanti.common.model.OrgRatepay" >
    insert into org_ratepay
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="uid != null" >
        uid,
      </if>
      <if test="operatingIncome != null" >
        operating_income,
      </if>
      <if test="managementCost != null" >
        management_cost,
      </if>
      <if test="operatingProfit != null" >
        operating_profit,
      </if>
      <if test="nonOperatingIncome != null" >
        non_operating_income,
      </if>
      <if test="nonTaxableIncome != null" >
        non_taxable_income,
      </if>
      <if test="taxExemptIncome != null" >
        tax_exempt_income,
      </if>
      <if test="subsidyIncome != null" >
        subsidy_income,
      </if>
      <if test="year != null" >
        year,
      </if>
      <if test="grossProfit != null" >
        gross_profit,
      </if>
      <if test="researchCost != null" >
        research_cost,
      </if>
      <if test="taxReturnUrl != null" >
        tax_return_url,
      </if>
      <if test="deletedSign != null" >
        deleted_sign,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="uid != null" >
        #{uid,jdbcType=VARCHAR},
      </if>
      <if test="operatingIncome != null" >
        #{operatingIncome,jdbcType=DECIMAL},
      </if>
      <if test="managementCost != null" >
        #{managementCost,jdbcType=DECIMAL},
      </if>
      <if test="operatingProfit != null" >
        #{operatingProfit,jdbcType=DECIMAL},
      </if>
      <if test="nonOperatingIncome != null" >
        #{nonOperatingIncome,jdbcType=DECIMAL},
      </if>
      <if test="nonTaxableIncome != null" >
        #{nonTaxableIncome,jdbcType=DECIMAL},
      </if>
      <if test="taxExemptIncome != null" >
        #{taxExemptIncome,jdbcType=DECIMAL},
      </if>
      <if test="subsidyIncome != null" >
        #{subsidyIncome,jdbcType=DECIMAL},
      </if>
      <if test="year != null" >
        #{year,jdbcType=INTEGER},
      </if>
      <if test="grossProfit != null" >
        #{grossProfit,jdbcType=DECIMAL},
      </if>
      <if test="researchCost != null" >
        #{researchCost,jdbcType=DECIMAL},
      </if>
       <if test="taxReturnUrl != null" >
        #{taxReturnUrl,jdbcType=VARCHAR},
      </if>
      <if test="deletedSign != null" >
        #{deletedSign,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.OrgRatepay" >
    update org_ratepay
    <set >
      <if test="uid != null" >
        uid = #{uid,jdbcType=VARCHAR},
      </if>
      <if test="operatingIncome != null" >
        operating_income = #{operatingIncome,jdbcType=DECIMAL},
      </if>
      <if test="managementCost != null" >
        management_cost = #{managementCost,jdbcType=DECIMAL},
      </if>
      <if test="operatingProfit != null" >
        operating_profit = #{operatingProfit,jdbcType=DECIMAL},
      </if>
      <if test="nonOperatingIncome != null" >
        non_operating_income = #{nonOperatingIncome,jdbcType=DECIMAL},
      </if>
      <if test="nonTaxableIncome != null" >
        non_taxable_income = #{nonTaxableIncome,jdbcType=DECIMAL},
      </if>
      <if test="taxExemptIncome != null" >
        tax_exempt_income = #{taxExemptIncome,jdbcType=DECIMAL},
      </if>
      <if test="subsidyIncome != null" >
        subsidy_income = #{subsidyIncome,jdbcType=DECIMAL},
      </if>
      <if test="year != null" >
        year = #{year,jdbcType=INTEGER},
      </if>
       <if test="grossProfit != null" >
        gross_profit = #{grossProfit,jdbcType=DECIMAL},
      </if>
       <if test="researchCost != null" >
        research_cost = #{researchCost,jdbcType=DECIMAL},
      </if>
      <if test="taxReturnUrl != null" >
        tax_return_url = #{taxReturnUrl,jdbcType=VARCHAR},
      </if>
      <if test="deletedSign != null" >
        deleted_sign = #{deletedSign,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.OrgRatepay" >
    update org_ratepay
    set uid = #{uid,jdbcType=VARCHAR},
      operating_income = #{operatingIncome,jdbcType=DECIMAL},
      management_cost = #{managementCost,jdbcType=DECIMAL},
      operating_profit = #{operatingProfit,jdbcType=DECIMAL},
      non_operating_income = #{nonOperatingIncome,jdbcType=DECIMAL},
      non_taxable_income = #{nonTaxableIncome,jdbcType=DECIMAL},
      tax_exempt_income = #{taxExemptIncome,jdbcType=DECIMAL},
      subsidy_income = #{subsidyIncome,jdbcType=DECIMAL},
      year = #{year,jdbcType=INTEGER},
      gross_profit = #{grossProfit,jdbcType=DECIMAL},
      research_cost = #{researchCost,jdbcType=DECIMAL},
      tax_return_url = #{taxReturnUrl,jdbcType=VARCHAR},
      deleted_sign = #{deletedSign,jdbcType=INTEGER}
    where id = #{id,jdbcType=VARCHAR}
  </update>
  
    <select id="findOrgRatepayListByPage" parameterType="java.lang.String" resultMap="BaseResultMap">
  	 select 
    <include refid="Base_Column_List" />
    from org_ratepay
    where deleted_sign = 0
    <if test="uid != null">
	    and  uid = #{uid,jdbcType=VARCHAR}
	</if>
	<if test="year != null">
		and year = #{year,jdbcType=INTEGER}
	</if>
	order by year desc
    <if test="page_sql != null">
    	${page_sql}
    </if>
    
  </select>
  
  <select id="findOrgRatepayCount" resultType="java.lang.Integer" parameterType="String">
   	select count(1) 
	    from org_ratepay
    where deleted_sign = 0
	    <if test="uid != null">
		    and  uid = #{uid,jdbcType=VARCHAR}
		</if>
		<if test="year != null">
		and year = #{year,jdbcType=INTEGER}
	    </if>
  </select>
  
  <update id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  	update org_ratepay set deleted_sign = 1
  	where  id in 
	<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
		#{item}
	</foreach>
  </update>
  
  <select id="selectRatepayByUidAndYear" resultMap="BaseResultMap"  >
    select 
    <include refid="Base_Column_List" />
    from org_ratepay
    where 
    	uid = #{uid,jdbcType=VARCHAR} 
    and year = #{year,jdbcType=INTEGER} 
    and deleted_sign = 0
  </select>
</mapper>