Blame view

fw-valhalla-dao/src/main/resources/mapper/ClueTaskMapper.xml 9.28 KB
786b1ee2   张志伟   feature(*): - 事故车...
1
2
3
  <?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.ClueTaskMapper">
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
4
5
6
7
8
9
10
11
      <select
              id="followList"
              resultType="cn.fw.valhalla.domain.dto.FollowPoolDTO"
              parameterType="cn.fw.valhalla.domain.query.FollowPoolQueryVO"
      >
          SELECT t1.id,
          if(t1.type=3 , t4.plate_no, t3.plate_no) plate_no,
          if(t1.type=3 , t4.frame_no, t3.frame_no) frame_no,
9612b098   张志伟   调整查询语句
12
13
          if(t1.type=3 , t4.mobile, t5.mobile) mobile,
          t3.cus_level cus_level,
06c394ca   张志伟   feature(*): 新增区域站...
14
          t1.clue_id clue_id,
9612b098   张志伟   调整查询语句
15
16
17
18
19
20
21
22
23
24
25
26
27
          t2.expires loan_expires,
          t1.type type,
          t1.follow_user user_id,
          t1.follow_user_name follow_user_name,
          t1.follow_shop shop_id,
          t1.finish_shop finish_shop,
          t1.finish_user_name finish_user_name,
          t1.create_time start_time,
          t3.buy_date buy_date,
          t3.insurance_expires insurance_expires,
          t3.arrival_time arrival_time,
          IFNULL(t1.times, 0) times,
          TIMESTAMPDIFF(HOUR, now(), t1.deadline) remaining,
9612b098   张志伟   调整查询语句
28
29
30
          t1.state state,
          t1.close_time close_time,
          t1.reason initiative,
89bd2e6c   张志伟   feature(*): 新增区域站...
31
          t1.version version,
35e78c48   张志伟   feature(*): 修复跟进池...
32
          t1.group_id group_id,
361bbddb   张志伟   feature(*): 修复bug
33
          t1.`version` `version`
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
34
35
          FROM clue_task t1
          left join follow_clue t6 on t1.clue_id=t6.id
1943d0bc   张志伟   feature(*): 公共线索池
36
          left join customer t3 on t6.vin = t3.frame_no and t6.group_id = t3.group_id and t3.yn=1
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
37
38
39
40
          left join customer_base_info t5 on t3.base_id = t5.id
          left join accident_pool t4 on t6.biz_id = t4.id
          left join customer_loan_info t2 on t6.vin = t2.frame_no and t6.group_id = t2.group_id
          <where>
9612b098   张志伟   调整查询语句
41
              t1.group_id = #{condition.groupId}
89bd2e6c   张志伟   feature(*): 新增区域站...
42
              and t1.type != 10
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
43
44
45
46
47
48
49
              <if test="condition.userId !=null">
                  and t1.follow_user = #{condition.userId}
              </if>
              <if test="condition.userName !=null and condition.userName != ''">
                  and t1.follow_user_name like concat('%',#{condition.userName},'%')
              </if>
              <if test="condition.plateNo != null and condition.plateNo !='' ">
9612b098   张志伟   调整查询语句
50
51
                  and (t3.plate_no like concat('%', #{condition.plateNo}, '%') or t4.plate_no like concat('%',
                  #{condition.plateNo}, '%'))
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
52
53
              </if>
              <if test="condition.frameNo != null and condition.frameNo !='' ">
1943d0bc   张志伟   feature(*): 公共线索池
54
                  and t6.vin like concat('%', #{condition.frameNo}, '%')
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
55
56
57
58
              </if>
              <if test="condition.type !=null">
                  and t1.type = #{condition.type}
              </if>
786b1ee2   张志伟   feature(*): - 事故车...
59
  
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
60
              <if test="condition.shopIds !=null">
9612b098   张志伟   调整查询语句
61
                  and t1.follow_shop in
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
62
63
64
65
66
                  <foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=",">
                      #{id}
                  </foreach>
              </if>
              <if test="condition.state != null">
9612b098   张志伟   调整查询语句
67
                  and t1.state in
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
68
69
70
71
72
73
74
75
                  <foreach collection="condition.state" item="id" index="index" open="(" close=")" separator=",">
                      #{id}
                  </foreach>
              </if>
              <if test="condition.loanCustomer !=null and condition.loanCustomer == 1">
                  and t2.expires > now()
              </if>
              <if test="condition.loanCustomer !=null and condition.loanCustomer == 0">
4dfe8030   张志伟   跟进池查询bug修复
76
                  and (t2.expires is null or t2.expires &lt;= now())
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
77
78
79
80
81
              </if>
              <if test="condition.startTime1 !=null">
                  and t1.create_time >= #{condition.startTime1}
              </if>
              <if test="condition.startTime2 !=null">
9612b098   张志伟   调整查询语句
82
83
84
85
86
87
88
89
90
91
92
93
94
                  and t1.create_time &lt;= #{condition.startTime2}
              </if>
              <if test="condition.closeTime1 !=null or condition.closeTime2 !=null">
                  and ( t1.close_time is null or (
                  <trim prefixOverrides="and">
                      <if test="condition.closeTime1 !=null">
                          and t1.close_time >= #{condition.closeTime1}
                      </if>
                      <if test="condition.closeTime2 !=null">
                          and t1.close_time &lt;= #{condition.closeTime2}
                      </if>
                  </trim>
                  ))
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
95
              </if>
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
96
97
98
              <if test="condition.initiative !=null">
                  and t1.reason = #{condition.initiative}
              </if>
3bb11446   张志伟   :bug:
99
              <if test="condition.ignoreChangeRole != null">
8bb7bea7   张志伟   :bug:
100
                  and (t1.reason is null or t1.reason not in (4))
3bb11446   张志伟   :bug:
101
              </if>
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
          </where>
          <if test="condition.orderString != null and condition.orderString !='' ">
              ${condition.orderString}
          </if>
          limit #{startIndex},#{pageSize};
      </select>
  
      <select
              id="followListCount"
              resultType="java.lang.Long"
              parameterType="cn.fw.valhalla.domain.query.FollowPoolQueryVO"
      >
          SELECT count(t1.id)
          FROM clue_task t1
          left join follow_clue t6 on t1.clue_id=t6.id
1943d0bc   张志伟   feature(*): 公共线索池
117
          left join customer t3 on t6.vin = t3.frame_no and t6.group_id = t3.group_id and t3.yn=1
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
118
119
120
121
          left join customer_base_info t5 on t3.base_id = t5.id
          left join accident_pool t4 on t6.biz_id = t4.id
          left join customer_loan_info t2 on t6.vin = t2.frame_no and t6.group_id = t2.group_id
          <where>
9612b098   张志伟   调整查询语句
122
              t1.group_id = #{condition.groupId}
89bd2e6c   张志伟   feature(*): 新增区域站...
123
              and t1.type != 10
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
124
125
126
127
128
129
130
              <if test="condition.userId !=null">
                  and t1.follow_user = #{condition.userId}
              </if>
              <if test="condition.userName !=null and condition.userName != ''">
                  and t1.follow_user_name like concat('%',#{condition.userName},'%')
              </if>
              <if test="condition.plateNo != null and condition.plateNo !='' ">
9612b098   张志伟   调整查询语句
131
132
                  and (t3.plate_no like concat('%', #{condition.plateNo}, '%') or t4.plate_no like concat('%',
                  #{condition.plateNo}, '%'))
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
133
134
              </if>
              <if test="condition.frameNo != null and condition.frameNo !='' ">
1943d0bc   张志伟   feature(*): 公共线索池
135
                  and t6.vin like concat('%', #{condition.frameNo}, '%')
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
136
137
138
139
140
141
              </if>
              <if test="condition.type !=null">
                  and t1.type = #{condition.type}
              </if>
  
              <if test="condition.shopIds !=null">
9612b098   张志伟   调整查询语句
142
                  and t1.follow_shop in
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
143
144
145
146
147
                  <foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=",">
                      #{id}
                  </foreach>
              </if>
              <if test="condition.state != null">
9612b098   张志伟   调整查询语句
148
                  and t1.state in
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
149
150
151
152
153
154
155
156
                  <foreach collection="condition.state" item="id" index="index" open="(" close=")" separator=",">
                      #{id}
                  </foreach>
              </if>
              <if test="condition.loanCustomer !=null and condition.loanCustomer == 1">
                  and t2.expires > now()
              </if>
              <if test="condition.loanCustomer !=null and condition.loanCustomer == 0">
17944d3c   张志伟   bug fix
157
                  and (t2.expires is null or t2.expires &lt;= now())
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
158
159
160
161
162
              </if>
              <if test="condition.startTime1 !=null">
                  and t1.create_time >= #{condition.startTime1}
              </if>
              <if test="condition.startTime2 !=null">
9612b098   张志伟   调整查询语句
163
164
165
166
                  and t1.create_time &lt;= #{condition.startTime2}
              </if>
              <if test="condition.closeTime1 !=null or condition.closeTime2 !=null">
                  and ( t1.close_time is null or (
361bbddb   张志伟   feature(*): 修复bug
167
168
169
170
171
172
173
174
                  <trim prefixOverrides="and">
                      <if test="condition.closeTime1 !=null">
                          and t1.close_time >= #{condition.closeTime1}
                      </if>
                      <if test="condition.closeTime2 !=null">
                          and t1.close_time &lt;= #{condition.closeTime2}
                      </if>
                  </trim>
9612b098   张志伟   调整查询语句
175
                  ))
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
176
              </if>
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
177
178
179
              <if test="condition.initiative !=null">
                  and t1.reason = #{condition.initiative}
              </if>
3bb11446   张志伟   :bug:
180
              <if test="condition.ignoreChangeRole != null">
8bb7bea7   张志伟   :bug:
181
                  and (t1.reason is null or t1.reason not in (4))
3bb11446   张志伟   :bug:
182
              </if>
d4e6d3ec   张志伟   feature(*): 跟进池接口调整
183
184
          </where>
      </select>
8c1f4b9a   张志伟   :alien:
185
186
  
  
8c1f4b9a   张志伟   :alien:
187
188
189
190
191
192
      <select
              id="queryBeCompleted"
              resultType="cn.fw.valhalla.domain.dto.ShouldBeCompletedDTO"
              parameterType="cn.fw.valhalla.domain.query.BeCompletedQuery"
      >
          SELECT
9612b098   张志伟   调整查询语句
193
194
195
          t2.vin,
          t1.follow_user user_id,
          t1.follow_user_name user_name,
95df3085   张志伟   :sparkles:
196
197
          t1.follow_shop shop_id,
          t1.state state
8c1f4b9a   张志伟   :alien:
198
199
200
201
          from clue_task t1
          inner join follow_clue t2 on t1.clue_id = t2.id
          <where>
              t1.redistribution = 0
bd5cb2d8   张志伟   feature(*): 修复成交池查询
202
              and t1.type != 10
8c1f4b9a   张志伟   :alien:
203
204
205
206
              <if test="condition.type !=null">
                  and t1.type = #{condition.type}
              </if>
              <if test="condition.shopId !=null">
0db5b9b7   张志伟   :sparkles:
207
208
209
210
                  and t1.follow_shop in
                  <foreach collection="condition.shopId" item="id" index="index" open="(" close=")" separator=",">
                      #{id}
                  </foreach>
8c1f4b9a   张志伟   :alien:
211
212
              </if>
              <if test="condition.userId !=null">
bfc3047a   张志伟   bug 修复
213
214
                  and (t1.follow_user = #{condition.userId}
                  or t1.finish_user = #{condition.userId})
8c1f4b9a   张志伟   :alien:
215
              </if>
9612b098   张志伟   调整查询语句
216
217
              and DATE(t1.close_time) BETWEEN DATE(from_unixtime(#{condition.startTime})) AND
              DATE(from_unixtime(#{condition.endTime}))
8c1f4b9a   张志伟   :alien:
218
219
          </where>
      </select>
786b1ee2   张志伟   feature(*): - 事故车...
220
  </mapper>