AccDiscountsProportionDetailMapper.xml 5.2 KB
<?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.sibu.orderHelper.integral.web.dao.AccDiscountsProportionDao">

    <sql id="Base_Column_List">
      id,start_amount,end_amount,rate,create_sys_user_id,update_sys_user_id,create_date,update_date
    </sql>
    <resultMap id="BaseResultMap" type="com.sibu.orderHelper.integral.model.AccDiscountsProportionDetail">
      <id column="id" jdbcType="VARCHAR" property="id" />
        <result column="start_amount" jdbcType="DECIMAL" property="startAmount"/>
        <result column="end_amount" jdbcType="DECIMAL" property="endAmount"/>
      <result column="rate" jdbcType="DECIMAL" property="rate"/>
      <result column="create_sys_user_id" jdbcType="VARCHAR" property="createSysUserId" />
      <result column="update_sys_user_id" jdbcType="VARCHAR" property="updateSysUserId" />
      <result column="create_date" jdbcType="TIMESTAMP" property="createDt"/>
      <result column="update_date" jdbcType="TIMESTAMP" property="updateDt"/>
    </resultMap>

    <select id="getAccDiscountsProportionDetail" parameterType="java.lang.String" resultMap="BaseResultMap">
      select <include refid="Base_Column_List" />
      from acc_discounts_proportion_detail
      where id = #{id}
    </select>


    <delete id="deleteAccDiscountsProportionDetail" parameterType="java.lang.String">
      delete from acc_discounts_proportion_detail where id = #{id}
    </delete>

    <insert id="insertAccDiscountsProportionDetail" parameterType="com.sibu.orderHelper.integral.model.AccDiscountsProportionDetail">
      insert into acc_discounts_proportion_detail (id, start_amount,end_amount,rate,create_sys_user_id,update_sys_user_id,
      create_date,update_date)
      values (#{id,jdbcType=VARCHAR},#{startAmount,jdbcType=DECIMAL},#{endAmount,jdbcType=DECIMAL},#{rate,jdbcType=DECIMAL},
      #{createSysUserId,jdbcType=VARCHAR},#{updateSysUserId,jdbcType=VARCHAR},NOW(),NOW())
    </insert>

    <update id="updateAccDiscountsProportionDetail" parameterType="com.sibu.orderHelper.integral.model.AccDiscountsProportionDetail">
      update acc_discounts_proportion_detail
      set start_amount = #{startAmount,jdbcType=DECIMAL},end_amount = #{endAmount,jdbcType=DECIMAL},rate = #{rate,jdbcType=DECIMAL},
      update_sys_user_id = #{updateSysUserId,jdbcType=VARCHAR}, update_date = NOW()
      where id = #{id,jdbcType=VARCHAR}
    </update>

    <!-- 批量保存 -->
    <insert id="batchSaveDiscountsProportion" parameterType="java.util.List">
        INSERT INTO acc_discounts_proportion_detail (
        id, start_amount,end_amount,rate,create_sys_user_id,update_sys_user_id, create_date,update_date
        ) VALUES
        <foreach collection="list" item="dp"  separator=",">
            (#{dp.id},#{dp.startAmount},#{dp.endAmount},#{dp.rate},
            #{dp.createSysUserId}, #{dp.updateSysUserId},now(),now())
        </foreach>
    </insert>

    <!-- 批量删除 -->
    <delete id="batchDeleteDiscountsProportion" parameterType="java.util.List">
        DELETE FROM acc_discounts_proportion_detail WHERE id in
        <foreach collection="list" item="item"  open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>

    <select id="listAccDiscountsProportionDetail"  resultMap="BaseResultMap" parameterType="map">
      select  <include refid="Base_Column_List" />
      from acc_discounts_proportion_detail
      where 1=1
      <if test="startAmount != null and startAmount !=''">
        and start_amount > #{startAmount}
      </if>
      <if test="endAmount != null and endAmount !=''">
          <![CDATA[
			   and end_amount < #{endAmount}
			]]>
      </if>
        <if test="startDate != null and startDate !=''">
            and create_date >= #{startDate}
        </if>
        <if test="endDate != null and endDate != ''">
            <![CDATA[
			  and create_date <= #{endDate}
			]]>
        </if>
      order by create_date desc
      LIMIT ${pageNow}, ${pageSize}
    </select>

    <select id="totalAccDiscountsProportionDetail" resultType="java.lang.Integer" parameterType="map">
      select COUNT(*) from acc_discounts_proportion_detail
      where 1=1
        <if test="startAmount != null and startAmount !=''">
            and start_amount > #{startAmount}
        </if>
        <if test="endAmount != null and endAmount !=''">
            <![CDATA[
			   and end_amount < #{endAmount}
			]]>
        </if>
        <if test="startDate != null and startDate !=''">
            and create_date >= #{startDate}
        </if>
        <if test="endDate != null and endDate != ''">
            <![CDATA[
			  and create_date <= #{endDate}
			]]>
        </if>
    </select>


    <select id="listAcquireDiscountsRateByamount"  resultMap="BaseResultMap" parameterType="map">
        select  <include refid="Base_Column_List" />
        from acc_discounts_proportion_detail
        where #{amount} >=start_amount
        <![CDATA[
			   and #{amount}  < end_amount
			]]>
        ORDER BY rate asc
    </select>

    <select id="discountsProportionList"  resultMap="BaseResultMap">
        select  <include refid="Base_Column_List" />
        from acc_discounts_proportion_detail
    </select>

</mapper>