OrderRefundSmapper.xml
29.6 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
<?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.OrderRefundSmapper">
<resultMap id="BaseResultMap" type="com.zteits.order.domain.OrderRefund">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="order_id" jdbcType="VARCHAR" property="orderId" />
<result column="order_big_type" jdbcType="INTEGER" property="orderBigType" />
<result column="pay_order_type" jdbcType="INTEGER" property="payOrderType" />
<result column="rlt_order_id" jdbcType="VARCHAR" property="rltOrderId" />
<result column="rlt_pay_order_id" jdbcType="VARCHAR" property="rltPayOrderId" />
<result column="order_state" jdbcType="INTEGER" property="orderState" />
<result column="refund_total_fee" jdbcType="BIGINT" property="refundTotalFee" />
<result column="refund_act_fee" jdbcType="BIGINT" property="refundActFee" />
<result column="terminal_source" jdbcType="INTEGER" property="terminalSource" />
<result column="pay_type" jdbcType="INTEGER" property="payType" />
<result column="order_dicount_fee" jdbcType="BIGINT" property="orderDicountFee" />
<result column="order_act_fee" jdbcType="BIGINT" property="orderActFee" />
<result column="order_total_fee" jdbcType="BIGINT" property="orderTotalFee" />
<result column="pay_finish_time" jdbcType="TIMESTAMP" property="payFinishTime" />
<result column="refund_finish_time" jdbcType="TIMESTAMP" property="refundFinishTime" />
<result column="cust_id" jdbcType="VARCHAR" property="custId" />
<result column="pl_no" jdbcType="VARCHAR" property="plNo" />
<result column="car_number" jdbcType="VARCHAR" property="carNumber" />
<result column="refund_reason" jdbcType="VARCHAR" property="refundReason" />
<result column="audit_state" jdbcType="INTEGER" property="auditState" />
<result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
<result column="try_num" jdbcType="INTEGER" property="tryNum" />
<result column="merchant_no" jdbcType="VARCHAR" property="merchantNo" />
<result column="error_code" jdbcType="VARCHAR" property="errorCode" />
<result column="error_msg" jdbcType="VARCHAR" property="errorMsg" />
<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="remark" jdbcType="VARCHAR" property="remark" />
<result column="app_id" jdbcType="VARCHAR" property="appId" />
<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="platform_service_fee" jdbcType="BIGINT" property="platformServiceFee" />
<result column="person_card_no" jdbcType="VARCHAR" property="personCardNo" />
<result column="return_invoice_state" jdbcType="INTEGER" property="returnInvoiceState" />
<result column="org_id" jdbcType="BIGINT" property="orgId" />
<result column="org_name" jdbcType="VARCHAR" property="orgName" />
</resultMap>
<sql id="Base_Column_List">
id, order_id, order_big_type, pay_order_type, rlt_order_id, rlt_pay_order_id, order_state,
refund_total_fee, refund_act_fee, terminal_source, pay_type, order_dicount_fee, order_act_fee,
order_total_fee, pay_finish_time, refund_finish_time, cust_id, pl_no, car_number,
refund_reason, audit_state, transaction_id, try_num, merchant_no, error_code, error_msg,
data_state, create_emp_id, create_emp_name, create_date, modfiy_emp_id, modfiy_emp_name,
modfiy_date, remark, app_id, qeual_type, diff_FEE, diff_remark, trade_service_fee,
platform_service_fee, person_card_no, return_invoice_state, org_id, org_name
</sql>
<!--查询所有退款单 langlw 2018-3-1-->
<select id="queryPayOrderRefundForList" resultType="com.zteits.order.domain.TdBPayBlncacResult">
SELECT
DATE_FORMAT(create_date,'%Y-%m-%d') as reportDate,
2 as busType,
pl_no as parkId,
rlt_pay_order_id as payOrderId,
'' as paySrcType,
rlt_order_id as orderId,
order_id as rltPayOrderId,
'' as payOrderType,
'' as payOrderUserName,
pay_type as payType,
terminal_source as paySource,
merchant_no as rltPayInstitId,
transaction_id as rltPayOrderId,
'' as payBankName,
transaction_id as payAccount,
refund_act_fee as orderActFee,
refund_act_fee as orderPayedFee,
refund_total_fee as orderTotalFee ,
create_date as payFinishTime,
data_state as dataState,
create_emp_id as createEmpid,
create_date as createDate,
modfiy_emp_id as modfiyEmpid,
modfiy_date as modfiyDate
FROM
order_refund
where order_state =70 /**订单状态:-10:支付失败,80:待退款 ,60:退款中、70:退款成功,-20:全部退款失败,-30:部分退款失败,90:退款待申请*/
and data_state=1
<![CDATA[and create_date >=#{beginTime}]]>
<![CDATA[and create_date <=#{endTime}]]>
</select>
<!-- 通过退款orderId 更新退款订单 -->
<update id="updateOrderRefundByOrderId" parameterType="com.zteits.order.domain.OrderRefund">
update order_refund
<set>
<if test="orderBigType != null">
order_big_type = #{orderBigType,jdbcType=INTEGER},
</if>
<if test="payOrderType != null">
pay_order_type = #{payOrderType,jdbcType=INTEGER},
</if>
<if test="rltOrderId != null">
rlt_order_id = #{rltOrderId,jdbcType=VARCHAR},
</if>
<if test="rltPayOrderId != null">
rlt_pay_order_id = #{rltPayOrderId,jdbcType=VARCHAR},
</if>
<if test="orderState != null">
order_state = #{orderState,jdbcType=INTEGER},
</if>
<if test="refundTotalFee != null">
refund_total_fee = #{refundTotalFee,jdbcType=BIGINT},
</if>
<if test="refundActFee != null">
refund_act_fee = #{refundActFee,jdbcType=BIGINT},
</if>
<if test="terminalSource != null">
terminal_source = #{terminalSource,jdbcType=INTEGER},
</if>
<if test="payType != null">
pay_type = #{payType,jdbcType=INTEGER},
</if>
<if test="orderDicountFee != null">
order_dicount_fee = #{orderDicountFee,jdbcType=BIGINT},
</if>
<if test="orderActFee != null">
order_act_fee = #{orderActFee,jdbcType=BIGINT},
</if>
<if test="orderTotalFee != null">
order_total_fee = #{orderTotalFee,jdbcType=BIGINT},
</if>
<if test="payFinishTime != null">
pay_finish_time = #{payFinishTime,jdbcType=TIMESTAMP},
</if>
<if test="refundFinishTime != null">
refund_finish_time = #{refundFinishTime,jdbcType=TIMESTAMP},
</if>
<if test="custId != null">
cust_id = #{custId,jdbcType=VARCHAR},
</if>
<if test="plNo != null">
pl_no = #{plNo,jdbcType=VARCHAR},
</if>
<if test="carNumber != null">
car_number = #{carNumber,jdbcType=VARCHAR},
</if>
<if test="refundReason != null">
refund_reason = #{refundReason,jdbcType=VARCHAR},
</if>
<if test="auditState != null">
audit_state = #{auditState,jdbcType=INTEGER},
</if>
<if test="transactionId != null">
transaction_id = #{transactionId,jdbcType=VARCHAR},
</if>
<if test="tryNum != null">
try_num = #{tryNum,jdbcType=INTEGER},
</if>
<if test="merchantNo != null">
merchant_no = #{merchantNo,jdbcType=VARCHAR},
</if>
<if test="errorCode != null">
error_code = #{errorCode,jdbcType=VARCHAR},
</if>
<if test="errorMsg != null">
error_msg = #{errorMsg,jdbcType=VARCHAR},
</if>
<if test="dataState != null">
data_state = #{dataState,jdbcType=INTEGER},
</if>
<if test="createEmpId != null">
create_emp_id = #{createEmpId,jdbcType=VARCHAR},
</if>
<if test="createEmpName != null">
create_emp_name = #{createEmpName,jdbcType=VARCHAR},
</if>
<if test="createDate != null">
create_date = #{createDate,jdbcType=TIMESTAMP},
</if>
<if test="modfiyEmpId != null">
modfiy_emp_id = #{modfiyEmpId,jdbcType=VARCHAR},
</if>
<if test="modfiyEmpName != null">
modfiy_emp_name = #{modfiyEmpName,jdbcType=VARCHAR},
</if>
<if test="modfiyDate != null">
modfiy_date = #{modfiyDate,jdbcType=TIMESTAMP},
</if>
<if test="remark != null">
remark = #{remark,jdbcType=VARCHAR},
</if>
<if test="appId != null">
app_id = #{appId,jdbcType=VARCHAR},
</if>
<if test="personCardNo != null">
person_card_no = #{personCardNo,jdbcType=VARCHAR},
</if>
</set>
where order_id = #{orderId,jdbcType=VARCHAR}
</update>
<!--账单管理定时任务查询退费 -->
<select id="queryOrderRefundForCheckDay" resultType="com.zteits.order.domain.TdBCheckDay">
SELECT
a.pl_no AS plNo,
DATE_FORMAT(a.refund_finish_time, '%Y-%m-%d') AS checkDate,
CASE
WHEN a.order_big_type =100 THEN
-100
WHEN a.order_big_type =200 THEN
-200
WHEN a.order_big_type =300 THEN
-300
ELSE
0
END AS checkFeeType,
sum(IFNULL(a.refund_total_fee, 0)) actFee,/** 支付方式 1:支付宝 2:微信 3:银联 4:微信公众号 6:现金 7:IC卡**/
sum(
CASE
WHEN b.pay_type = 1 THEN
IFNULL(a.refund_total_fee, 0)
ELSE
0
END
) aliFee,
sum(
CASE
WHEN b.pay_type = 1 THEN
1
ELSE
0
END
) aliChargeNum,
sum(
CASE
WHEN b.pay_type IN (2, 4) THEN
IFNULL(a.refund_total_fee, 0)
ELSE
0
END
) wxFee,
sum(
CASE
WHEN b.pay_type IN (2, 4) THEN
1
ELSE
0
END
) wxChargeNum,
sum(
CASE
WHEN b.pay_type = 5 THEN
IFNULL(a.refund_total_fee, 0)
ELSE
0
END
) balanceFee,
sum(
CASE
WHEN b.pay_type = 5 THEN
1
ELSE
0
END
) balanceChargeNum,
sum(
CASE
WHEN b.pay_type = 6 THEN
IFNULL(a.refund_total_fee, 0)
ELSE
0
END
) cashFee,
sum(
CASE
WHEN b.pay_type = 6 THEN
1
ELSE
0
END
) cashChargeNum
FROM
order_refund a, pay_order b
WHERE a.rlt_pay_order_id=b.pay_order_id
and a.data_state = 1
and a.order_state=70 /**订单状态 -10:支付失败,80:待退款 ,60:退款中、70:退款成功,-20:全部退款失败,-30:部分退款失败,90:退款待申请**/
and a.refund_finish_time BETWEEN #{beginTime} and #{endTime}
GROUP BY
plNo,
DATE_FORMAT(a.refund_finish_time, '%Y-%m-%d'),
checkFeeType
</select>
<select id="queryRefundOrderByCondition"
parameterType="com.zteits.clouds.api.dto.order.refundorder.param.RefundOrderQueryByConditionReq"
resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
order_refund
<where>
data_state = 1
<if test="orderIds != null and orderIds.size > 0">
AND order_id in
<foreach collection="orderIds" item="orderId" separator="," open="(" close=")">
#{orderId}
</foreach>
</if>
<if test="orderBigType != null">
AND order_big_type = #{orderBigType,jdbcType=INTEGER}
</if>
<if test="payOrderTypes != null and payOrderTypes.size>0">
AND pay_order_type IN
<foreach collection="payOrderTypes" item="payOrderType" open="(" close=")" separator=",">
#{payOrderType}
</foreach>
</if>
<if test="rltOrderIds != null and rltOrderIds.size > 0 ">
AND rlt_order_id IN
<foreach collection="rltOrderIds" item="rltOrderId" open="(" close=")" separator=",">
#{rltOrderId}
</foreach>
</if>
<if test="rltPayOrderIds != null and rltPayOrderIds.size > 0 ">
AND rlt_pay_order_id IN
<foreach collection="rltPayOrderIds" item="rltPayOrderId" open="(" close=")" separator=",">
#{rltPayOrderId}
</foreach>
</if>
<if test="orderStates != null and orderStates.size > 0 ">
AND order_state IN
<foreach collection="orderStates" item="orderState" open="(" close=")" separator=",">
#{orderState}
</foreach>
</if>
<if test="terminalSource != null">
and terminal_source = #{terminalSource,jdbcType=INTEGER},
</if>
<if test="payTypes != null and payTypes.size > 0 ">
AND pay_type IN
<foreach collection="payTypes" item="payType" open="(" close=")" separator=",">
#{payType}
</foreach>
</if>
<if test="payFinishTimeStart != null">
AND pay_finish_time >= #{payFinishTimeStart}
</if>
<if test="payFinishTimeEnd != null">
AND pay_finish_time <= #{payFinishTimeEnd}
</if>
<if test="refundFinishTimeStart != null">
AND refund_finish_time >= #{refundFinishTimeStart}
</if>
<if test="refundFinishTimeEnd != null">
AND refund_finish_time <= #{refundFinishTimeEnd}
</if>
<if test="plNos != null and plNos.size > 0 ">
AND pl_no IN
<foreach collection="plNos" item="plNo" open="(" close=")" separator=",">
#{plNo}
</foreach>
</if>
<if test="carNumber != null">
AND car_number LIKE concat ('%',#{carNumber},'%')
</if>
<if test="auditState != null">
AND audit_state = #{auditState,jdbcType=INTEGER}
</if>
<if test="allowRefundTime != null">
and pay_finish_time >= DATE_SUB(now(),INTERVAL #{allowRefundTime} SECOND)
</if>
<if test="orgId != null">
and org_id = #{orgId}
</if>
</where>
</select>
<!--对账单-查询除现金以为的所有退款单信息-->
<select id="queryOrderRefundForList" resultType="com.zteits.order.domain.TdBPayBlncacResult">
select
DATE_FORMAT(a.refund_finish_time,'%Y-%m-%d') as reportDate,
2 as busType,
a.pl_no as plNo,
'' as plName,
a.rlt_pay_order_id as payOrderId,
a.transaction_id as transactionId,
a.rlt_order_id as rltOrderId,
a.refund_finish_time as payFinishTime,
a.pay_type as payType,
1 as orderNum,
a.app_id as appId,
a.order_total_fee as totalFee,
a.order_act_fee as actFee,
a.order_dicount_fee as dicountFee,
a.refund_total_fee as refundTotalFee,
a.refund_act_fee as refundActFee,
a.refund_act_fee + ifnull(a.diff_FEE,0) as blncaceActualFee,
a.qeual_type as qeualType,
a.diff_FEE as diffFee,
a.diff_remark as diffRemark,
a.trade_service_fee as tradeServiceFee,
a.platform_service_fee as platformServiceFee,
a.data_state as dataState,
now() as createDate,
a.create_emp_id as createEmpId,
a.create_emp_name as createEmpName
from order_refund a
where 1=1
and a.data_state=1
and a.order_state in(70) /**订单状态:-10:支付失败,80:待退款 ,60:退款中、70:退款成功,-20:全部退款失败,-30:部分退款失败,90:退款待申请*/
and a.pay_type in(1,2,4,5) /**支付方式 -1:未知(创建时还不清楚支付方式)1:支付宝 2:微信 3:银联 4:微信公众号 5:个人账户 6:现金 7:IC卡*/
<![CDATA[and a.refund_finish_time >= #{beginTime}]]>
<![CDATA[and a.refund_finish_time <= #{endTime}]]>
and a.id%#{threadNum}=#{modId}
</select>
<!--对账单-查询除现金以为的所有退款单信息-->
<select id="queryOrderRefundByPayTypeForList" resultType="com.zteits.order.domain.PayOrderSuccess">
select
DATE_FORMAT(a.refund_finish_time,'%Y-%m-%d') as reportDate,
a.pl_no as plNo,
'' as plName,
a.rlt_pay_order_id as payOrderId,
a.transaction_id as transactionId,
a.rlt_order_id as rltOrderId,
a.org_id as orgId,
a.order_big_type as orderBigType,
a.pay_order_type as payOrderType,
a.refund_finish_time as payFinishTime,
a.pay_type as payType,
1 as orderNum,
a.app_id as appId,
a.order_dicount_fee as orderDicountFee,
a.refund_total_fee as orderActFee,
a.refund_total_fee as orderTotalFee,
a.platform_service_fee as platformServiceFee,
a.data_state as dataState,
now() as createDate,
a.create_emp_id as createEmpId,
a.create_emp_name as createEmpName
from order_refund a
where 1=1
and a.data_state=1
and a.order_state in(70) /**订单状态:-10:支付失败,80:待退款 ,60:退款中、70:退款成功,-20:全部退款失败,-30:部分退款失败,90:退款待申请*/
and a.pay_type in
<foreach collection="payTypeList" open="(" close=")" item="payType" separator=",">
#{payType}
</foreach>
<![CDATA[and a.refund_finish_time >= #{beginTime}]]>
<![CDATA[and a.refund_finish_time <= #{endTime}]]>
and a.rlt_pay_order_id %#{threadNum}=#{modId}
</select>
<!-- 会员卡退款详情查询 -->
<select id="queryRefundOrderMsg"
parameterType="com.zteits.clouds.api.dto.order.refundorder.param.QueryVipCardRefundReqest"
resultMap="BaseResultMap">
SELECT
<include refid="Base_Column_List"/>
FROM
order_refund
<where>
data_state = 1 AND person_card_no = #{personCardNo}
</where>
</select>
<!--根据退款日期返回退款金额(根据orgId、pay_type分组)-->
<select id="queryOrderRefundByPayType" resultType="com.zteits.order.domain.sdo.TdBSettlementRecordDO">
select
a.org_id as orgId,
sum(case when a.pay_type=1 then
IFNULL(a.refund_total_fee, 0)
ELSE
0
end) as aliRefundFee,
sum(case when a.pay_type in(2,4) then
IFNULL(a.refund_total_fee, 0)
ELSE
0
end) as wxRefundFee
from order_refund a
where 1=1
and a.data_state=1
and a.pay_type in(1,2,4)
and a.order_state in(70) /**订单状态:-10:支付失败,80:待退款 ,60:退款中、70:退款成功,-20:全部退款失败,-30:部分退款失败,90:退款待申请*/
and date(a.refund_finish_time)=date(#{refundTime})
group by a.org_id
</select>
<!--通过退款状态查询退款支付单-->
<select id="queryOrderRefundPayOrderIdsByOrderState" resultType="java.lang.String">
SELECT
a.pay_order_id
FROM
pay_order a,order_refund b
WHERE 1=1
and a.pay_order_id=b.rlt_pay_order_id
and a.data_state=b.data_state
and a.data_state=1
and a.order_big_type=200 /**关联的订单大类型:100:停车订单 200:充值订单*/
and a.terminal_source=1 /**终端来源:1:任你听 2:pda 3:微信公共号 4:云平台,5:道闸.*/
and a.pay_order_state=40
and a.org_id=#{orgId}
and b.order_state=#{orderState}
</select>
<!--根据退款时间及终端来源查询退款信息-->
<select id="queryRefundOrderByRefunFinshTimeAndTerminalSource" parameterType="com.zteits.clouds.api.dto.order.refundorder.param.QueryRefundOrderByRefQunFinshTimeAndTerminalSourceReq"
resultType="com.zteits.clouds.api.dto.order.refundorder.dto.OrderRefundDTO">
select
aa.pay_type as payType,
sum(IFNULL(aa.refund_total_fee,0)) as refundTotalFee
from (
SELECT
(case when b.pay_type in(2,4) then
2
else
b.pay_type
end) as pay_type,
sum(b.refund_total_fee) as refund_total_fee
FROM
order_refund b
WHERE 1=1
and b.data_state=1
and b.order_state=70
and b.order_big_type=200 /**关联的订单大类型:100:停车订单 200:充值订单*/
and b.pay_type in(1,2,4)
/**终端来源:1:任你听 2:pda 3:微信公共号 4:云平台,5:道闸.*/
and b.org_id=#{orgId}
<![CDATA[and b.refund_finish_time>=#{beginTime}
and b.refund_finish_time<=#{endTime}]]>
<if test="terminalSourceIds != null and terminalSourceIds.size>0">
and b.terminal_source in
<foreach collection="terminalSourceIds" item="terminalSourceId" open="(" close=")" separator=",">
#{terminalSourceId}
</foreach>
</if>
group by b.pay_type)aa
group by aa.pay_type
</select>
<!-- 根据条件查询退款汇总 -->
<select id="queryRefundOrderTotalByCondition"
parameterType="com.zteits.clouds.api.dto.order.refundorder.param.RefundOrderQueryByConditionReq"
resultType="com.zteits.clouds.api.dto.order.refundorder.dto.OrderRefundTotalDTO">
SELECT
IFNULL(sum(refund_total_fee), 0) allRefundFee,
sum(
CASE
WHEN pay_type = 1 THEN
IFNULL(refund_total_fee, 0)
ELSE
0
END
) AS aliRefundFee,
sum(
CASE
WHEN pay_type IN (2, 4) THEN
IFNULL(refund_total_fee, 0)
ELSE
0
END
) AS wxRefundFee,
sum(
CASE
WHEN pay_type IN (5, 6,34) THEN
IFNULL(refund_total_fee, 0)
ELSE
0
END
) AS otherRefundFee
FROM
order_refund
<where>
data_state = 1
<if test="orderIds != null and orderIds.size > 0">
AND order_id in
<foreach collection="orderIds" item="orderId" separator="," open="(" close=")">
#{orderId}
</foreach>
</if>
<if test="orderBigType != null">
AND order_big_type = #{orderBigType,jdbcType=INTEGER}
</if>
<if test="payOrderTypes != null and payOrderTypes.size>0">
AND pay_order_type IN
<foreach collection="payOrderTypes" item="payOrderType" open="(" close=")" separator=",">
#{payOrderType}
</foreach>
</if>
<if test="rltOrderIds != null and rltOrderIds.size > 0 ">
AND rlt_order_id IN
<foreach collection="rltOrderIds" item="rltOrderId" open="(" close=")" separator=",">
#{rltOrderId}
</foreach>
</if>
<if test="rltPayOrderIds != null and rltPayOrderIds.size > 0 ">
AND rlt_pay_order_id IN
<foreach collection="rltPayOrderIds" item="rltPayOrderId" open="(" close=")" separator=",">
#{rltPayOrderId}
</foreach>
</if>
<if test="orderStates != null and orderStates.size > 0 ">
AND order_state IN
<foreach collection="orderStates" item="orderState" open="(" close=")" separator=",">
#{orderState}
</foreach>
</if>
<if test="terminalSource != null">
and terminal_source = #{terminalSource,jdbcType=INTEGER},
</if>
<if test="payTypes != null and payTypes.size > 0 ">
AND pay_type IN
<foreach collection="payTypes" item="payType" open="(" close=")" separator=",">
#{payType}
</foreach>
</if>
<if test="payFinishTimeStart != null">
AND pay_finish_time >= #{payFinishTimeStart}
</if>
<if test="payFinishTimeEnd != null">
AND pay_finish_time <= #{payFinishTimeEnd}
</if>
<if test="refundFinishTimeStart != null">
AND refund_finish_time >= #{refundFinishTimeStart}
</if>
<if test="refundFinishTimeEnd != null">
AND refund_finish_time <= #{refundFinishTimeEnd}
</if>
<if test="plNos != null and plNos.size > 0 ">
AND pl_no IN
<foreach collection="plNos" item="plNo" open="(" close=")" separator=",">
#{plNo}
</foreach>
</if>
<if test="carNumber != null">
AND car_number LIKE concat ('%',#{carNumber},'%')
</if>
<if test="auditState != null">
AND audit_state = #{auditState,jdbcType=INTEGER}
</if>
<if test="allowRefundTime != null">
and pay_finish_time >= DATE_SUB(now(),INTERVAL #{allowRefundTime} SECOND)
</if>
<if test="orgId != null">
and org_id = #{orgId}
</if>
</where>
</select>
<!--根据终端来源查询所有支付单信息 -->
<select id="queryRefundOrderRntPayOrderIds" resultType="java.lang.String">
SELECT
a.rlt_pay_order_id
FROM
order_refund a
WHERE
a.data_state=1
<if test="terminalSource != null">
and a.terminal_source=#{terminalSource}
</if>
<![CDATA[and a.pay_finish_time >= #{beginTime}
and a.pay_finish_time <= #{endTime}]]>
and a.org_id=#{orgId}
</select>
<!--财务管理-账单管理(对账助手) 查询当天的退费-->
<select id="queryCurrentOrderRefundByTimeForFinanceBill" resultType="com.zteits.order.domain.IncomeFinanceBill">
SELECT
IFNULL(sum(case when a.order_big_type in(100,200) then IFNULL(a.refund_total_fee, 0)end ),0) as refundParkFee,
IFNULL(sum(case when a.order_big_type =300 then IFNULL(a.refund_total_fee, 0) end ),0) as refundVipFee,
0 as refundBackFee
FROM order_refund a, pay_order b
WHERE a.rlt_pay_order_id=b.pay_order_id
and a.data_state = 1
and a.order_state=70 /**订单状态 -10:支付失败,80:待退款 ,60:退款中、70:退款成功,-20:全部退款失败,-30:部分退款失败,90:退款待申请**/
and a.refund_finish_time BETWEEN #{startTime} and #{endTime}
and a.pl_no=#{plNo}
</select>
<!--查询线上退款-->
<select id="queryRefundIncomeOnlineBill" resultType="com.zteits.order.domain.IncomeOnlineBill">
SELECT
DATE_FORMAT(a.refund_finish_time, '%Y-%m-%d') AS checkDate,
a.org_id as orgId,
IFNULL(sum(IFNULL(a.refund_total_fee, 0)),0) as refundActFee,
IFNULL(sum(case when a.pay_type=1 then IFNULL(a.refund_total_fee, 0) end),0) as refundAliFee,
sum(CASE WHEN a.pay_type = 1 THEN 1 ELSE 0 END) refundAliChargeNum,
IFNULL(sum(case when a.pay_type in(2,4) then IFNULL(a.refund_total_fee, 0) end),0) as refundWxFee,
sum(CASE WHEN a.pay_type IN (2, 4) THEN 1 ELSE 0 END) refundWxChargeNum
FROM
order_refund a
WHERE 1=1
AND a.data_state = 1
and a.pay_type in(1,2,4)
AND a.order_state = 70 /**订单状态 -10:支付失败,80:待退款 ,60:退款中、70:退款成功,-20:全部退款失败,-30:部分退款失败,90:退款待申请**/
AND a.refund_finish_time BETWEEN #{startTime} and #{endTime}
group by DATE_FORMAT(a.refund_finish_time, '%Y-%m-%d'),a.org_id
</select>
</mapper>