TdBPayBlncacResultSmapper.xml
29.2 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
<?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.order.mapper.smapper.TdBPayBlncacResultSmapper">
<resultMap id="BaseResultMap" type="com.zteits.order.domain.TdBPayBlncacResult">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="report_date" jdbcType="DATE" property="reportDate" />
<result column="bus_type" jdbcType="INTEGER" property="busType" />
<result column="pl_no" jdbcType="VARCHAR" property="plNo" />
<result column="pl_name" jdbcType="VARCHAR" property="plName" />
<result column="pay_order_id" jdbcType="VARCHAR" property="payOrderId" />
<result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
<result column="rlt_order_id" jdbcType="VARCHAR" property="rltOrderId" />
<result column="pay_finish_time" jdbcType="TIMESTAMP" property="payFinishTime" />
<result column="pay_type" jdbcType="INTEGER" property="payType" />
<result column="app_id" jdbcType="VARCHAR" property="appId" />
<result column="order_num" jdbcType="INTEGER" property="orderNum" />
<result column="total_fee" jdbcType="BIGINT" property="totalFee" />
<result column="act_fee" jdbcType="BIGINT" property="actFee" />
<result column="dicount_fee" jdbcType="BIGINT" property="dicountFee" />
<result column="refund_total_fee" jdbcType="BIGINT" property="refundTotalFee" />
<result column="refund_act_fee" jdbcType="BIGINT" property="refundActFee" />
<result column="qeual_type" jdbcType="INTEGER" property="qeualType" />
<result column="diff_FEE" jdbcType="BIGINT" property="diffFee" />
<result column="diff_remark" jdbcType="VARCHAR" property="diffRemark" />
<result column="trade_service_fee" jdbcType="BIGINT" property="tradeServiceFee" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="data_state" jdbcType="INTEGER" property="dataState" />
<result column="create_emp_id" jdbcType="VARCHAR" property="createEmpId" />
<result column="create_emp_name" jdbcType="VARCHAR" property="createEmpName" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="modfiy_emp_id" jdbcType="VARCHAR" property="modfiyEmpId" />
<result column="modfiy_emp_name" jdbcType="VARCHAR" property="modfiyEmpName" />
<result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate" />
<result column="platform_service_fee" jdbcType="BIGINT" property="platformServiceFee" />
<result column="blncace_actual_fee" jdbcType="BIGINT" property="blncaceActualFee" />
</resultMap>
<sql id="Base_Column_List">
id, report_date, bus_type, pl_no, pl_name, pay_order_id, transaction_id, rlt_order_id,
pay_finish_time, pay_type, app_id, order_num, total_fee, act_fee, dicount_fee, refund_total_fee,
refund_act_fee, qeual_type, diff_FEE, diff_remark, trade_service_fee, remark, data_state,
create_emp_id, create_emp_name, create_date, modfiy_emp_id, modfiy_emp_name, modfiy_date,
platform_service_fee, blncace_actual_fee
</sql>
<!-- 根据制定时间删除 -->
<delete id="deleteTdBPayBlncacResulByReportDate" >
delete from td_b_pay_blncac_result
where <![CDATA[report_date >=#{beginDate} ]]>
<![CDATA[and report_date >=#{endDate} ]]>
</delete>
<!--批量插入-->
<insert id="batchTdBPayBlncacResul" >
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into td_b_pay_blncac_result (report_date, bus_type, pl_no,
pl_name, pay_order_id, transaction_id,
rlt_order_id, pay_finish_time, pay_type,
app_id, order_num, total_fee,
act_fee, dicount_fee, refund_total_fee,
refund_act_fee, qeual_type, diff_FEE,
diff_remark, trade_service_fee, remark,
data_state, create_emp_id, create_emp_name,
create_date, modfiy_emp_id, modfiy_emp_name,
modfiy_date, platform_service_fee, blncace_actual_fee
)
values
<foreach collection="list" item="item" separator=",">
(#{item.reportDate,jdbcType=DATE}, #{item.busType,jdbcType=INTEGER}, #{item.plNo,jdbcType=VARCHAR},
#{item.plName,jdbcType=VARCHAR}, #{item.payOrderId,jdbcType=VARCHAR}, #{item.transactionId,jdbcType=VARCHAR},
#{item.rltOrderId,jdbcType=VARCHAR}, #{item.payFinishTime,jdbcType=TIMESTAMP}, #{item.payType,jdbcType=INTEGER},
#{item.appId,jdbcType=VARCHAR}, #{item.orderNum,jdbcType=INTEGER}, #{item.totalFee,jdbcType=BIGINT},
#{item.actFee,jdbcType=BIGINT}, #{item.dicountFee,jdbcType=BIGINT}, #{item.refundTotalFee,jdbcType=BIGINT},
#{item.refundActFee,jdbcType=BIGINT}, #{item.qeualType,jdbcType=INTEGER}, #{item.diffFee,jdbcType=BIGINT},
#{item.diffRemark,jdbcType=VARCHAR}, #{item.tradeServiceFee,jdbcType=BIGINT}, #{item.remark,jdbcType=VARCHAR},
#{item.dataState,jdbcType=INTEGER}, #{item.createEmpId,jdbcType=VARCHAR}, #{item.createEmpName,jdbcType=VARCHAR},
#{item.createDate,jdbcType=TIMESTAMP}, #{item.modfiyEmpId,jdbcType=VARCHAR}, #{item.modfiyEmpName,jdbcType=VARCHAR},
#{item.modfiyDate,jdbcType=TIMESTAMP}, #{item.platformServiceFee,jdbcType=BIGINT}, #{item.blncaceActualFee,jdbcType=BIGINT}
)
</foreach>
</insert>
<!--<!–查询对账结果数据 实际结算=应结算金额 - 服务费 -退费–>-->
<select id="queryPayBlncacResultByReportDate" resultType="com.zteits.order.domain.TdBSettlementRecord">
select
cc.report_date as checkDate,
cc.org_id as orgId,
IFNULL(cc.settlement_total_fee,0) as settlementTotalFee,
IFNULL(cc.settlement_total_fee,0) - IFNULL(cc.ali_refund_fee,0) - IFNULL(cc.wx_refund_fee,0) -
IFNULL(cc.balance_refund_fee,0) - IFNULL(cc.ali_srv_fee,0) - IFNULL(cc.wx_srv_fee,0) as settlementActFee,
cc.check_status as checkStatus,
IFNULL(cc.ali_fee,0) as aliFee ,
IFNULL(cc.ali_refund_fee,0) as aliRefundFee,
IFNULL(cc.ali_srv_fee,0) as aliSrvFee,
IFNULL(cc.ali_charge_num,0) as aliChargeNum,
IFNULL(cc.wx_fee,0) as wxFee,
IFNULL(cc.wx_refund_fee,0) as wxRefundFee,
IFNULL(cc.wx_srv_fee,0) as wxSrvFee,
IFNULL(cc.wx_charge_num,0) as wxChargeNum,
IFNULL(cc.balance_fee,0) as balanceFee,
IFNULL(cc.balance_refund_fee,0) as balanceRefundFee,
IFNULL(cc.balance_srv_fee,0) as balanceSrvFee,
IFNULL(cc.balance_charge_num,0) as balanceChargeNum,
IFNULL(cc.platform_srv_fee,0) as platformSrvFee,
cc.data_state as dataState
from (
SELECT
a.report_date,
a.org_id,
sum( case when a.bus_type=1 THEN
a.order_payed_fee
end) as settlement_total_fee,
(case when a.blncac_diff_type =0 then
'100'
ELSE
'-100'
end) as check_status,
sum(case when a.pay_type =1 and a.bus_type=1 then
a.order_payed_fee
end) as ali_fee,
sum(case when a.pay_type =1 and a.bus_type=2 then
a.order_payed_fee
end) as ali_refund_fee,
sum(case when a.pay_type =1 and a.bus_type=1 then
1
end) as ali_charge_num,
sum(case when a.pay_type =1 and a.bus_type=1 then
a.serve_fee
end) as ali_srv_fee,
sum(case when a.pay_type in(2,4) and a.bus_type=1 then
a.order_payed_fee
end) as wx_fee,
sum(case when a.pay_type in(2,4) and a.bus_type=2 then
a.order_payed_fee
end) as wx_refund_fee,
sum(case when a.pay_type in(2,4) and a.bus_type=1 then
a.serve_fee
end) as wx_srv_fee,
sum(case when a.pay_type in(2,4) and a.bus_type=1 then
1
end) as wx_charge_num,
sum(case when a.pay_type in(5) and a.bus_type=1 then
a.order_payed_fee
end) as balance_fee,
sum(case when a.pay_type in(5) and a.bus_type=2 then
a.order_payed_fee
end) as balance_refund_fee,
'0' as balance_srv_fee,
sum(case when a.pay_type in(5) and a.bus_type=1 then
1
end) as balance_charge_num,
'0' as platform_srv_fee,
1 as data_state
FROM
td_b_pay_blncac_result a
where 1=1
and (a.shared_type =1 or a.shared_type is null) /**共享状态 1 非共享 2 共享*/
<![CDATA[and a.report_date >=#{beginTime}]]>
<![CDATA[and a.report_date <=#{endTime}]]>
group by a.report_date,check_status,
a.org_id) cc
</select>
<!-- 分页查询 按日 对账明细(每笔支付) langlw 2107-10-17 edit -->
<select id="queryBlancacforDayDetailPage"
parameterType="com.zteits.clouds.api.dto.clouds.param.BillReconciliationQueryRequest"
resultType="com.zteits.order.domain.TdBPayBlncacResult">
SELECT id as id,
report_date AS reportDate,
park_id AS parkId,
park_name AS ParkName,
pay_order_id AS payOrderId,
/** 平台支付单号 */
bill_remarks AS billRemarks,
blncace_finish_time AS blncaceFinishTime,
/** 支付完成时间(账文件记录交易完成时间) */
pay_order_state AS payOrderState,
blncac_pay_order_id as blncacPayOrderId,
blncace_account AS blncaceAccount,
/** 支付机构交易凭证号ID */
pay_finish_time AS payFinishTime,
sum(blncace_actual_fee) AS blncaceActualFee,
/** 对账文件记录费用(支付金额) 单位:分 */
sum(diff_FEE) AS diffFEE,
sum(order_payed_fee) AS orderPayedFee,
blncac_diff_type AS blncacDiffType,
qeual_type AS qeualType,
max(remark) AS remark
FROM td_b_pay_blncac_result
where data_state=1
<if test="plNos != null and plNos.size >0">
and park_id in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
</if>
<if test="beginTime != null ">
<![CDATA[ and DATE_FORMAT(report_date,'%Y-%m-%d') >= #{beginTime} ]]>
</if>
<if test="endTime != null ">
<![CDATA[ and DATE_FORMAT(report_date,'%Y-%m-%d') <= #{endTime} ]]>
</if>
<choose>
<when test="payType !=null and payType ==1">
and pay_type= #{payType}
</when>
<when test="payType !=null and payType ==2">
and pay_type in(2,4)
</when>
</choose>
<if test="blncacDiffType !=null and blncacDiffType==2">
and blncac_diff_type=0
</if>
<if test="blncacDiffType !=null and blncacDiffType==1">
and blncac_diff_type in(1,2,3)
</if>
<if test="areaParks != null and areaParks.size >0">
and berth_range_no in
<foreach collection="areaParks" open="(" close=")" item="berthRangeNo" separator=",">
#{berthRangeNo}
</foreach>
</if>
group by id,park_id,report_date,park_name,qeual_type,blncac_diff_type,pay_order_state,
blncace_finish_time,pay_order_id,bill_remarks ,blncace_account ,pay_finish_time
ORDER BY pay_finish_time DESC
</select>
<!-- 分页查询 按月 对账明细(每笔支付) langlw 2107-10-17 edit -->
<select id="queryBlancacforMonthDetailPage"
parameterType="com.zteits.clouds.api.dto.clouds.param.BillReconciliationQueryRequest"
resultType="com.zteits.order.domain.TdBPayBlncacResult">
SELECT id as id,
CONCAT(DATE_FORMAT(report_date,'%Y-%m'),'-00') AS reportDate,
park_id AS parkId,
park_name AS ParkName,
pay_order_id AS payOrderId,
/** 平台支付单号 */
bill_remarks AS billRemarks,
blncac_pay_order_id as blncacPayOrderId,
blncace_finish_time AS billPayFinishTime,
/** 支付完成时间(账文件记录交易完成时间) */
pay_order_state AS payOrderState,
blncace_account AS blncaceAccount,
/** 支付机构交易凭证号ID */
pay_finish_time AS payFinishTime,
sum(blncace_actual_fee) AS blncaceActualFee,
/** 对账文件记录费用(支付金额) 单位:分 */
sum(diff_FEE) AS diffFEE,
sum(order_payed_fee) AS orderPayedFee,
blncac_diff_type AS blncacDiffType,
qeual_type AS qeualType,
max(remark) AS remark
FROM td_b_pay_blncac_result
where data_state=1
<if test="plNos != null and plNos.size >0">
and park_id in
<foreach collection="plNos" open="(" close=")" item="plNo" separator=",">
#{plNo}
</foreach>
</if>
<if test="beginTime != null ">
<![CDATA[ and DATE_FORMAT(report_date,'%Y-%m') >= #{beginTime} ]]>
</if>
<if test="endTime != null ">
<![CDATA[ and DATE_FORMAT(report_date,'%Y-%m') <= #{endTime} ]]>
</if>
<choose>
<when test="payType !=null and payType ==1">
and pay_type= #{payType}
</when>
<when test="payType !=null and payType ==2">
and pay_type in(2,4)
</when>
</choose>
<if test="blncacDiffType !=null and blncacDiffType==2">
and blncac_diff_type=0
</if>
<if test="blncacDiffType !=null and blncacDiffType==1">
and blncac_diff_type in(1,2,3)
</if>
<if test="areaParks != null and areaParks.size >0">
and berth_range_no in
<foreach collection="areaParks" open="(" close=")" item="berthRangeNo" separator=",">
#{berthRangeNo}
</foreach>
</if>
group by id,park_id,report_date,park_name,qeual_type,blncac_diff_type,pay_order_state,
blncace_finish_time,pay_order_id,bill_remarks ,blncace_account ,pay_finish_time ,remark
order by report_date desc ,pay_finish_time desc
</select>
<!-- 对账合计查询-按日 -->
<select id="queryBillFillTotalListForDay"
parameterType="com.zteits.clouds.api.dto.clouds.param.BillReconciliationQueryRequest"
resultType="com.zteits.order.domain.sdo.BillReconciliationDO">
SELECT
sum(CASE WHEN bus_type=1 THEN
blncace_actual_fee ELSE 0 END) AS billTotalpayedFee,
sum(CASE WHEN bus_type=1 THEN
1 ELSE 0 END
) AS billTotalpayedCount,
sum(CASE WHEN bus_type=1 THEN
order_payed_fee ELSE 0 END
) AS totalPayedFee,
sum(CASE WHEN blncac_pay_order_id is not NULL AND bus_type=1 THEN
1 ELSE 0 END
) AS totalPayedCount,
sum(CASE WHEN bus_type=1 THEN
diff_FEE ELSE 0 END
) AS totalDiffFee,
sum(CASE
WHEN bus_type = 1 and blncac_diff_type in (1,2,3) THEN
1
ELSE
0
END ) AS totalDiffFeeCount,
sum(CASE WHEN bus_type=2 THEN
order_payed_fee ELSE 0 END
) AS totalRefundFee,
sum(CASE WHEN blncac_pay_order_id IS not NULL AND bus_type=2 THEN
1 ELSE 0 END
) AS totalRefundCount,
sum(CASE WHEN bus_type=2 THEN
diff_FEE ELSE 0 END
) AS refundTotalDiffFee,
sum(CASE
WHEN bus_type = 2 and blncac_diff_type in (1,2,3) THEN
1
ELSE
0
END ) AS refundTotalDiffCount,
sum(CASE WHEN bus_type=2 THEN
blncace_actual_fee ELSE 0 END ) AS billTotalRefundFee,
sum(CASE WHEN (blncac_pay_order_id IS not NULL AND bus_type=2) THEN
1 ELSE 0 END
) AS bilTotalRefundCount
FROM
td_b_pay_blncac_result
WHERE
data_state = 1
<![CDATA[and DATE_FORMAT(report_date,'%Y-%m-%d') >= #{beginTime}]]>
<![CDATA[and DATE_FORMAT(report_date,'%Y-%m-%d') <= #{endTime} ]]>
<choose >
<when test="payType != null and payType==2">
and pay_type in(2,4)
</when>
<when test="payType != null and payType==1">
and pay_type=#{payType}
</when>
</choose>
<if test="blncacDiffType !=null and blncacDiffType==2">
and blncac_diff_type=0
</if>
<if test="blncacDiffType !=null and blncacDiffType==1">
and blncac_diff_type in(1,2,3)
</if>
<if test="areaParks != null and areaParks.size >0">
and berth_range_no in
<foreach collection="areaParks" open="(" close=")" item="berthRangeNo" separator=",">
#{berthRangeNo}
</foreach>
</if>
<if test="null != plNos and plNos.size >0">
and park_id IN
<foreach collection="plNos" item="plNo" separator="," open="(" close=")" index="index">
#{plNo}
</foreach>
</if>
</select>
<!-- 对账合计查询-月 -->
<select id="queryBillFillTotalListForMonth"
parameterType="com.zteits.clouds.api.dto.clouds.param.BillReconciliationQueryRequest"
resultType="com.zteits.order.domain.sdo.BillReconciliationDO">
SELECT
/*bill_time as beginTime,*/
sum(CASE WHEN bus_type=1 THEN
blncace_actual_fee ELSE 0 END) AS billTotalpayedFee,
sum(CASE WHEN bus_type=1 THEN
1 ELSE 0 END
) AS billTotalpayedCount,
sum(CASE WHEN bus_type=1 THEN
order_payed_fee ELSE 0 END
) AS totalPayedFee,
sum(CASE WHEN blncac_pay_order_id is not NULL AND bus_type=1 THEN
1 ELSE 0 END
) AS totalPayedCount,
sum(CASE WHEN bus_type=1 THEN
diff_FEE ELSE 0 END
) AS totalDiffFee,
sum(CASE
WHEN bus_type = 1 and blncac_diff_type in (1,2,3) THEN
1
ELSE
0
END ) AS totalDiffFeeCount,
sum(CASE WHEN bus_type=2 THEN
order_payed_fee ELSE 0 END
) AS totalRefundFee,
sum(CASE WHEN blncac_pay_order_id IS not NULL AND bus_type=2 THEN
1 ELSE 0 END
) AS totalRefundCount,
sum(CASE WHEN bus_type=2 THEN
diff_FEE ELSE 0 END
) AS refundTotalDiffFee,
sum(CASE
WHEN bus_type = 2 and blncac_diff_type in (1,2,3) THEN
1
ELSE
0
END ) AS refundTotalDiffCount,
sum(CASE WHEN bus_type=2 THEN
blncace_actual_fee ELSE 0 END ) AS billTotalRefundFee,
sum(CASE WHEN (blncac_pay_order_id IS not NULL AND bus_type=2) THEN
1 ELSE 0 END
) AS bilTotalRefundCount
FROM
td_b_pay_blncac_result
WHERE
data_state = 1
<![CDATA[and DATE_FORMAT(report_date,'%Y-%m-%d') >= #{beginTime}]]>
<![CDATA[and DATE_FORMAT(report_date,'%Y-%m-%d') <= #{endTime} ]]>
<choose >
<when test="payType != null and payType==2">
and pay_type in(2,4)
</when>
<when test="payType != null and payType==1">
and pay_type=#{payType}
</when>
</choose>
<if test="blncacDiffType !=null and blncacDiffType==2">
and blncac_diff_type=0
</if>
<if test="blncacDiffType !=null and blncacDiffType==1">
and blncac_diff_type in(1,2,3)
</if>
<if test="areaParks != null and areaParks.size >0">
and berth_range_no in
<foreach collection="areaParks" open="(" close=")" item="berthRangeNo" separator=",">
#{berthRangeNo}
</foreach>
</if>
<if test="null != plNos and plNos.size >0">
and park_id IN
<foreach collection="plNos" item="plNo" separator="," open="(" close=")" index="index">
#{plNo}
</foreach>
</if>
</select>
<!-- 对账合计查询-按日分组 langlw 2017-10-24-->
<select id="queryBillFillTotalListForDayGroupByDay"
parameterType="com.zteits.clouds.api.dto.clouds.param.BillReconciliationQueryRequest"
resultType="com.zteits.order.domain.sdo.BillReconciliationDO">
SELECT
report_date as beginTime,
sum(CASE WHEN bus_type=1 THEN
blncace_actual_fee ELSE 0 END) AS billTotalpayedFee,
sum(CASE WHEN bus_type=1 THEN
1 ELSE 0 END
) AS billTotalpayedCount,
sum(CASE WHEN bus_type=1 THEN
order_payed_fee ELSE 0 END
) AS totalPayedFee,
sum(CASE WHEN blncac_pay_order_id is not NULL AND bus_type=1 THEN
1 ELSE 0 END
) AS totalPayedCount,
sum(CASE WHEN bus_type=1 THEN
diff_FEE ELSE 0 END
) AS totalDiffFee,
sum(CASE
WHEN bus_type = 1 and blncac_diff_type in (1,2,3) THEN
1
ELSE
0
END ) AS totalDiffFeeCount,
sum(CASE WHEN bus_type=2 THEN
order_payed_fee ELSE 0 END
) AS totalRefundFee,
sum(CASE WHEN blncac_pay_order_id IS not NULL AND bus_type=2 THEN
1 ELSE 0 END
) AS totalRefundCount,
sum(CASE WHEN bus_type=2 THEN
diff_FEE ELSE 0 END
) AS refundTotalDiffFee,
sum(CASE
WHEN bus_type = 2 and blncac_diff_type in (1,2,3) THEN
1
ELSE
0
END ) AS refundTotalDiffCount,
sum(CASE WHEN bus_type=2 THEN
blncace_actual_fee ELSE 0 END ) AS billTotalRefundFee,
sum(CASE WHEN (blncac_pay_order_id IS not NULL AND bus_type=2) THEN
1 ELSE 0 END
) AS bilTotalRefundCount
FROM
td_b_pay_blncac_result
WHERE
data_state = 1
<![CDATA[and DATE_FORMAT(report_date,'%Y-%m-%d') >= #{beginTime}]]>
<![CDATA[and DATE_FORMAT(report_date,'%Y-%m-%d') <= #{endTime} ]]>
<choose >
<when test="payType != null and payType==2">
and pay_type in(2,4)
</when>
<when test="payType != null and payType==1">
and pay_type=#{payType}
</when>
</choose>
<if test="blncacDiffType !=null and blncacDiffType==2">
and blncac_diff_type=0
</if>
<if test="blncacDiffType !=null and blncacDiffType==1">
and blncac_diff_type in(1,2,3)
</if>
<if test="areaParks != null and areaParks.size >0">
and berth_range_no in
<foreach collection="areaParks" open="(" close=")" item="berthRangeNo" separator=",">
#{berthRangeNo}
</foreach>
</if>
<if test="null != plNos and plNos.size >0">
and park_id IN
<foreach collection="plNos" item="plNo" separator="," open="(" close=")" index="index">
#{plNo}
</foreach>
</if>
GROUP BY beginTime
order by beginTime desc
</select>
<!-- 对账合计查询-按月分组 langlw 2017-10-24-->
<select id="queryBillFillTotalListForMonthGroupByMonth"
parameterType="com.zteits.clouds.api.dto.clouds.param.BillReconciliationQueryRequest"
resultType="com.zteits.order.domain.sdo.BillReconciliationDO">
SELECT
CONCAT(DATE_FORMAT(report_date,'%Y-%m'),'-00') AS beginTime,
sum(CASE WHEN bus_type=1 THEN
blncace_actual_fee ELSE 0 END) AS billTotalpayedFee,
sum(CASE WHEN bus_type=1 THEN
1 ELSE 0 END
) AS billTotalpayedCount,
sum(CASE WHEN bus_type=1 THEN
order_payed_fee ELSE 0 END
) AS totalPayedFee,
sum(CASE WHEN blncac_pay_order_id is not NULL AND bus_type=1 THEN
1 ELSE 0 END
) AS totalPayedCount,
sum(CASE WHEN bus_type=1 THEN
diff_FEE ELSE 0 END
) AS totalDiffFee,
sum(CASE
WHEN bus_type = 1 and blncac_diff_type in (1,2,3) THEN
1
ELSE
0
END ) AS totalDiffFeeCount,
sum(CASE WHEN bus_type=2 THEN
order_payed_fee ELSE 0 END
) AS totalRefundFee,
sum(CASE WHEN blncac_pay_order_id IS not NULL AND bus_type=2 THEN
1 ELSE 0 END
) AS totalRefundCount,
sum(CASE WHEN bus_type=2 THEN
diff_FEE ELSE 0 END
) AS refundTotalDiffFee,
sum(CASE
WHEN bus_type = 2 and blncac_diff_type in (1,2,3) THEN
1
ELSE
0
END ) AS refundTotalDiffCount,
sum(CASE WHEN bus_type=2 THEN
blncace_actual_fee ELSE 0 END ) AS billTotalRefundFee,
sum(CASE WHEN (blncac_pay_order_id IS not NULL AND bus_type=2) THEN
1 ELSE 0 END
) AS bilTotalRefundCount
FROM
td_b_pay_blncac_result
WHERE
data_state = 1
<![CDATA[and DATE_FORMAT(report_date,'%Y-%m') >= #{beginTime}]]>
<![CDATA[and DATE_FORMAT(report_date,'%Y-%m') <= #{endTime} ]]>
<choose >
<when test="payType != null and payType==2">
and pay_type in(2,4)
</when>
<when test="payType != null and payType==1">
and pay_type=#{payType}
</when>
</choose>
<if test="blncacDiffType !=null and blncacDiffType==2">
and blncac_diff_type=0
</if>
<if test="blncacDiffType !=null and blncacDiffType==1">
and blncac_diff_type in(1,2,3)
</if>
<if test="areaParks != null and areaParks.size >0">
and berth_range_no in
<foreach collection="areaParks" open="(" close=")" item="berthRangeNo" separator=",">
#{berthRangeNo}
</foreach>
</if>
<if test="null != plNos and plNos.size >0">
and park_id IN
<foreach collection="plNos" item="plNo" separator="," open="(" close=")" index="index">
#{plNo}
</foreach>
</if>
GROUP BY beginTime
order by beginTime desc
</select>
<!-- 对账汇总查询-->
<select id="queryReconciliationBillTotal"
parameterType="com.zteits.clouds.api.dto.clouds.param.BillReconciliationRequest"
resultType="com.zteits.clouds.api.dto.clouds.dto.BillReconciliationTotalDTO">
SELECT
pay_type AS payType,
SUM(CASE WHEN bus_type = 1 THEN (blncace_actual_fee)ELSE 0 END) AS blncaceActualFee,/*总实收*/
SUM(CASE WHEN bus_type = 1 THEN (1)ELSE 0 END) AS totalCount,/*总笔数*/
SUM(CASE WHEN qeual_type in(-1,0) THEN (diff_FEE)ELSE 0 END) AS diffFee,/*收入差异金额*/
SUM(CASE WHEN qeual_type in(-1,0) THEN (1)ELSE 0 END) AS diffCount,/*收入差异笔数*/
SUM(CASE WHEN bus_type = 2 THEN (refund_act_fee)ELSE 0 END) AS returnFee,/*退款金额*/
SUM(CASE WHEN bus_type = 2 THEN (1)ELSE 0 END) AS returnCount,/*退款笔数*/
SUM(CASE WHEN bus_type = 2 AND qeual_type in(-1,0) THEN (diff_FEE)ELSE 0 END) AS returnDiffFee,/*退款差异金额*/
SUM(CASE WHEN bus_type = 2 AND qeual_type in(-1,0) THEN (1)ELSE 0 END) AS returnDiffCount/*退款差异笔数*/
FROM td_b_pay_blncac_result
WHERE 1=1
AND data_state = 1
<![CDATA[and report_date >= #{beginTime}]]>
<![CDATA[and report_date <= #{endTime} ]]>
<if test="null != plNos and plNos.size >0">
and pl_no IN
<foreach collection="plNos" item="plNo" separator="," open="(" close=")" index="index">
#{plNo}
</foreach>
</if>
GROUP BY pay_type
</select>
<!-- 对账结果分页查询-->
<select id="queryReconciliationBillForPage"
parameterType="com.zteits.clouds.api.dto.clouds.param.BillReconciliationRequest"
resultType="com.zteits.clouds.api.dto.clouds.dto.BillReconciliationTotalDTO">
SELECT
pay_type AS payType,
<if test="dateType == 1">
report_date AS reportDate,
</if>
<if test="dateType == 2">
DATE_FORMAT(report_date,'%Y-%m') AS reportDate,
</if>
SUM(CASE WHEN bus_type = 1 THEN (blncace_actual_fee)ELSE 0 END) AS blncaceActualFee,/*总实收*/
SUM(CASE WHEN bus_type = 1 THEN (1)ELSE 0 END) AS totalCount,/*总笔数*/
SUM(CASE WHEN qeual_type in(-1,0) THEN (diff_FEE)ELSE 0 END) AS diffFee,/*收入差异金额*/
SUM(CASE WHEN qeual_type in(-1,0) THEN (1)ELSE 0 END) AS diffCount,/*收入差异笔数*/
SUM(CASE WHEN bus_type = 2 THEN (refund_act_fee)ELSE 0 END) AS returnFee,/*退款金额*/
SUM(CASE WHEN bus_type = 2 THEN (1)ELSE 0 END) AS returnCount,/*退款笔数*/
SUM(CASE WHEN bus_type = 2 AND qeual_type in(-1,0) THEN (diff_FEE)ELSE 0 END) AS returnDiffFee,/*退款差异金额*/
SUM(CASE WHEN bus_type = 2 AND qeual_type in(-1,0) THEN (1)ELSE 0 END) AS returnDiffCount/*退款差异笔数*/
FROM td_b_pay_blncac_result
WHERE 1=1
AND data_state = 1
<![CDATA[and report_date >= #{beginTime}]]>
<![CDATA[and report_date <= #{endTime} ]]>
<if test="null != plNos and plNos.size >0">
and pl_no IN
<foreach collection="plNos" item="plNo" separator="," open="(" close=")" index="index">
#{plNo}
</foreach>
</if>
<if test="dateType == 1">
GROUP BY report_date,pay_type
</if>
<if test="dateType == 2">
GROUP BY DATE_FORMAT(report_date,'%Y-%m'),pay_type
</if>
</select>
</mapper>