PayOrderSuccessSMapper.xml
26.3 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
<?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.PayOrderSuccessSMapper">
<resultMap id="BaseResultMap" type="com.zteits.order.domain.PayOrderSuccess">
<id column="id" jdbcType="BIGINT" property="id" />
<id column="pay_finish_time" jdbcType="TIMESTAMP" property="payFinishTime" />
<result column="pay_order_id" jdbcType="VARCHAR" property="payOrderId" />
<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="transaction_id" jdbcType="VARCHAR" property="transactionId" />
<result column="merchant_no" jdbcType="VARCHAR" property="merchantNo" />
<result column="buyer_logon_id" jdbcType="VARCHAR" property="buyerLogonId" />
<result column="buyer_user_name" jdbcType="VARCHAR" property="buyerUserName" />
<result column="pay_type" jdbcType="INTEGER" property="payType" />
<result column="terminal_source" jdbcType="INTEGER" property="terminalSource" />
<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_order_state" jdbcType="INTEGER" property="payOrderState" />
<result column="pay_bank_id" jdbcType="VARCHAR" property="payBankId" />
<result column="pay_bank_name" jdbcType="VARCHAR" property="payBankName" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="data_state" jdbcType="INTEGER" property="dataState" />
<result column="charger_code" jdbcType="VARCHAR" property="chargerCode" />
<result column="charger_name" jdbcType="VARCHAR" property="chargerName" />
<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="pay_order_title" jdbcType="VARCHAR" property="payOrderTitle" />
<result column="pl_no" jdbcType="VARCHAR" property="plNo" />
<result column="berth_range_no" jdbcType="VARCHAR" property="berthRangeNo" />
<result column="error_code" jdbcType="VARCHAR" property="errorCode" />
<result column="error_msg" jdbcType="VARCHAR" property="errorMsg" />
<result column="app_id" jdbcType="VARCHAR" property="appId" />
<result column="coupon_person_id" jdbcType="VARCHAR" property="couponPersonId" />
<result column="discount_remark" jdbcType="VARCHAR" property="discountRemark" />
<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="is_thirdparty_data" jdbcType="INTEGER" property="isThirdpartyData" />
<result column="platform_service_fee" jdbcType="BIGINT" property="platformServiceFee" />
<result column="org_id" jdbcType="BIGINT" property="orgId" />
<result column="org_name" jdbcType="VARCHAR" property="orgName" />
<result column="coupon_type" jdbcType="INTEGER" property="couponType" />
<result column="pay_order_out_id" jdbcType="VARCHAR" property="payOrderOutId" />
<result column="third_disc_fee" jdbcType="BIGINT" property="thirdDiscFee" />
<result column="third_disc" jdbcType="BIGINT" property="thirdDisc" />
<result column="third_disc_no" jdbcType="VARCHAR" property="thirdDiscNo" />
<result column="car_number" jdbcType="VARCHAR" property="carNumber" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="("
separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, pay_finish_time, pay_order_id, order_big_type, pay_order_type, rlt_order_id,
transaction_id, merchant_no, buyer_logon_id, buyer_user_name, pay_type, terminal_source,
order_dicount_fee, order_act_fee, order_total_fee, pay_order_state, pay_bank_id,
pay_bank_name, remark, data_state, charger_code, charger_name, create_emp_id, create_emp_name,
create_date, modfiy_emp_id, modfiy_emp_name, modfiy_date, pay_order_title, pl_no,
berth_range_no, error_code, error_msg, app_id, coupon_person_id, discount_remark,
qeual_type, diff_FEE, diff_remark, trade_service_fee, is_thirdparty_data, platform_service_fee,
org_id, org_name, coupon_type, pay_order_out_id, third_disc_fee, third_disc, third_disc_no,
car_number
</sql>
<insert id="batchSaveFromPayOrderByDate">
INSERT INTO pay_order_success(
<include refid="Base_Column_List"/>
) (
SELECT
<include refid="Base_Column_List"/>
FROM pay_order
WHERE
data_state = 1
AND pay_finish_time BETWEEN #{startDate} AND #{endDate}
AND pay_order_state = 40
LIMIT #{offSet}, #{batchSaveSize}
)
</insert>
<!--查询支付单-->
<select id="queryPayOrderSuccessForList" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from pay_order_success
where 1=1
AND data_state = 1
AND pay_order_state = 40
and pay_type in
<foreach collection="payTypeList" open="(" close=")" item="payType" separator=",">
#{payType}
</foreach>
AND pay_finish_time BETWEEN #{beginTime} AND #{endTime}
and pay_order_id%#{threadNum}=#{modId}
</select>
<!-- 根据收费员编码及时间查询收费员支付单收入-->
<select id="queryChargerIncomeStatisticDayBychargerCode" resultType="com.zteits.order.domain.ChargerIncomeStatisticDay">
select
a.charger_code as chargerCode,
DATE_FORMAT(a.pay_finish_time,'%Y-%m-%d') as staticDate,
sum( IFNULL( a.order_dicount_fee, 0 ) ) as dicountFee,
sum( IFNULL( a.order_total_fee, 0 ) ) AS totalFee,
sum( IFNULL( a.order_act_fee, 0 ) ) orderActFee,
sum(case when a.pay_order_type=103 then a.order_act_fee else 0 end) as backFee,
sum(case when a.pay_order_type=103 then 1 else 0 end) as backCount,
sum(case when a.pay_order_type=103 and a.terminal_source=1 then a.order_act_fee else 0 end) as appBackFee,
sum(case when a.pay_order_type=103 and a.terminal_source=1 then 1 else 0 end) as appBackCount,
sum(case when a.pay_order_type=103 and a.terminal_source=2 then a.order_act_fee else 0 end) as pdaBackFee,
sum(case when a.pay_order_type=103 and a.terminal_source=2 then 1 else 0 end) as pdaBackCount,
sum( CASE WHEN a.pay_type = 1 and a.pay_order_type in(101,102) THEN IFNULL( a.order_act_fee, 0 ) ELSE 0 END ) aliFee,
sum( CASE WHEN a.pay_type = 1 and a.pay_order_type in(101,102) THEN 1 ELSE 0 END ) aliCount,
sum( CASE WHEN a.pay_type IN ( 2, 4 ) and a.pay_order_type in(101,102) THEN IFNULL( a.order_act_fee, 0 ) ELSE 0 END ) wxFee,
sum( CASE WHEN a.pay_type IN ( 2, 4 ) and a.pay_order_type in(101,102) THEN 1 ELSE 0 END ) wxCount,
sum( CASE WHEN a.pay_type = 5 and a.pay_order_type in(101,102) THEN IFNULL( a.order_act_fee, 0 ) ELSE 0 END ) balanceFee,
sum( CASE WHEN a.pay_type = 5 and a.pay_order_type in(101,102) THEN 1 ELSE 0 END ) balanceCount,
sum( CASE WHEN a.pay_type = 6 and a.pay_order_type in(101,102) THEN IFNULL( a.order_act_fee, 0 ) ELSE 0 END ) cashFee,
sum( CASE WHEN a.pay_type = 6 and a.pay_order_type in(101,102) THEN 1 ELSE 0 END ) cashCount
FROM
pay_order_success a
WHERE
1 = 1
AND a.data_state = 1
AND a.order_big_type=100
and a.pay_order_state=40
and a.charger_code=#{chargeCode}
and date(a.pay_finish_time)=#{datatime}
group by a.charger_code, DATE_FORMAT(a.pay_finish_time,'%Y-%m-%d')
</select>
<!-- 根据时间查询收费员支付单收入List-->
<select id="queryChargerIncomeStatisticDayForList" resultType="com.zteits.order.domain.ChargerIncomeStatisticDay">
select
max(a.org_id) AS orgId,
max(a.pl_no) AS plNo,
max(a.charger_name) AS chargerName,
a.charger_code as chargerCode,
DATE_FORMAT(a.pay_finish_time,'%Y-%m-%d') as staticDate,
sum( IFNULL( a.order_dicount_fee, 0 ) ) as dicountFee,
sum( IFNULL( a.order_total_fee, 0 ) ) + sum( IFNULL( a.third_disc_fee, 0 ) )AS totalFee,
sum( IFNULL( a.order_act_fee, 0 ) )+ sum( IFNULL( a.third_disc_fee, 0 ) ) as orderActFee,
sum(case when a.pay_order_type=103 then a.order_act_fee else 0 end) as backFee,
sum(case when a.pay_order_type=103 then 1 else 0 end) as backCount,
sum(case when a.pay_order_type=103 and a.terminal_source != 2 then a.order_act_fee else 0 end) as appBackFee,
sum(case when a.pay_order_type=103 and a.terminal_source != 2 then 1 else 0 end) as appBackCount,
sum(case when a.pay_order_type=103 and a.terminal_source=2 then a.order_act_fee else 0 end) as pdaBackFee,
sum(case when a.pay_order_type=103 and a.terminal_source=2 then 1 else 0 end) as pdaBackCount,
sum( CASE WHEN a.pay_type = 1 and a.pay_order_type in(101,102) THEN IFNULL( a.order_act_fee, 0 ) ELSE 0 END ) aliFee,
sum( CASE WHEN a.pay_type = 1 and a.pay_order_type in(101,102) THEN 1 ELSE 0 END ) aliCount,
sum( CASE WHEN a.pay_type IN ( 2, 4 ) and a.pay_order_type in(101,102) THEN IFNULL( a.order_act_fee, 0 ) ELSE 0 END ) wxFee,
sum( CASE WHEN a.pay_type IN ( 2, 4 ) and a.pay_order_type in(101,102) THEN 1 ELSE 0 END ) wxCount,
sum( CASE WHEN a.pay_type = 5 and a.pay_order_type in(101,102) THEN IFNULL( a.order_act_fee, 0 ) ELSE 0 END ) balanceFee,
sum( CASE WHEN a.pay_type = 5 and a.pay_order_type in(101,102) THEN 1 ELSE 0 END ) balanceCount,
sum( CASE WHEN a.pay_type in (6,34) and a.pay_order_type in(101,102) THEN IFNULL( a.order_act_fee, 0 ) ELSE 0 END ) cashFee,
sum( CASE WHEN a.pay_type in (6,34) and a.pay_order_type in(101,102) THEN 1 ELSE 0 END ) cashCount
FROM
pay_order_success a
WHERE
1 = 1
AND a.data_state = 1
AND a.order_big_type=100
AND a.pay_type !=7
and a.pay_order_state=40
and a.charger_code is not null and a.charger_code != ""
and a.pay_finish_time BETWEEN #{beginTime} AND #{endTime}
group by a.charger_code, DATE_FORMAT(a.pay_finish_time,'%Y-%m-%d')
</select>
<!-- 财务管理-账单管理(对账助手) 临停、补缴、会员卡查询-->
<select id="queryIncomeFinanceBillByTime" resultType="com.zteits.order.domain.IncomeFinanceBill">
SELECT
a.pl_no AS plNo,
DATE_FORMAT(a.pay_finish_time, '%Y-%m-%d') AS checkDate,
/**临时停车应收*/
IFNULL(sum(case when a.pay_order_type in(101, 102) then IFNULL(a.order_total_fee, 0) end),0) as parkTotalFee,
/**临时停车实收*/
IFNULL(sum(case when a.pay_order_type in(101, 102) then IFNULL(a.order_act_fee, 0) end),0) as parkActFee,
/**临时停车优惠*/
IFNULL(sum(case when a.pay_order_type in(101, 102) then IFNULL(a.order_dicount_fee, 0) end),0) as parkDicountFee,
/**临时停车第三方优惠*/
IFNULL(sum(case when a.pay_order_type in(101, 102) and a.pay_type = 34 then IFNULL(a.third_disc_fee, 0) end),0) as parkThirdDiscFee,
/**临时停车阿里实收*/
IFNULL(sum(CASE WHEN a.pay_order_type in(101, 102) and a.pay_type = 1 THEN IFNULL(a.order_act_fee, 0) ELSE 0 END),0) parkAliFee,
/**临时停车支付宝次数*/
sum(CASE WHEN a.pay_order_type in(101, 102) and a.pay_type = 1 THEN 1 ELSE 0 END) parkAliChargeNum,
/**临时停车ETC实收*/
IFNULL(sum(CASE WHEN a.pay_order_type in(101, 102) and a.pay_type = 32 THEN IFNULL(a.order_act_fee, 0) ELSE 0 END),0) parkEtcFee,
/**临时停车ETC次数*/
sum(CASE WHEN a.pay_order_type in(101, 102) and a.pay_type = 32 THEN 1 ELSE 0 END) parkEtcChargeNum,
/**临时停车农行实收*/
IFNULL(sum(CASE WHEN a.pay_order_type in(101, 102) and a.pay_type = 34 THEN IFNULL(a.order_act_fee, 0) ELSE 0 END),0) parkAbcFee,
/**临时停车农行次数*/
sum(CASE WHEN a.pay_order_type in(101, 102) and a.pay_type = 34 THEN 1 ELSE 0 END) parkAbcChargeNum,
/**临时停车微信收入*/
IFNULL(sum(CASE WHEN a.pay_order_type in(101, 102) and a.pay_type IN (2, 4) THEN IFNULL(a.order_act_fee, 0) ELSE 0 END),0) parkWxFee,
/**临时停车微信次数*/
sum(CASE WHEN a.pay_order_type in(101, 102) and a.pay_type IN (2, 4) THEN 1 ELSE 0 END) parkWxChargeNum,
/**临时停车余额收入*/
IFNULL(sum(CASE WHEN a.pay_order_type in(101, 102) and a.pay_type = 5 THEN IFNULL(a.order_act_fee, 0) ELSE 0 END) ,0) AS parkBalanceFee,
/**临时停车余额次数*/
sum(CASE WHEN a.pay_order_type in(101, 102) and a.pay_type=5 THEN 1 ELSE 0 END) parkBalanceChargeNum,
/**临时停车现金收入*/
IFNULL(sum(CASE WHEN a.pay_order_type in(101, 102) and a.pay_type = 6 THEN IFNULL(a.order_act_fee, 0) ELSE 0 END),0) parkCashFee,
/**临时停车现金次数*/
sum(CASE WHEN a.pay_order_type in(101, 102) and a.pay_type=6 THEN 1 ELSE 0 END) parkCashChargeNum,
/*******************补缴*******************************************/
/**补缴应收 单位:分*/
IFNULL(sum(case when a.pay_order_type =103 then IFNULL(a.order_total_fee, 0) end),0) as backTotalFee,
/**总补缴实收 单位:分1*/
IFNULL(sum(case when a.pay_order_type =103 then IFNULL(a.order_act_fee, 0) end),0) as backActFeeTotal,
/**总补缴优惠 单位:分1*/
IFNULL(sum(case when a.pay_order_type =103 then IFNULL(a.order_dicount_fee, 0) end),0) as backDicountFeeTotal,
/**总补缴第三方优惠 单位:分*/
IFNULL(sum(case when a.pay_order_type =103 and a.pay_type = 34 then IFNULL(a.third_disc_fee, 0) end),0) as backThirdDiscFee,
/**补缴支付宝实收*/
IFNULL(sum(CASE WHEN a.pay_order_type =103 and a.pay_type = 1 THEN IFNULL(a.order_act_fee, 0)ELSE 0 END),0)backAliFee,
/**补缴支付宝次数*/
sum(CASE WHEN a.pay_order_type =103 and a.pay_type = 1 THEN 1 ELSE 0 END) backAliChargeNum,
/**补缴ETC实收*/
IFNULL(sum(CASE WHEN a.pay_order_type =103 and a.pay_type = 32 THEN IFNULL(a.order_act_fee, 0)ELSE 0 END),0)backEtcFee,
/**补缴ETC次数*/
sum(CASE WHEN a.pay_order_type =103 and a.pay_type = 32 THEN 1 ELSE 0 END) backEtcChargeNum,
/**补缴农行实收*/
IFNULL(sum(CASE WHEN a.pay_order_type =103 and a.pay_type = 34 THEN IFNULL(a.order_act_fee, 0)ELSE 0 END),0)backAbcFee,
/**补缴农行次数*/
sum(CASE WHEN a.pay_order_type =103 and a.pay_type = 34 THEN 1 ELSE 0 END) backAbcChargeNum,
/**补缴微信收入*/
IFNULL(sum(CASE WHEN a.pay_order_type =103 and a.pay_type IN (2, 4) THEN IFNULL(a.order_act_fee, 0) ELSE 0 END),0) backWxFee,
/**补缴微信次数*/
sum(CASE WHEN a.pay_order_type =103 and a.pay_type IN (2, 4) THEN 1 ELSE 0 END) backWxChargeNum,
/**补缴余额收入*/
IFNULL(sum(CASE WHEN a.pay_order_type =103 and a.pay_type = 5 THEN IFNULL(a.order_act_fee, 0) ELSE 0 END),0) backBalanceFee,
/**补缴余额次数*/
sum(CASE WHEN a.pay_order_type =103 and a.pay_type=5 THEN 1 ELSE 0 END) backBalanceChargeNum,
/**补缴现金收入*/
IFNULL(sum(CASE WHEN a.pay_order_type =103 and a.pay_type = 6 THEN IFNULL(a.order_act_fee, 0) ELSE 0 END),0) backCashFee,
/**补缴现金次数*/
sum(CASE WHEN a.pay_order_type =103 and a.pay_type=6 THEN 1 ELSE 0 END) backCashChargeNum,
/*******************会员卡*******************************************/
/**会员卡应收 单位:分*/
IFNULL(sum(case when a.pay_order_type in(301,302,304,305,306,307) then IFNULL(a.order_total_fee, 0) end),0) as vipTotalFee,
/**会员卡缴实收 单位:分1*/
IFNULL(sum(case when a.pay_order_type in(301,302,304,305,306,307) then IFNULL(a.order_act_fee, 0) end),0) as vipActFee,
/**会员卡缴优惠 单位:分1*/
IFNULL(sum(case when a.pay_order_type in(301,302,304,305,306,307) then IFNULL(a.order_dicount_fee, 0) end),0) as vipDicountFee,
/**会员卡支付宝实收*/
IFNULL(sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type = 1 THEN IFNULL(a.order_act_fee, 0) ELSE 0 END),0) vipAliFee,
/**会员卡支付宝次数*/
sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type = 1 THEN 1 ELSE 0 END) vipAliChargeNum,
/**会员卡农行实收*/
IFNULL(sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type = 34 THEN IFNULL(a.order_act_fee, 0) ELSE 0 END),0) vipAbcFee,
/**会员卡农行次数*/
sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type = 34 THEN 1 ELSE 0 END) vipAbcChargeNum,
/**会员卡微信收入*/
IFNULL(sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type IN (2, 4) THEN IFNULL(a.order_act_fee, 0) ELSE 0 END),0) vipWxFee,
/**会员卡微信次数*/
sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type IN (2, 4) THEN 1 ELSE 0 END) vipWxChargeNum,
/**会员卡余额收入*/
IFNULL(sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type = 5 THEN IFNULL(a.order_act_fee, 0) ELSE 0 END),0) vipBalanceFee,
/**会员卡余额次数*/
sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type=5 THEN 1 ELSE 0 END) vipBalanceChargeNum,
/**会员卡现金收入*/
IFNULL(sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type = 6 THEN IFNULL(a.order_act_fee, 0) ELSE 0 END),0) vipCashFee,
/**会员卡现金次数*/
sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type=6 THEN 1 ELSE 0 END) vipCashChargeNum,
/**会员卡付款码收入*/
IFNULL(sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type = 33 THEN IFNULL(a.order_act_fee, 0) ELSE 0 END),0) vipPaymentCodeFee ,
/**会员卡付款码次数*/
sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type=33 THEN 1 ELSE 0 END) vipPaymentCodeChargeNum
FROM
pay_order_success a
WHERE
1=1
AND a.data_state = 1
AND a.pay_order_state = 40
and a.pay_type !=7
<![CDATA[and a.pay_finish_time >= #{startTime}
and a.pay_finish_time <= #{endTime}]]>
and a.pl_no not in('001','002')
and a.pay_type in(1,2,4,5,6,32,33,34)
and a.pl_no=#{plNo}
GROUP BY a.pl_no,
DATE_FORMAT(a.pay_finish_time, '%Y-%m-%d')
</select>
<!-- 财务管理-账单管理(对账助手) 临停、补缴、会员卡查询-->
<select id="queryVipCardIncomeFinanceBillByTime" resultType="com.zteits.order.domain.IncomeFinanceBill">
select
/*******************会员卡*******************************************/
a.pl_no,
/**会员卡缴实收 单位:分1*/
IFNULL(sum(case when a.pay_order_type in(301,302,304,305,306,307) then IFNULL(b.card_act_amount, 0) end),0) as vipActFee,
/**会员卡缴优惠 单位:分1*/
IFNULL(sum(case when a.pay_order_type in(301,302,304,305,306,307) then IFNULL(a.order_dicount_fee, 0) end),0) as vipDicountFee,
/**会员卡支付宝实收*/
IFNULL(sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type = 1 THEN IFNULL(b.card_act_amount, 0) ELSE 0 END),0) vipAliFee,
/**会员卡支付宝次数*/
sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type = 1 THEN 1 ELSE 0 END) vipAliChargeNum,
/**会员卡农行实收*/
IFNULL(sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type = 34 THEN IFNULL(b.card_act_amount, 0) ELSE 0 END),0) vipABcFee,
/**会员卡农行次数*/
sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type = 34 THEN 1 ELSE 0 END) vipAbcChargeNum,
/**会员卡微信收入*/
IFNULL(sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type IN (2, 4) THEN IFNULL(b.card_act_amount, 0) ELSE 0 END),0) vipWxFee,
/**会员卡微信次数*/
sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type IN (2, 4) THEN 1 ELSE 0 END) vipWxChargeNum,
/**会员卡余额收入*/
IFNULL(sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type = 5 THEN IFNULL(b.card_act_amount, 0) ELSE 0 END),0) vipBalanceFee,
/**会员卡余额次数*/
sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type=5 THEN 1 ELSE 0 END) vipBalanceChargeNum,
/**会员卡现金收入*/
IFNULL(sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type = 6 THEN IFNULL(b.card_act_amount, 0) ELSE 0 END),0) vipCashFee,
/**会员卡现金次数*/
sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type=6 THEN 1 ELSE 0 END) vipCashChargeNum,
/**会员卡付款码收入*/
IFNULL(sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type = 33 THEN IFNULL(b.card_act_amount, 0) ELSE 0 END),0) vipPaymentCodeFee ,
/**会员卡付款码次数*/
sum(CASE WHEN a.pay_order_type in(301,302,304,305,306,307) and a.pay_type=33 THEN 1 ELSE 0 END) vipPaymentCodeChargeNum
FROM
pay_order_success a, order_vipcard_detail b
WHERE 1=1
AND a.data_state = 1
AND a.data_state=b.data_state
and a.rlt_order_id=b.order_id
AND a.pay_order_state = 40
and a.pl_no=#{plNo}
and a.pay_type !=7
<![CDATA[and b.create_date >=#{startTime}
and b.create_date <=#{endTime}]]>
and a.pl_no not in('001','002')
and a.pay_order_type in(301,302,304,305,306,307)
and a.pay_type in(1,2,4,5,6,32,33)
GROUP BY a.pl_no
</select>
<select id="queryChargerIncomeInfo" resultType="com.zteits.order.domain.PayOrderSuccess">
select
ifnull(sum(order_total_fee), 0) orderTotalFee,
ifnull(sum(order_act_fee), 0) orderActFee,
ifnull(sum(third_disc_fee), 0) thirdDiscFee,
ifnull(sum(order_dicount_fee), 0) orderDicountFee
from pay_order_success t
where t.charger_code = #{chargerCode}
and t.pay_finish_time between #{startTime} and #{endTime}
and t.pay_order_state = 40
and t.order_big_type = 100
and t.pay_order_type = 101
</select>
</mapper>