TVipAreaCardCustInfoSMapper.xml
27.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
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
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
<?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.TVipAreaCardCustInfoSMapper">
<resultMap id="BaseResultMap" type="com.zteits.bill.domain.TVipAreaCardCustInfo">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="cust_card_no" jdbcType="VARCHAR" property="custCardNo" />
<result column="card_no" jdbcType="VARCHAR" property="cardNo" />
<result column="parent_cust_card_no" jdbcType="VARCHAR" property="parentCustCardNo" />
<result column="car_number" jdbcType="VARCHAR" property="carNumber" />
<result column="phone" jdbcType="VARCHAR" property="phone" />
<result column="msg_state" jdbcType="INTEGER" property="msgState" />
<result column="res_code" jdbcType="VARCHAR" property="resCode" />
<result column="res_message" jdbcType="VARCHAR" property="resMessage" />
<result column="idertifier" jdbcType="VARCHAR" property="idertifier" />
<result column="card_res" jdbcType="INTEGER" property="cardRes" />
<result column="buy_type" jdbcType="INTEGER" property="buyType" />
<result column="num" jdbcType="INTEGER" property="num" />
<result column="discount_amount" jdbcType="BIGINT" property="discountAmount" />
<result column="act_amount" jdbcType="BIGINT" property="actAmount" />
<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="data_state" jdbcType="INTEGER" property="dataState" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="create_empid" jdbcType="VARCHAR" property="createEmpid" />
<result column="create_name" jdbcType="VARCHAR" property="createName" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="modify_empid" jdbcType="VARCHAR" property="modifyEmpid" />
<result column="modify_name" jdbcType="VARCHAR" property="modifyName" />
<result column="modify_date" jdbcType="TIMESTAMP" property="modifyDate" />
<result column="org_id" jdbcType="BIGINT" property="orgId" />
<result column="org_name" jdbcType="VARCHAR" property="orgName" />
</resultMap>
<sql id="Base_Column_List">
id, cust_card_no, card_no, parent_cust_card_no, car_number, phone, msg_state, res_code,
res_message, idertifier, card_res, buy_type, num, discount_amount, act_amount, total_amount,
eff_date, exp_date, data_state, remark, create_empid, create_name, create_date, modify_empid,
modify_name, modify_date, org_id, org_name
</sql>
<!--条件分页查询区域卡-->
<select id="queryTVipAreaCardCustInfoForPage" resultType="com.zteits.clouds.api.dto.bill.dto.TVipAreaCardCustInfoDTO"
parameterType="com.zteits.clouds.api.dto.bill.param.TVipAreaCardCustInfoQueryRequest">
select
a.id as id,
a.card_no as cardNo,
b.card_name as cardName,
b.card_type as cardType,
b.area_card_type as areaCardType,
b.eff_date as cardEffDate,
b.exp_date as cardExpDate,
b.car_type as carType,
a.buy_type as buyType,
a.cust_card_no as custCardNo,
a.num as num,
a.car_number as carNumber,
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,
a.act_amount as actAmount,
a.create_empid as createEmpid,
a.create_name as createName,
a.modify_name as modifyName,
a.modify_date as modifyDate
from t_vip_area_card_cust_info a ,t_vip_area_card b,
(
SELECT
cust_card_no
FROM
t_vip_area_card_cust_info_rel
WHERE
data_state = 1
<if test="plNos != null and plNos.size >0">
and pl_no in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
</if>
GROUP BY
cust_card_no)c
where a.card_no=b.card_no
and a.cust_card_no = c.cust_card_no
and a.data_state=1
and a.type=1
and b.type=1
and a.org_id =#{orgId}
<if test="carType != null ">
and b.car_type =#{carType}
</if>
<if test="cardType != null ">
and b.card_type =#{cardType}
</if>
<if test="cardNo != null and cardNo !=''">
and a.card_no =#{cardNo}
</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>
<if test="cardRess != null and cardRess.size >0">
and a.card_res in
<foreach collection="cardRess" open="(" close=")" item="cardRes" separator=",">
#{cardRes}
</foreach>
</if>
<if test="buyTypes != null and buyTypes.size >0">
and a.buy_type in
<foreach collection="buyTypes" open="(" close=")" item="buyType" separator=",">
#{buyType}
</foreach>
</if>
<if test="carNumber != null and carNumber !=''">
and a.car_number like CONCAT('%',#{carNumber},'%')
</if>
order by a.create_date desc
</select>
<!-- 按照终端来源、卡类型 查询会员卡汇总信息 -->
<select id="queryVipAreaCardStatisticTotal" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardOrderDetailTotalReq"
resultType="com.zteits.clouds.api.dto.order.vipcardorder.dto.OrderVipAreacardDetailTotalDTO">
SELECT
a.buy_type as orderType,
b.card_type as cardType,
b.area_card_type as areaCardType,
a.card_res as terminalSource ,
IFNULL(a.act_amount,0) as cardActAmount
from t_vip_area_card_cust_info a ,t_vip_area_card b
where a.card_no=b.card_no
and EXISTS (
SELECT
cust_card_no
FROM
t_vip_area_card_cust_info_rel
WHERE
data_state = 1
<if test="plNos != null and plNos.size >0">
and pl_no in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
</if>
GROUP BY
cust_card_no)
and a.data_state=1
and a.type=1
and a.org_id =#{orgId}
<if test="carNumber != null and carNumber != '' ">
and a.car_number = #{carNumber}
</if>
<if test="orderTypes != null and orderTypes.size > 0">
and a.buy_type in
<foreach collection="orderTypes" item="orderType" open="(" close=")" separator=",">
#{orderType}
</foreach>
</if>
<![CDATA[AND a.create_date >= #{beginTime}]]>
<![CDATA[AND a.create_date <= #{endTime}]]>
</select>
<!--根据车牌查询区域卡-->
<select id="queryVipAreaCardInfoByCarNumbers" resultType="com.zteits.clouds.api.dto.bill.dto.TVipAreaCardCustInfoDTO"
parameterType="com.zteits.clouds.api.dto.bill.param.TVipAreaCardCustInfoQueryRequest">
select
a.id as id,
a.card_no as cardNo,
b.card_name as cardName,
b.card_type as cardType,
b.area_card_type as areaCardType,
b.eff_date as cardEffDate,
b.exp_date as cardExpDate,
b.car_type as carType,
b.card_status as cardStatus,
a.cust_card_no as custCardNo,
a.num as num,
a.car_number as carNumber,
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,
a.act_amount as actAmount,
a.create_empid as createEmpid,
a.create_name as createName,
a.modify_name as modifyName,
a.modify_date as modifyDate
from t_vip_area_card_cust_info a ,t_vip_area_card b
where a.card_no=b.card_no
and a.cust_card_no IN (
SELECT
cust_card_no
FROM
t_vip_area_card_cust_info_rel
WHERE
data_state = 1
GROUP BY
cust_card_no)
and a.data_state=1
and a.type=1
and a.org_id =#{orgId}
<if test="cardRess != null and cardRess.size >0">
and a.card_res in
<foreach collection="cardRess" open="(" close=")" item="cardRes" separator=",">
#{cardRes}
</foreach>
</if>
and a.car_number in
<foreach collection="carNumbers" open="(" close=")" item="carNumber" separator=",">
#{carNumber}
</foreach>
order by a.create_date desc
</select>
<!--APP根据车牌查询区域卡-->
<select id="queryVipAreaCardInfoByCarNumbersForApp" resultType="com.zteits.clouds.api.dto.bill.dto.TVipAreaCardCustInfoDTO"
parameterType="com.zteits.clouds.api.dto.bill.param.TVipAreaCardCustInfoQueryRequest">
select
a.id as id,
a.card_no as cardNo,
b.card_name as cardName,
b.card_type as cardType,
b.area_card_type as areaCardType,
b.eff_date as cardEffDate,
b.exp_date as cardExpDate,
b.car_type as carType,
b.card_status as cardStatus,
a.cust_card_no as custCardNo,
a.num as num,
a.car_number as carNumber,
a.parent_cust_card_no as parentCustCardNo,
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,
a.act_amount as actAmount,
a.create_empid as createEmpid,
a.create_name as createName,
a.modify_name as modifyName,
a.modify_date as modifyDate
from t_vip_area_card_cust_info a ,t_vip_area_card b
where a.card_no=b.card_no
and a.cust_card_no IN (
SELECT
cust_card_no
FROM
t_vip_area_card_cust_info_rel
GROUP BY
cust_card_no)
and a.org_id =#{orgId}
and a.type=1
and a.data_state = 1
<if test="cardRess != null and cardRess.size >0">
and a.card_res in
<foreach collection="cardRess" open="(" close=")" item="cardRes" separator=",">
#{cardRes}
</foreach>
</if>
and a.car_number in
<foreach collection="carNumbers" open="(" close=")" item="carNumber" separator=",">
#{carNumber}
</foreach>
<if test="type != null ">
and a.type =#{type}
</if>
order by a.create_date desc
</select>
<!-- 查询未推送的会员卡数据 -->
<select id="queryNoPustVipCardCustInfo" resultType="com.zteits.bill.domain.TVipNoPushCardCustInfoDO" >
SELECT
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,
a.buy_type as cardBuyType,
c.eff_date as validStartTime,
c.exp_date as validEndTime,
c.card_type as cardType,
a.parent_cust_card_no as parentCustCardNo,
b.record_no as recordNo
FROM
t_vip_area_card_cust_info a,
t_vip_area_card_cust_info_rel b,
t_vip_area_card c
WHERE
a.cust_card_no = b.cust_card_no
and c.card_no = a.card_no
and b.pl_no not in('P15040410013','P15040410012')
and a.data_state = 1
and a.type=1
and b.data_state = 1
AND a.car_number = b.car_number
and b.push_state = 0
<if test="id != null ">
and b.id =#{id}
</if>
<![CDATA[and a.eff_date <= #{currentDate}]]>
order by a.id desc
</select>
<!-- 查询未推送和已推送的会员卡数据 -->
<select id="queryPustVipCardCustInfo" resultType="com.zteits.bill.domain.TVipNoPushCardCustInfoDO" >
SELECT
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,
a.buy_type as cardBuyType,
c.eff_date as validStartTime,
c.exp_date as validEndTime,
a.parent_cust_card_no as parentCustCardNo,
b.record_no as recordNo
FROM
t_vip_area_card_cust_info a,
t_vip_area_card_cust_info_rel b,
t_vip_area_card c
WHERE
a.cust_card_no = b.cust_card_no
and c.card_no = a.card_no
and b.data_state = 1
and a.type=1
and b.id =#{id}
<![CDATA[and a.eff_date <= #{currentDate}]]>
ORDER BY id desc;
</select>
<!--查询是否购买区域卡-->
<select id="queryIsBuyVipCardCust" resultType="java.lang.Integer" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryIsBuyVipCardCustReq">
SELECT
count(*)
FROM
t_vip_area_card_cust_info a,
t_vip_area_card_cust_info_rel b
where a.cust_card_no=b.cust_card_no
and a.type=1
and a.data_state=1
and a.car_number=#{carNumber}
and b.pl_no=#{plNo}
<![CDATA[and a.eff_date <=#{dateTime}
and a.exp_date >=#{dateTime}]]>
</select>
<!--根据车场编码查询购买的区域卡(非失效)数量(车场编号-卡数量)-->
<select id="queryParkVipAreaCardNumByPlNo"
resultType="com.zteits.clouds.api.dto.order.vipcardorder.dto.ParkVipAreaCardNumDTO">
SELECT
IFNULL(SUM(num),0) as num
FROM
`t_vip_area_card_cust_info`
WHERE
data_state = 1
and `type`=1
AND exp_date > SYSDATE()
AND org_id = #{orgId}
AND cust_card_no IN (
SELECT
cust_card_no
FROM
t_vip_area_card_cust_info_rel
WHERE
data_state = 1
AND pl_no = #{plNo}
AND org_id = #{orgId}
)
</select>
<!-- 查询即将到期的区域卡 -->
<select id="queryExpireVipCardCustInfo" resultMap="BaseResultMap"
parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.VipAreaCardExpireRequest">
select
<include refid="Base_Column_List" />
from t_vip_area_card_cust_info
where data_state = 1
and type=1
and (exp_date = #{nowDate} or date(DATE_SUB(exp_date,INTERVAL 4 DAY)) = date(#{nowDate}) )
</select>
<!-- 时域卡 -->
<!--条件分页查询时域卡-->
<select id="queryTVipTimeCardCustInfoForPage" resultType="com.zteits.clouds.api.dto.bill.dto.TVipAreaCardCustInfoDTO"
parameterType="com.zteits.clouds.api.dto.bill.param.TVipAreaCardCustInfoQueryRequest">
select
a.id as id,
a.card_free_surplus_time as cardFreeSurplusTime,
a.card_free_time as cardFreeTime,
a.card_no as cardNo,
b.card_name as cardName,
b.card_type as cardType,
b.area_card_type as areaCardType,
b.eff_date as cardEffDate,
b.exp_date as cardExpDate,
b.car_type as carType,
a.buy_type as buyType,
a.cust_card_no as custCardNo,
a.num as num,
a.car_number as carNumber,
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,
a.act_amount as actAmount,
a.create_empid as createEmpid,
a.create_name as createName,
a.modify_name as modifyName,
a.modify_date as modifyDate
from t_vip_area_card_cust_info a ,t_vip_area_card b
where a.card_no=b.card_no
and a.data_state=1
and a.type=2
and b.type=2
and a.org_id =#{orgId}
<if test="carType != null ">
and b.car_type =#{carType}
</if>
<if test="cardType != null ">
and b.card_type =#{cardType}
</if>
<if test="cardNo != null and cardNo !=''">
and a.card_no =#{cardNo}
</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>
<if test="cardRess != null and cardRess.size >0">
and a.card_res in
<foreach collection="cardRess" open="(" close=")" item="cardRes" separator=",">
#{cardRes}
</foreach>
</if>
<if test="buyTypes != null and buyTypes.size >0">
and a.buy_type in
<foreach collection="buyTypes" open="(" close=")" item="buyType" separator=",">
#{buyType}
</foreach>
</if>
<if test="carNumber != null and carNumber !=''">
and a.car_number like CONCAT('%',#{carNumber},'%')
</if>
order by a.create_date desc
</select>
<!-- 按照终端来源、卡类型 查询时域会员卡汇总信息 -->
<select id="queryVipTimeCardStatisticTotal" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardOrderDetailTotalReq"
resultType="com.zteits.clouds.api.dto.order.vipcardorder.dto.OrderVipAreacardDetailTotalDTO">
SELECT
a.buy_type as orderType,
b.card_type as cardType,
b.area_card_type as areaCardType,
a.card_res as terminalSource ,
IFNULL(a.act_amount,0) as cardActAmount
from t_vip_area_card_cust_info a ,t_vip_area_card b
where a.card_no=b.card_no
and a.type=2
and b.type=2
and a.data_state=1
and a.org_id =#{orgId}
<if test="cardNo != null and cardNo != '' ">
and a.card_no = #{cardNo}
</if>
<if test="carNumber != null and carNumber != '' ">
and a.car_number = #{carNumber}
</if>
<if test="orderTypes != null and orderTypes.size > 0">
and a.buy_type in
<foreach collection="orderTypes" item="orderType" open="(" close=")" separator=",">
#{orderType}
</foreach>
</if>
<![CDATA[AND a.create_date >= #{beginTime}]]>
<![CDATA[AND a.create_date <= #{endTime}]]>
</select>
<!--根据车牌查询时域卡-->
<select id="queryVipTimeCardInfoByCarNumbers" resultType="com.zteits.clouds.api.dto.bill.dto.TVipAreaCardCustInfoDTO"
parameterType="com.zteits.clouds.api.dto.bill.param.TVipAreaCardCustInfoQueryRequest">
select
a.id as id,
a.card_free_surplus_time as cardFreeSurplusTime,
a.card_free_time as cardFreeTime,
a.card_no as cardNo,
b.card_name as cardName,
b.card_type as cardType,
b.area_card_type as areaCardType,
b.eff_date as cardEffDate,
b.exp_date as cardExpDate,
b.car_type as carType,
b.card_status as cardStatus,
a.cust_card_no as custCardNo,
a.num as num,
a.car_number as carNumber,
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,
a.act_amount as actAmount,
a.create_empid as createEmpid,
a.create_name as createName,
a.modify_name as modifyName,
a.modify_date as modifyDate
from t_vip_area_card_cust_info a ,t_vip_area_card b
where a.card_no=b.card_no
and a.type=2
and b.type=2
and a.data_state=1
and a.org_id =#{orgId}
<if test="cardRess != null and cardRess.size >0">
and a.card_res in
<foreach collection="cardRess" open="(" close=")" item="cardRes" separator=",">
#{cardRes}
</foreach>
</if>
and a.car_number in
<foreach collection="carNumbers" open="(" close=")" item="carNumber" separator=",">
#{carNumber}
</foreach>
order by a.create_date desc
</select>
<!--APP根据车牌查询时域卡-->
<select id="queryVipTimeCardInfoByCarNumbersForApp" resultType="com.zteits.clouds.api.dto.bill.dto.TVipAreaCardCustInfoDTO"
parameterType="com.zteits.clouds.api.dto.bill.param.TVipAreaCardCustInfoQueryRequest">
select
a.id as id,
a.card_free_surplus_time as cardFreeSurplusTime,
a.card_free_time as cardFreeTime,
a.card_no as cardNo,
b.card_name as cardName,
b.card_type as cardType,
b.area_card_type as areaCardType,
b.eff_date as cardEffDate,
b.exp_date as cardExpDate,
b.car_type as carType,
b.card_status as cardStatus,
a.cust_card_no as custCardNo,
a.num as num,
a.car_number as carNumber,
a.parent_cust_card_no as parentCustCardNo,
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,
a.act_amount as actAmount,
a.create_empid as createEmpid,
a.create_name as createName,
a.modify_name as modifyName,
a.modify_date as modifyDate,
a.type as type
from t_vip_area_card_cust_info a ,t_vip_area_card b
where a.card_no=b.card_no
and a.data_state=1
and a.type=2
and b.type=2
and a.org_id =#{orgId}
<if test="cardRess != null and cardRess.size >0">
and a.card_res in
<foreach collection="cardRess" open="(" close=")" item="cardRes" separator=",">
#{cardRes}
</foreach>
</if>
<if test="carNumber != null and carNumber != '' ">
and a.car_number = #{carNumber}
</if>
<if test="carNumbers != null and carNumbers.size >0">
and a.car_number in
<foreach collection="carNumbers" open="(" close=")" item="carNumber" separator=",">
#{carNumber}
</foreach>
</if>
<if test="cardStateTag != null and cardStateTag != 1 ">
<if test="cardStateTag == 2 ">
<![CDATA[and a.eff_date <= sysdate()
and a.exp_date >=sysdate()]]>
</if>
<if test="cardStateTag == 5 ">
<![CDATA[and a.eff_date <= sysdate()
and a.exp_date >=sysdate()]]>
and a.card_free_surplus_time > 0
</if>
</if>
order by a.create_date desc
</select>
<!--查询是否购买时域卡-->
<select id="queryIsBuyTimeVipCardCust" resultType="java.lang.Integer" parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.QueryIsBuyVipCardCustReq">
SELECT
count(*)
FROM
t_vip_area_card_cust_info a
where a.data_state=1
and a.type=2
and a.car_number=#{carNumber}
<![CDATA[and a.eff_date <=#{dateTime}
and a.exp_date >=#{dateTime}]]>
</select>
<!-- 查询即将到期的时域卡 -->
<select id="queryExpireTimeVipCardCustInfo" resultMap="BaseResultMap"
parameterType="com.zteits.clouds.api.dto.bill.vipcard.param.VipAreaCardExpireRequest">
select
<include refid="Base_Column_List" />
from t_vip_area_card_cust_info
where data_state = 1
and a.type=2
and (date(exp_date) = date(#{nowDate}) or date(DATE_SUB(exp_date,INTERVAL 4 DAY)) = date(#{nowDate}) )
</select>
<!-- 根据车牌号查询当月购买的时域卡总次数和总时长 -->
<select id="queryTimeCardBuyTimesByCarNumber" resultType="com.zteits.bill.domain.TVipAreaCardCustInfo"
parameterType="com.zteits.clouds.api.dto.bill.param.ValidVipAreaCardCustInfoRequest">
SELECT
IFNULL(sum(num),0) num,
IFNULL(sum(card_free_time),0) cardFreeTime
FROM
`t_vip_area_card_cust_info`
WHERE
data_state = 1
AND type = 2
AND car_number =#{carNumber}
<![CDATA[AND create_date >=#{beginTime}
AND create_date <=#{endTime}]]>
AND card_no = #{cardNo}
</select>
<!-- 时域卡 -->
<!-- 查询未同步的全域卡 -->
<select id="queryTVipAreaCardCustInfoListByAreaCardType" resultType="com.zteits.bill.domain.TVipAreaCardCustInfo"
parameterType="com.zteits.clouds.api.dto.bill.param.TVipAreaCardCustInfoRequest">
select
a.cust_card_no as custCardNo,
a.car_number as carNumber,
a.eff_date as effDate,
a.exp_date as expDate,
a.org_id as orgId,
a.type as type
from t_vip_area_card_cust_info a
left join t_vip_area_card_cust_info_rel c on a.cust_card_no = c.cust_card_no and c.pl_no = #{dealPlNo},
t_vip_area_card b
where a.card_no=b.card_no
and a.data_state = 1
and a.org_id =#{orgId}
and a.exp_date > #{expDate}
and b.area_card_type =#{areaCardType}
and c.pl_no is null
</select>
<!-- -->
<select id="queryAllActiveInfo" resultType="com.zteits.bill.domain.TVipAreaCardCustInfo">
SELECT c.car_number as carNumber FROM t_vip_area_card_cust_info c
left join t_vip_area_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>
</mapper>