TdCAcctPersonSMapper.xml
10.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
<?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.TdCAcctPersonSMapper" >
<resultMap id="BaseResultMap" type="com.zteits.pay.domain.TdCAcctPerson">
<id column="id" jdbcType="BIGINT" property="id" />
<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="acct_balance" jdbcType="DECIMAL" property="acctBalance" />
<result column="acct_default_balance" jdbcType="DECIMAL" property="acctDefaultBalance" />
<result column="acct_name" jdbcType="VARCHAR" property="acctName" />
<result column="acct_type_unit" jdbcType="INTEGER" property="acctTypeUnit" />
<result column="acct_order" jdbcType="INTEGER" property="acctOrder" />
<result column="main_flg" jdbcType="INTEGER" property="mainFlg" />
<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, acct_id, cust_id, acct_type, acct_balance, acct_default_balance, acct_name, acct_type_unit,
acct_order, main_flg, data_state, create_empid, create_date, modfiy_empid, modfiy_date,
org_id, org_name
</sql>
<!-- 修改账户 -->
<update id="updateAcctPerson" parameterType="com.zteits.pay.domain.TdCAcctPerson">
update td_c_acct_person
<set>
<if test="acctId != null">
acct_id = #{acctId,jdbcType=VARCHAR},
</if>
<if test="custId != null">
cust_id = #{custId,jdbcType=VARCHAR},
</if>
<if test="acctType != null">
acct_type = #{acctType,jdbcType=INTEGER},
</if>
<if test="acctBalance != null">
acct_balance = #{acctBalance,jdbcType=DECIMAL},
</if>
<if test="acctDefaultBalance != null">
acct_default_balance = #{acctDefaultBalance,jdbcType=DECIMAL},
</if>
<if test="acctName != null">
acct_name = #{acctName,jdbcType=VARCHAR},
</if>
<if test="acctTypeUnit != null">
acct_type_unit = #{acctTypeUnit,jdbcType=INTEGER},
</if>
<if test="acctOrder != null">
acct_order = #{acctOrder,jdbcType=INTEGER},
</if>
<if test="mainFlg != null">
main_flg = #{mainFlg,jdbcType=INTEGER},
</if>
<if test="dataState != null">
data_state = #{dataState,jdbcType=INTEGER},
</if>
<if test="createEmpid != null">
create_empid = #{createEmpid,jdbcType=VARCHAR},
</if>
<if test="createDate != null">
create_date = #{createDate,jdbcType=TIMESTAMP},
</if>
<if test="modfiyEmpid != null">
modfiy_empid = #{modfiyEmpid,jdbcType=VARCHAR},
</if>
<if test="modfiyDate != null">
modfiy_date = #{modfiyDate,jdbcType=TIMESTAMP},
</if>
<if test="orgId != null">
org_id = #{orgId,jdbcType=BIGINT},
</if>
<if test="orgName != null">
org_name = #{orgName,jdbcType=VARCHAR},
</if>
</set>
where data_state = 1
and cust_id = #{custId} and acct_type = #{acctType}
and org_id = #{orgId}
</update>
<select id="getAcctPerson" resultMap="BaseResultMap"
parameterType="com.zteits.pay.domain.TdCAcctPerson">
select
<include refid="Base_Column_List" />
from td_c_acct_person
where data_state = 1
and cust_id = #{custId} and acct_type = #{acctType} and org_id = #{orgId}
</select>
<!-- 通过custId和账户类型查询个人账户信息-->
<select id="queryAcctPersonByCustIdAndAcctType" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from td_c_acct_person
where data_state = 1
<if test="custId != null and custId != ''">
and cust_id = #{custId,jdbcType=VARCHAR}
</if>
<if test="custIds != null and custIds.size >0">
and cust_id in
<foreach collection="custIds" item="custId" open="(" close=")" separator=",">
#{custId}
</foreach>
</if>
<if test="acctTypeList != null and acctTypeList.size >0">
and acct_type in
<foreach collection="acctTypeList" item="acctType" open="(" close=")" separator=",">
#{acctType}
</foreach>
</if>
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
</select>
<select id="getAcctPersonGroupByOrgId" resultType="com.zteits.clouds.api.dto.pay.AcctPersonDTO" parameterType="com.zteits.clouds.api.dto.pay.param.QueryAcctPersonByCustIdsAndAcctTypeReq">
SELECT
org_id orgId,
sum( acct_balance ) acctBalance,
sum(case when acct_type in (1,4,7) then ifnull(acct_balance, 0) else 0 end) rechargeAccount,
sum(case when acct_type = 8 then ifnull(acct_balance, 0) else 0 end) giftAccount
FROM
td_c_acct_person
WHERE
data_state = 1
and cust_id = #{custId}
<if test="acctTypeList != null and acctTypeList.size >0">
and acct_type in
<foreach collection="acctTypeList" item="acctType" open="(" close=")" separator=",">
#{acctType}
</foreach>
</if>
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
GROUP BY
orgId
</select>
<select id="getAcctPersonGroupByAcctType" resultType="com.zteits.pay.domain.TdCAcctPerson" parameterType="com.zteits.clouds.api.dto.pay.param.QueryAcctPersonByCustIdsAndAcctTypeReq">
SELECT
org_id orgId,
acct_type acctType,
sum(acct_balance) acctBalance
FROM
td_c_acct_person
WHERE
data_state = 1
and cust_id = #{custId}
<if test="acctTypeList != null and acctTypeList.size >0">
and acct_type in
<foreach collection="acctTypeList" item="acctType" open="(" close=")" separator=",">
#{acctType}
</foreach>
</if>
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
GROUP BY
orgId,
acctType
</select>
<!-- 账单充值和支出明细-分页查询 -->
<select id="queryAccountInOutDetailsForPage" resultType="com.zteits.clouds.api.dto.pay.account.dto.AccountInOutDetailForPageDTO"
parameterType="com.zteits.clouds.api.dto.pay.account.param.AcctInOutDetailForPageRequest">
<if test="detailType == 1">
select 1 as type, b.acct_type acctType,b.recharge_type payType,b.recharge_fee changeFee,b.create_date createDate,b.rlt_order_id orderId
from td_c_acct_source b
where b.cust_id = #{custId}
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
order by b.create_date desc
</if>
<if test="detailType == 2">
select type,acctType,payType,changeFee,createDate,orderId
from
(select 2 as type, a.acct_type acctType,a.trade_type payType,sum(a.trade_fee) changeFee,a.create_date createDate,a.rlt_order_id orderId
from td_c_acct_payout a
where a.cust_id = #{custId}
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
group by a.rlt_order_id) b
order by b.createDate desc
</if>
<if test="detailType == null || detailType == ''">
select * from
(select 2 as type, a.acct_type acctType,a.trade_type payType,sum(a.trade_fee) changeFee,a.create_date createDate,a.rlt_order_id orderId
from td_c_acct_payout a
where a.cust_id = #{custId}
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
group by a.rlt_order_id
union
select 1 as type, b.acct_type acctType,b.recharge_type payType,b.recharge_fee changeFee,b.create_date createDate,b.rlt_order_id orderId
from td_c_acct_source b
where b.cust_id = #{custId}
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
)c
order by c.createDate desc
</if>
</select>
<!-- 个人账户金额加或者减操作-->
<update id="addOrsubAcctPersonFeeByAcctId" parameterType="com.zteits.clouds.api.dto.pay.param.AddOrsubAcctPersonFeeByAcctIdReq">
UPDATE td_c_acct_person a
<if test="addOrSubType == 1">
SET a.acct_balance = a.acct_balance + #{acctFee}
</if>
<if test="addOrSubType == 2">
SET a.acct_balance = a.acct_balance - #{acctFee}
</if>
WHERE
1 = 1
AND a.data_state = 1
and a.acct_id = #{acctId}
</update>
<!-- 分页查询储值车账户 -->
<select id="queryAcctPersonStoreCarForPage" resultType="com.zteits.clouds.api.dto.pay.dto.AcctPersonForStoreCarDTO"
parameterType="com.zteits.clouds.api.dto.pay.param.QueryAcctPersonForPageReq">
select
a.cust_id custId,
a.user_phone userPhone,
b.acct_id acctId,
b.acct_type acctType,
b.acct_name acctName,
ifnull(b.acct_balance,0) acctBalance,
case when ifnull(b.cust_id,'0') = '0' then 0 else 1 end isOpen
from td_c_cust_person a
left join td_c_acct_person b on a.cust_id = b.cust_id and b.data_state = 1 and b.acct_type = #{acctType} and b.org_id = #{orgId}
left join td_c_store_car c on a.cust_id = c.cust_id and c.data_state = 1
where a.data_state = 1
<if test="userPhone != null and userPhone != ''">
and a.user_phone = #{userPhone}
</if>
<if test="carNumber != null and carNumber != ''">
and c.car_number = #{carNumber}
</if>
<if test="acctName != null and acctName != ''">
and b.acct_name like concat('%',#{acctName},'%')
</if>
group by a.cust_id
order by isOpen desc , userPhone
</select>
<!-- 账单充值和支出明细-分页查询 -->
<select id="queryAccountRecordDetails" resultType="com.zteits.clouds.api.dto.pay.account.dto.AccountInOutDetailForPageDTO"
parameterType="com.zteits.clouds.api.dto.pay.account.param.AccoutRecordDetailRequest">
select 2 as type,
a.acct_type acctType,
a.trade_type payType,
a.trade_fee changeFee,
a.create_date createDate,
a.rlt_order_id orderId,
a.trade_time tradeTime,
a.trade_type tradeType
from td_c_acct_payout a
where a.cust_id = #{custId}
and a.rlt_order_id = #{orderId}
<if test="orgId != null">
and org_id = #{orgId,jdbcType=BIGINT}
</if>
order by createDate desc
</select>
</mapper>