CutDownPriceProductMapper.xml 2.72 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.yoho.activity.dal.CutDownPriceProductMapper">
  <resultMap id="BaseResultMap" type="com.yoho.activity.dal.model.CutDownPriceProduct">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="activity_id" property="activityId" jdbcType="INTEGER"  />
    <result column="product_skn" property="productSkn" jdbcType="INTEGER"  />
    <result column="high_price" property="highPrice" jdbcType="DECIMAL"  />
    <result column="low_price" property="lowPrice" jdbcType="DECIMAL"  />
    <result column="join_num" property="joinNum" jdbcType="INTEGER"  />
    <result column="status" property="status" jdbcType="INTEGER"  />
    <result column="create_time" property="createTime" jdbcType="INTEGER"  />
    <result column="update_time" property="updateTime" jdbcType="INTEGER"  />
  </resultMap>

  <sql id="Base_Column_List" >
    id, activity_id, product_skn, high_price, low_price, join_num, status, create_time, update_time
  </sql>

  <select id="selectCutDownPriceProduct" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from cutdown_price_product
    where activity_id = #{activityId,jdbcType=INTEGER}
    AND product_skn = #{productSkn,jdbcType=INTEGER}
    AND status=1
  </select>

  <select id="selectCutDownPriceProductList" resultMap="BaseResultMap" parameterType="java.util.List">
    select
    <include refid="Base_Column_List" />
    from cutdown_price_product
    where
    <foreach collection="list" item="item" index="index" separator="OR">
      (activity_id=#{item.activityId,jdbcType=INTEGER} and product_skn=#{item.productSkn,jdbcType=INTEGER})
    </foreach>
  </select>

  <update id="updateCutDownPriceProductStatus" >
    update cutdown_price_product set status = #{status,jdbcType=INTEGER}
    where product_skn = #{productSkn,jdbcType=INTEGER}
  </update>

  <insert id="updateCutDownPriceProduct">
    INSERT INTO cutdown_price_product
    <![CDATA[
    (activity_id,
      product_skn,
      join_num,
      high_price,
      low_price,
      create_time,
      update_time,
      status)
    VALUES
    ]]>
    <foreach item="item" collection="list" separator=",">
      ( #{item.activityId},
      #{item.productSkn},
      #{item.joinNum},
      #{item.highPrice},
      #{item.lowPrice},
      #{item.createTime},
      #{item.updateTime},
      #{item.status})
    </foreach>
    ON DUPLICATE KEY UPDATE
    product_skn = VALUES(product_skn),
    join_num = VALUES(join_num),
    update_time = VALUES(update_time),
    high_price = VALUES(high_price),
    low_price = VALUES(low_price),
    status = VALUES(status)
  </insert>
</mapper>