CutDownPriceUserRecordMapper.xml
4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?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>