user-balance-daily-mapper.xml
3.83 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
<?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 tongxiaochuan -->
<mapper namespace="com.cjs.cms.dao.user.fund.UserBalanceListDao">
<sql id="searchCondition">
where 1=1
<if test="queryType != null and queryType != ''">
<![CDATA[and IFNULL(t.current_balance, 0.00) != IFNULL(r.avl_bal, 0.00) ]]>
</if>
<if test="userId != null and userId != ''">
and t.client_id = #{userId}
</if>
</sql>
<select id="search" parameterType="map" resultType="map">
select t.client_id,t.current_balance as hundsun,IFNULL(r.avl_bal,0.00) as pnr,t.data_date from
(select format(a.current_balance,2) current_balance,a.client_id,a.data_date from fund_real a
where a.data_date = #{data_date} and a.current_balance != 0) t
left join
(select format(b.avl_bal,2) avl_bal, b.user_id, b.data_date from user_balance_huifu_daily b
where b.data_date = #{data_date} and b.avl_bal != 0) r
on t.client_id = r.user_id
<include refid="searchCondition" />
union
select r.user_id,IFNULL(t.current_balance,0.00) as hundsun,r.avl_bal as pnr,r.data_date from
(select format(a.current_balance,2) current_balance,a.client_id,a.data_date from fund_real a
where a.data_date = #{data_date} and a.current_balance != 0) t
right join
(select format(b.avl_bal,2) avl_bal, b.user_id, b.data_date from user_balance_huifu_daily b
where b.data_date = #{data_date} and b.avl_bal != 0) r
on t.client_id = r.user_id
<include refid="searchCondition" />
</select>
<select id="searchTotal" parameterType="map" resultType="int">
select count(1) from
(select t.client_id,t.current_balance as hundsun,IFNULL(r.avl_bal,0.00) as pnr,t.data_date from
(select format(a.current_balance,2) current_balance,a.client_id,a.data_date from fund_real a
where a.data_date = #{data_date} and a.current_balance != 0) t
left join
(select format(b.avl_bal,2) avl_bal, b.user_id, b.data_date from user_balance_huifu_daily b
where b.data_date = #{data_date} and b.avl_bal != 0) r
on t.client_id = r.user_id
<include refid="searchCondition" />
union
select r.user_id,IFNULL(t.current_balance,0.00) as hundsun,r.avl_bal as pnr,r.data_date from
(select format(a.current_balance,2) current_balance,a.client_id,a.data_date from fund_real a
where a.data_date = #{data_date} and a.current_balance != 0) t
right join
(select format(b.avl_bal,2) avl_bal, b.user_id, b.data_date from user_balance_huifu_daily b
where b.data_date = #{data_date} and b.avl_bal != 0) r
on t.client_id = r.user_id
<include refid="searchCondition" />) t
</select>
<!-- 定时器执行search无法识别typ,故直接写 -->
<select id="searchDiff" parameterType="map" resultType="map">
select t.client_id,t.current_balance as hundsun,IFNULL(r.avl_bal,0.00) as pnr,t.data_date from
(select format(a.current_balance,2) current_balance,a.client_id,a.data_date from fund_real a
where a.data_date = #{data_date} and a.current_balance != 0) t
left join
(select format(b.avl_bal,2) avl_bal, b.user_id, b.data_date from user_balance_huifu_daily b
where b.data_date = #{data_date} and b.avl_bal != 0) r
on t.client_id = r.user_id
where IFNULL(t.current_balance, 0.00) != IFNULL(r.avl_bal, 0.00)
union
select r.user_id,IFNULL(t.current_balance,0.00) as hundsun,r.avl_bal as pnr,r.data_date from
(select format(a.current_balance,2) current_balance,a.client_id,a.data_date from fund_real a
where a.data_date = #{data_date} and a.current_balance != 0) t
right join
(select format(b.avl_bal,2) avl_bal, b.user_id, b.data_date from user_balance_huifu_daily b
where b.data_date = #{data_date} and b.avl_bal != 0) r
on t.client_id = r.user_id
where IFNULL(t.current_balance, 0.00) != IFNULL(r.avl_bal, 0.00)
</select>
</mapper>