TdCCouponRuleSMapper.xml
15.5 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
<?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.zteits.pay.mapper.smapper.TdCCouponRuleSMapper">
<resultMap id="BaseResultMap" type="com.zteits.pay.domain.TdCCouponRule">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="card_no" jdbcType="VARCHAR" property="cardNo" />
<result column="card_name" jdbcType="VARCHAR" property="cardName" />
<result column="card_res" jdbcType="INTEGER" property="cardRes" />
<result column="card_type" jdbcType="INTEGER" property="cardType" />
<result column="coupons_type" jdbcType="INTEGER" property="couponsType" />
<result column="is_recommend" jdbcType="INTEGER" property="isRecommend" />
<result column="use_rule" jdbcType="INTEGER" property="useRule" />
<result column="disc_value" jdbcType="VARCHAR" property="discValue" />
<result column="full_cut_value" jdbcType="INTEGER" property="fullCutValue" />
<result column="need_integral" jdbcType="INTEGER" property="needIntegral" />
<result column="is_superp_use" jdbcType="INTEGER" property="isSuperpUse" />
<result column="begin_time" jdbcType="TIMESTAMP" property="beginTime" />
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
<result column="card_rest_num" jdbcType="INTEGER" property="cardRestNum" />
<result column="card_num" jdbcType="INTEGER" property="cardNum" />
<result column="card_state" jdbcType="INTEGER" property="cardState" />
<result column="card_remarks" jdbcType="VARCHAR" property="cardRemarks" />
<result column="data_state" jdbcType="INTEGER" property="dataState" />
<result column="create_empid" jdbcType="VARCHAR" property="createEmpid" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="modfiy_empid" jdbcType="VARCHAR" property="modfiyEmpid" />
<result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate" />
<result column="card_content" jdbcType="VARCHAR" property="cardContent" />
<result column="valid_days" jdbcType="INTEGER" property="validDays" />
<result column="receive_channels" jdbcType="INTEGER" property="receiveChannels" />
<result column="receive_num" jdbcType="INTEGER" property="receiveNum" />
<result column="org_id" jdbcType="BIGINT" property="orgId" />
</resultMap>
<sql id="Base_Column_List">
id, card_no, card_name, card_res, card_type, coupons_type, is_recommend, use_rule,
disc_value, full_cut_value, need_integral, is_superp_use, begin_time, end_time, card_rest_num,
card_num, card_state, card_remarks, data_state, create_empid, create_date, modfiy_empid,
modfiy_date,card_content, valid_days, receive_channels, receive_num, org_id
</sql>
<!--根据卡类型查询优惠券规则表 langlw 2017-12-27 Query the coupon rule table based on the card type-->
<select id="queryCouponRuleList" parameterType="com.zteits.clouds.api.dto.pay.param.TdCCouponRuleRequest"
resultType="com.zteits.clouds.api.dto.pay.TdCCouponRuleDTO">
select
a.card_no as cardNo,
a.card_name as cardName,
a.card_type as cardType,
a.coupons_type as couponsType,
a.use_rule as useRule,
a.disc_value as discValue,
a.full_cut_value as fullCutValue,
a.need_integral as needIntegral,
a.is_superp_use as isSuperpUse,
a.card_rest_num as cardRestNum,
a.card_num as cardNum,
a.card_state as cardState,
a.begin_time as beginTime,
a.end_time as endTime,
a.create_date as createDate,
a.card_content as cardContent,
a.valid_days validDays,
a.receive_channels receiveChannels,
a.receive_num receiveNum,
a.org_id orgId
from
td_c_coupon_rule a
where a.data_state=1
and a.card_state =1 /**卡券状态:1、上架;2、下架 **/
AND a.end_time >= #{queryDate} /***只查询在有效期内的券 **/
AND #{queryDate} >= a.begin_time /***只查询在有效期内的券 **/
<if test="orgId != null">
and a.org_id = #{orgId}
</if>
<if test="cardType != null ">
and a.card_type = #{cardType}
</if>
<if test="cardTypes != null and cardTypes.size > 0 ">
and a.card_type in
<foreach collection="cardTypes" item="cardType" open="(" close=")" separator=",">
#{cardType}
</foreach>
</if>
<if test="receiveChannelsList != null and receiveChannelsList.size > 0 ">
and a.receive_channels in
<foreach collection="receiveChannelsList" item="receiveChannels" open="(" close=")" separator=",">
#{receiveChannels}
</foreach>
</if>
order by a.create_date , a.need_integral desc
</select>
<!-- 查询所有上架卡券 -->
<select id="queryAllSellingCoupons" parameterType="com.zteits.clouds.api.dto.pay.param.TdCCouponRuleRequest"
resultType="com.zteits.clouds.api.dto.pay.TdCCouponRuleDTO">
SELECT
a.id id, a.card_no cardNo, a.card_name cardName, card_res cardRes, card_type cardType, coupons_type couponsType,
is_recommend isRecommend, use_rule useRule,disc_value discValue, full_cut_value fullCutValue,
need_integral needIntegral, is_superp_use isSuperpUse, begin_time beginTime, end_time endTime,
card_rest_num cardRestNum, card_num cardNum, card_state cardState, card_remarks cardRemarks,
a.data_state dataState, a.create_empid createEmpid, a.create_date createDate, a.modfiy_empid modfiyEmpid,
a.modfiy_date modfiyDate,GROUP_CONCAT(b.pl_no) plNos,a.card_content as cardContent,
a.valid_days validDays, a.receive_channels receiveChannels, a.receive_num receiveNum,
a.org_id orgId
FROM
td_c_coupon_rule a
LEFT JOIN td_c_coupon_rule_park b ON a.card_no = b.card_no
WHERE 1 = 1
AND a.data_state = 1
AND a.card_state = 1
and a.receive_num > 0
AND a.end_time >= #{queryDate} /***只查询在有效期内的券 **/
AND #{queryDate} >= a.begin_time /***只查询在有效期内的券 **/
<if test="orgId != null">
and a.org_id = #{orgId}
</if>
<if test="cardNos != null and cardNos.size > 0 ">
and a.card_no in
<foreach collection="cardNos" item="cardNo" open="(" close=")" separator=",">
#{cardNo}
</foreach>
</if>
<if test="cardTypes != null and cardTypes.size > 0 ">
and a.card_type in
<foreach collection="cardTypes" item="cardType" open="(" close=")" separator=",">
#{cardType}
</foreach>
</if>
<if test="receiveChannelsList != null and receiveChannelsList.size > 0 ">
and a.receive_channels in
<foreach collection="receiveChannelsList" item="receiveChannels" open="(" close=")" separator=",">
#{receiveChannels}
</foreach>
</if>
GROUP BY
a.id,a.card_no,a.card_name,card_res, card_type, coupons_type, is_recommend, use_rule,
disc_value, full_cut_value, need_integral, is_superp_use, begin_time, end_time, card_rest_num,
card_num, card_state, card_remarks, a.data_state, a.create_empid, a.create_date, a.modfiy_empid,
a.modfiy_date,a.card_content,a.valid_days, a.receive_channels, a.receive_num,a.org_id
ORDER BY card_res ASC ,card_type ASC,begin_time ASC
</select>
<!--查询热门优惠券 langlw 2017-12-28 Query the hot coupon -->
<select id="queryHotCouponRuleForList" parameterType="com.zteits.clouds.api.dto.pay.param.QueryHotCouponRequest"
resultType="com.zteits.clouds.api.dto.pay.TdCCouponRuleDTO">
SELECT
a.card_no AS cardNo,
a.card_name AS cardName,
a.card_type AS cardType,
a.coupons_type AS couponsType,
a.use_rule AS useRule,
a.disc_value AS discValue,
a.full_cut_value AS fullCutValue,
a.need_integral AS needIntegral,
a.is_superp_use AS isSuperpUse,
a.card_rest_num AS cardRestNum,
a.card_num AS cardNum,
a.card_state AS cardState,
a.begin_time AS beginTime,
a.end_time AS endTime,
a.create_date AS createDate,
a.card_content as cardContent,
a.valid_days validDays,
a.receive_channels receiveChannels,
a.receive_num receiveNum,
a.org_id orgId
FROM
td_c_coupon_rule a
WHERE
a.data_state = 1
<if test="orgId != null">
and a.org_id = #{orgId}
</if>
<if test="cardNos != null and cardNos.size > 0 ">
and a.card_no in
<foreach collection="cardNos" item="cardNo" open="(" close=")" separator=",">
#{cardNo}
</foreach>
</if>
<if test="cardTypes != null and cardTypes.size > 0 ">
and a.card_type in
<foreach collection="cardTypes" item="cardType" open="(" close=")" separator=",">
#{cardType}
</foreach>
</if>
<if test="receiveChannelsList != null and receiveChannelsList.size > 0 ">
and a.receive_channels in
<foreach collection="receiveChannelsList" item="receiveChannels" open="(" close=")" separator=",">
#{receiveChannels}
</foreach>
</if>
AND a.card_state = 1 /**卡券状态:1、上架;2、下架 **/
AND a.end_time >= #{queryDate} /***只查询在有效期内的券 **/
AND #{queryDate} >= a.begin_time /***只查询在有效期内的券 **/
and a.card_rest_num >0
ORDER BY round(a.card_rest_num/a.card_num,3) ASC
limit 3
</select>
<!--查询冷门优惠券 langlw 2017-12-28 Query the cold coupon -->
<select id="queryColdCouponRuleForList" parameterType="com.zteits.clouds.api.dto.pay.param.QueryHotCouponRequest"
resultType="com.zteits.clouds.api.dto.pay.TdCCouponRuleDTO">
SELECT
a.card_no AS cardNo,
a.card_name AS cardName,
a.card_type AS cardType,
a.coupons_type AS couponsType,
a.use_rule AS useRule,
a.disc_value AS discValue,
a.full_cut_value AS fullCutValue,
a.need_integral AS needIntegral,
a.is_superp_use AS isSuperpUse,
a.card_rest_num AS cardRestNum,
a.card_num AS cardNum,
a.card_state AS cardState,
a.begin_time AS beginTime,
a.end_time AS endTime,
a.create_date AS createDate,
a.card_content as cardContent,
a.valid_days validDays,
a.receive_channels receiveChannels,
a.receive_num receiveNum,
a.org_id orgId
FROM
td_c_coupon_rule a
WHERE
a.data_state = 1
<if test="orgId != null">
and a.org_id = #{orgId}
</if>
<if test="cardNos != null and cardNos.size > 0 ">
and a.card_no in
<foreach collection="cardNos" item="cardNo" open="(" close=")" separator=",">
#{cardNo}
</foreach>
</if>
<if test="cardTypes != null and cardTypes.size > 0 ">
and a.card_type in
<foreach collection="cardTypes" item="cardType" open="(" close=")" separator=",">
#{cardType}
</foreach>
</if>
<if test="receiveChannelsList != null and receiveChannelsList.size > 0 ">
and a.receive_channels in
<foreach collection="receiveChannelsList" item="receiveChannels" open="(" close=")" separator=",">
#{receiveChannels}
</foreach>
</if>
AND a.card_state = 1 /**卡券状态:1、上架;2、下架 **/
AND a.end_time >= #{queryDate} /***只查询在有效期内的券 **/
AND #{queryDate} >= a.begin_time /***只查询在有效期内的券 **/
and a.is_recommend = 1
and a.card_rest_num > 0
order by a.create_date desc
limit 3
</select>
<!--根据卡类型查询优惠券详细信息 xiejp 2017-12-27 Query the coupon rule table based on the card type-->
<select id="queryCouponRuleParkMsg" parameterType="com.zteits.clouds.api.dto.pay.param.TdCCouponRuleRequest"
resultType="com.zteits.clouds.api.dto.pay.TdCCouponRuleDTO">
SELECT
a.card_no AS cardNo,
a.card_name AS cardName,
a.card_type AS cardType,
a.coupons_type AS couponsType,
a.use_rule AS useRule,
a.disc_value AS discValue,
a.full_cut_value AS fullCutValue,
a.need_integral AS needIntegral,
a.is_superp_use AS isSuperpUse,
a.card_rest_num AS cardRestNum,
a.card_num AS cardNum,
a.card_state AS cardState,
a.begin_time AS beginTime,
a.end_time AS endTime,
a.create_date AS createDate,
a.card_content as cardContent,
a.valid_days validDays,
a.receive_channels receiveChannels,
a.receive_num receiveNum,
a.org_id orgId,
b.pl_no as plNo
FROM
td_c_coupon_rule a LEFT JOIN td_c_coupon_rule_park b on a.card_no = b.card_no
WHERE a.card_no = #{cardNo}
</select>
<select id="selectByCardNo" parameterType="java.lang.String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from td_c_coupon_rule
where card_no = #{cardNo,jdbcType=VARCHAR}
</select>
<!-- 查询是否存在重复的卡券编码 -->
<select id="queryCouponRuleByCardNoList" resultMap="BaseResultMap">
select card_no
from td_c_coupon_rule
where
<if test="cardNos != null and cardNos.size > 0 ">
card_no in
<foreach collection="cardNos" item="cardNo" open="(" close=")" separator=",">
#{cardNo}
</foreach>
</if>
</select>
<!-- 批量插入停车卡券 -->
<insert id="saveCouponRuleList" parameterType="java.util.List">
insert into td_c_coupon_rule (card_no, card_name, card_res,
card_type, coupons_type, is_recommend,
use_rule, disc_value, full_cut_value,
need_integral, is_superp_use, begin_time,
end_time, card_rest_num, card_num,
card_state, card_remarks, data_state,
create_empid, create_date, modfiy_empid,
modfiy_date, card_content, valid_days,
receive_channels, receive_num, org_id,
is_uesed, batch_no)
values
<foreach collection="tdCCouponRuleList" item="item" index="index" separator=",">
(#{item.cardNo,jdbcType=VARCHAR}, #{item.cardName,jdbcType=VARCHAR}, #{item.cardRes,jdbcType=INTEGER},
#{item.cardType,jdbcType=INTEGER}, #{item.couponsType,jdbcType=INTEGER}, #{item.isRecommend,jdbcType=INTEGER},
#{item.useRule,jdbcType=INTEGER}, #{item.discValue,jdbcType=VARCHAR}, #{item.fullCutValue,jdbcType=INTEGER},
#{item.needIntegral,jdbcType=INTEGER}, #{item.isSuperpUse,jdbcType=INTEGER}, #{item.beginTime,jdbcType=TIMESTAMP},
#{item.endTime,jdbcType=TIMESTAMP}, #{item.cardRestNum,jdbcType=INTEGER}, #{item.cardNum,jdbcType=INTEGER},
#{item.cardState,jdbcType=INTEGER}, #{item.cardRemarks,jdbcType=VARCHAR}, #{item.dataState,jdbcType=INTEGER},
#{item.createEmpid,jdbcType=VARCHAR}, #{item.createDate,jdbcType=TIMESTAMP}, #{item.modfiyEmpid,jdbcType=VARCHAR},
#{item.modfiyDate,jdbcType=TIMESTAMP}, #{item.cardContent,jdbcType=VARCHAR}, #{item.validDays,jdbcType=INTEGER},
#{item.receiveChannels,jdbcType=INTEGER}, #{item.receiveNum,jdbcType=INTEGER}, #{item.orgId,jdbcType=BIGINT},
#{item.isUesed,jdbcType=INTEGER}, #{item.batchNo,jdbcType=VARCHAR})
</foreach>
</insert>
</mapper>