FollowClueMapper.xml
8.71 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
<?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="cn.fw.valhalla.dao.mapper.FollowClueMapper">
<select
id="clueList"
resultType="cn.fw.valhalla.domain.dto.FollowClueDTO"
parameterType="cn.fw.valhalla.domain.query.CustomerCluePoolQueryVO"
>
SELECT t2.id customer_id,
if(t1.clue_type=3 , t3.plate_no, t2.plate_no) plate_no,
t1.clue_type type,
t1.vin frame_no,
t2.buy_date buy_date,
t2.arrival_time arrival_time,
t2.insurance_expires insurance_expires,
t1.start_time create_date,
t1.end_time deadline,
t1.clue_state clue_status,
t1.close_time close_time,
t4.expires loan_expires
FROM follow_clue t1
left join customer t2 on t1.vin = t2.frame_no and t2.group_id = t1.group_id and t2.yn=1
left join accident_pool t3 on t1.biz_id = t3.id
left join customer_loan_info t4 on t2.frame_no = t4.frame_no and t2.group_id = t4.group_id
<where>
and t1.clue_state != 1
<if test="condition.type !=null">
and t1.clue_type = #{condition.type}
</if>
<if test="condition.groupId !=null">
and t1.group_id = #{condition.groupId}
</if>
<if test="condition.frameNo !=null and condition.frameNo != ''">
and t1.vin like concat('%', #{condition.frameNo}, '%')
</if>
<if test="condition.plateNo != null and condition.plateNo !=''">
and (t2.plate_no like concat('%', #{condition.plateNo}, '%') or t3.plate_no like concat('%', #{condition.plateNo}, '%'))
</if>
<if test="condition.startTime !=null">
and DATE_FORMAT(t1.start_time, '%Y-%m') = DATE_FORMAT(#{condition.startTime}, '%Y-%m')
</if>
<if test="condition.closeTime1 !=null">
and DATE_FORMAT(t1.close_time, '%Y-%m-%d') >= DATE_FORMAT(#{condition.closeTime1}, '%Y-%m-%d')
</if>
<if test="condition.closeTime2 !=null">
and DATE_FORMAT(t1.close_time, '%Y-%m-%d') <= DATE_FORMAT(#{condition.closeTime2}, '%Y-%m-%d')
</if>
<if test="condition.deadline1 !=null">
and DATE_FORMAT(t1.start_time, '%Y-%m-%d') < DATE_FORMAT(#{condition.deadline1}, '%Y-%m-%d')
and DATE_FORMAT(t1.end_time, '%Y-%m-%d') >= DATE_FORMAT(#{condition.deadline1}, '%Y-%m-%d')
</if>
<if test="condition.deadline2 !=null">
and DATE_FORMAT(t1.end_time, '%Y-%m-%d') <= DATE_FORMAT(#{condition.deadline2}, '%Y-%m-%d')
</if>
<if test="condition.loanCustomer !=null and condition.loanCustomer == 1">
and t4.expires > now()
</if>
<if test="condition.loanCustomer !=null and condition.loanCustomer == 0">
and t4.expires <= now()
</if>
<if test="condition.shopIds !=null">
and t1.suggest_shop_id in
<foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="condition.status !=null and condition.status ==2">
and t1.clue_state = #{condition.status}
</if>
</where>
<if test="condition.orderString != null and condition.orderString !='' ">
${condition.orderString}
</if>
limit #{startIndex},#{pageSize};
</select>
<select
id="clueListCount"
resultType="java.lang.Long"
parameterType="cn.fw.valhalla.domain.query.CustomerCluePoolQueryVO"
>
SELECT
count(t1.id)
FROM follow_clue t1
left join customer t2 on t1.vin = t2.frame_no and t2.group_id = t1.group_id and t2.yn=1
left join accident_pool t3 on t1.biz_id = t3.id
left join customer_loan_info t4 on t2.frame_no = t4.frame_no and t2.group_id = t4.group_id
<where>
and t1.clue_state != 1
<if test="condition.type !=null">
and t1.clue_type = #{condition.type}
</if>
<if test="condition.groupId !=null">
and t1.group_id = #{condition.groupId}
</if>
<if test="condition.frameNo !=null and condition.frameNo != ''">
and t1.vin like concat('%', #{condition.frameNo}, '%')
</if>
<if test="condition.plateNo != null and condition.plateNo !=''">
and (t2.plate_no like concat('%', #{condition.plateNo}, '%') or t3.plate_no like concat('%', #{condition.plateNo}, '%'))
</if>
<if test="condition.startTime !=null">
and DATE_FORMAT(t1.start_time, '%Y-%m') = DATE_FORMAT(#{condition.startTime}, '%Y-%m')
</if>
<if test="condition.closeTime1 !=null">
and DATE_FORMAT(t1.close_time, '%Y-%m-%d') >= DATE_FORMAT(#{condition.closeTime1}, '%Y-%m-%d')
</if>
<if test="condition.closeTime2 !=null">
and DATE_FORMAT(t1.close_time, '%Y-%m-%d') <= DATE_FORMAT(#{condition.closeTime2}, '%Y-%m-%d')
</if>
<if test="condition.deadline1 !=null">
and DATE_FORMAT(t1.start_time, '%Y-%m-%d') < DATE_FORMAT(#{condition.deadline1}, '%Y-%m-%d')
and DATE_FORMAT(t1.end_time, '%Y-%m-%d') >= DATE_FORMAT(#{condition.deadline1}, '%Y-%m-%d')
</if>
<if test="condition.deadline2 !=null">
and DATE_FORMAT(t1.end_time, '%Y-%m-%d') <= DATE_FORMAT(#{condition.deadline2}, '%Y-%m-%d')
</if>
<if test="condition.loanCustomer !=null and condition.loanCustomer == 1">
and t4.expires > now()
</if>
<if test="condition.loanCustomer !=null and condition.loanCustomer == 0">
and t4.expires <= now()
</if>
<if test="condition.shopIds !=null">
and t1.suggest_shop_id in
<foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=",">
#{id}
</foreach>
</if>
<if test="condition.status !=null and condition.status ==2">
and t1.clue_state = #{condition.status}
</if>
</where>
</select>
<select
id="completeNum"
resultType="java.lang.Long"
>
SELECT
count(t1.id)
FROM follow_clue t1
left join customer t2 on t1.vin = t2.frame_no and t2.group_id = t1.group_id and t2.yn=1
left join accident_pool t3 on t1.biz_id = t3.id
<where>
and DATE_FORMAT(t1.close_time, '%Y-%m') = DATE_FORMAT(now(), '%Y-%m')
and t1.clue_state = 3
<if test="condition.type !=null">
and t1.clue_type = #{condition.type}
</if>
<if test="condition.groupId !=null">
and t1.group_id = #{condition.groupId}
</if>
</where>
</select>
<select
id="defeatNum"
resultType="java.lang.Long"
>
SELECT
count(t1.id)
FROM follow_clue t1
left join customer t2 on t1.vin = t2.frame_no and t2.group_id = t1.group_id and t2.yn=1
left join accident_pool t3 on t1.biz_id = t3.id
<where>
and DATE_FORMAT(t1.close_time, '%Y-%m') = DATE_FORMAT(now(), '%Y-%m')
and t1.clue_state = 4
<if test="condition.type !=null">
and t1.clue_type = #{condition.type}
</if>
<if test="condition.groupId !=null">
and t1.group_id = #{condition.groupId}
</if>
</where>
</select>
<select
id="onGoingNum"
resultType="java.lang.Long"
>
SELECT
count(t1.id)
FROM follow_clue t1
left join customer t2 on t1.vin = t2.frame_no and t2.group_id = t1.group_id and t2.yn=1
left join accident_pool t3 on t1.biz_id = t3.id
<where>
and t1.clue_state = 2
<if test="condition.type !=null">
and t1.clue_type = #{condition.type}
</if>
<if test="condition.groupId !=null">
and t1.group_id = #{condition.groupId}
</if>
</where>
</select>
</mapper>