CutDownPriceUserRecordMapper.xml 4.27 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.CutDownPriceUserRecordMapper">
  <resultMap id="BaseResultMap" type="com.yoho.activity.dal.model.CutDownPriceUserRecord">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="user_id" property="userId" jdbcType="INTEGER"  />
    <result column="activity_id" property="activityId" jdbcType="INTEGER"  />
    <result column="product_skn" property="productSkn" jdbcType="INTEGER"  />
    <result column="help_count" property="helpCount" jdbcType="INTEGER"  />
    <result column="use_count" property="useCount" jdbcType="INTEGER"  />
    <result column="create_time" property="createTime" jdbcType="INTEGER"  />
    <result column="update_time" property="updateTime" jdbcType="INTEGER"  />
    <result column="cut_time" property="cutTime" jdbcType="INTEGER"  />
    <result column="status" property="status" jdbcType="INTEGER"  />
  </resultMap>
  <sql id="Base_Column_List" >
    id, user_id, activity_id, product_skn, help_count, use_count, create_time, update_time, cut_time, status
  </sql>

  <insert id="addCutDownUserRecord" parameterType="com.yoho.activity.dal.model.CutDownPriceUserRecord" useGeneratedKeys="true" keyProperty="id">
    insert into cutdown_price_user_record (user_id, activity_id, product_skn, create_time)
    values (#{userId,jdbcType=INTEGER}, #{activityId,jdbcType=INTEGER}, #{productSkn,jdbcType=INTEGER}, #{createTime,jdbcType=INTEGER}
      )
  </insert>

  <select id="selectCutDownUserRecordCount" resultType="java.lang.Integer" >
    select
    count(id)
    from cutdown_price_user_record
    where 1=1
    and user_id = #{userId,jdbcType=INTEGER}
  </select>

  <select id="selectCutDownPriceUserRecordByPage" resultMap="BaseResultMap" >
    select
    <include refid="Base_Column_List" />
    from cutdown_price_user_record
    where 1=1
    and user_id = #{userId,jdbcType=INTEGER}
    order by create_time DESC
    limit #{start,jdbcType=INTEGER}, #{size,jdbcType=INTEGER}
  </select>

  <select id="selectCutDownPriceUserRecord" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from cutdown_price_user_record
    where activity_id = #{activityId,jdbcType=INTEGER}
    and user_id = #{userId,jdbcType=INTEGER}
    and product_skn = #{productSkn,jdbcType=INTEGER}
    order by create_time DESC
    limit 1
  </select>

  <select id="selectCutDownPriceUserRecordById" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from cutdown_price_user_record
    where id = #{cutRecordId,jdbcType=INTEGER}
  </select>

  <select id="selectCutDownPriceUserRecordList" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from cutdown_price_user_record
    where activity_id = #{activityId,jdbcType=INTEGER}
    and user_id = #{userId,jdbcType=INTEGER}
    and product_skn = #{productSkn,jdbcType=INTEGER}
    order by create_time DESC
  </select>

  <update id="updateCutDownHelpCount" >
    update cutdown_price_user_record
    set help_count = help_count+1, update_time= UNIX_TIMESTAMP(), cut_time= UNIX_TIMESTAMP()
    where user_id = #{userId,jdbcType=INTEGER}
    and activity_id = #{activityId,jdbcType=INTEGER}
    and product_skn = #{productSkn,jdbcType=INTEGER}
    and id = #{cutRecordId,jdbcType=INTEGER}
  </update>

  <update id="updateDecreaseUseCount" >
    update cutdown_price_user_record
    set use_count = use_count-1, update_time= UNIX_TIMESTAMP()
    where user_id = #{userId,jdbcType=INTEGER}
    and activity_id = #{activityId,jdbcType=INTEGER}
    and product_skn = #{productSkn,jdbcType=INTEGER}
    and id = #{cutRecordId,jdbcType=INTEGER}
  </update>

  <update id="updateIncreaseUseCount" >
    update cutdown_price_user_record
    set use_count = use_count+1, update_time= UNIX_TIMESTAMP()
    where user_id = #{userId,jdbcType=INTEGER}
    and activity_id = #{activityId,jdbcType=INTEGER}
    and product_skn = #{productSkn,jdbcType=INTEGER}
    and id = #{cutRecordId,jdbcType=INTEGER}
    and use_count=0
  </update>

  <update id="updateCutSuccess" >
    update cutdown_price_user_record
    set status=1, update_time= UNIX_TIMESTAMP()
    where 1=1
    and id = #{id,jdbcType=INTEGER}
  </update>
</mapper>