CouponMapper.xml
10.3 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<?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.CouponMapper">
<resultMap id="BaseResultMap" type="com.yoho.ufo.model.coupon.Coupon">
<result column="id" property="id" jdbcType="INTEGER" />
<result column="coupon_token" property="couponToken" jdbcType="VARCHAR" />
<result column="coupon_name" property="couponName" jdbcType="VARCHAR" />
<result column="coupon_amount" property="couponAmount" jdbcType="FLOAT" />
<result column="coupon_type" property="couponType" jdbcType="INTEGER" />
<result column="coupon_num" property="couponNum" jdbcType="INTEGER" />
<result column="use_num" property="useNum" jdbcType="INTEGER" />
<result column="send_num" property="sendNum" jdbcType="INTEGER" />
<result column="use_limit_type" property="useLimitType" jdbcType="INTEGER" />
<result column="use_limit_value" property="useLimitValue" jdbcType="INTEGER" />
<result column="product_limit_type" property="productLimitType" jdbcType="INTEGER" />
<result column="product_limit_value" property="productLimitValue" jdbcType="VARCHAR" />
<result column="start_time" property="startTime" jdbcType="INTEGER" />
<result column="end_time" property="endTime" jdbcType="INTEGER" />
<result column="status" property="status" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="pid" property="pid" jdbcType="INTEGER" />
<result column="remark" property="remark" jdbcType="VARCHAR" />
<result column="skup_forbid_type" property="skupForbidType" jdbcType="VARCHAR" />
<result column="skup_allow_type" property="skupAllowType" jdbcType="VARCHAR" />
<result column="business_client" property="businessClient" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List">
id,coupon_token,coupon_name,coupon_amount,coupon_type,coupon_num,use_num,send_num,
use_limit_type,use_limit_value,product_limit_type,product_limit_value,start_time,
end_time,status,create_time,pid,remark,skup_forbid_type,skup_allow_type,business_client
</sql>
<insert id="insertOrUpdate" useGeneratedKeys="true" keyProperty="param.id">
insert into coupon(id,coupon_token,coupon_name,coupon_amount,coupon_type,coupon_num,use_num,send_num,
use_limit_type,
<if test="param.useLimitType == 2">
use_limit_value,
</if>
product_limit_type,
<if test="param.productLimitType != 1">
product_limit_value,
</if>
start_time,end_time,status,create_time,pid,remark)
values(#{param.id},#{param.couponToken},#{param.couponName},#{param.couponAmount},#{param.couponType}
,#{param.couponNum},#{param.useNum},#{param.sendNum},#{param.useLimitType},
<if test="param.useLimitType == 2">
#{param.useLimitValue},
</if>
#{param.productLimitType},
<if test="param.productLimitType != 1">
#{param.productLimitValue},
</if>
#{param.startTime},#{param.endTime},#{param.status},#{param.createTime},#{param.pid},#{param.remark})
on duplicate key update
coupon_name=#{param.couponName},coupon_amount=#{param.couponAmount},coupon_type=#{param.couponType},coupon_num=#{param.couponNum}
,use_num=#{param.useNum},send_num=#{param.sendNum},
use_limit_type=#{param.useLimitType},
<if test="param.useLimitType == 2">
use_limit_value=#{param.useLimitValue},
</if>
product_limit_type=#{param.productLimitType},
<if test="param.productLimitType != 1">
product_limit_value=#{param.productLimitValue},
</if>
start_time=#{param.startTime},end_time=#{param.endTime},status=#{param.status},pid=#{param.pid},remark=#{param.remark}
</insert>
<insert id="insertByCouponSaveUpdateReq" useGeneratedKeys="true" keyProperty="param.id">
insert into coupon(coupon_token,coupon_name,coupon_amount,coupon_type,coupon_num,use_num,send_num,
use_limit_type,
<if test="param.useLimitType == 2">
use_limit_value,
</if>
product_limit_type,
start_time,end_time,status,create_time,pid,remark,skup_forbid_type,skup_allow_type, business_client)
values(#{param.couponToken},#{param.couponName},#{param.couponAmount},#{param.couponType}
,#{param.couponNum},#{param.useNum},#{param.sendNum},#{param.useLimitType},
<if test="param.useLimitType == 2">
#{param.useLimitValue},
</if>
#{param.productLimitType},
#{param.startTime},#{param.endTime},#{param.status},#{param.createTime},#{param.pid},#{param.remark},#{param.skupForbidType},#{param.skupAllowType},#{param.businessClient})
</insert>
<update id="updateByCouponSaveUpdateReq">
update coupon
<set>
<if test="param.couponToken != null">
coupon_token=#{param.couponToken},
</if>
<if test="param.couponName != null">
coupon_name=#{param.couponName},
</if>
<if test="param.couponAmount != null">
coupon_amount=#{param.couponAmount},
</if>
<if test="param.couponType != null">
coupon_type=#{param.couponType},
</if>
<if test="param.couponNum != null">
coupon_num=#{param.couponNum},
</if>
<if test="param.useNum != null">
use_num=#{param.useNum},
</if>
<if test="param.sendNum != null">
send_num=#{param.sendNum},
</if>
<if test="param.useLimitType != null">
use_limit_type=#{param.useLimitType},
</if>
<if test="param.useLimitValue != null">
use_limit_value=#{param.useLimitValue},
</if>
<if test="param.productLimitType != null">
product_limit_type=#{param.productLimitType},
</if>
<if test="param.startTime != null">
start_time=#{param.startTime},
</if>
<if test="param.endTime != null">
end_time=#{param.endTime},
</if>
<if test="param.status != null">
status=#{param.status},
</if>
<if test="param.createTime != null">
create_time=#{param.createTime},
</if>
<if test="param.pid != null">
pid=#{param.pid},
</if>
<if test="param.remark != null">
remark=#{param.remark},
</if>
<if test="param.skupAllowType != null">
skup_allow_type=#{param.skupAllowType},
</if>
</set>
where id = #{param.id}
</update>
<select id="selectTotalByCondition" resultType="java.lang.Integer">
select count(1) from coupon where 1=1
<if test="param.id != null">
and id=#{param.id}
</if>
<if test="param.name != null">
and coupon_name=#{param.name}
</if>
<if test="param.startTime != null">
and start_time>=#{param.startTime}
</if>
<if test="param.endTime != null">
and end_time <![CDATA[<= ]]> #{param.endTime}
</if>
<if test="param.status != null">
<if test="param.status == 3">
<!--已作废-->
and status=#{param.status}
</if>
<if test="param.status == 2">
<!--已过期-->
and end_time <![CDATA[< ]]> #{param.curTime}
and status != 3
</if>
<if test="param.status == 1">
<!--生效中-->
and start_time <![CDATA[<= ]]> #{param.curTime}
and end_time >= #{param.curTime}
and status != 3
</if>
<if test="param.status == 0">
<!--未生效-->
and start_time > #{param.curTime}
and status != 3
</if>
</if>
</select>
<select id="selectByCondition" resultType="com.yoho.ufo.model.coupon.Coupon">
select <include refid="Base_Column_List" /> from coupon where 1=1
<if test="param.id != null">
and id=#{param.id}
</if>
<if test="param.name != null">
and coupon_name=#{param.name}
</if>
<if test="param.startTime != null">
and start_time>=#{param.startTime}
</if>
<if test="param.endTime != null">
and end_time <![CDATA[<= ]]> #{param.endTime}
</if>
<if test="param.status != null">
<if test="param.status == 3">
<!--已作废-->
and status=#{param.status}
</if>
<if test="param.status == 2">
<!--已过期-->
and end_time <![CDATA[< ]]> #{param.curTime}
and status != 3
</if>
<if test="param.status == 1">
<!--生效中-->
and start_time <![CDATA[<= ]]> #{param.curTime}
and end_time >= #{param.curTime}
and status != 3
</if>
<if test="param.status == 0">
<!--未生效-->
and start_time > #{param.curTime}
and status != 3
</if>
</if>
order by id desc
<if test="param.size > 0">
limit #{param.start},#{param.size}
</if>
</select>
<select id="selectById" resultType="com.yoho.ufo.model.coupon.Coupon">
select <include refid="Base_Column_List" /> from coupon where id=#{id} limit 1;
</select>
<select id="selectValidByToken" resultType="com.yoho.ufo.model.coupon.Coupon">
select <include refid="Base_Column_List" /> from coupon
where coupon_token =#{token} and status = 1 limit 1;
</select>
<select id="selectByIds" resultType="com.yoho.ufo.model.coupon.Coupon">
select <include refid="Base_Column_List" /> from coupon where id in
<foreach collection="ids" close=")" open="(" separator="," item="item">
#{item}
</foreach>
</select>
</mapper>