active-gift-mapper.xml
2.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
<?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">
<!-- @author tongxiaochuan -->
<mapper namespace="com.cjs.cms.dao.user.point.ActiveGiftDao">
<update id="updateRemainAmount" parameterType="map">
update active_gift set gift_remain_amount = gift_remain_amount - #{amount}
where id = #{id} and gift_remain_amount >= #{amount}
</update>
<insert id="insert" parameterType="ActiveGiftInfo" useGeneratedKeys="true" keyProperty="id">
insert into active_gift(active_id, gift_name, gift_code, gift_amount, gift_remain_amount, gift_type,
gift_price, create_at, create_by)
values(#{activeId}, #{giftName}, #{giftCode}, #{giftAmount}, #{giftRemainAmount}, #{giftType}, #{giftPrice},
CURRENT_TIMESTAMP, #{createBy})
</insert>
<update id="update" parameterType="ActiveGiftInfo">
update active_gift set active_id = #{activeId}, gift_name = #{giftName}, gift_code = #{giftCode},
gift_amount = #{giftAmount}, gift_remain_amount = #{giftRemainAmount}, gift_type = #{giftType},
gift_price = #{giftPrice}, create_at = CURRENT_TIMESTAMP, create_by = #{createBy}
where id = #{id}
</update>
<sql id="active_gift_field">
id, active_id, gift_name, gift_code, gift_amount, gift_remain_amount, gift_type, gift_price, create_at, create_by
</sql>
<select id="queryByActiveId" parameterType="int" resultType="ActiveGiftInfo">
select <include refid="active_gift_field" /> from active_gift
where active_id = #{activeId}
</select>
<select id="queryById" parameterType="int" resultType="ActiveGiftInfo">
select <include refid="active_gift_field" /> from active_gift
where id = #{id}
</select>
<delete id="delete" parameterType="int">
delete from active_gift where id = #{id}
</delete>
<select id="queryGiftCodeByActiveId" parameterType="int" resultType="string">
select gift_code from active_gift
where active_id = #{activeId}
</select>
<select id="queryGiftId" parameterType="map" resultType="int">
select id from active_gift
where active_id = #{activeId} and gift_code = #{giftCode}
</select>
<select id="queryGiftName" parameterType="string" resultType="string">
select distinct(gift_name) from active_gift where gift_code = #{giftCode}
</select>
</mapper>