TdCAcctSourceSMapper.xml
13.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
<?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.pay.mapper.smapper.TdCAcctSourceSMapper" >
<resultMap id="BaseResultMap" type="com.zteits.pay.domain.TdCAcctSource">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="source_bill_id" jdbcType="VARCHAR" property="sourceBillId" />
<result column="acct_id" jdbcType="VARCHAR" property="acctId" />
<result column="cust_id" jdbcType="VARCHAR" property="custId" />
<result column="acct_type" jdbcType="INTEGER" property="acctType" />
<result column="terminal_source" jdbcType="INTEGER" property="terminalSource" />
<result column="pl_no" jdbcType="VARCHAR" property="plNo" />
<result column="berth_no" jdbcType="VARCHAR" property="berthNo" />
<result column="recharge_type" jdbcType="INTEGER" property="rechargeType" />
<result column="recharge_remark" jdbcType="VARCHAR" property="rechargeRemark" />
<result column="recharge_fee" jdbcType="DECIMAL" property="rechargeFee" />
<result column="recharge_balance" jdbcType="DECIMAL" property="rechargeBalance" />
<result column="recharge_ID" jdbcType="VARCHAR" property="rechargeId" />
<result column="recharge_name" jdbcType="VARCHAR" property="rechargeName" />
<result column="recharge_time" jdbcType="TIMESTAMP" property="rechargeTime" />
<result column="rlt_order_id" jdbcType="VARCHAR" property="rltOrderId" />
<result column="rlt_payorder_id" jdbcType="VARCHAR" property="rltPayorderId" />
<result column="qeual_type" jdbcType="INTEGER" property="qeualType" />
<result column="other_service_fee" jdbcType="DECIMAL" property="otherServiceFee" />
<result column="rnt_service_fee" jdbcType="DECIMAL" property="rntServiceFee" />
<result column="acct_upt_state" jdbcType="INTEGER" property="acctUptState" />
<result column="data_state" jdbcType="INTEGER" property="dataState" />
<result column="create_empid" jdbcType="VARCHAR" property="createEmpid" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="modfiy_empid" jdbcType="VARCHAR" property="modfiyEmpid" />
<result column="modfiy_date" jdbcType="TIMESTAMP" property="modfiyDate" />
<result column="org_id" jdbcType="BIGINT" property="orgId" />
<result column="org_name" jdbcType="VARCHAR" property="orgName" />
</resultMap>
<sql id="Base_Column_List">
id, source_bill_id, acct_id, cust_id, acct_type, terminal_source, pl_no, berth_no,
recharge_type,recharge_remark, recharge_fee, recharge_balance, recharge_ID, recharge_name, recharge_time,
rlt_order_id, rlt_payorder_id, qeual_type, other_service_fee, rnt_service_fee, acct_upt_state,
data_state, create_empid, create_date, modfiy_empid, modfiy_date, org_id, org_name
</sql>
<select id="getAcctSource" resultMap="BaseResultMap"
parameterType="com.zteits.pay.domain.TdCAcctSource">
select
<include refid="Base_Column_List" />
from td_c_acct_source
where data_state = 1
<if test="sourceBillId != null">
and source_bill_id = #{sourceBillId,jdbcType=VARCHAR}
</if>
<if test="acctId != null">
and acct_id = #{acctId,jdbcType=VARCHAR}
</if>
<if test="custId != null">
and cust_id = #{custId,jdbcType=VARCHAR}
</if>
<if test="acctType != null">
and acct_type = #{acctType,jdbcType=INTEGER}
</if>
<if test="terminalSource != null">
and terminal_source = #{terminalSource,jdbcType=INTEGER}
</if>
<if test="plNo != null">
and pl_no = #{plNo,jdbcType=VARCHAR}
</if>
<if test="berthNo != null">
and berth_no = #{berthNo,jdbcType=VARCHAR}
</if>
<if test="rechargeType != null">
and recharge_type = #{rechargeType,jdbcType=INTEGER}
</if>
<if test="rechargeRemark != null">
and recharge_remark = #{rechargeRemark,jdbcType=VARCHAR}
</if>
<if test="rechargeFee != null">
and recharge_fee = #{rechargeFee,jdbcType=DECIMAL}
</if>
<if test="rechargeBalance != null">
and recharge_balance = #{rechargeBalance,jdbcType=DECIMAL}
</if>
<if test="rechargeId != null">
and recharge_ID = #{rechargeId,jdbcType=VARCHAR}
</if>
<if test="rechargeName != null">
and recharge_name = #{rechargeName,jdbcType=VARCHAR}
</if>
<if test="rechargeTime != null">
and recharge_time = #{rechargeTime,jdbcType=TIMESTAMP}
</if>
<if test="rltOrderId != null">
and rlt_order_id = #{rltOrderId,jdbcType=VARCHAR}
</if>
<if test="rltPayorderId != null">
and rlt_payorder_id = #{rltPayorderId,jdbcType=VARCHAR}
</if>
<if test="qeualType != null">
and qeual_type = #{qeualType,jdbcType=INTEGER}
</if>
<if test="otherServiceFee != null">
and other_service_fee = #{otherServiceFee,jdbcType=DECIMAL}
</if>
<if test="rntServiceFee != null">
and rnt_service_fee = #{rntServiceFee,jdbcType=DECIMAL}
</if>
<if test="acctUptState != null">
and acct_upt_state = #{acctUptState,jdbcType=INTEGER}
</if>
<if test="dataState != null">
and data_state = #{dataState,jdbcType=INTEGER}
</if>
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
order by create_date desc
</select>
<!-- 查询共享车位的总收入 -->
<select id="queryShareBerthActFee" resultType="java.lang.Long"
parameterType="com.zteits.pay.domain.TdCAcctSource">
select
IFNULL(sum(recharge_fee),0)
from td_c_acct_source
where data_state=1
and cust_id = #{custId,jdbcType=VARCHAR}
and pl_no = #{plNo,jdbcType=VARCHAR}
and berth_no = #{berthNo,jdbcType=VARCHAR}
and acct_type = #{acctType,jdbcType=INTEGER}
</select>
<!-- 查询车主收费端每日充值的收入 third:第三方农行掌银,other:农行补贴-->
<select id="queryCustRechargeFeeStatic" resultType="com.zteits.clouds.api.dto.pay.AcctSourceQueryRechargeStaticDTO"
parameterType="com.zteits.clouds.api.dto.pay.param.QueryAcctSourceStaticRequest">
select
date(recharge_time) rechargeTime,
IFNULL(count(case when recharge_type in (1, 2, 21,34) and acct_type in (1,11) then recharge_fee end), 0) totalNum,
IFNULL(sum(case when recharge_type in (1, 2, 21,34) and acct_type in (1,11) then recharge_fee end), 0) total,
IFNULL(count(case when recharge_type = 1 and acct_type = 1 then recharge_fee end), 0) zfbNum,
IFNULL(sum(case when recharge_type = 1 and acct_type = 1 then recharge_fee end), 0) zfb,
IFNULL(count(case when recharge_type = 2 and acct_type = 1 then recharge_fee end), 0) wxNum,
IFNULL(sum(case when recharge_type = 2 and acct_type = 1 then recharge_fee end), 0) wx,
IFNULL(count(case when recharge_type = 21 and acct_type = 1 then recharge_fee end), 0) chuzkNum,
IFNULL(sum(case when recharge_type = 21 and acct_type = 1 then recharge_fee end), 0) chuzk,
IFNULL(count(case when recharge_type = 34 and acct_type = 11 then recharge_fee end), 0) otherNum,
IFNULL(sum(case when recharge_type = 34 and acct_type = 11 then recharge_fee end), 0) other,
IFNULL(count(case when recharge_type = 34 and acct_type = 1 then recharge_fee end), 0) thirdNum,
IFNULL(sum(case when recharge_type = 34 and acct_type = 1 then recharge_fee end), 0) third
from td_c_acct_source
where data_state=1
<if test="userPhone != null and userPhone != ''">
and cust_id in (
select cust_id from td_c_cust_person
where user_phone = #{userPhone}
)
</if>
<if test="payTypeList != null and payTypeList.size > 0">
and recharge_type in
<foreach collection="payTypeList" open="(" close=")" item="payType" separator=",">
#{payType}
</foreach>
</if>
and org_id=#{orgId}
and recharge_time >= #{startTime} AND recharge_time <=#{endTime}
group by date(recharge_time) desc
</select>
<!-- 查询车主收费端每日充值的收入详情 -->
<select id="queryCustRechargeFeeStaticMsg" resultType="com.zteits.clouds.api.dto.pay.AcctSourceQueryRechargeDetailDTO"
parameterType="com.zteits.clouds.api.dto.pay.param.QueryAcctSourceStaticRequest">
select
tp.user_phone userPhone,
ts.recharge_type rechargeType,
ts.recharge_fee rechargeFee,
ts.recharge_balance rechargeBalance,
ts.recharge_time rechargeTime,
ts.acct_type acctType
from
(select cust_id,acct_type,recharge_type ,recharge_fee ,recharge_balance ,recharge_time
from td_c_acct_source
where data_state = 1 AND acct_type in (1,7,11)
<if test="custId != null and custId != ''">
and cust_id = #{custId}
</if>
<if test="userPhone != null and userPhone != ''">
and cust_id in (
select cust_id from td_c_cust_person
where user_phone = #{userPhone}
)
</if>
<if test="orgId != null and orgId != ''">
and org_id=#{orgId}
</if>
<if test="startTime != null and endTime != null">
and recharge_time >= #{startTime} AND recharge_time <=#{endTime}
</if>
<if test="payTypeList != null and payTypeList.size > 0">
and recharge_type in
<foreach collection="payTypeList" open="(" close=")" item="payType" separator=",">
#{payType}
</foreach>
</if>
)ts,td_c_cust_person tp
where tp.cust_id = ts.cust_id
order by ts.recharge_time desc
</select>
<!-- 按客户id查询账户充值记录 -->
<select id="queryAcctRechargeForPage" resultMap="BaseResultMap"
parameterType="com.zteits.clouds.api.dto.pay.param.AcctPayoutForPageRequest">
select
<include refid="Base_Column_List" />
from td_c_acct_source
where data_state = 1
<if test="acctId != null">
and acct_id = #{acctId,jdbcType=VARCHAR}
</if>
<if test="custId != null and custId != ''">
and cust_id =#{custId}
</if>
<if test="acctTypeList != null and acctTypeList.size > 0">
and acct_type in
<foreach collection="acctTypeList" open="(" close=")" item="acctType" separator=",">
#{acctType}
</foreach>
</if>
<if test="custIds != null and custIds.size >0">
and cust_id in
<foreach collection="custIds" item="cust_id" open="(" close=")" separator=",">
#{cust_id}
</foreach>
</if>
<if test="beginTime != null ">
<![CDATA[ and recharge_time >= #{beginTime} ]]>
</if>
<if test="endTime != null ">
<![CDATA[ and recharge_time <= #{endTime} ]]>
</if>
<if test="rechargeType != null and rechargeType == 20">
and recharge_fee > 0
</if>
<if test="rechargeType != null and rechargeType == 30">
and recharge_fee <= 0
</if>
order by (recharge_time) desc
</select>
<select id="statisticAcctRecharge" resultType="com.zteits.clouds.api.dto.pay.AcctRechargeStatisticDTO">
select
ifnull(sum(CASE WHEN recharge_fee > 0
THEN recharge_fee
ELSE 0 END), 0) positiveFee,
ifnull(sum(CASE WHEN recharge_fee > 0
THEN 1
ELSE 0 END), 0) positiveNum,
ifnull(sum(CASE WHEN recharge_fee <= 0
THEN recharge_fee
ELSE 0 END), 0) negativeFee,
ifnull(sum(CASE WHEN recharge_fee <= 0
THEN 1
ELSE 0 END), 0) negativeNum
from td_c_acct_source
where data_state = 1
<if test="custId != null and custId != ''">
and cust_id =#{custId}
</if>
<if test="acctTypeList != null and acctTypeList.size > 0">
and acct_type in
<foreach collection="acctTypeList" open="(" close=")" item="acctType" separator=",">
#{acctType}
</foreach>
</if>
<if test="custIds != null and custIds.size >0">
and cust_id in
<foreach collection="custIds" item="cust_id" open="(" close=")" separator=",">
#{cust_id}
</foreach>
</if>
<if test="beginTime != null ">
<![CDATA[ and recharge_time >= #{beginTime} ]]>
</if>
<if test="endTime != null ">
<![CDATA[ and recharge_time <= #{endTime} ]]>
</if>
</select>
<!--通过手机号、cust_id 查询用户充值明细记录-->
<select id="queryCustRechargeByPhoneNumOrCustId" resultType="com.zteits.clouds.api.dto.pay.QueryRechargeByPhoneNumOrCustIdDTO"
parameterType="com.zteits.clouds.api.dto.pay.param.QueryRechargeByPhoneNumOrCustIdReq">
SELECT
b.cust_id as custId,
b.user_phone as userPhone,
a.rlt_payorder_id as rltPayorderId,
IFNULL(sum(case when a.acct_type =1 then
IFNULL(a.recharge_fee,0)
end),0) as rechargeFee,
IFNULL(sum(case when a.acct_type =1 then
IFNULL(a.recharge_balance,0)
end),0) as rechargeBalance,
IFNULL(sum(case when a.acct_type =7 then
IFNULL(a.recharge_fee,0)
end),0) as giveRechargeFee,
IFNULL(sum(case when a.acct_type =7 then
IFNULL(a.recharge_balance,0)
end),0) as giveRechargeBalance,
recharge_name as rechargeName,
recharge_time as rechargeTime
FROM td_c_cust_person b left join td_c_acct_source a on a.cust_id=b.cust_id
where 1=1
and b.data_state=1
and b.org_id=#{orgId}
and a.acct_type in(1,7)
<if test="custId != null ">
and a.cust_id=#{custId}
</if>
<if test="userPhone != null ">
and b.user_phone=#{userPhone}
</if>
<if test="rechargeBeginTime != null ">
<![CDATA[ and a.recharge_time >=#{rechargeBeginTime} ]]>
</if>
<if test="rechargeEndTime != null ">
<![CDATA[ and a.recharge_time <=#{rechargeEndTime} ]]>
</if>
group by b.cust_id,
b.user_phone,
b.cust_id,
b.user_phone,
a.rlt_payorder_id
order by a.acct_id asc,a.id desc
</select>
</mapper>