UserCouponMapper.xml
3.57 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
<?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.ufo.dal.UserCouponMapper">
<resultMap id="BaseResultMap" type="com.yoho.ufo.model.coupon.UserCoupon">
<result column="id" property="id" jdbcType="INTEGER" />
<result column="uid" property="uid" jdbcType="INTEGER" />
<result column="coupon_id" property="couponId" jdbcType="INTEGER" />
<result column="coupon_type" property="couponType" jdbcType="INTEGER" />
<result column="coupon_code" property="couponCode" jdbcType="VARCHAR" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="order_code" property="orderCode" jdbcType="BIGINT" />
<result column="use_time" property="useTime" jdbcType="INTEGER" />
<result column="start_time" property="startTime" jdbcType="INTEGER" />
<result column="end_time" property="endTime" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="coupon_token" property="couponToken" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
id,uid,coupon_id,coupon_type,coupon_code,status,order_code,use_time,start_time,end_time,create_time,coupon_token
</sql>
<select id="selectByCouponIds" resultType="com.yoho.ufo.model.coupon.UserCouponNum">
select
count(uid) cnt, coupon_id
from user_coupon
where
coupon_id IN
<foreach collection="couponIds" item="couponId" open="(" separator="," close=")">
#{couponId,jdbcType=INTEGER}
</foreach>
group by coupon_id
</select>
<select id="selectByCouponIdsAndStatus" resultType="com.yoho.ufo.model.coupon.UserCouponNum">
select
count(uid) cnt, coupon_id
from user_coupon
where
status=1 and
coupon_id IN
<foreach collection="couponIds" item="couponId" open="(" separator="," close=")">
#{couponId,jdbcType=INTEGER}
</foreach>
group by coupon_id
</select>
<select id="selectByCondition" resultType="com.yoho.ufo.model.coupon.UserCoupon">
select <include refid="Base_Column_List"/> from user_coupon
inner join (
select id from user_coupon
<where>
<if test="param.couponId != null">
and coupon_Id=#{param.couponId}
</if>
<if test="param.couponCode != null">
and coupon_code=#{param.couponCode}
</if>
<if test="param.uid != null">
and uid=#{param.uid}
</if>
<if test="param.status != null">
and status=#{param.status}
</if>
</where>
order by id desc
<if test="param.size > 0">
limit #{param.start},#{param.size}
</if>
)
a using(id)
</select>
<select id="selectTotalByCondition" resultType="java.lang.Integer">
select count(1) from user_coupon
where 1=1
<if test="param.couponId != null">
and coupon_Id=#{param.couponId}
</if>
<if test="param.couponCode != null">
and coupon_code=#{param.couponCode}
</if>
<if test="param.uid != null">
and uid=#{param.uid}
</if>
<if test="param.status != null">
and status=#{param.status}
</if>
</select>
</mapper>