Blame view

fw-valhalla-dao/src/main/resources/mapper/StammkundePoolMapper.xml 14.3 KB
7c9f5c47   张志伟   :art:
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.StammkundePoolMapper">
39e85d50   张志伟   :art:
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
      <select
              id="stammkundeList"
              resultType="cn.fw.valhalla.domain.dto.StammkundePoolDTO"
              parameterType="cn.fw.valhalla.domain.query.StammkundePoolQueryVO"
      >
          SELECT t2.id                                                                                    customer_id,
          t2.plate_no                                                                                     plate_no,
          t2.frame_no                                                                                     frame_no,
          concat_ws(' ', ifnull(t2.brand_name, ''), ifnull(t2.series_name, ''), ifnull(t2.spec_name, '')) car_name,
          t1.shop_id                                                                                      shop_id,
          t1.adviser_name                                                                                 adviser_name,
          t1.activation_time                                                                              activation_time,
          t1.sources                                                                                      sources,
          t1.reject_time                                                                                  defeat_time,
          t1.pool_status                                                                                  pool_status,
1b7b7d85   张志伟   ✨ v1.1.1 调整保有客池查...
19
          t1.reason                                                                                       reason,
3015fc0c   张志伟   :construction:
20
21
22
23
          t1.new_user_id                                                                                  new_user_id,
          t1.new_user_name                                                                                new_user_name,
          t1.new_shop_id                                                                                  new_shop_id,
          t1.new_shop_name                                                                                new_shop_name,
39e85d50   张志伟   :art:
24
25
          t3.name                                                                                         customer_name,
          t3.address                                                                                      address,
e3648560   张志伟   :fire:
26
          t3.city_name                                                                                    region_name,
39e85d50   张志伟   :art:
27
28
29
30
31
32
          t2.cus_level                                                                                    customer_level,
          t2.tags                                                                                         tags,
          t4.expires                                                                                      loan_expires,
          t2.buy_date                                                                                     buy_date,
          t2.insurance_expires                                                                            insurance_expires,
          t2.arrival_time                                                                                 arrival_time,
bff962f1   张志伟   :sparkles:
33
          t2.arrival_count                                                                                times
39e85d50   张志伟   :art:
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
          FROM stammkunde_pool t1
          left join customer t2 on t1.customer_id = t2.id
          left join customer_base_info t3 on t2.base_id = t3.id
          left join customer_loan_info t4 on t2.frame_no = t4.frame_no and t2.group_id = t4.group_id
          <where>
              <if test="condition.groupId !=null">
                  and t1.group_id = #{condition.groupId}
              </if>
              <if test="condition.userId !=null">
                  and t1.adviser_id = #{condition.userId}
              </if>
              <if test="condition.userName !=null and condition.userName != ''">
                  and t1.adviser_name like concat('%', #{condition.userName}, '%')
              </if>
              <if test="condition.plateNo != null and condition.plateNo !=''">
                  and t2.plate_no like concat('%', #{condition.plateNo}, '%')
              </if>
9f75788b   张志伟   :construction_wor...
51
52
53
              <if test="condition.frameNo != null and condition.frameNo !=''">
                  and t2.frame_no like concat('%', #{condition.frameNo}, '%')
              </if>
39e85d50   张志伟   :art:
54
55
56
57
58
59
60
61
62
63
64
65
66
67
              <if test="condition.brandId !=null">
                  and t2.brand_id = #{condition.brandId}
              </if>
              <if test="condition.seriesId !=null">
                  and t2.series_id = #{condition.seriesId}
              </if>
              <if test="condition.specId !=null">
                  and t2.spec_id = #{condition.specId}
              </if>
              <if test="condition.shopIds !=null">
                  and  t1.shop_id in
                  <foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=",">
                      #{id}
                  </foreach>
39e85d50   张志伟   :art:
68
              </if>
1b7b7d85   张志伟   ✨ v1.1.1 调整保有客池查...
69
70
              <if test="condition.activationTime !=null">
                  and t1.activation_time &lt;= #{condition.activationTime}
0763739a   张志伟   :bug:
71
                  and (t1.reject_time > #{condition.activationTime} or t1.reject_time is null)
1b7b7d85   张志伟   ✨ v1.1.1 调整保有客池查...
72
73
74
75
76
77
              </if>
              <if test="condition.startTime1 !=null">
                  and t1.activation_time >= #{condition.startTime1}
              </if>
              <if test="condition.startTime2 !=null">
                  and t1.activation_time &lt;=  #{condition.startTime2}
39e85d50   张志伟   :art:
78
79
80
81
82
83
84
85
86
87
88
              </if>
              <if test="condition.sources !=null">
                  and t1.sources = #{condition.sources}
              </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 &lt;= now()
              </if>
              <if test="condition.defeatTime1 !=null">
6e2dbad8   张志伟   :bug:
89
                  and DATE_FORMAT(t1.reject_time, '%Y-%m-%d') >= DATE_FORMAT(#{condition.defeatTime1}, '%Y-%m-%d')
39e85d50   张志伟   :art:
90
91
              </if>
              <if test="condition.defeatTime2 !=null">
6e2dbad8   张志伟   :bug:
92
                  and DATE_FORMAT(t1.reject_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{condition.defeatTime2}, '%Y-%m-%d')
39e85d50   张志伟   :art:
93
94
95
96
97
98
99
              </if>
              <if test="condition.poolStatus !=null">
                  and t1.pool_status = #{condition.poolStatus}
              </if>
              <if test="condition.customerName !=null and condition.customerName !=''">
                  and t3.name like concat('%', #{condition.customerName}, '%')
              </if>
240a6575   张志伟   :sparkles:
100
101
              <if test="condition.regionCode !=null and condition.regionCode !=''">
                  and t3.city_code like concat(#{condition.regionCode}, '%')
39e85d50   张志伟   :art:
102
103
104
105
              </if>
              <if test="condition.level !=null">
                  and t2.cus_level = #{condition.level}
              </if>
1b7b7d85   张志伟   ✨ v1.1.1 调整保有客池查...
106
              <if test="condition.reason != null">
790c2e65   张志伟   :construction_wor...
107
108
109
110
                  and  t1.reason in
                  <foreach collection="condition.reason" item="id" index="index" open="(" close=")" separator=",">
                      #{id}
                  </foreach>
1b7b7d85   张志伟   ✨ v1.1.1 调整保有客池查...
111
              </if>
26c464db   张志伟   :bug:
112
              <if test="condition.defeated !=null and condition.defeated == 1">
6e2dbad8   张志伟   :bug:
113
                  and t1.aktiv = 0
80d226d2   张志伟   :bug:
114
115
116
                  <if test="condition.reason == null">
                      and t1.reason not in (99, 10, 9)
                  </if>
26c464db   张志伟   :bug:
117
118
              </if>
              <if test="condition.defeated !=null and condition.defeated == 0">
6e2dbad8   张志伟   :bug:
119
                  and t1.aktiv = 1
26c464db   张志伟   :bug:
120
              </if>
39e85d50   张志伟   :art:
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
              <if test="condition.warrantyCard !=null and condition.warrantyCard == 1">
                  and FIND_IN_SET('qua_ass_card', t2.tags) != 0
              </if>
              <if test="condition.warrantyCard !=null and condition.warrantyCard == 0">
                  and FIND_IN_SET('qua_ass_card', t2.tags) = 0
              </if>
              <if test="condition.maintainCard !=null and condition.maintainCard == 1">
                  and FIND_IN_SET('maintain_card', t2.tags) != 0
              </if>
              <if test="condition.maintainCard !=null and condition.maintainCard == 0">
                  and FIND_IN_SET('maintain_card', t2.tags) = 0
              </if>
          </where>
          <if test="condition.orderString != null and condition.orderString !='' ">
              ${condition.orderString}
          </if>
          limit #{startIndex},#{pageSize};
      </select>
cc14a87c   张志伟   :art:
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
  
  
      <select
              id="stammkundeListCount"
              resultType="java.lang.Long"
              parameterType="cn.fw.valhalla.domain.query.StammkundePoolQueryVO"
      >
          SELECT count(t1.id)
          FROM stammkunde_pool t1
          left join customer t2 on t1.customer_id = t2.id
          left join customer_base_info t3 on t2.base_id = t3.id
          left join customer_loan_info t4 on t2.frame_no = t4.frame_no and t2.group_id = t4.group_id
          <where>
              <if test="condition.groupId !=null">
                  and t1.group_id = #{condition.groupId}
              </if>
              <if test="condition.userId !=null">
                  and t1.adviser_id = #{condition.userId}
              </if>
              <if test="condition.userName !=null and condition.userName != ''">
                  and t1.adviser_name like concat('%', #{condition.userName}, '%')
              </if>
              <if test="condition.plateNo != null and condition.plateNo !=''">
                  and t2.plate_no like concat('%', #{condition.plateNo}, '%')
              </if>
9f75788b   张志伟   :construction_wor...
164
165
166
              <if test="condition.frameNo != null and condition.frameNo !=''">
                  and t2.frame_no like concat('%', #{condition.frameNo}, '%')
              </if>
cc14a87c   张志伟   :art:
167
168
169
170
171
172
173
174
175
176
177
178
179
180
              <if test="condition.brandId !=null">
                  and t2.brand_id = #{condition.brandId}
              </if>
              <if test="condition.seriesId !=null">
                  and t2.series_id = #{condition.seriesId}
              </if>
              <if test="condition.specId !=null">
                  and t2.spec_id = #{condition.specId}
              </if>
              <if test="condition.shopIds !=null">
                  and  t1.shop_id in
                  <foreach collection="condition.shopIds" item="id" index="index" open="(" close=")" separator=",">
                      #{id}
                  </foreach>
cc14a87c   张志伟   :art:
181
              </if>
1b7b7d85   张志伟   ✨ v1.1.1 调整保有客池查...
182
183
              <if test="condition.activationTime !=null">
                  and t1.activation_time &lt;= #{condition.activationTime}
0763739a   张志伟   :bug:
184
                  and (t1.reject_time > #{condition.activationTime} or t1.reject_time is null)
1b7b7d85   张志伟   ✨ v1.1.1 调整保有客池查...
185
186
187
188
189
190
              </if>
              <if test="condition.startTime1 !=null">
                  and t1.activation_time >= #{condition.startTime1}
              </if>
              <if test="condition.startTime2 !=null">
                  and t1.activation_time &lt;=  #{condition.startTime2}
cc14a87c   张志伟   :art:
191
192
193
194
195
196
197
198
199
200
201
              </if>
              <if test="condition.sources !=null">
                  and t1.sources = #{condition.sources}
              </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 &lt;= now()
              </if>
              <if test="condition.defeatTime1 !=null">
6e2dbad8   张志伟   :bug:
202
                  and DATE_FORMAT(t1.reject_time, '%Y-%m-%d') >= DATE_FORMAT(#{condition.defeatTime1}, '%Y-%m-%d')
cc14a87c   张志伟   :art:
203
204
              </if>
              <if test="condition.defeatTime2 !=null">
6e2dbad8   张志伟   :bug:
205
                  and DATE_FORMAT(t1.reject_time, '%Y-%m-%d') &lt;= DATE_FORMAT(#{condition.defeatTime2}, '%Y-%m-%d')
cc14a87c   张志伟   :art:
206
207
208
209
210
211
212
              </if>
              <if test="condition.poolStatus !=null">
                  and t1.pool_status = #{condition.poolStatus}
              </if>
              <if test="condition.customerName !=null and condition.customerName !=''">
                  and t3.name like concat('%', #{condition.customerName}, '%')
              </if>
240a6575   张志伟   :sparkles:
213
214
              <if test="condition.regionCode !=null and condition.regionCode !=''">
                  and t3.city_code like concat(#{condition.regionCode}, '%')
cc14a87c   张志伟   :art:
215
              </if>
6e2dbad8   张志伟   :bug:
216
217
218
              <if test="condition.level !=null">
                  and t2.cus_level = #{condition.level}
              </if>
1b7b7d85   张志伟   ✨ v1.1.1 调整保有客池查...
219
              <if test="condition.reason != null">
790c2e65   张志伟   :construction_wor...
220
221
222
223
                  and  t1.reason in
                  <foreach collection="condition.reason" item="id" index="index" open="(" close=")" separator=",">
                      #{id}
                  </foreach>
1b7b7d85   张志伟   ✨ v1.1.1 调整保有客池查...
224
              </if>
6e2dbad8   张志伟   :bug:
225
226
              <if test="condition.defeated !=null and condition.defeated == 1">
                  and t1.aktiv = 0
80d226d2   张志伟   :bug:
227
228
229
                  <if test="condition.reason == null">
                      and t1.reason not in (99, 10, 9)
                  </if>
6e2dbad8   张志伟   :bug:
230
231
232
              </if>
              <if test="condition.defeated !=null and condition.defeated == 0">
                  and t1.aktiv = 1
cc14a87c   张志伟   :art:
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
              </if>
              <if test="condition.warrantyCard !=null and condition.warrantyCard == 1">
                  and FIND_IN_SET('qua_ass_card', t2.tags) != 0
              </if>
              <if test="condition.warrantyCard !=null and condition.warrantyCard == 0">
                  and FIND_IN_SET('qua_ass_card', t2.tags) = 0
              </if>
              <if test="condition.maintainCard !=null and condition.maintainCard == 1">
                  and FIND_IN_SET('maintain_card', t2.tags) != 0
              </if>
              <if test="condition.maintainCard !=null and condition.maintainCard == 0">
                  and FIND_IN_SET('maintain_card', t2.tags) = 0
              </if>
          </where>
      </select>
bfac3874   xianpengcheng   public_report_dat...
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
  
  
      <select id="countStammkundePoolList" resultType="cn.fw.valhalla.domain.dto.StammkundePoolReportDTO" parameterType="cn.fw.valhalla.domain.dto.StammkundePoolReportQueryDTO">
          SELECT
          shop_id,
          adviser_id,
          adviser_name,
          COUNT(*) total
          FROM
          stammkunde_pool
          <where>
              group_id = #{groupId}
              <if test="fromPublic != null">
                  and from_public = #{fromPublic}
              </if>
              <if test="startDate != null">
                  and create_time <![CDATA[ >= ]]> #{startDate}
              </if>
              <if test="endDate != null">
                  and create_time <![CDATA[ <= ]]> #{endDate}
              </if>
              <if test="sourceSets != null and sourceSets.size > 0 ">
                  AND sources IN
                  <foreach collection="sourceSets" item="v" separator=" , " open="(" close=")">
                      #{v}
                  </foreach>
              </if>
          </where>
          GROUP BY
          shop_id,
          adviser_id
      </select>
  
  
7c9f5c47   张志伟   :art:
282
  </mapper>