trust-apply-mapper.xml
13.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
<?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">
<!-- 托管 @author 仝玉甫 -->
<mapper namespace="com.cjs.cms.dao.ration.TrustApplyDao">
<sql id="querySumCondition">
<if test="otcCode != null and otcCode != ''">
and t.otc_code = #{otcCode}
</if>
<if test="startDate != null and startDate != ''">
<if test="applyType == -1">
<![CDATA[and t.apply_date >= #{startDate}]]>
</if>
<if test="applyType == 6">
<![CDATA[and t.storage_date >= #{startDate}]]>
</if>
</if>
<if test="endDate != null and endDate != ''">
<if test="applyType == -1">
<![CDATA[and t.apply_date <= #{endDate}]]>
</if>
<if test="applyType == 6">
<![CDATA[and t.storage_date <= #{endDate}]]>
</if>
</if>
</sql>
<!-- 托管统计 -->
<select id="querySum" resultType="map" parameterType="map">
<include refid="common.pageStart"/>
SELECT A.*, C.OTC_NAME,
(SELECT MAX(B.STORAGE_DATE)
FROM HS_ASSET.TRUSTAPPLY B
WHERE B.OTC_CODE = A.OTC_CODE) AS LAST_STORAGE_DATE
FROM
(SELECT OTC_CODE,
SUM(APPLY_COUNT) APPLY_COUNT_SUM,
SUM(APPROVAL_COUNT) APPROVAL_COUNT_SUM,
SUM(BACK_AMOUNT) BACK_AMOUNT_SUM,
SUM(PRE_IN_AMOUNT) PRE_IN_AMOUNT_SUM,
sum(RETURNS_BACK_AMOUNT)RETURN_BACK_AMOUNT,
sum(RETURNS_EXT_APPROVAL_COUNT)RETURN_EXT_APPROVAL_COUNT
from(
select T.APPLY_COUNT, T.APPROVAL_COUNT , T.BACK_AMOUNT, T.PRE_IN_AMOUNT, OTC_CODE, OTC_NAME,
case when T.remove_way = '1' then T.BACK_AMOUNT else 0 end as RETURNS_BACK_AMOUNT,
case when t_ext.return_status = '2'then T.BACK_AMOUNT else 0 end as RETURNS_EXT_APPROVAL_COUNT
FROM HS_ASSET.TRUSTAPPLY T, hs_asset.trustapply_ext t_ext
WHERE T.apply_no = t_ext.apply_no(+) and
T.APPLY_TYPE not in ('1', '7')
<include refid="querySumCondition" />
)GROUP BY OTC_CODE) A, HS_OTC.OTCCODE C
WHERE A.OTC_CODE = C.OTC_CODE
<if test="orderBy == 0">
ORDER BY A.OTC_CODE
</if>
<if test="orderBy == 1">
ORDER BY LAST_STORAGE_DATE DESC
</if>
<include refid="common.pageEnd"/>
</select>
<select id="querySumTotal" resultType="int" parameterType="map">
SELECT COUNT(*)
FROM
(SELECT OTC_CODE,OTC_NAME,
SUM(APPLY_COUNT) APPLY_COUNT_SUM,
SUM(APPROVAL_COUNT) APPROVAL_COUNT_SUM,
SUM(BACK_AMOUNT) BACK_AMOUNT_SUM,
SUM(PRE_IN_AMOUNT) PRE_IN_AMOUNT_SUM,
sum(RETURNS_BACK_AMOUNT)RETURN_BACK_AMOUNT,
sum(RETURNS_EXT_APPROVAL_COUNT)RETURN_EXT_APPROVAL_COUNT
from(
select T.APPLY_COUNT, T.APPROVAL_COUNT , T.BACK_AMOUNT, T.PRE_IN_AMOUNT, OTC_CODE, OTC_NAME,
case when T.remove_way = '1' then T.BACK_AMOUNT else 0 end as RETURNS_BACK_AMOUNT,
case when t_ext.return_status = '2'then T.BACK_AMOUNT else 0 end as RETURNS_EXT_APPROVAL_COUNT
FROM HS_ASSET.TRUSTAPPLY T, hs_asset.trustapply_ext t_ext
WHERE T.apply_no = t_ext.apply_no(+) and
T.APPLY_TYPE not in ('1','7')
<include refid="querySumCondition" />
)GROUP BY OTC_CODE,OTC_NAME) A, HS_OTC.OTCCODE C
WHERE A.OTC_CODE = C.OTC_CODE
</select>
<!-- 托管详情 -->
<sql id="searchCondition">
WHERE T.APPLY_TYPE != 1
<if test="otcCode != null and otcCode != ''">
AND INSTR(T.OTC_CODE, #{otcCode}) > 0
</if>
<if test="otcName != null and otcName != ''">
AND INSTR(T.OTC_NAME, #{otcName}) > 0
</if>
<if test="applyType != null and applyType != ''">
AND INSTR(#{applyType}, T.APPLY_TYPE) > 0
</if>
<if test="startDate != null and startDate != ''">
<![CDATA[AND T.CURR_DATE >= #{startDate}]]>
</if>
<if test="endDate != null and endDate != ''">
<![CDATA[AND T.CURR_DATE <= #{endDate}]]>
</if>
<if test="innercirculatNo != null and innercirculatNo != ''">
AND T.INNERCIRCULAT_NO = #{innercirculatNo}
</if>
<if test="fundAccount != null and fundAccount != ''">
AND T.FUND_ACCOUNT = #{fundAccount}
</if>
<if test="telphone != null and telphone != ''">
AND INSTR(T.TELPHONE, #{telphone}) > 0
</if>
<if test="clientName != null and clientName != ''">
AND INSTR(T.CLIENT_NAME, #{clientName}) > 0
</if>
<if test="code != null and code != ''">
AND W.CODE = #{code}
</if>
<if test="name != null and name != ''">
AND W.NAME = #{name}
</if>
<if test="idNo != null and idNo != ''">
AND T.ID_NO = #{idNo}
</if>
<if test="applyNo != null and applyNo != ''">
AND T.APPLY_NO = #{applyNo}
</if>
</sql>
<select id="search" parameterType="map" resultType="map">
<include refid="common.pageStart"/>
SELECT T.*,W.CODE,W.NAME
FROM HS_ASSET.TRUSTAPPLY T
LEFT JOIN HS_ASSET.WAREHOUSE W ON T.ACCEPT_NO = W.CODE
<include refid="searchCondition" />
ORDER BY T.INNERCIRCULAT_NO DESC
<include refid="common.pageEnd"/>
</select>
<select id="searchTotal" parameterType="map" resultType="int">
SELECT COUNT(*)
FROM HS_ASSET.TRUSTAPPLY T
LEFT JOIN HS_ASSET.WAREHOUSE W ON T.ACCEPT_NO = W.CODE
<include refid="searchCondition" />
</select>
<sql id="trust_apply_field">
APPLY_NO,FUND_ACCOUNT,CLIENT_NAME,APPLY_DATE,OTC_CODE,OTC_NAME,APPLY_COUNT,ISSUE_PRICE,APPRAISAL_FARE,TRUSTEE_FARE,REMARK
</sql>
<!-- 托管申请查询 -->
<select id="selectApply" parameterType="Map" resultType="Map">
<include refid="common.pageStart" />
select <include refid="trust_apply_field" /> from HS_ASSET.TRUSTAPPLY_VIEW
where 1=1 and APPLY_TYPE != 1
<include refid="selectApplyCondition" />
order by APPLY_NO desc
<include refid="common.pageEnd" />
</select>
<sql id="selectApplyCondition">
<if test="startDate != null and startDate != ''">
<![CDATA[and APPLY_DATE >= #{startDate}]]>
</if>
<if test="endDate != null and endDate != ''">
<![CDATA[and APPLY_DATE <= #{endDate}]]>
</if>
<if test="otcCode != null and otcCode != ''">
and otc_code = #{otcCode}
</if>
<if test="fundAccount != null and fundAccount != ''">
and fund_account = #{fundAccount}
</if>
</sql>
<select id="selectApplyTotal" parameterType="Map" resultType="int">
select count(1) from HS_ASSET.TRUSTAPPLY_VIEW
where 1=1 and APPLY_TYPE != 1
<include refid="selectApplyCondition" />
</select>
<!-- 申请数量、鉴定费用、上挂费用汇总 -->
<select id="selectApplySumTotal" parameterType="Map" resultType="Map">
select sum(APPLY_COUNT) as APPLY_COUNT,sum(APPRAISAL_FARE) as APPRAISAL_FARE,
sum(TRUSTEE_FARE) as TRUSTEE_FARE from HS_ASSET.TRUSTAPPLY_VIEW
where 1=1 and APPLY_TYPE != 1
<include refid="selectApplyCondition" />
</select>
<!-- 托管转赵涌在线数据查询 -->
<sql id="apply_to_zhaoonline_field">
INNERCIRCULAT_NO,OTC_CODE,OTC_NAME,FUND_ACCOUNT,CLIENT_NAME,APPLY_COUNT,APPROVAL_COUNT,BACK_AMOUNT,
STORAGE_DATE,APPLY_TYPE,REMARK,ADDRESSX
</sql>
<sql id="apply_to_zhaoonline_field2">
INNERCIRCULAT_NO,OTC_CODE,OTC_NAME,FUND_ACCOUNT,CLIENT_NAME,ID_NO,TELPHONE, APPLY_COUNT,APPROVAL_COUNT,BACK_AMOUNT,
STORAGE_DATE,APPLY_TYPE,REMARK,ADDRESSX
</sql>
<select id="selectToOnline2" parameterType="Map" resultType="Map">
<include refid="common.pageStart" />
select <include refid="apply_to_zhaoonline_field2" /> from HS_ASSET.TRUSTAPPLY
where BACK_AMOUNT > 0 and ADDRESSX like '赵涌在线%'
<include refid="selectToOnlineCondition" />
order by INNERCIRCULAT_NO desc
<include refid="common.pageEnd" />
</select>
<select id="selectToOnline" parameterType="Map" resultType="Map">
<include refid="common.pageStart" />
select <include refid="apply_to_zhaoonline_field" /> from HS_ASSET.TRUSTAPPLY_VIEW
where BACK_AMOUNT > 0 and ADDRESSX like '赵涌在线%'
<include refid="selectToOnlineCondition" />
order by INNERCIRCULAT_NO desc
<include refid="common.pageEnd" />
</select>
<select id="selectToOnlineTotal" parameterType="Map" resultType="int">
select count(1) from HS_ASSET.TRUSTAPPLY_VIEW
where BACK_AMOUNT > 0 and ADDRESSX like '赵涌在线%'
<include refid="selectToOnlineCondition" />
</select>
<select id="selectByApplyNo" parameterType="String" resultType="map">
select apply_no, fund_account, otc_code, otc_name, apply_count, back_amount
from HS_ASSET.TRUSTAPPLY_VIEW
where apply_no = #{applyNo}
</select>
<select id="queryByApplyNo" parameterType="string" resultType="map">
SELECT APPLY_NO, FUND_ACCOUNT, OTC_CODE, OTC_NAME, APPLY_COUNT,
APPROVAL_COUNT, BACK_AMOUNT, ACCEPT_NO, APPLY_TYPE, APPRAISAL_FARE
FROM HS_ASSET.TRUSTAPPLY
WHERE APPLY_NO = #{applyNo}
</select>
<!-- 转赵涌在线 -->
<update id="updateAddressx" parameterType="String" >
update HS_ASSET.TRUSTAPPLY set addressx= concat('赵涌在线:',#{online})
where INNERCIRCULAT_NO = #{innerNo}
</update>
<select id="isOnline" parameterType="Map" resultType="int">
select count(1)
from HS_ASSET.TRUSTAPPLY_VIEW
where addressx like '赵涌在线%' and innercirculat_no=#{innerNo}
</select>
<sql id="selectToOnlineCondition">
<if test="startDate != null and startDate != ''">
<![CDATA[and STORAGE_DATE >= #{startDate}]]>
</if>
<if test="endDate != null and endDate != ''">
<![CDATA[and STORAGE_DATE <= #{endDate}]]>
</if>
<if test="otcCode != null and otcCode != ''">
and otc_code = #{otcCode}
</if>
<if test="fundAccount != null and fundAccount != ''">
and fund_account = #{fundAccount}
</if>
</sql>
<!-- 导出后变更订单状态 -->
<update id="exportUpdate" parameterType="map">
update HS_ASSET.TRUSTAPPLY set CURR_DATE = #{currDate}, CURR_TIME = #{currTime},
APPLY_TYPE = #{applyType}, REMARK = #{remark}
where APPLY_NO = #{applyNo}
</update>
<!-- 入库数据查询 -->
<select id="queryStorageInfo" parameterType="map" resultType="map">
<include refid="common.pageStart" />
select apply_no, innercirculat_no, apply_date, fund_account, otc_code, otc_name, apply_count,
approval_count, back_amount, apply_type, operator_name, storage_date, remark ,
APPRAISAL_FARE, TRUSTEE_FARE
from hs_asset.trustapply
<include refid="storageCondition" />
order by apply_no desc
<include refid="common.pageEnd" />
</select>
<!-- 入库数据条目数查询 -->
<select id="queryStorageTotal" parameterType="map" resultType="int">
select count(1) from hs_asset.trustapply
<include refid="storageCondition" />
</select>
<sql id="storageCondition">
where 1 = 1
<if test="otcCode != null and otcCode != ''">
and otc_code = #{otcCode}
</if>
<if test="otcName != null and otcName != ''">
and otc_name = #{otcName}
</if>
<if test="fundAccount != null and fundAccount != ''">
and fund_account = #{fundAccount}
</if>
<if test="innercirculatNo != null and innercirculatNo != ''">
and innercirculat_no = #{innercirculatNo}
</if>
<if test="applyType != null and applyType != ''">
and apply_type = #{applyType}
</if>
<if test="applyNo != null and applyNo != ''">
and apply_no = #{applyNo}
</if>
</sql>
<!-- 入库数据导出 -->
<select id="queryForExport" parameterType="map" resultType="map">
select otc_code,otc_account,approval_count from hs_asset.trustapply
where apply_type = '5'
<if test="otcCode != null and otcCode != ''">
and otc_code = #{otcCode}
</if>
</select>
<!-- 入库数据导出变更状态 -->
<update id="storageExport" parameterType="map">
update HS_ASSET.TRUSTAPPLY set CURR_DATE = #{currDate}, CURR_TIME = #{currTime},
APPLY_TYPE = '6', REMARK = '确权文件已导出'
<include refid="storageCondition" />
and APPLY_TYPE = '5'
</update>
<sql id="queryAgreeSql">
select a.otc_code,a.otc_name, a.innercirculat_no, a.fund_account, a.client_name,a.apply_no,a.mobile,
a.telphone, a.approval_count, a.apply_count, a.apply_date,
case when b.aggree_status is null then '未确认'
else '同意' end aggree_status,
case when b.aggree_status is null then ''
else to_char(b.aggree_date)
end aggree_date
from hs_asset.trustapply a ,hs_asset.trustapply_ext b
where a.apply_no=b.apply_no(+) and a.otc_code in
<foreach collection="otcCodes" item="otcCode" open="(" close=")"
separator=","> #{otcCode} </foreach>
<if test="userId!=null and userId!=''">
and a.fund_account=#{userId}
</if>
<if test="clientName!=null and clientName!=''">
and a.client_name=#{clientName}
</if>
<if test="applyNo!=null and applyNo!=''">
and a.apply_no=#{applyNo}
</if>
<if test="aggreeStatus ==0 and aggreeStatus!=''">
and b.aggree_status is not null
</if>
<if test="aggreeStatus ==1 and aggreeStatus!=''">
and b.aggree_status is null
</if>
<if test="startDate != null and startDate != ''">
<![CDATA[ and to_date(to_char(b.aggree_date),'yyyyMMdd') >= to_date(#{startDate},'yyyy-MM-dd')]]>
</if>
<if test="endDate != null and endDate != ''">
<![CDATA[ and to_date(to_char(b.aggree_date),'yyyyMMdd') <= to_date(#{endDate},'yyyy-MM-dd')]]>
</if>
order by a.apply_date desc
</sql>
<!-- 查看是否同意配售 -->
<select id="queryAgree" parameterType="map" resultType="map">
<include refid="common.pageStart" />
<include refid="queryAgreeSql" />
<include refid="common.pageEnd" />
</select>
<select id="queryAgreeTotal" parameterType="map" resultType="int">
select count(1) from (
<include refid="queryAgreeSql" />
) a
</select>
<!-- 取消托管单 -->
<update id="cancelApply" parameterType="string">
UPDATE HS_ASSET.TRUSTAPPLY T SET T.APPLY_TYPE = '7', T.APPRAISAL_FARE = 0, T.REMARK = '客户取消托管'
WHERE T.APPLY_NO = #{value} AND T.APPLY_TYPE = '2'
</update>
<!-- 鉴定否决 -->
<update id="voteApply">
UPDATE HS_ASSET.TRUSTAPPLY T SET T.APPLY_TYPE = '3', T.APPROVAL_COUNT = 0,
T.BACK_AMOUNT = #{backAmount}, T.REMARK = '鉴定否决'
WHERE T.APPLY_NO = #{applyNo} AND T.APPLY_TYPE IN ('2', '3', '4')
</update>
</mapper>