TVipCardCustInfoSmapper.xml
25 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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
<?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.bill.mapper.smapper.TVipCardCustInfoSmapper">
<resultMap id="BaseResultMap" type="com.zteits.bill.domain.TVipCardCustInfo">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="cust_id" jdbcType="VARCHAR" property="custId"/>
<result column="cust_card_no" jdbcType="VARCHAR" property="custCardNo"/>
<result column="card_no" jdbcType="VARCHAR" property="cardNo"/>
<result column="car_number" jdbcType="VARCHAR" property="carNumber"/>
<result column="card_res" jdbcType="INTEGER" property="cardRes"/>
<result column="car_type" jdbcType="INTEGER" property="carType"/>
<result column="price" jdbcType="BIGINT" property="price"/>
<result column="num" jdbcType="INTEGER" property="num"/>
<result column="discount_amount" jdbcType="BIGINT" property="discountAmount"/>
<result column="disc_no" jdbcType="VARCHAR" property="discNo"/>
<result column="disc_rule_no" jdbcType="VARCHAR" property="discRuleNo"/>
<result column="total_amount" jdbcType="BIGINT" property="totalAmount"/>
<result column="eff_date" jdbcType="TIMESTAMP" property="effDate"/>
<result column="exp_date" jdbcType="TIMESTAMP" property="expDate"/>
<result column="is_support_renew" jdbcType="INTEGER" property="isSupportRenew"/>
<result column="remark" jdbcType="VARCHAR" property="remark"/>
<result column="data_state" jdbcType="INTEGER" property="dataState"/>
<result column="check_status" jdbcType="INTEGER" property="checkStatus"/>
<result column="create_empid" jdbcType="BIGINT" property="createEmpid"/>
<result column="create_name" jdbcType="VARCHAR" property="createName"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="modify_empid" jdbcType="BIGINT" property="modifyEmpid"/>
<result column="modify_name" jdbcType="VARCHAR" property="modifyName"/>
<result column="modify_date" jdbcType="TIMESTAMP" property="modifyDate"/>
<result column="parent_cust_card_no" jdbcType="VARCHAR" property="parentCustCardNo"/>
<result column="update_num" jdbcType="INTEGER" property="updateNum"/>
</resultMap>
<sql id="Base_Column_List">
id, cust_id, cust_card_no, card_no, car_number, card_res, car_type, price, num, discount_amount,
disc_no, disc_rule_no, total_amount, eff_date, exp_date, is_support_renew, remark,
data_state, check_status, create_empid, create_name, create_date, modify_empid, modify_name,
modify_date,parent_cust_card_no,update_num
</sql>
<!--用户购买会员卡记录-->
<select id="queryVipCardCustInfoForList"
parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.VipCardCustInfoBuyReq"
resultType="com.zteits.bill.domain.sdomain.VipCardCustInfoBuyDO">
select
tv.id AS pushId,
tv.push_state AS pushState,
a.id as id,
a.card_no as cardNo,
b.card_name as cardName,
b.card_type as cardType,
b.eff_date as cardEffDate,
b.exp_date as cardExpDate,
b.car_type as carType,
a.cust_id as peronCustId,
a.cust_card_no as custCardNo,
a.num as num,
a.car_number as carNumber,
tv.pl_no as plNo,
a.price as price,
a.eff_date as effDate,
a.exp_date as expDate,
a.create_date as createDate,
a.discount_amount as discountAmount,
a.total_amount as totalAmount,
ifnull(a.total_amount,0) - ifnull(a.discount_amount,0) as actFee,
a.create_empid as createEmpid,
a.create_name as createName,
a.modify_name as modifyName,
a.modify_date as modifyDate,
a.cust_name as personCustName,
a.cust_phone as userPhone
from t_vip_card_cust_info a ,t_vip_card b ,
(SELECT
c.cust_card_no,
c.pl_no,
c.push_state,
c.id
FROM
t_vip_card_park_cust_rel c
group by c.cust_card_no,c.pl_no,c.push_state,c.id) tv
where a.card_no=b.card_no
and tv.cust_card_no = a.cust_card_no
and a.data_state=1
and b.data_state=1
<if test="plNos != null and plNos.size >0">
and tv.pl_no in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
</if>
<if test="carType != null ">
and b.car_type =#{carType}
</if>
<if test="cardType != null ">
and b.card_type =#{cardType}
</if>
<if test="carNumber != null and carNumber !=''">
and a.car_number like CONCAT('%',#{carNumber},'%')
</if>
<if test="beginTime != null ">
<![CDATA[and a.create_date >= #{beginTime}]]>
</if>
<if test="endTime !=null ">
<![CDATA[and a.create_date <= #{endTime}]]>
</if>
/**卡状态:1:全部 2:生效中 3:近期失效7 4:已失效.*/
<if test="cardStateTag == 2 ">
<![CDATA[ and a.eff_date <= now() and now() <= a.exp_date ]]>
</if>
<if test="cardStateTag == 3 ">
<![CDATA[ and a.exp_date >= now() and a.exp_date <= date_add(now(), interval 7 day) ]]>
</if>
<if test="cardStateTag == 4 ">
<![CDATA[ and a.exp_date < now() ]]>
</if>
order by a.create_date desc
</select>
<!--批量保存用户购买会员卡记录-->
<insert id="batchSaveVipCardCustInfo">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into t_vip_card_cust_info (cust_id, cust_card_no, card_no,
car_number, card_res, car_type,
price, num, discount_amount,
disc_no,disc_rule_no, total_amount, eff_date,
exp_date, is_support_renew,remark, data_state,
check_status, create_empid, create_name,
create_date)
values
<foreach collection="vipCardCustInfoList" item="item" index="index" separator=",">
(#{item.custId,jdbcType=VARCHAR}, #{item.custCardNo,jdbcType=VARCHAR}, #{item.cardNo,jdbcType=VARCHAR},
#{item.carNumber,jdbcType=VARCHAR}, #{item.cardRes,jdbcType=INTEGER}, #{item.carType,jdbcType=INTEGER},
#{item.price,jdbcType=BIGINT}, #{item.num,jdbcType=INTEGER}, #{item.discountAmount,jdbcType=BIGINT},
#{item.discNo,jdbcType=VARCHAR}, #{item.discRuleNo,jdbcType=VARCHAR}, #{item.totalAmount,jdbcType=BIGINT},
#{item.effDate,jdbcType=TIMESTAMP},
#{item.expDate,jdbcType=TIMESTAMP}, #{item.isSupportRenew,jdbcType=INTEGER},#{item.remark,jdbcType=VARCHAR},
#{item.dataState,jdbcType=INTEGER},
#{item.checkStatus,jdbcType=INTEGER}, #{item.createEmpid,jdbcType=BIGINT},
#{item.createName,jdbcType=VARCHAR},
#{item.createDate,jdbcType=TIMESTAMP})
</foreach>
</insert>
<select id="queryVipCardCustInfoByCustId"
parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardCustInfoByCustIdRequest"
resultMap="BaseResultMap">
select
<include refid="Base_Column_List"></include>
from t_vip_card_cust_info
where data_state=1
<if test="custId != null and custId !=''">
and cust_id =#{custId}
</if>
<if test="id !=null">
and id =#{id}
</if>
<if test="custCardNo != null and custCardNo !=''">
and cust_card_no =#{custCardNo}
</if>
</select>
<!--通过车牌,停车场编码查询车辆是否购买会员卡-->
<select id="queryCarNumIsBuyVipCard" resultType="com.zteits.bill.domain.TVipCardCustInfo">
select a.card_no as cardNo,
a.cust_card_no as custCardNo,
a.car_number as carNumber,
a.car_type as carType
from t_vip_card_cust_info a ,
t_vip_card_park_cust_rel b
where a.data_state=b.data_state
and a.data_state=1
and a.check_status=3 /**审核状态1:待审核 2: 审核不通过 3:审核通过*/
and a.cust_card_no=b.cust_card_no
and a.car_type=#{request.carType} /**车辆类型 1:大型车 2:小型车*/
and a.car_number =#{request.carNumber}
and b.pl_no = #{request.plNo}
<![CDATA[and a.eff_date <= #{currentDate}]]>
<![CDATA[and a.exp_date >= #{currentDate}]]>
limit 0,1
</select>
<!-- 查询未推送的会员卡数据 -->
<select id="queryNoPustVipCardCustInfo" resultType="com.zteits.bill.domain.TVipNoPushCardCustInfoDO">
SELECT
a.cust_id custId,
a.cust_card_no custCardNo,
a.card_no cardNo,
a.car_number carNumber,
a.remark remark,
a.eff_date as effDate,
a.exp_date as expDate,
b.id id,
b.pl_no plNo,
b.push_state as pushState,
b.card_buy_type as cardBuyType,
c.special_day_type as specialDayType,
c.valid_start_time as validStartTime,
c.valid_end_time as validEndTime,
a.parent_cust_card_no as parentCustCardNo,
b.record_no as recordNo
FROM
t_vip_card_cust_info a,
t_vip_card_park_cust_rel b,
t_vip_card c
WHERE
a.cust_card_no = b.cust_card_no
and c.card_no = a.card_no
and c.data_state = 1
AND a.cust_id = b.cust_id
and a.check_status = 3
and b.push_state = 0
<if test="id != null ">
and b.id =#{id}
</if>
<![CDATA[and a.eff_date <= #{currentDate}]]>
order by a.id
</select>
<!-- 查询未推送和已推送的会员卡数据 -->
<select id="queryPustVipCardCustInfo" resultType="com.zteits.bill.domain.TVipNoPushCardCustInfoDO">
SELECT
a.cust_id custId,
a.cust_card_no custCardNo,
a.card_no cardNo,
a.car_number carNumber,
a.remark remark,
a.eff_date as effDate,
a.exp_date as expDate,
b.id id,
b.pl_no plNo,
b.push_state as pushState,
b.card_buy_type as cardBuyType,
c.special_day_type as specialDayType,
c.valid_start_time as validStartTime,
c.valid_end_time as validEndTime,
a.parent_cust_card_no as parentCustCardNo,
b.record_no as recordNo
FROM
t_vip_card_cust_info a,
t_vip_card_park_cust_rel b,
t_vip_card c
WHERE
a.cust_card_no = b.cust_card_no
and c.card_no = a.card_no
and c.data_state = 1
AND a.cust_id = b.cust_id
and a.check_status = 3
and b.id =#{id}
<![CDATA[and a.eff_date <= #{currentDate}]]>
ORDER BY id desc;
</select>
<!-- 查询未推送给艾润优惠券的车牌信息 zwg 20180330 -->
<select id="queryCouponNoPushInfo" resultType="com.zteits.bill.domain.TVipNoPushCardCustInfoDO"
parameterType="java.lang.String">
SELECT
b.pl_no as plNo,
b.car_number as carNumber,
b.cust_id as custId,
b.cust_card_no as custCardNo,
a.card_no as cardNo,
c.special_day_type as specialDayType,
b.id as id
FROM
t_vip_card_cust_info a,
t_vip_card_park_cust_rel b,
t_vip_card c
WHERE
a.cust_card_no = b.cust_card_no
AND c.card_no = a.card_no
AND c.data_state = 1
AND b.data_state = 1
AND a.cust_id = b.cust_id
AND a.data_state = 1
AND b.push_state = 1
and c.card_type in (6,7) <!--卡类型为:6-错峰年卡(周末免费);7-错峰月卡(周末免费) -->
<![CDATA[and a.exp_date >= #{date}]]> <!-- 失效时间大于等于传递的时间 -->
and b.pl_no like 'P11010%' <!-- 只查询西城停车场的数据 -->
AND NOT EXISTS ( <!-- 去除已经推送成功的 -->
SELECT 1 FROM t_coupon_push_log log
WHERE log.card_park_cust_rel_id = b.id
<![CDATA[AND log.time_start <= #{date} AND log.time_end >= #{date} ]]>
and log.push_state = 1 <!-- 已经推送成功的 -->
)
</select>
<select id="queryNoPustVipCardCustInfoByCarNum" resultType="java.lang.Integer"
parameterType="com.zteits.bill.domain.TVipCardCustInfo">
SELECT
count(1)
FROM
t_vip_card_cust_info a,t_vip_card_park_cust_rel b
WHERE
a.data_state = 1
and a.cust_card_no = b.cust_card_no
<![CDATA[ and a.exp_date >= #{createDate}]]>
<![CDATA[AND ((#{effDate} >= a.eff_date AND #{effDate} <= a.exp_date)
OR (#{expDate} >= a.eff_date AND #{expDate} <= a.exp_date)
OR (#{effDate} <= a.eff_date AND #{expDate} >= a.exp_date )
OR (#{effDate} > a.eff_date AND #{expDate} < a.exp_date))
]]>
AND a.car_number = #{carNumber}
AND b.pl_no=#{plNo}
</select>
<!--分页查询-会员卡记录(订单管理-会员卡记录页面)-->
<select id="queryVipCardBuyInfoForPage"
parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardBuyInfoForPageRequest"
resultType="com.zteits.bill.domain.VipCardBuyInfoDO">
select
a.cust_card_no as custCardNo,
a.cust_id as personCustId,
a.car_number as carNumber,
b.card_type as cardType,
a.num as num,
a.price as price,
a.total_amount as totalAmount,
a.eff_date as effDate,
a.exp_date as expDate,
a.create_date as createDate,
a.create_empid as createEmpid,
a.create_name as createName
from t_vip_card_cust_info a ,
t_vip_card b ,
(select c.cust_card_no
from t_vip_card_park_cust_rel c
where c.data_state=1
<if test="plNos != null and plNos.size >0">
and c.pl_no in
<foreach collection="plNos" open="(" close=")" item="parkId" separator=",">
#{parkId}
</foreach>
</if>
GROUP BY c.cust_card_no
) dd
where a.data_state=1
and a.card_no=b.card_no
and dd.cust_card_no=a.cust_card_no
<if test="beginTime != null and beginTime !=''">
<![CDATA[and a.create_date >= #{beginTime}]]>
</if>
<if test="endTime != null and endTime !=''">
<![CDATA[and a.create_date <= #{endTime}]]>
</if>
<if test="carNum != null and carNum !=''">
and a.car_number=#{carNum}
</if>
</select>
<!-- 账单管理 底层会员卡数据查询,获取时间段内会员卡购买汇总
-->
<select id="queryVipCardForPerson" resultType="com.zteits.bill.domain.TdBVipCardInfoCheckDayDO">
select
b.cust_card_no as custCardNo,
DATE_FORMAT(b.create_date,'%Y-%m-%d') as checkDate,
cc.pl_no as plNo,
(case when cc.plNoCounts >1 then
'301'
ELSE
'300'
end) as checkFeeType,
sum(b.price * b.num - IFNULL(b.discount_amount,0)) as dicountFee,
sum(IFNULL(b.discount_amount,0)) as actFee ,
sum(b.price * b.num) as totalFee,
'0' as aliFee,
'0' as aliChargeNum,
'0' as wxFee,
'0' as wxChargeNum,
'0' as cashFee,
'0' as cashChargeNum,
'0' as balanceFee,
'0' as balanceChargeNum,
'1' as dataState,
now() as createDate
from t_vip_card_cust_info b ,
(SELECT
max(a.pl_no) pl_no ,
a.cust_card_no,
count(a.cust_card_no) as plNoCounts
FROM
t_vip_card_park_cust_rel a
group by a.cust_card_no ) cc
where cc.cust_card_no=b.cust_card_no
<![CDATA[and b.create_date >=#{beginTime}]]>
<![CDATA[and b.create_date <=#{endTime}]]>
group by cc.pl_no, DATE_FORMAT(b.create_date,'%Y-%m-%d'),b.cust_card_no
</select>
<!-- 通过custCardNo修改个人会员卡 -->
<update id="updateVipCardCustInfoByCustCardNo" parameterType="com.zteits.bill.domain.TVipCardCustInfo">
update t_vip_card_cust_info
<set>
<if test="custId != null">
cust_id = #{custId,jdbcType=VARCHAR},
</if>
<if test="cardNo != null">
card_no = #{cardNo,jdbcType=VARCHAR},
</if>
<if test="carNumber != null">
car_number = #{carNumber,jdbcType=VARCHAR},
</if>
<if test="cardRes != null">
card_res = #{cardRes,jdbcType=INTEGER},
</if>
<if test="carType != null">
car_type = #{carType,jdbcType=INTEGER},
</if>
<if test="price != null">
price = #{price,jdbcType=BIGINT},
</if>
<if test="num != null">
num = #{num,jdbcType=INTEGER},
</if>
<if test="discountAmount != null">
discount_amount = #{discountAmount,jdbcType=BIGINT},
</if>
<if test="discNo != null">
disc_no = #{discNo,jdbcType=VARCHAR},
</if>
<if test="discRuleNo != null">
disc_rule_no = #{discRuleNo,jdbcType=VARCHAR},
</if>
<if test="totalAmount != null">
total_amount = #{totalAmount,jdbcType=BIGINT},
</if>
<if test="effDate != null">
eff_date = #{effDate,jdbcType=TIMESTAMP},
</if>
<if test="expDate != null">
exp_date = #{expDate,jdbcType=TIMESTAMP},
</if>
<if test="isSupportRenew != null">
is_support_renew = #{isSupportRenew,jdbcType=INTEGER},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="dataState != null">
data_state = #{dataState,jdbcType=INTEGER},
</if>
<if test="checkStatus != null">
check_status = #{checkStatus,jdbcType=INTEGER},
</if>
<if test="createEmpid != null">
create_empid = #{createEmpid,jdbcType=BIGINT},
</if>
<if test="createName != null">
create_name = #{createName,jdbcType=VARCHAR},
</if>
<if test="createDate != null">
create_date = #{createDate,jdbcType=TIMESTAMP},
</if>
<if test="modifyEmpid != null">
modify_empid = #{modifyEmpid,jdbcType=BIGINT},
</if>
<if test="modifyName != null">
modify_name = #{modifyName,jdbcType=VARCHAR},
</if>
<if test="modifyDate != null">
modify_date = #{modifyDate,jdbcType=TIMESTAMP},
</if>
<if test="updateNum != null">
update_num = #{updateNum,jdbcType=INTEGER},
</if>
</set>
where cust_card_no = #{custCardNo,jdbcType=VARCHAR}
</update>
<select id="selectVipCardCustInfoByCustCardNo" resultType="java.lang.Integer" parameterType="java.lang.String">
select
count(1)
from t_vip_card_cust_info
where cust_card_no = #{custCardNo,jdbcType=VARCHAR}
</select>
<select id="queryCardCustInfoBycustCardNo" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_vip_card_cust_info
where cust_card_no = #{custCardNo,jdbcType=VARCHAR}
and data_state = 1
</select>
<select id="selectVipCardCustInfoByCardNo" resultType="java.lang.Integer" parameterType="java.lang.String">
select
count(1)
from t_vip_card_cust_info
where card_no = #{cardNo,jdbcType=VARCHAR}
and data_state = 1
</select>
<!--根据失效时间查询会员卡信息-->
<select id="queryVipCardByExpireDate" resultType="com.zteits.clouds.api.dto.bill.vipcard.VipCardExpireWarnPushDTO">
SELECT
a.cust_card_no as custCardNo,
a.car_number as carNumber,
a.cust_id as custId,
b.pl_no as plNo,
DATE_FORMAT(a.exp_date,'%Y-%m-%d') as expDate
FROM
t_vip_card_cust_info a,
t_vip_card_park_cust_rel b
where 1=1
and a.cust_card_no=b.cust_card_no
and a.data_state=b.data_state
and a.data_state=1
<![CDATA[and a.exp_date >=#{beginTime}
and a.exp_date <=#{endTime}
]]>
</select>
<!-- 根据停车场编号与车牌号码查询当前有效的会员车信息 -->
<select id="queryCardCustInfoByParkcodeAndCarnumber" resultType="com.zteits.bill.domain.TVipCardCustInfo">
SELECT
a.card_no cardNo,
a.car_number carNumber,
b.pl_no parkCode,
a.eff_date as effDate,
a.exp_date as expDate
FROM
t_vip_card_cust_info a,
t_vip_card_park_cust_rel b,
t_vip_card c
WHERE
a.cust_card_no = b.cust_card_no
and c.card_no = a.card_no
and c.data_state = 1
AND a.cust_id = b.cust_id
and a.check_status = 3 <!-- 审核状态1:待审核 2: 审核不通过 3:审核通过 -->
and a.exp_date >= now()
and a.eff_date <= now()
<if test="plNo != null and plNo != ''">
and b.pl_no = #{plNo}
</if>
<if test="carNumber != null and carNumber != ''">
and a.car_number = #{carNumber}
</if>
limit 1
</select>
<!-- 停车场编号与车牌号码查询该车所有有效的会员卡记录,包括已过期数据 -->
<select id="queryAllCardCustInfoByParkcodeAndCarnumber"
resultType="com.zteits.clouds.api.dto.bill.vipcard.VipCardCustInfoDTO">
SELECT
a.card_no cardNo,
a.car_number carNumber,
b.pl_no parkCode,
a.eff_date AS effDate,
a.exp_date AS expDate,
c.valid_start_time AS validStartTime,
c.valid_end_time AS validEndTime,
c.card_name AS cardName
FROM
t_vip_card_cust_info a,
t_vip_card_park_cust_rel b,
t_vip_card c
WHERE
a.cust_card_no = b.cust_card_no
AND c.card_no = a.card_no
AND c.data_state = 1
AND a.cust_id = b.cust_id
AND a.check_status = 3
<if test="plNo != null and plNo != ''">
and b.pl_no = #{plNo}
</if>
<if test="carNumber != null and carNumber != ''">
and a.car_number = #{carNumber}
</if>
ORDER BY
a.eff_date ASC
</select>
<select id="queryAllCardCustInfoByCardNoAndCarnumber"
resultType="com.zteits.clouds.api.dto.bill.vipcard.VipCardCustInfoDTO">
SELECT
a.card_no cardNo,
a.car_number carNumber,
b.pl_no parkCode,
a.eff_date AS effDate,
a.exp_date AS expDate
FROM
t_vip_card_cust_info a,
t_vip_card_park_cust_rel b,
t_vip_card c
WHERE
a.cust_card_no = b.cust_card_no
AND c.card_no = a.card_no
AND c.data_state = 1
AND a.cust_id = b.cust_id
AND a.check_status = 3
<if test="cardNo != null and cardNo != ''">
and a.card_no = #{cardNo}
</if>
<if test="carNumber != null and carNumber != ''">
and a.car_number = #{carNumber}
</if>
ORDER BY
a.eff_date ASC
</select>
<select id="queryAllActiveInfo" resultType="com.zteits.bill.domain.TVipCardCustInfo">
SELECT c.car_number as carNumber FROM t_vip_card_cust_info c
left join t_vip_card t
on c.card_no = t.card_no
where
t.org_id = #{orgId}
and c.data_state = 1
and t.data_state = 1
and c.eff_date < now()
and c.exp_date > now()
</select>
<!-- 重置会员卡修改次数 -->
<update id="resetVipCardUpdateNum" parameterType="java.lang.Integer">
UPDATE t_vip_card_cust_info
SET update_num = #{updateNum}
WHERE data_state = 1
</update>
<!--检验会员卡购买数量-->
<select id="checkVipCarBuyNum" resultType="com.zteits.clouds.api.dto.bill.vipcard.VipCardInfoBuyNumDTO">
SELECT DATE_FORMAT(#{startTime}, '%Y-%m') as buyDate,
count(*) as alreadyBuyNum
FROM t_vip_card_cust_info a
WHERE a.data_state = 1
and a.card_no=#{cardNo}
<![CDATA[
and DATE_FORMAT(a.eff_date, '%Y-%m') <= DATE_FORMAT(#{startTime}, '%Y-%m')
and DATE_FORMAT(a.exp_date, '%Y-%m') >= DATE_FORMAT(#{startTime}, '%Y-%m')
and ((a.eff_date <= #{startTime} and #{startTime} <= a.exp_date)
or (a.eff_date <= #{endTime} and #{endTime} <= a.exp_date))
]]>
group by buyDate
</select>
<!--检验会员卡购买数量-->
<select id="queryParentCard"
parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardCustInfoByCustIdRequest"
resultType="com.zteits.clouds.api.dto.bill.vipcard.VipCardCustInfoDTO">
SELECT
cust_card_no custCardNo,
exp_date expDate
from t_vip_card_cust_info
where data_state = 1
and eff_date = #{effDate}
and cust_card_no = #{custCardNo}
</select>
</mapper>